pub struct EmailAddress { /* private fields */ }Expand description
A validated RFC 5322 addr-spec email address.
§Domain case-folding
Per RFC 5321 §2.4 the domain part of an address is
case-insensitive while the local part “MUST BE treated as case
sensitive.” On construction this type lowercases the domain to
ASCII-lowercase and preserves the local-part bytes verbatim, so
"User.Name@Example.COM" and "User.Name@example.com" compare
equal via the derived PartialEq / Eq / Hash. IP-literal
domains ([192.0.2.1], [IPv6:::1]) are not case-folded, RFC 5321
§4.1.3 says address literals are case-sensitive, they keep the
caller’s bytes.
The case fold is intentional: HashSet<EmailAddress> and
Envelope::rcpt_to: Vec<EmailAddress> dedup paths previously kept
differently-cased spellings of the same SMTP mailbox as distinct
recipients. Callers who need byte-faithful preservation of the
original input should keep the source String separately; this
type is the SMTP-equivalence value.
Implementations§
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for EmailAddress
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for EmailAddress
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 AsRef<str> for EmailAddress
impl AsRef<str> for EmailAddress
Source§impl Clone for EmailAddress
impl Clone for EmailAddress
Source§fn clone(&self) -> EmailAddress
fn clone(&self) -> EmailAddress
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EmailAddress
impl Debug for EmailAddress
Source§impl<'de> Deserialize<'de> for EmailAddress
Available on crate feature serde only.
impl<'de> Deserialize<'de> for EmailAddress
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 EmailAddress
impl Display for EmailAddress
Source§impl From<EmailAddress> for Mailbox
impl From<EmailAddress> for Mailbox
Source§fn from(email: EmailAddress) -> Self
fn from(email: EmailAddress) -> Self
Source§impl From<EmailAddress> for String
impl From<EmailAddress> for String
Source§fn from(value: EmailAddress) -> Self
fn from(value: EmailAddress) -> Self
Source§impl FromStr for EmailAddress
impl FromStr for EmailAddress
Source§impl Hash for EmailAddress
impl Hash for EmailAddress
Source§impl JsonSchema for EmailAddress
Available on crate feature schemars only.
impl JsonSchema for EmailAddress
schemars only.Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§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§impl PartialEq for EmailAddress
impl PartialEq for EmailAddress
Source§impl Serialize for EmailAddress
Available on crate feature serde only.
impl Serialize for EmailAddress
serde only.Source§impl TryFrom<&str> for EmailAddress
impl TryFrom<&str> for EmailAddress
Source§fn try_from(value: &str) -> Result<Self, Self::Error>
fn try_from(value: &str) -> Result<Self, Self::Error>
Parses and validates an email from a string slice.
use email_message::EmailAddress;
let email = EmailAddress::try_from("jdoe@one.test").unwrap();
assert_eq!(email.as_str(), "jdoe@one.test");