[−][src]Enum melib::email::address::Address
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for Address
[src]
impl Eq for Address
[src]
impl Hash for Address
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Into<Address> for EmailAddress
[src]
impl PartialEq<Address> for Address
[src]
impl Serialize for Address
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'_> TryFrom<&'_ str> for Address
[src]
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]
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> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,