ceal 0.1.0

Opportunistic E-Mail Encryption - Stand-Alone Library and Extensions for Lettre
Documentation
//! This mod contains the [`Address`] trait.

use email_address::EmailAddress;

pub trait Address {
	/// Return the local part of the E-Mail address.
	fn local(&self) -> &str;

	/// Return the domain part of the E-Mail address.
	fn domain(&self) -> &str;
}

impl Address for EmailAddress {
	fn local(&self) -> &str {
		EmailAddress::local_part(self)
	}

	fn domain(&self) -> &str {
		EmailAddress::domain(self)
	}
}

#[cfg(feature = "lettre")]
impl Address for lettre::Address {
	fn local(&self) -> &str {
		lettre::Address::user(self)
	}

	fn domain(&self) -> &str {
		lettre::Address::domain(self)
	}
}

#[cfg(feature = "lettre")]
impl Address for lettre::message::Mailbox {
	fn local(&self) -> &str {
		lettre::Address::user(&self.email)
	}

	fn domain(&self) -> &str {
		lettre::Address::domain(&self.email)
	}
}