[][src]Struct restartables::Restartable

pub struct Restartable<Fut, Test, Factory, T, E> where
    Fut: Future,
    Factory: Fn() -> Fut,
    Test: Fn(Fut::Output) -> Result<T, E>, 
{ /* fields omitted */ }

Wraps an inner future, restarting it until it resolves a value that passes a test, or times out.

This is a Future adaptor, meaning it wraps other futures, like future::map When this future is polled, it polls the inner future. If the inner futures resolves, its value is run through a test closure.

If the test is successful, the value is returned with timing information. If the test is unsuccessful, the future is recreated and retried. Because this fail-restart loop could go on forever, you should supply a timeout. If a None timeout is used, then awaiting the Restartable is not guaranteed to resolve.

Methods

impl<Fut, Test, Factory, T, E> Restartable<Fut, Test, Factory, T, E> where
    Fut: Future,
    Factory: Fn() -> Fut,
    Test: Fn(Fut::Output) -> Result<T, E>, 
[src]

pub fn new(factory: Factory, timeout: Option<Duration>, test: Test) -> Self[src]

Trait Implementations

impl<Fut, Test, Factory, T, E> Future for Restartable<Fut, Test, Factory, T, E> where
    Fut: Future,
    Factory: Fn() -> Fut,
    Test: Fn(Fut::Output) -> Result<T, E>, 
[src]

type Output = Result<Success<T>, Failure<E>>

The type of value produced on completion.

impl<Fut, Test, Factory, T, E> PinnedDrop for Restartable<Fut, Test, Factory, T, E> where
    Fut: Future,
    Factory: Fn() -> Fut,
    Test: Fn(Fut::Output) -> Result<T, E>, 
[src]

impl<'pin, Fut, Test, Factory, T, E> Unpin for Restartable<Fut, Test, Factory, T, E> where
    Fut: Future,
    Factory: Fn() -> Fut,
    Test: Fn(Fut::Output) -> Result<T, E>,
    __Restartable<'pin, Fut, Test, Factory, T, E>: Unpin
[src]

Auto Trait Implementations

impl<Fut, Test, Factory, T, E> RefUnwindSafe for Restartable<Fut, Test, Factory, T, E> where
    Factory: RefUnwindSafe,
    Fut: RefUnwindSafe,
    Test: RefUnwindSafe

impl<Fut, Test, Factory, T, E> Send for Restartable<Fut, Test, Factory, T, E> where
    Factory: Send,
    Fut: Send,
    Test: Send

impl<Fut, Test, Factory, T, E> Sync for Restartable<Fut, Test, Factory, T, E> where
    Factory: Sync,
    Fut: Sync,
    Test: Sync

impl<Fut, Test, Factory, T, E> UnwindSafe for Restartable<Fut, Test, Factory, T, E> where
    Factory: UnwindSafe,
    Fut: UnwindSafe,
    Test: UnwindSafe

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, 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.