Skip to main content

Connection

Trait Connection 

Source
pub trait Connection: Send {
    // Required methods
    fn recv(&mut self) -> BoxFut<'_, TransportResult<Option<Vec<u8>>>>;
    fn send<'a>(
        &'a mut self,
        frame: &'a [u8],
    ) -> BoxFut<'a, TransportResult<()>>;
    fn peer(&self) -> &PeerInfo;
}
Expand description

A framed, bidirectional pipe — role-neutral (yielded by either Listener::accept or Dialer::connect).

Required Methods§

Source

fn recv(&mut self) -> BoxFut<'_, TransportResult<Option<Vec<u8>>>>

Receive one logical frame. Ok(None) signals the peer closed.

Source

fn send<'a>(&'a mut self, frame: &'a [u8]) -> BoxFut<'a, TransportResult<()>>

Send one logical frame.

Source

fn peer(&self) -> &PeerInfo

Peer metadata (remote addr, headers, pre-resolved auth).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S, F, const RC: usize, const WC: usize> Connection for FramedConnection<S, F, RC, WC>
where S: ByteStream + Send, F: Framer + Send,