[][src]Struct new_tokio_smtp::send_mail::SendAllMails

pub struct SendAllMails<I> { /* fields omitted */ }

Adapter to send all mails from an iterable instance through a smtp connection.

Implementations

impl<I, E> SendAllMails<I> where
    I: Iterator<Item = Result<MailEnvelop, E>>,
    E: From<GeneralError>, 
[src]

pub fn new<V>(con: Connection, mails: V) -> Self where
    V: IntoIterator<IntoIter = I, Item = Result<MailEnvelop, E>>, 
[src]

create a new SendAllMails stream adapter

pub fn take_connection(&mut self) -> Option<Connection>[src]

takes the connection out of the adapter

  • if there currently is a pending future this will always be None
  • if mails is not completed and this adapter is polled afterwards all later mails will fail with M::Error::from(GeneralError::PreviousErrorKilledConnection)

pub fn set_connection(&mut self, con: Connection) -> Option<Connection>[src]

sets the connection to use in the adapter for sending mails

returns the currently set connection, if any

pub fn is_pending(&self) -> bool[src]

true if a mail is currently in the process of being send

pub fn quit_on_completion(self) -> impl Stream<Item = (), Error = E>[src]

Quits the contained connection once the stream is completed.

The result from quitting is discarded, which is fine as this only happens if:

  1. for some reason the connection was interrupted (the server already quit)
  2. the server responds with a error to sending the QUIT command

In both cases it's reasonable to simply drop the connection when dropping this stream.

pub fn on_completion<F, ITF>(self, func: F) -> impl Stream<Item = (), Error = E> where
    F: FnOnce(Option<Connection>) -> ITF,
    ITF: IntoFuture<Item = (), Error = ()>, 
[src]

Calls a closure once the stream completed with the connection (if there is one).

The closure can resolve to a future which is resolved, but the result of the future is ignored.

A common think to do once the SendAllFuture is done is to quit the connection, through for this quit_on_completion should be used. Another possibility is that if you have a pool of connections the closure will put the connection back into the pool it took it out from to allow connection reuse.

Trait Implementations

impl<I, E> Stream for SendAllMails<I> where
    I: Iterator<Item = Result<MailEnvelop, E>>,
    E: From<GeneralError>, 
[src]

type Item = ()

The type of item this stream will yield on success.

type Error = E

The type of error this stream may generate.

Auto Trait Implementations

impl<I> !RefUnwindSafe for SendAllMails<I>

impl<I> Send for SendAllMails<I> where
    I: Send

impl<I> !Sync for SendAllMails<I>

impl<I> Unpin for SendAllMails<I> where
    I: Unpin

impl<I> !UnwindSafe for SendAllMails<I>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StreamExt for T where
    T: Stream + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.