Struct MailAssertion

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

An assertion object for testing the mails sent on a MockServer. See MockServer::assert for calling the MailAssertion.

§Examples

Assert user@domain.tld sent something.

let ma = maik::MailAssertion::new().sender_is("user@domain.tld");

Assert user@domain.tld sent Hi,\r\n\r\nBye! to at least user1@domain.tld and user2@domain.tld.

let mut recipients = std::collections::HashSet::new();
recipients.insert("user1@domain.tld");
recipients.insert("user2@domain.tld");

let ma = maik::MailAssertion::new()
    .sender_is("user@domain.tld")
    .recipients_contain(recipients)
    .body_is("Hi,\r\n\r\nBye!");

Assert user@domain.tld received an email that contains “verification code: “.

let mut recipients = std::collections::HashSet::new();
recipients.insert("user@domain.tld");

let ma = maik::MailAssertion::new()
    .recipients_are(recipients)
    .body_contains("verification code: ");

Implementations§

Source§

impl MailAssertion

Source

pub fn new() -> Self

Creates a MailAssertion object.

Source

pub fn sender_is(self, user: &str) -> Self

Asserts that the sender equals to the given user.

Source

pub fn recipients_are(self, users: HashSet<&str>) -> Self

Asserts that the recipients equal to the given users.

Source

pub fn recipients_contain(self, users: HashSet<&str>) -> Self

Asserts that the recipients contain the given users.

Source

pub fn body_is(self, text: &str) -> Self

Asserts that the body equals the given text.

Source

pub fn body_contains(self, text: &str) -> Self

Asserts that the body contains the given text.

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.