tls_api_not_tls_2/
connector.rs1use std::future::Future;
2
3use tls_api::spi_connector_common;
4use tls_api::AsyncSocket;
5use tls_api::AsyncSocketBox;
6use tls_api::ImplInfo;
7
8pub struct TlsConnectorBuilder(pub ());
9
10impl tls_api::TlsConnectorBuilder for TlsConnectorBuilder {
11 type Connector = TlsConnector;
12 type Underlying = ();
13
14 fn underlying_mut(&mut self) -> &mut Self::Underlying {
15 &mut self.0
16 }
17
18 fn set_alpn_protocols(&mut self, protocols: &[&[u8]]) -> anyhow::Result<()> {
19 let _ = protocols;
20 Err(crate::Error::Alpn.into())
21 }
22
23 fn set_verify_hostname(&mut self, verify: bool) -> anyhow::Result<()> {
24 let _ = verify;
25 Ok(())
26 }
27
28 fn add_root_certificate(&mut self, cert: &[u8]) -> anyhow::Result<()> {
29 let _ = cert;
30 Ok(())
31 }
32
33 fn build(self) -> anyhow::Result<Self::Connector> {
34 Ok(TlsConnector(self.0))
35 }
36}
37
38pub struct TlsConnector(pub ());
39
40impl TlsConnector {
41 fn connect_impl<'a, S>(
42 &'a self,
43 domain: &'a str,
44 stream: S,
45 ) -> impl Future<Output = anyhow::Result<crate::TlsStream<S>>> + 'a
46 where
47 S: AsyncSocket,
48 {
49 let _ = domain;
50 async { Ok(crate::stream::TlsStream(stream)) }
51 }
52}
53
54impl tls_api::TlsConnector for TlsConnector {
55 type Builder = TlsConnectorBuilder;
56
57 const IMPLEMENTED: bool = false;
58 const SUPPORTS_ALPN: bool = false;
59
60 type Underlying = ();
61 type TlsStream = crate::TlsStream<AsyncSocketBox>;
62
63 fn underlying_mut(&mut self) -> &mut Self::Underlying {
64 &mut self.0
65 }
66
67 fn info() -> ImplInfo {
68 crate::info()
69 }
70
71 fn builder() -> anyhow::Result<TlsConnectorBuilder> {
72 Ok(TlsConnectorBuilder(()))
73 }
74
75 spi_connector_common!();
76}