MCPcopy Index your code
hub / github.com/denoland/rustls-tokio-stream

github.com/denoland/rustls-tokio-stream @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
200 symbols 629 edges 10 files 27 documented · 14% updated 11mo ago★ 332 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

rustls-tokio-stream

rustls-tokio-stream is a Rust crate that provides an AsyncRead/AsyncWrite interface for rustls.

Features:

  • Supports duplex I/O via tokio::io::split and other methods out-of-the-box
  • Does not require either read or write polling to perform handshakes

Examples

Create a server and client running on localhost:

  fn server_config() -> ServerConfig {
    ServerConfig::builder()
      .with_safe_defaults()
      .with_no_client_auth()
      .with_single_cert(vec![certificate()], private_key())
      .expect("Failed to build server config")
  }

  fn client_config() -> ClientConfig {
    ClientConfig::builder()
      .with_safe_defaults()
      .with_no_client_auth()
  }

  async fn tcp_pair() -> (TcpStream, TcpStream) {
    let listener = TcpListener::bind(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, 0)))
      .await
      .unwrap();
    let port = listener.local_addr().unwrap().port();
    let server = spawn(async move { listener.accept().await.unwrap().0 });
    let client = spawn(async move {
      TcpSocket::new_v4()
        .unwrap()
        .connect(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::LOCALHOST, port)))
        .await
        .unwrap()
    });

    let (server, client) = (server.await.unwrap(), client.await.unwrap());
    (server, client)
  }

  async fn tls_pair() -> (TlsStream, TlsStream) {
    let (server, client) = tcp_pair().await;
    let server = TlsStream::new_server_side(server, server_config().into());
    let client = TlsStream::new_client_side(
      client,
      client_config().into(),
      "example.com".try_into().unwrap(),
    );

    (server, client)
  }

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 97
Method 84
Class 14
Enum 4
Interface 1

Languages

Rust100%

Modules by API surface

src/stream.rs107 symbols
src/connection_stream.rs38 symbols
src/lib.rs14 symbols
src/handshake.rs13 symbols
src/adapter.rs13 symbols
examples/ssl_trace.rs6 symbols
src/system_test/disconnect_test.rs4 symbols
src/system_test/fastwebsockets.rs3 symbols
src/system_test/speed_test.rs2 symbols

For agents

$ claude mcp add rustls-tokio-stream \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page