[][src]Struct futures_retry::StreamRetry

pub struct StreamRetry<F, S> { /* fields omitted */ }

Provides a way to handle errors during a Stream execution, i.e. it gives you an ability to poll for future stream's items with a delay.

This type is similar to FutureRetry, but with a different semantics. For example, if for FutureRetry we need a factory that creates Futures, we don't need one for Streams, since Stream itself is a natural producer of new items, so we don't have to recreated it if an error is encountered.

A typical usage might be recovering from connection errors while trying to accept a connection on a TCP server.

A tcp-listener example is available in the examples folder.

Also have a look at StreamRetryExt trait for a more convenient usage.

Implementations

impl<F, S> StreamRetry<F, S>[src]

pub fn new(stream: S, error_action: F) -> Self where
    S: TryStream, 
[src]

Creates a StreamRetry using a provided stream and an object of ErrorHandler type that decides on a retry-policy depending on an encountered error.

Please refer to the tcp-listener example in the examples folder to have a look at a possible usage or to a very convenient extension trait StreamRetryExt.

Arguments

  • stream: a stream of future items,
  • error_action: a type that handles an error and decides which route to take: simply try again, wait and then try, or give up (on a critical error for exapmle).

pub fn with_counter(stream: S, error_action: F, attempt_counter: usize) -> Self[src]

Like a new method, but a custom attempt counter initial value might be provided.

Trait Implementations

impl<F, S> Stream for StreamRetry<F, S> where
    S: TryStream,
    F: ErrorHandler<S::Error>, 
[src]

type Item = Result<(S::Ok, usize), (F::OutError, usize)>

Values yielded by the stream.

impl<'__pin, F, S> Unpin for StreamRetry<F, S> where
    __Origin<'__pin, F, S>: Unpin
[src]

Auto Trait Implementations

impl<F, S> !RefUnwindSafe for StreamRetry<F, S>[src]

impl<F, S> Send for StreamRetry<F, S> where
    F: Send,
    S: Send
[src]

impl<F, S> Sync for StreamRetry<F, S> where
    F: Sync,
    S: Sync
[src]

impl<F, S> !UnwindSafe for StreamRetry<F, S>[src]

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

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.

impl<S, T, E> TryStream for S where
    S: Stream<Item = Result<T, E>> + ?Sized

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<S> TryStreamExt for S where
    S: TryStream + ?Sized