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