pub trait Codec: Debug + Sized {
    fn encode(&self, bytes: &mut Vec<u8>);
    fn read(_: &mut Reader<'_>) -> Option<Self>;

    fn get_encoding(&self) -> Vec<u8> { ... }
    fn read_bytes(bytes: &[u8]) -> Option<Self> { ... }
}
Expand description

Trait for implementing encoding and decoding functionality on something.

Required Methods

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

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

Provided Methods

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

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

Implementations on Foreign Types

Implementors