New imap-proto

This commit is contained in:
Jon Gjengset 2018-04-27 16:27:38 -04:00
parent c28d08851c
commit d132de4834
No known key found for this signature in database
GPG key ID: D64AC9D67176DC71
3 changed files with 8 additions and 1 deletions

View file

@ -28,7 +28,7 @@ path = "src/lib.rs"
native-tls = "0.1" native-tls = "0.1"
regex = "0.2" regex = "0.2"
bufstream = "0.1" bufstream = "0.1"
imap-proto = "0.4" imap-proto = "0.4.1"
nom = "3.2.1" nom = "3.2.1"
[dev-dependencies] [dev-dependencies]

View file

@ -82,6 +82,7 @@ pub fn parse_fetches(lines: Vec<u8>) -> ZeroCopyResult<Vec<Fetch>> {
message: num, message: num,
flags: vec![], flags: vec![],
uid: None, uid: None,
rfc822_header: None,
rfc822: None, rfc822: None,
}; };
@ -93,6 +94,7 @@ pub fn parse_fetches(lines: Vec<u8>) -> ZeroCopyResult<Vec<Fetch>> {
} }
AttributeValue::Uid(uid) => fetch.uid = Some(uid), AttributeValue::Uid(uid) => fetch.uid = Some(uid),
AttributeValue::Rfc822(rfc) => fetch.rfc822 = rfc, AttributeValue::Rfc822(rfc) => fetch.rfc822 = rfc,
AttributeValue::Rfc822Header(rfc) => fetch.rfc822_header = rfc,
_ => {} _ => {}
} }
} }

View file

@ -5,6 +5,7 @@ pub struct Fetch {
pub message: u32, pub message: u32,
pub(crate) flags: Vec<&'static str>, pub(crate) flags: Vec<&'static str>,
pub uid: Option<u32>, pub uid: Option<u32>,
pub(crate) rfc822_header: Option<&'static [u8]>,
pub(crate) rfc822: Option<&'static [u8]>, pub(crate) rfc822: Option<&'static [u8]>,
} }
@ -13,6 +14,10 @@ impl Fetch {
&self.flags[..] &self.flags[..]
} }
pub fn rfc822_header<'a>(&'a self) -> Option<&'a [u8]> {
self.rfc822_header
}
pub fn rfc822<'a>(&'a self) -> Option<&'a [u8]> { pub fn rfc822<'a>(&'a self) -> Option<&'a [u8]> {
self.rfc822 self.rfc822
} }