pub struct AddressList<'m> { /* private fields */ }Expand description
An address list: mailboxes and groups in document order (issue #98). Lists compare by content.
use mail_parser::{Address, MessageParser};
let raw = b"To: Ann <ann@example.com>, team: bob@example.com, cy@example.com;\r\n\r\n";
let message = MessageParser::new().parse(raw).expect("message");
let to = message.to().expect("addresses");
let addresses: Vec<_> = to.mailboxes().filter_map(|mailbox| mailbox.address()).collect();
assert_eq!(addresses, ["ann@example.com", "bob@example.com", "cy@example.com"]);
assert!(matches!(to.iter().nth(1), Some(Address::Group(group)) if group.name() == Some("team")));
assert!(to.contains("BOB@example.com"));Implementations§
Source§impl<'m> AddressList<'m>
impl<'m> AddressList<'m>
Sourcepub fn iter(&self) -> impl Iterator<Item = Address<'m>> + use<'m>
pub fn iter(&self) -> impl Iterator<Item = Address<'m>> + use<'m>
Mailboxes and groups in document order.
Sourcepub fn mailboxes(
&self,
) -> impl DoubleEndedIterator<Item = Mailbox<'m>> + use<'m>
pub fn mailboxes( &self, ) -> impl DoubleEndedIterator<Item = Mailbox<'m>> + use<'m>
Every mailbox, groups flattened.
Sourcepub fn groups(
&self,
) -> impl Iterator<Item = (Option<&'m str>, AddressRun<'m>)> + use<'m>
pub fn groups( &self, ) -> impl Iterator<Item = (Option<&'m str>, AddressRun<'m>)> + use<'m>
The JMAP asGroupedAddresses shape (RFC 8621): each group with its
name, and each run of mailboxes outside groups as an unnamed group.
Sourcepub fn contains(&self, address: &str) -> bool
pub fn contains(&self, address: &str) -> bool
Whether any mailbox has this address (ASCII case-insensitive).
Sourcepub fn has_groups(&self) -> bool
pub fn has_groups(&self) -> bool
Whether the list contains at least one group.
Trait Implementations§
Source§impl<'m> Clone for AddressList<'m>
impl<'m> Clone for AddressList<'m>
impl<'m> Copy for AddressList<'m>
Source§impl Debug for AddressList<'_>
impl Debug for AddressList<'_>
impl Eq for AddressList<'_>
Auto Trait Implementations§
impl<'m> Freeze for AddressList<'m>
impl<'m> RefUnwindSafe for AddressList<'m>
impl<'m> Send for AddressList<'m>
impl<'m> Sync for AddressList<'m>
impl<'m> Unpin for AddressList<'m>
impl<'m> UnsafeUnpin for AddressList<'m>
impl<'m> UnwindSafe for AddressList<'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