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?