Trait io_tether::TetherResolver

source ·
pub trait TetherResolver: Unpin {
    type Error;

    // Required method
    fn disconnected(
        &mut self,
        context: &Context,
        state: &State<Self::Error>,
    ) -> impl Future<Output = bool> + Send;
}
Expand description

Represents a type which drives reconnects

Since the disconnected method asynchronous, and is invoked when the underlying stream disconnects things like tokio::time::sleep work out of the box.

Required Associated Types§

Required Methods§

source

fn disconnected( &mut self, context: &Context, state: &State<Self::Error>, ) -> impl Future<Output = bool> + Send

Invoked by Tether when an error/disconnect is encountered.

Returning true will result in a reconnect being attempted via <T as TetherIo>::reconnect, returning false will result in the error being returned from the originating call.

§Note

The State will describe the type of the underlying error. It can either be State::Eof, in which case the end of file was reached, or an error. This information can be leveraged in this function to determine whether to attempt to reconnect.

Object Safety§

This trait is not object safe.

Implementors§