aboutsummaryrefslogtreecommitdiff
path: root/src/mail/mod.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 19:24:21 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 19:24:21 +0200
commit509e7e4bed3b011b5e0b276db3900edb9fee7255 (patch)
tree8bf760b1c367160ce4364f1485bc5598b78ec36b /src/mail/mod.rs
parenta8d0e4a994daca39f9619cddf2847c1a7820c040 (diff)
downloadaerogramme-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.rs11
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 })
+ }
+}