[][src]Struct email_address_parser::EmailAddress

pub struct EmailAddress { /* fields omitted */ }

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]

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

impl IntoWasmAbi for EmailAddress[src]

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary. Read more

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

impl RefMutFromWasmAbi for EmailAddress[src]

type Abi = u32

Same as RefFromWasmAbi::Abi

type Anchor = RefMut<'static, EmailAddress>

Same as RefFromWasmAbi::Anchor

impl WasmDescribe for EmailAddress[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ReturnWasmAbi for T where
    T: IntoWasmAbi
[src]

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.