Merge pull request #150 from open-xchange/body-structure-exposure-merge

Add bodystructure exposing function to Fetch structure.
This commit is contained in:
Jon Gjengset 2019-10-29 09:54:42 -04:00 committed by GitHub
commit 271599bb78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
use super::{Flag, Seq, Uid};
use chrono::{DateTime, FixedOffset};
use imap_proto::types::{AttributeValue, Envelope, MessageSection, SectionPath};
use imap_proto::types::{AttributeValue, BodyStructure, Envelope, MessageSection, SectionPath};
/// Format of Date and Time as defined RFC3501.
/// See `date-time` element in [Formal Syntax](https://tools.ietf.org/html/rfc3501#section-9)
@ -145,4 +145,18 @@ impl Fetch {
},
)
}
/// Extract the `BODYSTRUCTURE` of a `FETCH` response
///
/// See [section 2.3.6 of RFC 3501](https://tools.ietf.org/html/rfc3501#section-2.3.6) for
/// details.
pub fn bodystructure<'a>(&self) -> Option<&BodyStructure<'a>> {
self.fetch
.iter()
.filter_map(|av| match av {
AttributeValue::BodyStructure(bs) => Some(bs),
_ => None,
})
.next()
}
}