1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use tls_api::spi_connector_common;
use tls_api::AsyncSocket;
use tls_api::AsyncSocketBox;
use tls_api::ImplInfo;

use void::Void;

use crate::Error;
use std::future::Future;

/// Non-instantiatable.
pub struct TlsConnectorBuilder(Void);
/// Non-instantiatable.
pub struct TlsConnector(Void);

impl tls_api::TlsConnectorBuilder for TlsConnectorBuilder {
    type Connector = TlsConnector;

    type Underlying = Void;

    fn underlying_mut(&mut self) -> &mut Void {
        &mut self.0
    }

    fn set_alpn_protocols(&mut self, _protocols: &[&[u8]]) -> anyhow::Result<()> {
        Err(anyhow::Error::new(Error))
    }

    fn set_verify_hostname(&mut self, _verify: bool) -> anyhow::Result<()> {
        Err(anyhow::Error::new(Error))
    }

    fn add_root_certificate(&mut self, _cert: &[u8]) -> anyhow::Result<()> {
        Err(anyhow::Error::new(Error))
    }

    fn build(self) -> anyhow::Result<TlsConnector> {
        Err(anyhow::Error::new(Error))
    }
}

impl TlsConnector {
    fn connect_impl<'a, S>(
        &'a self,
        _domain: &'a str,
        _stream: S,
    ) -> impl Future<Output = anyhow::Result<crate::TlsStream<S>>> + 'a
    where
        S: AsyncSocket,
    {
        async { Err(anyhow::Error::new(Error)) }
    }
}

impl tls_api::TlsConnector for TlsConnector {
    type Builder = TlsConnectorBuilder;

    const IMPLEMENTED: bool = false;
    const SUPPORTS_ALPN: bool = false;

    type Underlying = Void;
    type TlsStream = crate::TlsStream<AsyncSocketBox>;

    fn underlying_mut(&mut self) -> &mut Self::Underlying {
        &mut self.0
    }

    fn info() -> ImplInfo {
        crate::info()
    }

    fn builder() -> anyhow::Result<TlsConnectorBuilder> {
        Err(anyhow::Error::new(Error))
    }

    spi_connector_common!();
}