pub trait ReconnectingStream{
// 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§
Sourcefn with_reconnect_backoff<St, InitError>(
self,
policy: ReconnectionBackoffPolicy,
stream_key: StreamKey,
) -> impl Stream<Item = St>
fn with_reconnect_backoff<St, InitError>( self, policy: ReconnectionBackoffPolicy, stream_key: StreamKey, ) -> impl Stream<Item = St>
Add an exponential backoff policy to an initialised ReconnectingStream using the
provided ReconnectionBackoffPolicy.
Sourcefn with_termination_on_error<St, T, E, FnIsTerminal>(
self,
is_terminal: FnIsTerminal,
stream_key: StreamKey,
) -> impl Stream<Item = impl Stream<Item = Result<T, E>>>
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>>>
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.
Sourcefn with_reconnection_events<St, Origin>(
self,
origin: Origin,
) -> impl Stream<Item = Event<Origin, St::Item>>
fn with_reconnection_events<St, Origin>( self, origin: Origin, ) -> impl Stream<Item = Event<Origin, St::Item>>
Maps every ReconnectingStream Stream::Item into an reconnect::Event::Item,
and chain a reconnect::Event::Reconnecting
Sourcefn with_error_handler<FnOnErr, Origin, T, E>(
self,
op: FnOnErr,
) -> impl Stream<Item = Event<Origin, T>>
fn with_error_handler<FnOnErr, Origin, T, E>( self, op: FnOnErr, ) -> impl Stream<Item = Event<Origin, T>>
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.
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.