Struct new_tokio_smtp::send_mail::SendAllMails
source · pub struct SendAllMails<I> { /* private fields */ }
Expand description
Adapter to send all mails from an iterable instance through a smtp connection.
Implementations§
source§impl<I, E> SendAllMails<I>where
I: Iterator<Item = Result<MailEnvelop, E>>,
E: From<GeneralError>,
impl<I, E> SendAllMails<I>where
I: Iterator<Item = Result<MailEnvelop, E>>,
E: From<GeneralError>,
sourcepub fn new<V>(con: Connection, mails: V) -> Selfwhere
V: IntoIterator<IntoIter = I, Item = Result<MailEnvelop, E>>,
pub fn new<V>(con: Connection, mails: V) -> Selfwhere
V: IntoIterator<IntoIter = I, Item = Result<MailEnvelop, E>>,
create a new SendAllMails
stream adapter
sourcepub fn take_connection(&mut self) -> Option<Connection>
pub fn take_connection(&mut self) -> Option<Connection>
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 withM::Error::from(GeneralError::PreviousErrorKilledConnection)
sourcepub fn set_connection(&mut self, con: Connection) -> Option<Connection>
pub fn set_connection(&mut self, con: Connection) -> Option<Connection>
sets the connection to use in the adapter for sending mails
returns the currently set connection, if any
sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
true if a mail is currently in the process of being send
sourcepub fn quit_on_completion(self) -> impl Stream<Item = (), Error = E>
pub fn quit_on_completion(self) -> impl Stream<Item = (), Error = E>
Quits the contained connection once the stream is completed.
The result from quitting is discarded, which is fine as this only happens if:
- for some reason the connection was interrupted (the server already quit)
- 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.
sourcepub fn on_completion<F, ITF>(self, func: F) -> impl Stream<Item = (), Error = E>where
F: FnOnce(Option<Connection>) -> ITF,
ITF: IntoFuture<Item = (), Error = ()>,
pub fn on_completion<F, ITF>(self, func: F) -> impl Stream<Item = (), Error = E>where
F: FnOnce(Option<Connection>) -> ITF,
ITF: IntoFuture<Item = (), Error = ()>,
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§
source§impl<I, E> Stream for SendAllMails<I>where
I: Iterator<Item = Result<MailEnvelop, E>>,
E: From<GeneralError>,
impl<I, E> Stream for SendAllMails<I>where
I: Iterator<Item = Result<MailEnvelop, E>>,
E: From<GeneralError>,
source§fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>
None
if
the stream is finished. Read moresource§fn wait(self) -> Wait<Self>where
Self: Sized,
fn wait(self) -> Wait<Self>where
Self: Sized,
source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
Future
. Read moresource§fn map_err<U, F>(self, f: F) -> MapErr<Self, F>where
F: FnMut(Self::Error) -> U,
Self: Sized,
fn map_err<U, F>(self, f: F) -> MapErr<Self, F>where
F: FnMut(Self::Error) -> U,
Self: Sized,
source§fn filter<F>(self, f: F) -> Filter<Self, F>where
F: FnMut(&Self::Item) -> bool,
Self: Sized,
fn filter<F>(self, f: F) -> Filter<Self, F>where
F: FnMut(&Self::Item) -> bool,
Self: Sized,
source§fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>where
F: FnMut(Self::Item) -> Option<B>,
Self: Sized,
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>where
F: FnMut(Self::Item) -> Option<B>,
Self: Sized,
source§fn then<F, U>(self, f: F) -> Then<Self, F, U>where
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Self: Sized,
fn then<F, U>(self, f: F) -> Then<Self, F, U>where
F: FnMut(Result<Self::Item, Self::Error>) -> U,
U: IntoFuture,
Self: Sized,
f
. Read moresource§fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Self: Sized,
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Error = Self::Error>,
Self: Sized,
f
. Read moresource§fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>where
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Self: Sized,
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>where
F: FnMut(Self::Error) -> U,
U: IntoFuture<Item = Self::Item>,
Self: Sized,
f
. Read moresource§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
source§fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
source§fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
true
. Read moresource§fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>where
P: FnMut(&Self::Item) -> R,
R: IntoFuture<Item = bool, Error = Self::Error>,
Self: Sized,
true
. Read moresource§fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
Self: Sized,
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>where
F: FnMut(Self::Item) -> U,
U: IntoFuture<Item = (), Error = Self::Error>,
Self: Sized,
source§fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
fn from_err<E>(self) -> FromErr<Self, E>where
E: From<Self::Error>,
Self: Sized,
From
for
this stream’s Error
, returning a new stream. Read moresource§fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
amt
items of the underlying stream. Read moresource§fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
amt
items of the underlying stream. Read moresource§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
finished. Read moresource§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
source§fn merge<S>(self, other: S) -> Merge<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
fn merge<S>(self, other: S) -> Merge<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
select
nowsource§fn zip<S>(self, other: S) -> Zip<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
fn zip<S>(self, other: S) -> Zip<Self, S>where
S: Stream<Error = Self::Error>,
Self: Sized,
source§fn chain<S>(self, other: S) -> Chain<Self, S>where
S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized,
fn chain<S>(self, other: S) -> Chain<Self, S>where
S: Stream<Item = Self::Item, Error = Self::Error>,
Self: Sized,
source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read more