tls_api_stub/
connector.rs

1use tls_api::spi_connector_common;
2use tls_api::AsyncSocket;
3use tls_api::AsyncSocketBox;
4use tls_api::ImplInfo;
5
6use void::Void;
7
8use crate::Error;
9
10/// Non-instantiatable.
11pub struct TlsConnectorBuilder(Void);
12/// Non-instantiatable.
13pub struct TlsConnector(Void);
14
15impl tls_api::TlsConnectorBuilder for TlsConnectorBuilder {
16    type Connector = TlsConnector;
17
18    type Underlying = Void;
19
20    fn underlying_mut(&mut self) -> &mut Void {
21        &mut self.0
22    }
23
24    fn set_alpn_protocols(&mut self, _protocols: &[&[u8]]) -> anyhow::Result<()> {
25        Err(anyhow::Error::new(Error))
26    }
27
28    fn set_verify_hostname(&mut self, _verify: bool) -> anyhow::Result<()> {
29        Err(anyhow::Error::new(Error))
30    }
31
32    fn add_root_certificate(&mut self, _cert: &[u8]) -> anyhow::Result<()> {
33        Err(anyhow::Error::new(Error))
34    }
35
36    fn build(self) -> anyhow::Result<TlsConnector> {
37        Err(anyhow::Error::new(Error))
38    }
39}
40
41impl TlsConnector {
42    async fn connect_impl<'a, S>(
43        &'a self,
44        _domain: &'a str,
45        _stream: S,
46    ) -> anyhow::Result<crate::TlsStream<S>>
47    where
48        S: AsyncSocket,
49    {
50        Err(anyhow::Error::new(Error))
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 = Void;
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        Err(anyhow::Error::new(Error))
73    }
74
75    spi_connector_common!(crate::TlsStream<S>);
76}