diff --git a/src/lib.rs b/src/lib.rs index ded02c1..2e3eb46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1360,6 +1360,16 @@ pub trait MimeHeaders<'x> { .and_then(|cd| cd.attribute("filename")) .or_else(|| self.content_type().and_then(|ct| ct.attribute("name"))) } + // Returns true is the content type matches + fn is_content_type(&self, type_: &str, subtype: &str) -> bool { + self.content_type().map_or(false, |ct| { + ct.c_type.eq_ignore_ascii_case(type_) + && ct + .c_subtype + .as_ref() + .map_or(false, |st| st.eq_ignore_ascii_case(subtype)) + }) + } } impl<'x> MimeHeaders<'x> for Message<'x> { diff --git a/src/parsers/fields/date.rs b/src/parsers/fields/date.rs index e324476..f235790 100644 --- a/src/parsers/fields/date.rs +++ b/src/parsers/fields/date.rs @@ -20,7 +20,7 @@ pub static MONTH: &[&str] = &[ impl DateTime { /// Parses an RFC822 date - pub fn parse_rfc822(&self, value: &str) -> Option { + pub fn parse_rfc822(value: &str) -> Option { match MessageStream::new(value.as_bytes()).parse_date() { HeaderValue::DateTime(dt) => dt.into(), _ => None,