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
use std::future::Future; use tls_api::spi_connector_common; use tls_api::AsyncSocket; use tls_api::AsyncSocketBox; use tls_api::ImplInfo; pub struct TlsConnectorBuilder(pub ()); impl tls_api::TlsConnectorBuilder for TlsConnectorBuilder { type Connector = TlsConnector; type Underlying = (); fn underlying_mut(&mut self) -> &mut Self::Underlying { &mut self.0 } fn set_alpn_protocols(&mut self, protocols: &[&[u8]]) -> tls_api::Result<()> { let _ = protocols; Err(crate::Error::Alpn.into()) } fn set_verify_hostname(&mut self, verify: bool) -> tls_api::Result<()> { let _ = verify; Ok(()) } fn add_root_certificate(&mut self, cert: &[u8]) -> tls_api::Result<()> { let _ = cert; Ok(()) } fn build(self) -> tls_api::Result<Self::Connector> { Ok(TlsConnector(self.0)) } } pub struct TlsConnector(pub ()); impl TlsConnector { fn connect_impl<'a, S>( &'a self, domain: &'a str, stream: S, ) -> impl Future<Output = tls_api::Result<crate::TlsStream<S>>> + 'a where S: AsyncSocket, { let _ = domain; async { Ok(crate::stream::TlsStream(stream)) } } } impl tls_api::TlsConnector for TlsConnector { type Builder = TlsConnectorBuilder; const IMPLEMENTED: bool = false; const SUPPORTS_ALPN: bool = false; type Underlying = (); type TlsStream = crate::TlsStream<AsyncSocketBox>; fn underlying_mut(&mut self) -> &mut Self::Underlying { &mut self.0 } fn info() -> ImplInfo { crate::info() } fn builder() -> tls_api::Result<TlsConnectorBuilder> { Ok(TlsConnectorBuilder(())) } spi_connector_common!(); }