diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-29 19:24:21 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-29 19:24:21 +0200 |
commit | 509e7e4bed3b011b5e0b276db3900edb9fee7255 (patch) | |
tree | 8bf760b1c367160ce4364f1485bc5598b78ec36b /src/mail/mod.rs | |
parent | a8d0e4a994daca39f9619cddf2847c1a7820c040 (diff) | |
download | aerogramme-509e7e4bed3b011b5e0b276db3900edb9fee7255.tar.gz aerogramme-509e7e4bed3b011b5e0b276db3900edb9fee7255.zip |
Implement beginning of a FETCH command
Diffstat (limited to 'src/mail/mod.rs')
-rw-r--r-- | src/mail/mod.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mail/mod.rs b/src/mail/mod.rs index bbb553a..8dc42c4 100644 --- a/src/mail/mod.rs +++ b/src/mail/mod.rs @@ -1,3 +1,5 @@ +use std::convert::TryFrom; + pub mod mailbox; pub mod uidindex; pub mod unique_ident; @@ -9,3 +11,12 @@ 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 }) + } +} |