Trait VecEncodable

Source
pub trait VecEncodable: CompactEncoding {
    // Required method
    fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>
       where Self: Sized;

    // Provided methods
    fn vec_encode<'a>(
        vec: &[Self],
        buffer: &'a mut [u8],
    ) -> Result<&'a mut [u8], EncodingError>
       where Self: Sized { ... }
    fn vec_decode(buffer: &[u8]) -> Result<(Vec<Self>, &[u8]), EncodingError>
       where Self: Sized { ... }
}
Expand description

Implement this for type T to have CompactEncoding implemented for Vec<T>

Required Methods§

Source

fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>
where Self: Sized,

Calculate the resulting size in bytes of vec

Provided Methods§

Source

fn vec_encode<'a>( vec: &[Self], buffer: &'a mut [u8], ) -> Result<&'a mut [u8], EncodingError>
where Self: Sized,

Encode vec to buffer

Source

fn vec_decode(buffer: &[u8]) -> Result<(Vec<Self>, &[u8]), EncodingError>
where Self: Sized,

Decode Vec<Self> from buffer

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl VecEncodable for u32

Source§

fn vec_encode<'a>( vec: &[Self], buffer: &'a mut [u8], ) -> Result<&'a mut [u8], EncodingError>
where Self: Sized,

Encode vec to buffer

Source§

fn vec_decode(buffer: &[u8]) -> Result<(Vec<Self>, &[u8]), EncodingError>
where Self: Sized,

Decode Vec<Self> from buffer

Source§

fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>
where Self: Sized,

Source§

impl<const N: usize> VecEncodable for [u8; N]

Source§

fn vec_encoded_size(vec: &[Self]) -> Result<usize, EncodingError>
where Self: Sized,

Implementors§