Skip to main content

StreamMux

Trait StreamMux 

Source
pub trait StreamMux: Send + Sync {
    // Required methods
    fn open_stream(
        &self,
    ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send;
    fn accept_stream(
        &self,
    ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send;
    fn peer_endpoint(&self) -> Option<Endpoint>;
    fn local_endpoint(&self) -> Option<Endpoint>;
}
Expand description

Multiplexed connection that yields multiple independent streams from a single underlying connection (e.g., QUIC).

Each stream is a Box<dyn ByteStream> that can be wrapped with framed_conn() for message framing.

§Example

use karyon_net::{quic, StreamMux, Endpoint};

async {
    let ep: Endpoint = "quic://127.0.0.1:9000".parse().unwrap();
    // let mux = quic::QuicEndpoint::dial(&ep, config, "localhost").await?;
    // let stream = mux.open_stream().await?;
    // let mut conn = framed_conn(stream, codec);
};

Required Methods§

Source

fn open_stream( &self, ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send

Open a new bidirectional stream.

Source

fn accept_stream( &self, ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send

Accept a stream opened by the peer.

Source

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

Remote peer address.

Source

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

Local address.

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§