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§
Sourcefn open_stream(
&self,
) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send
fn open_stream( &self, ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send
Open a new bidirectional stream.
Sourcefn accept_stream(
&self,
) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send
fn accept_stream( &self, ) -> impl Future<Output = Result<Box<dyn ByteStream>>> + Send
Accept a stream opened by the peer.
Sourcefn peer_endpoint(&self) -> Option<Endpoint>
fn peer_endpoint(&self) -> Option<Endpoint>
Remote peer address.
Sourcefn local_endpoint(&self) -> Option<Endpoint>
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.