expose naive fields

This commit is contained in:
Quentin 2023-09-18 18:06:37 +02:00
parent 8b17af73fa
commit 0a7179a17c
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 18 additions and 0 deletions

View file

@ -49,6 +49,16 @@ pub enum AnyMIME<'a> {
Txt(MIME<'a, r#type::DeductibleText>),
Bin(MIME<'a, r#type::Binary>),
}
impl<'a> AnyMIME<'a> {
pub fn fields(&self) -> &NaiveMIME<'a> {
match self {
Self::Mult(v) => &v.fields,
Self::Msg(v) => &v.fields,
Self::Txt(v) => &v.fields,
Self::Bin(v) => &v.fields,
}
}
}
impl<'a, T: WithDefaultType> From<AnyMIMEWithDefault<'a, T>> for AnyMIME<'a> {
fn from(a: AnyMIMEWithDefault<'a, T>) -> Self {

View file

@ -58,6 +58,14 @@ impl<'a> AnyPart<'a> {
_ => None,
}
}
pub fn mime(self) -> &NaiveMIME<'a> {
match self {
Self::Mult(v) => &v.mime.fields,
Self::Msg(v) => &v.mime.fields,
Self::Txt(v) => &v.mime.fields,
Self::Bin(v) => &v.mime.fields,
}
}
}
impl<'a> From<Multipart<'a>> for AnyPart<'a> {
fn from(m: Multipart<'a>) -> Self {