Skip to main content

AddressList

Struct AddressList 

Source
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>

Source

pub fn is_empty(&self) -> bool

Whether the list has neither mailboxes nor groups.

Source

pub fn iter(&self) -> impl Iterator<Item = Address<'m>> + use<'m>

Mailboxes and groups in document order.

Source

pub fn mailboxes( &self, ) -> impl DoubleEndedIterator<Item = Mailbox<'m>> + use<'m>

Every mailbox, groups flattened.

Source

pub fn first(&self) -> Option<Mailbox<'m>>

The first mailbox, groups flattened.

Source

pub fn last(&self) -> Option<Mailbox<'m>>

The last mailbox, groups flattened.

Source

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.

Source

pub fn contains(&self, address: &str) -> bool

Whether any mailbox has this address (ASCII case-insensitive).

Source

pub fn has_groups(&self) -> bool

Whether the list contains at least one group.

Trait Implementations§

Source§

impl<'m> Clone for AddressList<'m>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'m> Copy for AddressList<'m>

Source§

impl Debug for AddressList<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for AddressList<'_>

Source§

impl PartialEq for AddressList<'_>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.