extern crate base64;
extern crate charset;
extern crate quoted_printable;
use std::collections::BTreeMap;
use charset::decode_latin1;
use charset::Charset;
pub mod body;
mod dateparse;
mod error;
use body::Body;
pub use dateparse::dateparse;
pub use error::*;
/// A struct that represents a single header in the message.
/// It holds slices into the raw byte array passed to parse_mail, and so the
/// lifetime of this struct must be contained within the lifetime of the raw
/// input. There are additional accessor functions on this struct to extract
/// the data as Rust strings.
#[derive(Debug)]
pub struct MailHeader<'a> {
key: &'a [u8],
value: &'a [u8],
}
fn is_boundary(line: &str, ix: Option<usize>) -> bool {
ix.and_then(|v| line.chars().nth(v))
.map(|c| c.is_whitespace() || c == '"' || c == '(' || c == ')' || c == '<' || c == '>')
.unwrap_or(true)
}
fn find_from(line: &str, ix_start: usize, key: &str) -> Option<usize> {
line[ix_start..].find(key).map(|v| ix_start + v)
}
fn find_from_u8(line: &[u8], ix_start: usize, key: &[u8]) -> Option<usize> {
assert!(!key.is_empty());
assert!(ix_start < line.len());
if line.len() < key.len() {
return None;
}
let ix_end = line.len() - key.len();
if