pub struct Mailbox { /* private fields */ }Expand description
A mailbox address with optional display name.
Implementations§
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Mailbox
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Mailbox
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for Mailbox
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Mailbox
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for Mailbox
Renders the mailbox as "display name" <email> or just email if no
display name is set.
impl Display for Mailbox
Renders the mailbox as "display name" <email> or just email if no
display name is set.
The output is UTF-8-direct: a non-ASCII display name is emitted
verbatim (e.g. "José" <jose@example.com>). This is the right shape
for HTTP-API consumers (Postmark, Resend, Mailgun, Loops) which
JSON-encode UTF-8 strings natively.
Do not use the result directly as an RFC 5322 header value. SMTP
headers are 7-bit and require RFC 2047 encoded-word wrapping for
non-ASCII display names; the wire renderer
(email_message_wire::render_rfc822) applies that encoding
separately. Routing Mailbox::to_string() straight into a From:
or To: header would emit a malformed RFC 5322 line.
Source§impl Extend<Mailbox> for MailboxList
impl Extend<Mailbox> for MailboxList
Source§fn extend<T: IntoIterator<Item = Mailbox>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Mailbox>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<(String, EmailAddress)> for Mailbox
impl From<(String, EmailAddress)> for Mailbox
Source§fn from((name, email): (String, EmailAddress)) -> Self
fn from((name, email): (String, EmailAddress)) -> Self
Source§impl From<EmailAddress> for Mailbox
impl From<EmailAddress> for Mailbox
Source§fn from(email: EmailAddress) -> Self
fn from(email: EmailAddress) -> Self
Source§impl FromIterator<Mailbox> for MailboxList
impl FromIterator<Mailbox> for MailboxList
Source§impl JsonSchema for Mailbox
Available on crate feature schemars only.
impl JsonSchema for Mailbox
schemars only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl TryFrom<&str> for Mailbox
impl TryFrom<&str> for Mailbox
Source§fn try_from(value: &str) -> Result<Self, Self::Error>
fn try_from(value: &str) -> Result<Self, Self::Error>
Parses a single mailbox from a string slice.
use email_message::Mailbox;
let mailbox = Mailbox::try_from("Mary Smith <mary@x.test>").unwrap();
assert_eq!(mailbox.name(), Some("Mary Smith"));
assert_eq!(mailbox.email().as_str(), "mary@x.test");