Enum rustls::unbuffered::ConnectionState
source · #[non_exhaustive]pub enum ConnectionState<'c, 'i, Data> {
ReadTraffic(ReadTraffic<'c, 'i, Data>),
Closed,
ReadEarlyData(ReadEarlyData<'c, 'i, Data>),
EncodeTlsData(EncodeTlsData<'c, Data>),
TransmitTlsData(TransmitTlsData<'c, Data>),
BlockedHandshake,
WriteTraffic(WriteTraffic<'c, Data>),
}
Expand description
The state of the UnbufferedConnectionCommon
object
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ReadTraffic(ReadTraffic<'c, 'i, Data>)
One, or more, application data records are available
See ReadTraffic
for more details on how to use the enclosed object to access
the received data.
Closed
Connection has been cleanly closed by the peer
ReadEarlyData(ReadEarlyData<'c, 'i, Data>)
One, or more, early (RTT-0) data records are available
EncodeTlsData(EncodeTlsData<'c, Data>)
A Handshake record is ready for encoding
Call EncodeTlsData::encode
on the enclosed object, providing an outgoing_tls
buffer to store the encoding
TransmitTlsData(TransmitTlsData<'c, Data>)
Previously encoded handshake records need to be transmitted
Transmit the contents of the outgoing_tls
buffer that was passed to previous
EncodeTlsData::encode
calls to the peer.
After transmitting the contents, call TransmitTlsData::done
on the enclosed object.
The transmitted contents MUST not be sent to the peer more than once so they SHOULD be
discarded at this point.
At some stages of the handshake process, it’s possible to send application-data alongside
handshake records. Call TransmitTlsData::may_encrypt_app_data
on the enclosed
object to probe if that’s allowed.
BlockedHandshake
More TLS data is needed to continue with the handshake
Request more data from the peer and append the contents to the incoming_tls
buffer that
was passed to UnbufferedConnectionCommon::process_tls_records
.
WriteTraffic(WriteTraffic<'c, Data>)
The handshake process has been completed.
WriteTraffic::encrypt
can be called on the enclosed object to encrypt application
data into an outgoing_tls
buffer. Similarly, WriteTraffic::queue_close_notify
can
be used to encrypt a close_notify alert message into a buffer to signal the peer that the
connection is being closed. Data written into outgoing_buffer
by either method MAY be
transmitted to the peer during this state.
Once this state has been reached, data MAY be requested from the peer and appended to an
incoming_tls
buffer that will be passed to a future
UnbufferedConnectionCommon::process_tls_records
invocation. When enough data has been
appended to incoming_tls
, UnbufferedConnectionCommon::process_tls_records
will yield
the ConnectionState::ReadTraffic
state.