[−][src]Struct email_address_parser::EmailAddress
Email address struct.
Examples
use email_address_parser::EmailAddress; assert!(EmailAddress::parse("foo@-bar.com", Some(true)).is_none()); let email = EmailAddress::parse("foo@bar.com", Some(true)); assert!(email.is_some()); let email = email.unwrap(); assert_eq!(email.get_local_part(), "foo"); assert_eq!(email.get_domain(), "bar.com"); assert_eq!(format!("{}", email), "foo@bar.com");
Implementations
impl EmailAddress
pub fn new(local_part: &str, domain: &str) -> EmailAddress
[src]
Instantiates a new EmailAddress
.
Accessible from WASM.
#Examples
use email_address_parser::EmailAddress; let email = EmailAddress::new("foo", "bar.com");
pub fn parse(input: &str, is_strict: Option<bool>) -> Option<EmailAddress>
[src]
Parses a given string as an email address.
Accessible from WASM.
Returns Some(EmailAddress)
if the parsing is successful, else None
.
#Examples
use email_address_parser::EmailAddress; // strict parsing let email = EmailAddress::parse("foo@bar.com", Some(true)); assert!(email.is_some()); let email = email.unwrap(); assert_eq!(email.get_local_part(), "foo"); assert_eq!(email.get_domain(), "bar.com"); // non-strict parsing let email = EmailAddress::parse("\u{0d}\u{0a} \u{0d}\u{0a} test@iana.org", None); assert!(email.is_some()); // parsing invalid address let email = EmailAddress::parse("test@-iana.org", Some(true)); assert!(email.is_none()); let email = EmailAddress::parse("test@-iana.org", None); assert!(email.is_none()); let email = EmailAddress::parse("test", Some(true)); assert!(email.is_none()); let email = EmailAddress::parse("test", None); assert!(email.is_none());
impl EmailAddress
[src]
pub fn get_local_part(&self) -> &str
[src]
Returns the local part of the email address.
Not accessible from WASM.
#Examples
use email_address_parser::EmailAddress; let email = EmailAddress::new("foo", "bar.com"); assert_eq!(email.get_local_part(), "foo"); let email = EmailAddress::parse("foo@bar.com", Some(true)).unwrap(); assert_eq!(email.get_local_part(), "foo");
pub fn get_domain(&self) -> &str
[src]
Returns the domain of the email address.
Not accessible from WASM.
#Examples
use email_address_parser::EmailAddress; let email = EmailAddress::new("foo", "bar.com"); assert_eq!(email.get_domain(), "bar.com"); let email = EmailAddress::parse("foo@bar.com", Some(true)).unwrap(); assert_eq!(email.get_domain(), "bar.com");
Trait Implementations
impl Debug for EmailAddress
[src]
impl Display for EmailAddress
[src]
impl From<EmailAddress> for JsValue
[src]
fn from(value: EmailAddress) -> Self
[src]
impl FromWasmAbi for EmailAddress
[src]
type Abi = u32
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: u32) -> Self
[src]
impl IntoWasmAbi for EmailAddress
[src]
type Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self) -> u32
[src]
impl OptionFromWasmAbi for EmailAddress
[src]
impl OptionIntoWasmAbi for EmailAddress
[src]
impl RefFromWasmAbi for EmailAddress
[src]
type Abi = u32
The wasm ABI type references to Self
are recovered from.
type Anchor = Ref<'static, EmailAddress>
The type that holds the reference to Self
for the duration of the invocation of the function that has an &Self
parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl RefMutFromWasmAbi for EmailAddress
[src]
type Abi = u32
Same as RefFromWasmAbi::Abi
type Anchor = RefMut<'static, EmailAddress>
Same as RefFromWasmAbi::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl WasmDescribe for EmailAddress
[src]
Auto Trait Implementations
impl RefUnwindSafe for EmailAddress
impl Send for EmailAddress
impl Sync for EmailAddress
impl Unpin for EmailAddress
impl UnwindSafe for EmailAddress
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
[src]
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,