pub trait StreamLayer: Send {
// Required methods
fn receive(&mut self, data: &[u8]) -> Result<()>;
fn read_plaintext(&mut self, out: &mut Vec<u8>) -> Result<()>;
fn is_established(&self) -> bool;
fn send(&mut self, plaintext: &[u8]) -> Result<()>;
fn write_wire(&mut self, out: &mut Vec<u8>) -> Result<()>;
fn close(&mut self);
fn peer_closed(&self) -> bool;
}Expand description
Required Methods§
Sourcefn receive(&mut self, data: &[u8]) -> Result<()>
fn receive(&mut self, data: &[u8]) -> Result<()>
Takes bytes received from the peer and processes them.
§Errors
A protocol error (bad record, failed certificate verification): the connection is reset.
Sourcefn read_plaintext(&mut self, out: &mut Vec<u8>) -> Result<()>
fn read_plaintext(&mut self, out: &mut Vec<u8>) -> Result<()>
Appends the plaintext received so far to out.
Sourcefn is_established(&self) -> bool
fn is_established(&self) -> bool
Whether plaintext can be sent: the handshake is complete.
Sourcefn write_wire(&mut self, out: &mut Vec<u8>) -> Result<()>
fn write_wire(&mut self, out: &mut Vec<u8>) -> Result<()>
Appends the bytes the layer has to write to out.
Sourcefn peer_closed(&self) -> bool
fn peer_closed(&self) -> bool
Whether the peer closed the layer (TLS close_notify received).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".