Skip to main content

EmailClient

Enum EmailClient 

Source
pub enum EmailClient {
    Smtp(SmtpClient),
    Terminal(TerminalClient),
    Memory(MemoryClient),
    MailerSend(MailerSendClient),
}
Available on crate features document-features or mailersend or memory or smtp or terminal only.
Expand description

EmailClient Enum representing different types of email clients. Currently supported email clients: SMTP, Terminal, Memory.

§Examples

To integrate SMTP email client:

 use email_clients::clients::EmailClient;
 use email_clients::clients::smtp::{SmtpClient, SmtpConfig};
 let config = SmtpConfig::default();
 let smtp_email_client = EmailClient::Smtp(SmtpClient::new(config));

To integrate Terminal email client:

 use email_clients::clients::EmailClient;
 use email_clients::configuration::EmailConfiguration::Terminal;
 use email_clients::clients::terminal::{TerminalClient, TerminalConfig};
 let config = TerminalConfig::default() ;
 let terminal_email_client = EmailClient::Terminal(TerminalClient::new(config));

To integrate Memory email client:

 use email_clients::clients::EmailClient;
 use email_clients::configuration::EmailConfiguration::Memory;
 use email_clients::clients::memory::{MemoryClient, MemoryConfig};
let config = MemoryConfig::default();

let memory_email_client = EmailClient::Memory(MemoryClient::new(config));

To integrate mailersend client:

 use email_clients::clients::EmailClient;
 use email_clients::clients::mailersend::{MailerSendClient, MailerSendConfig};

 let config = MailerSendConfig::default().api_token("API_TOKEN");
 let mailersend_client = EmailClient::MailerSend(MailerSendClient::new(config));

Variants§

§

Smtp(SmtpClient)

Available on crate feature smtp only.
§

Terminal(TerminalClient)

Available on crate feature terminal only.
§

Memory(MemoryClient)

Available on crate feature memory only.
§

MailerSend(MailerSendClient)

Available on crate feature mailersend only.

Implementations§

Source§

impl EmailClient

Source

pub fn unwrap(self) -> Box<dyn EmailTrait + Send>

Unwrap the EmailClient enum variant and convert it into a Box<dyn EmailTrait + Send>.

This method allows us to obtain a Boxed trait object which implements EmailTrait and Send from an instance of EmailClient regardless of its variant.

§Examples

Basic usage:

 use email_clients::email::EmailObject;

let config = SmtpConfig::default();
let smtp_email_client = EmailClient::Smtp(SmtpClient::new(config));

// Unwrapping converts the specific variant into a Boxed trait object.
let unwrapped_client = smtp_email_client.unwrap();

// Now we can use unwrapped_client directly to use methods of EmailTrait.
unwrapped_client.send_emails(EmailObject::default()).await?;

Trait Implementations§

Source§

impl Clone for EmailClient

Source§

fn clone(&self) -> EmailClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EmailClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EmailClient

Available on crate feature terminal only.
Source§

fn default() -> Self

Default constructor for EmailClient.

This method will create a new EmailClient configured with default TerminalClient. This is useful when you want to quickly get a working EmailClient without specifying any configuration.

§Examples

Basic usage:

let client = EmailClient::default();
assert_eq!(client.unwrap().get_sender().to_string(), "");

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more