Skip to main content

ByteStream

Trait ByteStream 

Source
pub trait ByteStream:
    AsyncRead
    + AsyncWrite
    + Send
    + Sync
    + Unpin {
    // Required methods
    fn peer_endpoint(&self) -> Option<Endpoint>;
    fn local_endpoint(&self) -> Option<Endpoint>;

    // Provided method
    fn peer_certificates(&self) -> Option<Vec<CertificateDer<'static>>> { ... }
}
Expand description

Byte-oriented bidirectional stream.

Implemented by TCP, TLS, Unix, and QUIC streams. Extends AsyncRead + AsyncWrite for compatibility with IO libraries. Use framed() to convert into a FramedConn with a codec.

Required Methods§

Source

fn peer_endpoint(&self) -> Option<Endpoint>

Remote peer address, if available.

Source

fn local_endpoint(&self) -> Option<Endpoint>

Local address, if available.

Provided Methods§

Source

fn peer_certificates(&self) -> Option<Vec<CertificateDer<'static>>>

Peer certificate chain when the underlying transport authenticates the peer with X.509 (TLS, QUIC). Returns None for plain TCP/Unix and other unauthenticated transports.

Trait Implementations§

Source§

impl ClientLayer<Box<dyn ByteStream>, Box<dyn ByteStream>> for Socks5Layer

Source§

async fn handshake( &self, stream: Box<dyn ByteStream>, ) -> Result<Box<dyn ByteStream>>

Source§

impl ClientLayer<Box<dyn ByteStream>, Box<dyn ByteStream>> for TlsLayer

Source§

async fn handshake( &self, stream: Box<dyn ByteStream>, ) -> Result<Box<dyn ByteStream>>

Source§

impl<C> ClientLayer<Box<dyn ByteStream>, WsConn<C>> for WsLayer<C>
where C: Codec<Message> + Clone + Send + Sync + 'static, C::Message: Send + Sync + 'static, C::Error: From<Error> + Into<Error> + Send + Sync,

Source§

async fn handshake(&self, stream: Box<dyn ByteStream>) -> Result<WsConn<C>>

Source§

impl ServerLayer<Box<dyn ByteStream>, Box<dyn ByteStream>> for TlsLayer

Source§

async fn handshake( &self, stream: Box<dyn ByteStream>, ) -> Result<Box<dyn ByteStream>>

Source§

impl<C> ServerLayer<Box<dyn ByteStream>, WsConn<C>> for WsLayer<C>
where C: Codec<Message> + Clone + Send + Sync + 'static, C::Message: Send + Sync + 'static, C::Error: From<Error> + Into<Error> + Send + Sync,

Source§

async fn handshake(&self, stream: Box<dyn ByteStream>) -> Result<WsConn<C>>

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§