pub(crate) trait ChannelBaseHandshake<T>{
// 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§
Sourcefn framed_tls(&mut self) -> &mut Framed<T, ChannelCellHandler>
fn framed_tls(&mut self) -> &mut Framed<T, ChannelCellHandler>
Return a mutable reference to the channel frame.
Provided Methods§
Sourceasync fn send_versions_cell<F>(
&mut self,
now_fn: F,
) -> Result<(Instant, SystemTime)>where
F: FnOnce() -> SystemTime,
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.
Sourceasync fn recv_versions_cell(&mut self) -> Result<u16>
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.
Sourcefn set_link_protocol(&mut self, link_protocol: u16) -> Result<()>
fn set_link_protocol(&mut self, link_protocol: u16) -> Result<()>
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§
impl<T, S> ChannelBaseHandshake<T> for RelayResponderHandshake<T, S>where
T: AsyncRead + AsyncWrite + CertifiedConn + StreamOps + Send + Unpin + 'static,
S: CoarseTimeProvider + SleepProvider,
Implement the base channel handshake trait.
impl<T, S> ChannelBaseHandshake<T> for ClientInitiatorHandshake<T, S>where
T: AsyncRead + AsyncWrite + StreamOps + Send + Unpin + 'static,
S: CoarseTimeProvider + SleepProvider,
Implement the base channel handshake trait.
impl<T, S> ChannelBaseHandshake<T> for RelayInitiatorHandshake<T, S>where
T: AsyncRead + AsyncWrite + CertifiedConn + StreamOps + Send + Unpin + 'static,
S: CoarseTimeProvider + SleepProvider,
Implement the base channel handshake trait.