[][src]Enum melib::email::address::Address

pub enum Address {
    Mailbox(MailboxAddress),
    Group(GroupAddress),
}

An email address.

Conforms to RFC5322 - Internet Message Format.

Creating an Address

You can directly create an address with Address::new,

let addr = Address::new(Some("Jörg Doe".to_string()), "joerg@example.com".to_string());
assert_eq!(addr.to_string().as_str(), "Jörg Doe <joerg@example.com>");

or parse it from a raw value:

let (rest_bytes, addr) = melib::email::parser::address::address("=?utf-8?q?J=C3=B6rg_Doe?= <joerg@example.com>".as_bytes()).unwrap();
assert!(rest_bytes.is_empty());
assert_eq!(addr.get_display_name(), Some("Jörg Doe".to_string()));
assert_eq!(addr.get_email(), "joerg@example.com".to_string());

Variants

Mailbox(MailboxAddress)
Group(GroupAddress)

Implementations

impl Address[src]

pub fn new(display_name: Option<String>, address: String) -> Self[src]

pub fn new_group(display_name: String, mailbox_list: Vec<Address>) -> Self[src]

pub fn raw(&self) -> &[u8][src]

pub fn get_display_name(&self) -> Option<String>[src]

Get the display name of this address.

If it's a group, it's the name of the group. Otherwise it's the display_name part of the mailbox:

          raw                         raw
┌──────────┴────────────┐   ┌──────────┴────────────────────┐
Name <address@domain.tld>   "Name Name2" <address@domain.tld>
└─┬┘  └──────────┬─────┘     └─────┬──┘   └──────────┬─────┘
display_name     │          display_name             │
                 │                                   │
           address_spec                        address_spec

pub fn get_email(&self) -> String[src]

Get the address spec part of this address. A group returns an empty String.

pub fn address_spec_raw(&self) -> &[u8][src]

pub fn get_fqdn(&self) -> Option<String>[src]

pub fn get_tags(&self, separator: char) -> Vec<String>[src]

pub fn list_try_from(val: &str) -> Result<Vec<Address>>[src]

pub fn contains_address(&self, other: &Address) -> bool[src]

pub fn subaddress(&self, separator: &str) -> Option<(Self, String)>[src]

Get subaddress out of an address (e.g. ken+subaddress@example.org).

Subaddresses are commonly text following a "+" character in an email address's local part . They are defined in RFC5233 Sieve Email Filtering: Subaddress Extension

Examples

let addr = "ken+sieve@example.org";
let (rest, val) = melib::email::parser::address::address(addr.as_bytes()).unwrap();
assert!(rest.is_empty());
assert_eq!(
    val.subaddress("+"),
    Some((
        Address::new(None, "ken@example.org".to_string()),
        "sieve".to_string()
    ))
);

Trait Implementations

impl Clone for Address[src]

impl Debug for Address[src]

impl<'de> Deserialize<'de> for Address[src]

impl Display for Address[src]

impl Eq for Address[src]

impl Hash for Address[src]

impl Into<Address> for EmailAddress[src]

impl PartialEq<Address> for Address[src]

impl Serialize for Address[src]

impl<'_> TryFrom<&'_ str> for Address[src]

type Error = MeliError

The type returned in the event of a conversion error.

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

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]