From 0a7179a17c893514e51a47af1b9e37a1f1a946f8 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 18 Sep 2023 18:06:37 +0200 Subject: [PATCH] expose naive fields --- src/mime/mod.rs | 10 ++++++++++ src/part/mod.rs | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/mime/mod.rs b/src/mime/mod.rs index 542d083..a4637cf 100644 --- a/src/mime/mod.rs +++ b/src/mime/mod.rs @@ -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> for AnyMIME<'a> { fn from(a: AnyMIMEWithDefault<'a, T>) -> Self { diff --git a/src/part/mod.rs b/src/part/mod.rs index cc5c4b5..9171fe0 100644 --- a/src/part/mod.rs +++ b/src/part/mod.rs @@ -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> for AnyPart<'a> { fn from(m: Multipart<'a>) -> Self { -- 2.45.2