Trait mailparse::MailHeaderMap
[−]
[src]
pub trait MailHeaderMap { fn get_first_value(
&self,
key: &str
) -> Result<Option<String>, MailParseError>; fn get_all_values(&self, key: &str) -> Result<Vec<String>, MailParseError>; }
A trait that is implemented by the Vec
Required Methods
fn get_first_value(&self, key: &str) -> Result<Option<String>, MailParseError>
Look through the list of headers and return the value of the first one that matches the provided key. It returns Ok(None) if the no matching header was found. Header names are matched case-insensitively.
Examples
use mailparse::{parse_mail, MailHeaderMap}; let headers = parse_mail(concat!( "Subject: Test\n", "\n", "This is a test message").as_bytes()) .unwrap().headers; assert_eq!(headers.get_first_value("Subject").unwrap(), Some("Test".to_string()));
fn get_all_values(&self, key: &str) -> Result<Vec<String>, MailParseError>
Look through the list of headers and return the values of all headers matching the provided key. Returns an empty vector if no matching headers were found. The order of the returned values is the same as the order of the matching headers in the message. Header names are matched case-insensitively.
Examples
use mailparse::{parse_mail, MailHeaderMap}; let headers = parse_mail(concat!( "Key: Value1\n", "Key: Value2").as_bytes()) .unwrap().headers; assert_eq!(headers.get_all_values("Key").unwrap(), vec!["Value1".to_string(), "Value2".to_string()]);
Implementations on Foreign Types
impl<'a> MailHeaderMap for Vec<MailHeader<'a>>
[src]
impl<'a> MailHeaderMap for Vec<MailHeader<'a>>
fn get_first_value(&self, key: &str) -> Result<Option<String>, MailParseError>
[src]
fn get_first_value(&self, key: &str) -> Result<Option<String>, MailParseError>
fn get_all_values(&self, key: &str) -> Result<Vec<String>, MailParseError>
[src]
fn get_all_values(&self, key: &str) -> Result<Vec<String>, MailParseError>