How could I do to support async for rustls?

โš“ Rust    ๐Ÿ“… 2026-01-11    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 1      

surdeus

Basically, I want to create a TlsStream struct but prefer not to use crates like tokio_rustls. I want to explore how to manually implement AsyncRead and AsyncWrite for it. I tried using AI to generate code, and it came up with an approach like this*:

Create an adapter that implements Read and Write (returning std::io::Result<Poll>). For reading/writing plaintext, use rustls::Connection::{reader.read, writer.write}; for reading/writing encrypted text, use read_tls/write_tls with the adapter.

Iโ€™ve been trying in this direction for almost an entire day, and I felt like the code was extremely messyโ€”either ending up in infinite loops or failing to close connections, with a bunch of issues. How can I properly add async support?

1 post - 1 participant

Read full topic

๐Ÿท๏ธ Rust_feed