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, D>(user: U, domain: D) -> Result<Address, AddressError>
pub fn new<U, D>(user: U, domain: D) -> Result<Address, 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 Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.