aboutsummaryrefslogtreecommitdiff
path: root/src/mail/mod.rs
blob: b6054b0ca8f54b57409a4575417167a12d5b6d95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::convert::TryFrom;

pub mod incoming;
pub mod mailbox;
pub mod uidindex;
pub mod unique_ident;
pub mod user;

// Internet Message Format
// aka RFC 822 - RFC 2822 - RFC 5322
pub struct IMF<'a> {
    raw: &'a [u8],
    parsed: mail_parser::Message<'a>,
}

impl<'a> TryFrom<&'a [u8]> for IMF<'a> {
    type Error = ();

    fn try_from(body: &'a [u8]) -> Result<IMF<'a>, ()> {
        let parsed = mail_parser::Message::parse(body).ok_or(())?;
        Ok(Self { raw: body, parsed })
    }
}