email_parser/address.rs
1use std::borrow::Cow;
2
3#[derive(Debug, Clone)]
4pub struct Mailbox<'a> {
5 /// The name associated with an email.\
6 /// Each name is stored individually in the `Vec`. For example "Elton John" results in `Some(["Elton", "John"])`.\
7 /// Be aware that might also get `Some(["Elton John"])` when the `mime` feature is enabled because whitespaces may appear after decoding encoded data.
8 pub name: Option<Vec<Cow<'a, str>>>,
9 pub address: EmailAddress<'a>,
10}
11
12#[derive(Debug, Clone)]
13pub struct EmailAddress<'a> {
14 pub local_part: Cow<'a, str>,
15 pub domain: Cow<'a, str>,
16}
17
18#[derive(Debug, Clone)]
19pub enum Address<'a> {
20 Mailbox(Mailbox<'a>),
21 Group((Vec<Cow<'a, str>>, Vec<Mailbox<'a>>)),
22}