pub struct MessageHandler<'a, 'm, Side: SideData> { /* private fields */ }Expand description
Driver for handling messages from the TlsInputBuffer.
Must be driven to completion to make progress, by calling either Self::handle_all() or
repeatedly calling Self::next_payload() until it returns None.
Backpressure is provided by the TlsInputBuffer implementation. When using a VecInput
buffer, VecInput::read() will not ingest more data once the internal buffer is full.
Implementations§
Source§impl<'a, 'm, Side: SideData> MessageHandler<'a, 'm, Side>
impl<'a, 'm, Side: SideData> MessageHandler<'a, 'm, Side>
Sourcepub fn handle_all(self, buf: &mut Vec<u8>) -> Result<IoState, Error>
pub fn handle_all(self, buf: &mut Vec<u8>) -> Result<IoState, Error>
Handles all complete messages from the input buffer.
Writes any plaintext application data from the input into buf, and returns the I/O
state of the connection after processing the last message. If an error is returned,
the connection is in a fatal error state and no further progress can be made. After
an error is received from this function, you should not continue to fill up the buffer.
However, you may call the other methods on the connection, including
Connection::send_close_notify(). Any alert produced by the error will have
been appended to the tls buffer; most likely you will want to send that data
to the peer and then close the underlying connection.
Sourcepub fn next_payload(&mut self) -> Option<Result<Payload<'_>, Error>>
pub fn next_payload(&mut self) -> Option<Result<Payload<'_>, Error>>
Yields the first payload of plaintext application data from the input buffer.
Should be called repeatedly until it returns None, at which point the input buffer no
longer contains any complete messages and should be refilled by the application.
Early (“0-RTT”) data received by a server while the handshake is still in progress
is not yielded here; it is only available from
next_early_data() and is dropped if
encountered by this method.
Source§impl<'a, 'm> MessageHandler<'a, 'm, ServerSide>
impl<'a, 'm> MessageHandler<'a, 'm, ServerSide>
Sourcepub fn next_early_data(&mut self) -> Option<Result<Payload<'_>, Error>>
pub fn next_early_data(&mut self) -> Option<Result<Payload<'_>, Error>>
Yields the next payload application data received from the client.
Early data is only received during the handshake, from clients resuming an earlier
session, and only if the connection was configured with a non-zero
ServerConfig::max_early_data_size.
Beware that early data is subject to replay by an attacker; see RFC 8446 appendix E.5 for more detail.
Call this until it returns None before processing regular application data with
next_payload() or
handle_all(): early data encountered by those
methods is dropped.
None means no early data is currently available: the early data phase may have
ended, or processing may require further input.
If this yields an error, stop calling it: the same error will also be reported by
next_payload() and
handle_all(), so it can be ignored here.