stream
import std::net::tls::stream; · source
TlsStream
type struct TlsStream {
ssl: void*;
inner: TcpStream;
static from_parts(ssl: void*, inner: TcpStream) -> TlsStream;
ssl_ptr(&this) -> void*;
raw_fd(&this) -> i32;
negotiated_alpn(&this) -> AlpnProtocol;
drop(mut &this) -> void;
}
A TlsStream owns both the SSL* and the underlying TcpStream, hence the descriptor. You obtain one from a TlsConnector or TlsAcceptor; from_parts is the constructor those use. ssl_ptr and raw_fd expose the handles for code that needs to talk to OpenSSL or the socket directly — setting a socket option, say — not for reading or writing, which would desynchronise the record layer.
Drop order is load-bearing: SSL_shutdown sends close_notify, SSL_free releases the SSL and its context reference (the socket BIO is BIO_NOCLOSE, so the descriptor survives), and finally TcpStream::drop closes it. All of that is the inherent drop on this type.
AlpnProtocol
type enum AlpnProtocol {
None;
Http11;
H2;
}
negotiated_alpn() reports what the ALPN extension settled on: H2, Http11, or None when the connector did not offer anything or the server did not answer.
Trait implementations
implement trait AsyncTransport for struct TlsStream // std::net::tls::future
AsyncTransport is the seam the HTTP and WebSocket layers are written against: a BufStream<TlsStream> and a BufStream<TcpStream> are the same code above this point. The impl's read_into and write_from are the TlsRead and TlsWrite futures.