tls_api_stub/
acceptor.rs

1use void::Void;
2
3use tls_api::spi_acceptor_common;
4use tls_api::AsyncSocket;
5use tls_api::AsyncSocketBox;
6use tls_api::ImplInfo;
7
8use crate::Error;
9
10/// Non-instantiatable.
11pub struct TlsAcceptorBuilder(Void);
12/// Non-instantiatable.
13pub struct TlsAcceptor(Void);
14
15impl tls_api::TlsAcceptorBuilder for TlsAcceptorBuilder {
16    type Acceptor = TlsAcceptor;
17
18    type Underlying = Void;
19
20    fn set_alpn_protocols(&mut self, _protocols: &[&[u8]]) -> anyhow::Result<()> {
21        Err(anyhow::Error::new(Error))
22    }
23
24    fn underlying_mut(&mut self) -> &mut Void {
25        &mut self.0
26    }
27
28    fn build(self) -> anyhow::Result<TlsAcceptor> {
29        Err(anyhow::Error::new(Error))
30    }
31}
32
33impl TlsAcceptor {
34    async fn accept_impl<S>(&self, _stream: S) -> anyhow::Result<crate::TlsStream<S>>
35    where
36        S: AsyncSocket,
37    {
38        Err(anyhow::Error::new(Error))
39    }
40}
41
42impl tls_api::TlsAcceptor for TlsAcceptor {
43    type Builder = TlsAcceptorBuilder;
44
45    const IMPLEMENTED: bool = false;
46    const SUPPORTS_ALPN: bool = false;
47    const SUPPORTS_DER_KEYS: bool = false;
48    const SUPPORTS_PKCS12_KEYS: bool = false;
49
50    type Underlying = Void;
51    type TlsStream = crate::TlsStream<AsyncSocketBox>;
52
53    fn underlying_mut(&mut self) -> &mut Self::Underlying {
54        &mut self.0
55    }
56
57    fn info() -> ImplInfo {
58        crate::info()
59    }
60
61    spi_acceptor_common!(crate::TlsStream<S>);
62}