imap_types/
envelope.rs

1//! Envelope-related types.
2
3#[cfg(feature = "arbitrary")]
4use arbitrary::Arbitrary;
5#[cfg(feature = "bounded-static")]
6use bounded_static::ToStatic;
7#[cfg(feature = "serde")]
8use serde::{Deserialize, Serialize};
9
10use crate::core::NString;
11
12#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
13#[cfg_attr(feature = "bounded-static", derive(ToStatic))]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15#[derive(Debug, Clone, PartialEq, Eq, Hash)]
16pub struct Envelope<'a> {
17    pub date: NString<'a>,
18    pub subject: NString<'a>,
19    pub from: Vec<Address<'a>>,
20    pub sender: Vec<Address<'a>>,
21    pub reply_to: Vec<Address<'a>>,
22    pub to: Vec<Address<'a>>,
23    pub cc: Vec<Address<'a>>,
24    pub bcc: Vec<Address<'a>>,
25    pub in_reply_to: NString<'a>,
26    pub message_id: NString<'a>,
27}
28
29/// An address structure describes an electronic mail address.
30#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
31#[cfg_attr(feature = "bounded-static", derive(ToStatic))]
32#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
33#[derive(Debug, Clone, PartialEq, Eq, Hash)]
34/// TODO(misuse):
35///
36///   Here are many invariants ...
37///
38///   mailbox:
39///     NIL indicates end of [RFC-2822] group;
40///     if non-NIL and host is NIL, holds [RFC-2822] group name.
41///     Otherwise, holds [RFC-2822] local-part after removing [RFC-2822] quoting
42///
43///   host:
44///     NIL indicates [RFC-2822] group syntax.
45///     Otherwise, holds [RFC-2822] domain name
46pub struct Address<'a> {
47    /// Personal name
48    pub name: NString<'a>,
49    /// At-domain-list (source route)
50    pub adl: NString<'a>,
51    /// Mailbox name
52    pub mailbox: NString<'a>,
53    /// Host name
54    pub host: NString<'a>,
55}