future
import std::net::tls::future; · source
The TLS counterparts of TcpConnect, TcpRead, and TcpWrite, with the same ownership handshake: the stream (and, for a read or write, the buffer) goes in through start and comes back out through take_stream / take_buf on the TlsIo outcome. TlsHandshake completes with the stream itself once the handshake is done, or the error that ended it.
They differ from their TCP counterparts in one respect. OpenSSL may need to write to make progress on a read (a renegotiation, a close_notify) or vice versa, so each remembers which direction it last armed with the reactor and re-registers for whichever SSL_get_error asks for — SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE — rather than assuming a read always waits on readability.
Dropping any of these mid-operation releases its registration.
TlsHandshake
type struct TlsHandshake {
tls: TlsStream;
is_client: boolean;
verify: boolean;
rt: Reactor*;
armed: u32;
static start(tls: TlsStream, is_client: boolean, verify: boolean) -> TlsHandshake;
}
Drives SSL_connect or SSL_accept to completion, re-arming for whichever direction OpenSSL asks for, and completes with the stream. Dropping it closes the half-established connection.
TlsRead
type struct TlsRead {
tls: TlsStream;
buf: Array<u8>;
rt: Reactor*;
armed: u32;
static start(tls: TlsStream, buf: Array<u8>) -> TlsRead;
}
One SSL_read into buf. A TlsRead that completes with 0 bytes saw close_notify, the TLS equivalent of EOF.
TlsWrite
type struct TlsWrite {
tls: TlsStream;
buf: Array<u8>;
rt: Reactor*;
armed: u32;
static start(tls: TlsStream, buf: Array<u8>) -> TlsWrite;
}
One SSL_write from buf, completing with the bytes accepted.
TlsIo
type struct TlsIo {
tls: TlsStream;
buf: Array<u8>;
result: Result<u64, IoError>;
take_stream(mut &this) -> TlsStream;
take_buf(mut &this) -> Array<u8>;
outcome(&this) -> Result<u64, IoError>;
}
The outcome of a read or write: the stream and buffer back through take_stream / take_buf, and outcome() for the count or the error.
Trait implementations
implement trait Future for struct TlsHandshake
implement trait Drop for struct TlsHandshake
implement trait Future for struct TlsRead
implement trait Drop for struct TlsRead
implement trait Future for struct TlsWrite
implement trait Drop for struct TlsWrite