Skip to main content

EmailNotifier

Struct EmailNotifier 

Source
pub struct EmailNotifier { /* private fields */ }
Expand description

Struct containing config and a tag. Associated methods are used to send email and to enclose functions in status updates.

Implementations§

Source§

impl EmailNotifier

Source

pub fn new(tag: impl ToString) -> Self

Constructs a new EmailNotifier. The parameter tag is a descriptive name given to the process that you are monitoring. This tag will be included in the subject line of any sent emails. Configuration is loaded from the default location.

§Example
use email_notif::EmailNotifier;
let em = EmailNotifier::new();
Source

pub fn send_update(&self, body: String)

Send an update email about the running process, with the given body text.

Source

pub fn send_success(&self)

Send a message indicating the process has completed successfully.

Source

pub fn send_error(&self)

Send a message indicating the process has resulted in a panic.

Source

pub fn capture<F>(self, f: F)

Run a closure and send an email when the closure completes successfully (EmailNotifier::send_success) or if the process results in a panic, send an error message (EmailNotifier::send_error)

§Example
use email_notif::EmailNotifier;
EmailNotifier::new("Test").capture(|em|{
   for i in 0..10 {
     em.send_update(format!("iteration {i} complete."));
   }
});

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.