pub struct Email { /* private fields */ }
Expand description
A validated Email object.
These can be created from a string using Email::from_string
,
Email::from_str
, or String::parse
.
Once built you can turn this like a String
, use with Serde, or Sea Orm.
Note that Email objects are case sensetive.
The email addresses Email::from_str("bob@example.com")
and Email::from_str("BoB@example.com")
,
will not be equal to each other.
Implementations§
Source§impl Email
impl Email
Sourcepub fn from_string(raw_email: String) -> Result<Self, EmailError>
pub fn from_string(raw_email: String) -> Result<Self, EmailError>
Creates a new Email, from the String
given.
If the given string doesn’t look like a valid email, then this will return an EmailError.
Sourcepub fn from_str<S>(raw_email: S) -> Result<Self, EmailError>
pub fn from_str<S>(raw_email: S) -> Result<Self, EmailError>
Creates a new Email, from the str
given.
If the given string doesn’t look like a valid email, then this will return an EmailError.
Sourcepub fn to_lowercase(&self) -> Self
pub fn to_lowercase(&self) -> Self
Returns a new Email, where the email has been uppercased.
Sourcepub fn to_uppercase(&self) -> Self
pub fn to_uppercase(&self) -> Self
Returns a new Email, where the internal email has been uppercased.
pub fn as_str<'a>(&'a self) -> &'a str
Trait Implementations§
Source§impl Default for Email
This is a common default, provided in use for stuff like tests.
impl Default for Email
This is a common default, provided in use for stuff like tests.
The default email is default@example.com
.