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