pub struct Address { /* private fields */ }
Expand description
Represents an email address with a user and a domain name.
This type contains email in canonical form (user@domain.tld).
NOTE: Enable feature “serde” to be able to serialize/deserialize it using serde.
§Examples
You can create an Address
from a user and a domain:
use lettre::Address;
let address = Address::new("user", "email.com")?;
assert_eq!(address.user(), "user");
assert_eq!(address.domain(), "email.com");
You can also create an Address
from a string literal by parsing it:
use lettre::Address;
let address = "user@email.com".parse::<Address>()?;
assert_eq!(address.user(), "user");
assert_eq!(address.domain(), "email.com");
Implementations§
source§impl Address
impl Address
sourcepub fn new<U: AsRef<str>, D: AsRef<str>>(
user: U,
domain: D
) -> Result<Self, AddressError>
pub fn new<U: AsRef<str>, D: AsRef<str>>( user: U, domain: D ) -> Result<Self, AddressError>
Creates a new email address from a user and domain.
§Examples
use lettre::Address;
let address = Address::new("user", "email.com")?;
let expected = "user@email.com".parse::<Address>()?;
assert_eq!(expected, address);
Trait Implementations§
source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl FromStr for Address
impl FromStr for Address
§type Err = AddressError
type Err = AddressError
The associated error which can be returned from parsing.
source§impl Ord for Address
impl Ord for Address
source§impl PartialEq for Address
impl PartialEq for Address
source§impl PartialOrd for Address
impl PartialOrd for Address
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl TryFrom<String> for Address
impl TryFrom<String> for Address
§type Error = AddressError
type Error = AddressError
The type returned in the event of a conversion error.
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more