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 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 Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
Source§impl TryFrom<String> for Address
impl TryFrom<String> for Address
Source§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