Skip to main content

StreamLayer

Trait StreamLayer 

Source
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

A security layer between the framing and the socket: TLS for TURN over TLS, in its sans-I/O form. Ciphertext comes in with receive, plaintext goes out with send once the handshake is done, and the table collects what the layer has to write after every call.

Required Methods§

Source

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.

Source

fn read_plaintext(&mut self, out: &mut Vec<u8>) -> Result<()>

Appends the plaintext received so far to out.

Source

fn is_established(&self) -> bool

Whether plaintext can be sent: the handshake is complete.

Source

fn send(&mut self, plaintext: &[u8]) -> Result<()>

Takes plaintext to send.

Source

fn write_wire(&mut self, out: &mut Vec<u8>) -> Result<()>

Appends the bytes the layer has to write to out.

Source

fn close(&mut self)

Starts an orderly close (TLS close_notify).

Source

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".

Implementors§