pub trait FutureFactory {
type FutureItem: TryFuture;
// Required method
fn new(&mut self) -> Self::FutureItem;
}
Expand description
A factory trait used to create futures.
We need a factory for the retry logic because when (and if) a future returns an error, its internal state is undefined and we can’t poll on it anymore. Hence we need to create a new one.
By the way, this trait is implemented for any closure that returns a Future
, so you don’t
have to write your own type and implement it to handle some simple cases.
Required Associated Types§
Sourcetype FutureItem: TryFuture
type FutureItem: TryFuture
An future type that is created by the new
method.
Required Methods§
Sourcefn new(&mut self) -> Self::FutureItem
fn new(&mut self) -> Self::FutureItem
Creates a new future. We don’t need the factory to be immutable so we pass self
as a
mutable reference.