pub trait Handshake: Pea2Pea
where Self: Clone + Send + Sync + 'static,
{ const TIMEOUT_MS: u64 = 3_000u64; // Required method fn perform_handshake( &self, conn: Connection ) -> impl Future<Output = Result<Connection>> + Send; // Provided methods fn enable_handshake(&self) -> impl Future<Output = ()> + Send { ... } fn borrow_stream<'a>(&self, conn: &'a mut Connection) -> &'a mut TcpStream { ... } fn take_stream(&self, conn: &mut Connection) -> TcpStream { ... } fn return_stream<T: AsyncRead + AsyncWrite + Send + Sync + 'static>( &self, conn: &mut Connection, stream: T ) { ... } }
Expand description

Can be used to specify and enable network handshakes. Upon establishing a connection, both sides will need to adhere to the specified handshake rules in order to finalize the connection and be able to send or receive any messages.

Provided Associated Constants§

source

const TIMEOUT_MS: u64 = 3_000u64

The maximum time allowed for a connection to perform a handshake before it is rejected.

The default value is 3000ms.

Required Methods§

source

fn perform_handshake( &self, conn: Connection ) -> impl Future<Output = Result<Connection>> + Send

Performs the handshake; temporarily assumes control of the Connection and returns it if the handshake is successful.

Provided Methods§

source

fn enable_handshake(&self) -> impl Future<Output = ()> + Send

Prepares the node to perform specified network handshakes.

source

fn borrow_stream<'a>(&self, conn: &'a mut Connection) -> &'a mut TcpStream

Borrows the full connection stream to be used in the implementation of Handshake::perform_handshake.

source

fn take_stream(&self, conn: &mut Connection) -> TcpStream

Assumes full control of a connection’s stream in the implementation of Handshake::perform_handshake, by the end of which it must be followed by Handshake::return_stream.

source

fn return_stream<T: AsyncRead + AsyncWrite + Send + Sync + 'static>( &self, conn: &mut Connection, stream: T )

This method only needs to be called if Handshake::take_stream had been called before; it is used to return a (potentially modified) stream back to the applicable connection.

Object Safety§

This trait is not object safe.

Implementors§