[question] TlsStreams with async-h1
- Dominant language
- Rust
- Stars
- 166
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
Please consider this more of a question than a bug report. I am trying to implement a TLS listener with tide, which requires me to implement a ToListener/Listener. For this to work I need to be able to implement a similar pattern as found in the tide unix listener such as:
```rust
fn handle_unix(app: Server, stream: UnixStream) {
task::spawn(async move {
let local_addr = unix_socket_addr_to_string(stream.local_addr());
let peer_addr = unix_socket_addr_to_string(stream.peer_addr());
let fut = async_h1::accept(stream, |mut req| async {
req.set_local_addr(local_addr.as_ref());
req.set_peer_addr(peer_addr.as_ref());
app.respond(req).await
});
if let Err(error) = fut.await {
log::error!("async-h1 error", { error: error.to_string() });
}
});
}
```
The issue that I'm having is that async_h1::accept requires trait bounds of Clone, future::io::AsyncRead and future::io::AsyncWrite. I have noticed though that tokio_openssl and tokio-native-tls both implement only tokio::io::AsyncRead and AsyncWrite which are not compatible to the future::io versions. As well neither tokio openssl or native-tls are Clone on the resulting TlsStream.
So I think my question is:
* Is there a current rust library that implements the future::io versions of AsyncRead and allows a TLS stream for use with async_h1::accept?
* What's the best way to find or search for things that would or do implement these traits?
* Are there any known examples of TLS + async_h1 that I can reference?
* What would be required to allow async_h1 to work with tokio_openssl OR what would need to change in tokio_openssl to allow it to work with tide + async_h1
Anyway, thanks very much for your time :)
Contributor guide
Research direction
Start by reading async_h1::accept and the Tide Unix listener pattern shown in the issue, then compare the future::io and tokio::io trait implementations in tokio_openssl and tokio-native-tls. Check existing examples or compatibility adapters for TLS streams. Done means identifying a supported TLS integration path or clearly scoping the changes needed for compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100