extern crate base64;
extern crate charset;
extern crate quoted_printable;
use std::collections::BTreeMap;
use std::error;
use std::fmt;
use std::ops::Deref;
use charset::decode_latin1;
use charset::Charset;
pub mod body;
mod addrparse;
mod dateparse;
use body::Body;
pub use addrparse::{addrparse, GroupInfo, MailAddr, SingleInfo};
pub use dateparse::dateparse;
/// An error type that represents the different kinds of errors that may be
/// encountered during message parsing.
#[derive(Debug)]
pub enum MailParseError {
/// Data that was specified as being in the quoted-printable transfer-encoding
/// could not be successfully decoded as quoted-printable data.
QuotedPrintableDecodeError(quoted_printable::QuotedPrintableError),
/// Data that was specified as being in the base64 transfer-encoding could
/// not be successfully decoded as base64 data.
Base64DecodeError(base64::DecodeError),
/// An error occurred when converting the raw byte data to Rust UTF-8 string
/// format using the charset specified in the message.
EncodingError(std::borrow::Cow<'static, str>),
/// Some other error occurred while parsing the message; the description string
/// provides additional details.
Generic(&'static str),
}
impl fmt::Display for MailParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
MailParseError::QuotedPrintableDecodeError(ref err) => {
write!(f, "QuotedPrintable decode error: {}", err)
}
MailParseError::Base64DecodeError(ref