Proposal: A shared trait for tls acceptors that are implemented by both async-tls and async-native-tls
- Dominant language
- Rust
- Stars
- 172
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
I have some code that implements this using wrapper types, but would really love for a trait like this to exist:
A proposed `async-tls-acceptor` crate that publishes this trait:
```rust
#[async_trait]
pub trait Acceptor: Clone + Send + Sync + 'static
where
Input: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static,
{
type Output: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static;
type Error: std::fmt::Debug + Send + Sync;
async fn accept(&self, input: Input) -> Result;
}
```
The implementation for async-tls would be:
```rust
#[async_trait]
impl Acceptor for async_tls::TlsAcceptor
where
Input: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static,
{
type Output = async_tls::TlsStream;
type Error = std::io::Error;
async fn accept(&self, input: Input) -> Result {
async_tls::TlsAcceptor::accept(&self, input).await
}
}
```
Would this be welcomed?
refs: https://github.com/async-email/async-native-tls/issues/27
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the proposed `Acceptor` trait and the referenced async-native-tls issue #27, then compare how async-tls and async-native-tls expose their acceptors. Determine whether a shared `async-tls-acceptor` crate and the shown implementations fit both projects; done means the API and ownership are agreed before implementation begins.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100