pub struct SendTraffic(/* private fields */);Expand description
The send-side of a connection, after a successful handshake.
You can use this object to send data to the peer.
Implementations§
Source§impl SendTraffic
impl SendTraffic
Sourcepub fn write(&mut self, application_data: OutboundPlain<'_>, tls: &mut Vec<u8>)
pub fn write(&mut self, application_data: OutboundPlain<'_>, tls: &mut Vec<u8>)
Write application data to the peer.
The TLS data to send to the peer is written into tls. This data should then be
communicated to the peer.
When you need to handle a ReceiveTrafficState::FlushSender state, you can call this
method with OutboundPlain::new_empty() to flush any pending TLS data to the peer.
Sourcepub fn close(self, tls: &mut Vec<u8>)
pub fn close(self, tls: &mut Vec<u8>)
Conclude sending traffic by sending a close_notify alert.
The alert is written into tls along with any pending data.
This data should then be communicated to the peer.
This is the final possible operation with a SendTraffic.
Sourcepub fn refresh_traffic_keys(&mut self, tls: &mut Vec<u8>) -> Result<(), Error>
pub fn refresh_traffic_keys(&mut self, tls: &mut Vec<u8>) -> Result<(), Error>
Writes a TLS 1.3 key_update message into tls to refresh a connection’s keys.
The main reason to call this manually is to roll keys when it is known a connection will be idle for a long period.
rustls implicitly and automatically refreshes traffic keys when needed according to the selected cipher suite’s cryptographic constraints. There is therefore no need to call this manually to avoid cryptographic keys “wearing out”.
This call refreshes our encryption keys. Once the peer receives the message, it refreshes its encryption and decryption keys and sends a response. Once we receive that response, we refresh our decryption keys to match. At the end of this process, keys in both directions have been refreshed.
This returns an error if a version prior to TLS1.3 is negotiated.
§Usage advice
Note that other implementations (including rustls) may enforce limits on
the number of key_update messages allowed on a given connection to prevent
denial of service. Therefore, this should be called sparingly.
rustls only allows one outstanding request at a time; this function succeeds but sends nothing if a request is already in-flight.