ReconnectingStream

Trait ReconnectingStream 

Source
pub trait ReconnectingStream
where Self: Stream + Sized,
{ // Provided methods fn with_reconnect_backoff<St, InitError>( self, policy: ReconnectionBackoffPolicy, stream_key: StreamKey, ) -> impl Stream<Item = St> where Self: Stream<Item = Result<St, InitError>>, St: Stream, InitError: Debug { ... } fn with_termination_on_error<St, T, E, FnIsTerminal>( self, is_terminal: FnIsTerminal, stream_key: StreamKey, ) -> impl Stream<Item = impl Stream<Item = Result<T, E>>> where Self: Stream<Item = St>, St: Stream<Item = Result<T, E>>, FnIsTerminal: Fn(&E) -> bool + Copy { ... } fn with_reconnection_events<St, Origin>( self, origin: Origin, ) -> impl Stream<Item = Event<Origin, St::Item>> where Self: Stream<Item = St>, St: Stream, Origin: Clone + 'static { ... } fn with_error_handler<FnOnErr, Origin, T, E>( self, op: FnOnErr, ) -> impl Stream<Item = Event<Origin, T>> where Self: Stream<Item = Event<Origin, Result<T, E>>>, FnOnErr: Fn(E) + 'static { ... } fn forward_to<Transmitter>( self, tx: Transmitter, ) -> impl Future<Output = ()> + Send where Self: Stream + Sized + Send, Self::Item: Into<Transmitter::Item>, Transmitter: Tx + Send + 'static { ... } }
Expand description

Utilities for handling a continually reconnecting Stream initialised via the init_reconnecting_stream function.

Provided Methods§

Source

fn with_reconnect_backoff<St, InitError>( self, policy: ReconnectionBackoffPolicy, stream_key: StreamKey, ) -> impl Stream<Item = St>
where Self: Stream<Item = Result<St, InitError>>, St: Stream, InitError: Debug,

Add an exponential backoff policy to an initialised ReconnectingStream using the provided ReconnectionBackoffPolicy.

Source

fn with_termination_on_error<St, T, E, FnIsTerminal>( self, is_terminal: FnIsTerminal, stream_key: StreamKey, ) -> impl Stream<Item = impl Stream<Item = Result<T, E>>>
where Self: Stream<Item = St>, St: Stream<Item = Result<T, E>>, FnIsTerminal: Fn(&E) -> bool + Copy,

Terminates the inner Stream if the encountered error is determined to be unrecoverable by the provided closure. This will cause the ReconnectingStream to re-initialise the inner Stream.

Source

fn with_reconnection_events<St, Origin>( self, origin: Origin, ) -> impl Stream<Item = Event<Origin, St::Item>>
where Self: Stream<Item = St>, St: Stream, Origin: Clone + 'static,

Maps every ReconnectingStream Stream::Item into an reconnect::Event::Item, and chain a reconnect::Event::Reconnecting

Source

fn with_error_handler<FnOnErr, Origin, T, E>( self, op: FnOnErr, ) -> impl Stream<Item = Event<Origin, T>>
where Self: Stream<Item = Event<Origin, Result<T, E>>>, FnOnErr: Fn(E) + 'static,

Handles all encountered errors with the provided closure before filtering them out, returning a Stream of the Ok values. Useful for logging recoverable errors before continuing.

Source

fn forward_to<Transmitter>( self, tx: Transmitter, ) -> impl Future<Output = ()> + Send
where Self: Stream + Sized + Send, Self::Item: Into<Transmitter::Item>, Transmitter: Tx + Send + 'static,

Future for forwarding items in Self to the provided channel Tx.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> ReconnectingStream for T
where T: Stream,