UnderlyingStream

Trait UnderlyingStream 

Source
pub trait UnderlyingStream<C, I, E>: Sized + Unpin
where C: Clone + Send + Unpin, E: Error,
{ // Required methods fn establish( ctor_arg: C, ) -> Pin<Box<dyn Future<Output = Result<Self, E>> + Send>>; fn is_write_disconnect_error(&self, err: &E) -> bool; fn exhaust_err() -> E; // Provided method fn is_read_disconnect_error(&self, item: &I) -> bool { ... } }
Expand description

Trait that should be implemented for an Stream and/or Sink item to enable it to work with the ReconnectStream struct.

Required Methods§

Source

fn establish( ctor_arg: C, ) -> Pin<Box<dyn Future<Output = Result<Self, E>> + Send>>

The creation function is used by ReconnectStream in order to establish both the initial IO connection in addition to performing reconnects.

Source

fn is_write_disconnect_error(&self, err: &E) -> bool

When sink send experience an Error during operation, it does not necessarily mean it is a disconnect/termination (ex: WouldBlock). You may specify which errors are considered “disconnects” by this method.

Source

fn exhaust_err() -> E

This is returned when retry quota exhausted.

Provided Methods§

Source

fn is_read_disconnect_error(&self, item: &I) -> bool

It’s common practice for Stream implementations that return an Err when there’s an error. You may match the result to tell them apart from normal response. By default, no response is considered a “disconnect”.

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§