pub struct Email(/* private fields */);Expand description
A structure representing an email address.
§Structure
Email stores an email address as a string and provides various
implementations for validation, conversion, and serialization.
§Implementations
Constructor:Email::new(email: String) -> Result<Self, TypeMoreError>- Accepts an email string and returns an
Emailif the email is valid.
- Accepts an email string and returns an
FromStr: Implements theFromStrtrait for conversion from string toEmail.Display: Implements theDisplaytrait for printingEmailas a string.Serialize: Implements theSerializetrait for serialization to a string format.Deserialize: Implements theDeserializetrait for deserialization from a string format.
Implementations§
Source§impl Email
Implementation of the constructor and validation for Email.
impl Email
Implementation of the constructor and validation for Email.
Sourcepub fn new(email: String) -> Result<Self, TypeMoreError>
pub fn new(email: String) -> Result<Self, TypeMoreError>
Creates a new instance of Email.
§Parameters
email: A string representing the email address.
§Returns
Ok(Self(email)): If the email is valid.Err(TypeMoreError::ParseError("invalid email".to_string())): If the email is invalid.
§Errors
TypeMoreError::UnhandledError("invalid regex pattern".to_string()): If the regex pattern is invalid.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Email
Implementation of the Deserialize trait for deserializing Email.
impl<'de> Deserialize<'de> for Email
Implementation of the Deserialize trait for deserializing Email.
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 Email
Implementation of the FromStr trait for converting from string to Email.
impl FromStr for Email
Implementation of the FromStr trait for converting from string to Email.
impl StructuralPartialEq for Email
Auto Trait Implementations§
impl Freeze for Email
impl RefUnwindSafe for Email
impl Send for Email
impl Sync for Email
impl Unpin for Email
impl UnwindSafe for Email
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