pub struct ContentType<'m> { /* private fields */ }Expand description
A Content-Type or Content-Disposition value. Type, subtype and parameter names are lowercase; RFC 2231 and RFC 2047 encoded parameter values are decoded. Values compare by content.
use mail_parser::MessageParser;
let raw = b"Content-Type: Text/Plain; Charset=\"utf-8\"; format=flowed\r\n\r\nbody";
let message = MessageParser::new().parse(raw).expect("message");
let content_type = message.content_type().expect("content type");
assert_eq!((content_type.ctype(), content_type.subtype()), ("text", Some("plain")));
assert_eq!(content_type.attribute("charset"), Some("utf-8"));
assert!(message.is_content_type("text", "plain"));Implementations§
Source§impl<'m> ContentType<'m>
impl<'m> ContentType<'m>
Sourcepub fn subtype(&self) -> Option<&'m str>
pub fn subtype(&self) -> Option<&'m str>
The subtype (plain, mixed, …); None for a disposition or a
type without /.
Sourcepub fn attribute(&self, name: &str) -> Option<&'m str>
pub fn attribute(&self, name: &str) -> Option<&'m str>
The first parameter with this (lowercase) name.
Sourcepub fn attributes(
&self,
) -> impl ExactSizeIterator<Item = (&'m str, &'m str)> + DoubleEndedIterator + use<'m>
pub fn attributes( &self, ) -> impl ExactSizeIterator<Item = (&'m str, &'m str)> + DoubleEndedIterator + use<'m>
Every parameter in document order.
Sourcepub fn has_attribute(&self, name: &str) -> bool
pub fn has_attribute(&self, name: &str) -> bool
Whether a parameter with this (lowercase) name is present.
Sourcepub fn is_attachment(&self) -> bool
pub fn is_attachment(&self) -> bool
Whether this is Content-Disposition: attachment.
Trait Implementations§
Source§impl<'m> Clone for ContentType<'m>
impl<'m> Clone for ContentType<'m>
impl<'m> Copy for ContentType<'m>
Source§impl Debug for ContentType<'_>
impl Debug for ContentType<'_>
impl Eq for ContentType<'_>
Auto Trait Implementations§
impl<'m> Freeze for ContentType<'m>
impl<'m> RefUnwindSafe for ContentType<'m>
impl<'m> Send for ContentType<'m>
impl<'m> Sync for ContentType<'m>
impl<'m> Unpin for ContentType<'m>
impl<'m> UnsafeUnpin for ContentType<'m>
impl<'m> UnwindSafe for ContentType<'m>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more