qmux 0.0.2

QMux protocol (draft-ietf-quic-qmux-00) over reliable transports
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use tokio::net::{TcpStream, ToSocketAddrs};

use crate::transport::StreamTransport;
use crate::{Error, Session, Version};

/// Connect to a TCP server. Always uses the QMux wire format.
pub async fn connect(addr: impl ToSocketAddrs) -> Result<Session, Error> {
    let stream = TcpStream::connect(addr).await?;
    let transport = StreamTransport::new(stream);
    Ok(Session::connect(transport, Version::QMux00, None))
}

/// Accept a TCP connection. Always uses the QMux wire format.
pub async fn accept(stream: TcpStream) -> Result<Session, Error> {
    let transport = StreamTransport::new(stream);
    Ok(Session::accept(transport, Version::QMux00, None))
}