tls_api/stream_dyn.rs
1use crate::AsyncSocket;
2use crate::ImplInfo;
3
4/// Trait implemented by all `TlsStream` objects.
5///
6/// Provide access to some TLS stream properties (only ALPN at the moment.)
7pub trait TlsStreamDyn: AsyncSocket {
8 /// Get negotiated ALPN protocol negotiated.
9 fn get_alpn_protocol(&self) -> anyhow::Result<Option<Vec<u8>>>;
10
11 /// Implementation info for this stream (e. g. which crate provides it).
12 fn impl_info(&self) -> ImplInfo;
13
14 /// Get the underlying socket.
15 fn get_socket_dyn_mut(&mut self) -> &mut dyn AsyncSocket;
16
17 /// Get the underlying socket.
18 fn get_socket_dyn_ref(&self) -> &dyn AsyncSocket;
19}
20
21/// Get the underlying socket.
22pub trait TlsStreamWithSocketDyn<S>: TlsStreamDyn {
23 /// Get the underlying socket.
24 fn get_socket_mut(&mut self) -> &mut S;
25
26 /// Get the underlying socket.
27 fn get_socket_ref(&self) -> &S;
28}
29
30/// Interface upcast. This is an interface for API implementors.
31pub trait TlsStreamWithUpcastDyn<S>: TlsStreamWithSocketDyn<S> {
32 /// Upcast.
33 fn upcast_box(self: Box<Self>) -> Box<dyn TlsStreamDyn>;
34}