Trait rustls::internal::msgs::codec::Codec

source ·
pub trait Codec: Debug + Sized {
    // Required methods
    fn encode(&self, bytes: &mut Vec<u8>);
    fn read(_: &mut Reader<'_>) -> Result<Self, InvalidMessage>;

    // Provided methods
    fn get_encoding(&self) -> Vec<u8> { ... }
    fn read_bytes(bytes: &[u8]) -> Result<Self, InvalidMessage> { ... }
}
Expand description

Trait for implementing encoding and decoding functionality on something.

Required Methods§

source

fn encode(&self, bytes: &mut Vec<u8>)

Function for encoding itself by appending itself to the provided vec of bytes.

source

fn read(_: &mut Reader<'_>) -> Result<Self, InvalidMessage>

Function for decoding itself from the provided reader will return Some if the decoding was successful or None if it was not.

Provided Methods§

source

fn get_encoding(&self) -> Vec<u8>

Convenience function for encoding the implementation into a vec and returning it

source

fn read_bytes(bytes: &[u8]) -> Result<Self, InvalidMessage>

Function for wrapping a call to the read function in a Reader for the slice of bytes provided

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Codec for u8

source§

fn encode(&self, bytes: &mut Vec<u8>)

source§

fn read(r: &mut Reader<'_>) -> Result<Self, InvalidMessage>

source§

impl Codec for u16

source§

fn encode(&self, bytes: &mut Vec<u8>)

source§

fn read(r: &mut Reader<'_>) -> Result<Self, InvalidMessage>

source§

impl Codec for u32

source§

fn encode(&self, bytes: &mut Vec<u8>)

source§

fn read(r: &mut Reader<'_>) -> Result<Self, InvalidMessage>

source§

impl Codec for u64

source§

fn encode(&self, bytes: &mut Vec<u8>)

source§

fn read(r: &mut Reader<'_>) -> Result<Self, InvalidMessage>

source§

impl<T: Codec + TlsListElement + Debug> Codec for Vec<T>

Implement Codec for lists of elements that implement TlsListElement.

TlsListElement provides the size of the length prefix for the list.

source§

fn encode(&self, bytes: &mut Vec<u8>)

source§

fn read(r: &mut Reader<'_>) -> Result<Self, InvalidMessage>

Implementors§