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
impl EmailNotifier
Sourcepub fn new(tag: impl ToString) -> Self
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();Sourcepub fn send_update(&self, body: String)
pub fn send_update(&self, body: String)
Send an update email about the running process, with the given body text.
Sourcepub fn send_success(&self)
pub fn send_success(&self)
Send a message indicating the process has completed successfully.
Sourcepub fn send_error(&self)
pub fn send_error(&self)
Send a message indicating the process has resulted in a panic.
Sourcepub fn capture<F>(self, f: F)
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§
impl Freeze for EmailNotifier
impl RefUnwindSafe for EmailNotifier
impl Send for EmailNotifier
impl Sync for EmailNotifier
impl Unpin for EmailNotifier
impl UnsafeUnpin for EmailNotifier
impl UnwindSafe for EmailNotifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more