1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#[cfg(feature = "arbitrary")]
use arbitrary::Arbitrary;
#[cfg(feature = "bounded-static")]
use bounded_static::ToStatic;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use crate::core::NString;

/// An address structure describes an electronic mail address.
#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
#[cfg_attr(feature = "bounded-static", derive(ToStatic))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
/// TODO(misuse):
///
///   Here are many invariants ...
///
///   mailbox:
///     NIL indicates end of [RFC-2822] group;
///     if non-NIL and host is NIL, holds [RFC-2822] group name.
///     Otherwise, holds [RFC-2822] local-part after removing [RFC-2822] quoting
///
///   host:
///     NIL indicates [RFC-2822] group syntax.
///     Otherwise, holds [RFC-2822] domain name
pub struct Address<'a> {
    /// Personal name
    pub name: NString<'a>,
    /// At-domain-list (source route)
    pub adl: NString<'a>,
    /// Mailbox name
    pub mailbox: NString<'a>,
    /// Host name
    pub host: NString<'a>,
}