Merge pull request 'expose naive fields' (#27) from fetch-mime-from-anypart into main

Reviewed-on: #27
This commit is contained in:
Quentin 2023-09-18 16:07:16 +00:00
commit df0c6fa34f
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 {