Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: A shared trait for tls acceptors that are implemented by both async-tls and async-native-tls #27

Open
jbr opened this issue Feb 4, 2021 · 1 comment · May be fixed by #30

Comments

@jbr
Copy link

jbr commented Feb 4, 2021

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:

#[async_trait]
pub trait Acceptor<Input>: 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<Self::Output, Self::Error>;
}

The implementation for async-native-tls would be:

#[async_trait]
impl<Input> Acceptor<Input> for async_native_tls::TlsAcceptor
where
    Input: AsyncRead + AsyncWrite + Send + Sync + Unpin + 'static,
{
    type Output = async_native_tls::TlsStream<Input>;
    type Error = async_native_tls::Error;
    async fn accept(&self, input: Input) -> Result<Self::Output, Self::Error> {
        async_native_tls::TlsAcceptor::accept(&self, input).await
    }
}

Would this be welcomed?

refs: async-rs/async-tls#43

@flub
Copy link
Member

flub commented Feb 10, 2021

at first sight this seems reasonable to me. Let's see what async-tls thinks about this as well.

@jbr jbr linked a pull request Apr 30, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants