Skip to main content

Crate net_mux

Crate net_mux 

Source
Expand description

net-mux is an asynchronous connection multiplexing library built on Tokio.

It multiplexes a single ordered, connection-oriented byte stream (TCP, KCP, TLS-over-TCP, …) into many bidirectional logical streams with credit-based flow control, ping keepalive, and graceful shutdown.

§Quick start

use net_mux::{Config, Session};
use tokio::net::TcpStream;

let conn = TcpStream::connect("127.0.0.1:7777").await?;
let session = Session::client(conn, Config::default());

let mut stream = session.open().await?;
tokio::io::AsyncWriteExt::write_all(&mut stream, b"hello").await?;

See the examples/ directory for end-to-end demos.

Re-exports§

pub use crate::config::Config;
pub use crate::config::ConfigBuilder;

Modules§

config
Session configuration.

Structs§

Session
Multiplexed session over a single connection of type T.
Stream
One bidirectional logical stream multiplexed over a session.

Enums§

Error
Top-level error type.
ErrorCode
Wire-level error code, transmitted in GoAway frames as a u32.

Type Aliases§

Result
Crate-wide Result alias.
StreamId
Unique identifier of a logical stream within a session.