1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::borrow::Cow;

#[derive(Debug, Clone)]
pub struct Mailbox<'a> {
    /// The name associated with an email.\
    /// Each name is stored individually in the `Vec`. For example "Elton John" results in `Some(["Elton", "John"])`.\
    /// Be aware that might also get `Some(["Elton John"])` when the `mime` feature is enabled because whitespaces may appear after decoding encoded data.
    pub name: Option<Vec<Cow<'a, str>>>,
    pub address: EmailAddress<'a>,
}

#[derive(Debug, Clone)]
pub struct EmailAddress<'a> {
    pub local_part: Cow<'a, str>,
    pub domain: Cow<'a, str>,
}

#[derive(Debug, Clone)]
pub enum Address<'a> {
    Mailbox(Mailbox<'a>),
    Group((Vec<Cow<'a, str>>, Vec<Mailbox<'a>>)),
}