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
use native_tls::TlsStream as native_tls_TlsStream;
use std::fmt;
use std::marker::PhantomData;
use tls_api::async_as_sync::AsyncIoAsSyncIo;
use tls_api::async_as_sync::AsyncWrapperOps;
use tls_api::async_as_sync::TlsStreamOverSyncIo;
use tls_api::spi_async_socket_impl_delegate;
use tls_api::spi_tls_stream_over_sync_io_wrapper;
use tls_api::AsyncSocket;
use tls_api::ImplInfo;
spi_tls_stream_over_sync_io_wrapper!(TlsStream, native_tls_TlsStream);
#[derive(Debug)]
pub(crate) struct AsyncWrapperOpsImpl<S, A>(PhantomData<(S, A)>)
where
S: fmt::Debug + Unpin + Send + 'static,
A: AsyncSocket;
impl<S, A> AsyncWrapperOps<A> for AsyncWrapperOpsImpl<S, A>
where
S: fmt::Debug + Unpin + Send + 'static,
A: AsyncSocket,
{
type SyncWrapper = native_tls::TlsStream<AsyncIoAsSyncIo<A>>;
fn impl_info() -> ImplInfo {
crate::info()
}
fn debug(w: &Self::SyncWrapper) -> &dyn fmt::Debug {
w
}
fn get_mut(w: &mut Self::SyncWrapper) -> &mut AsyncIoAsSyncIo<A> {
w.get_mut()
}
fn get_ref(w: &Self::SyncWrapper) -> &AsyncIoAsSyncIo<A> {
w.get_ref()
}
fn get_alpn_protocol(w: &Self::SyncWrapper) -> anyhow::Result<Option<Vec<u8>>> {
w.negotiated_alpn().map_err(anyhow::Error::new)
}
}