Skip to main content

ChannelBaseHandshake

Trait ChannelBaseHandshake 

Source
pub(crate) trait ChannelBaseHandshake<T>
where T: AsyncRead + AsyncWrite + StreamOps + Send + Unpin + 'static,
{ // Required methods fn framed_tls(&mut self) -> &mut Framed<T, ChannelCellHandler>; fn unique_id(&self) -> &UniqId; // Provided methods async fn send_versions_cell<F>( &mut self, now_fn: F, ) -> Result<(Instant, SystemTime)> where F: FnOnce() -> SystemTime { ... } async fn recv_versions_cell(&mut self) -> Result<u16> { ... } fn set_link_protocol(&mut self, link_protocol: u16) -> Result<()> { ... } }
Expand description

Base trait that all handshake type must implement.

It has common code that all handshake share including getters for the channel frame for cell decoding/encoding and the unique ID used for logging.

It has both a recv() and send() function for the VERSIONS cell since every handshake must start with this cell to negotiate the link protocol version.

Required Methods§

Source

fn framed_tls(&mut self) -> &mut Framed<T, ChannelCellHandler>

Return a mutable reference to the channel frame.

Source

fn unique_id(&self) -> &UniqId

Return a reference to the unique ID of this handshake.

Provided Methods§

Source

async fn send_versions_cell<F>( &mut self, now_fn: F, ) -> Result<(Instant, SystemTime)>
where F: FnOnce() -> SystemTime,

Send a msg::Versions cell.

A tuple is returned that is respectively the instant and wallclock of the send.

Source

async fn recv_versions_cell(&mut self) -> Result<u16>

Receive a msg::Versions cell.

The negotiated link protocol is returned, and also recorded in the underlying channel frame. This automatically transitions the frame into the “Handshake” state of the underlying cell handler. In other words, once the link protocol version is negotiated, the handler can encode and decode cells for that version in order to continue the handshake.

Given a link protocol version, set it into our channel cell handler. All channel type do this after negotiating a msg::Versions cell.

This will effectively transition the handler’s state from New to Handshake.

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, S> ChannelBaseHandshake<T> for RelayResponderHandshake<T, S>

Implement the base channel handshake trait.

Source§

impl<T, S> ChannelBaseHandshake<T> for ClientInitiatorHandshake<T, S>

Implement the base channel handshake trait.

Source§

impl<T, S> ChannelBaseHandshake<T> for RelayInitiatorHandshake<T, S>

Implement the base channel handshake trait.