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
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
sourcefn 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
sourceimpl FromStr for Address
impl FromStr for Address
type Err = AddressError
type Err = AddressError
The associated error which can be returned from parsing.
sourceimpl Ord for Address
impl Ord for Address
sourceimpl PartialOrd<Address> for Address
impl PartialOrd<Address> for Address
sourcefn partial_cmp(&self, other: &Address) -> Option<Ordering>
fn partial_cmp(&self, other: &Address) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl 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.
sourcefn try_from(serialized: String) -> Result<Self, AddressError>
fn try_from(serialized: String) -> Result<Self, AddressError>
Performs the conversion.
impl Eq for Address
impl StructuralEq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more