Trait ContainerBytes

Source
pub trait ContainerBytes {
    // Required methods
    fn from_bytes(bytes: Bytes) -> Self;
    fn length_in_bytes(&self) -> usize;
    fn into_bytes<W: Write>(&self, writer: &mut W);
}
Expand description

A container-oriented version of Bytesable that can be implemented here for Vec<T> and other containers.

Required Methods§

Source

fn from_bytes(bytes: Bytes) -> Self

Wrap bytes as Self.

Source

fn length_in_bytes(&self) -> usize

The number of bytes required to serialize the data.

Source

fn into_bytes<W: Write>(&self, writer: &mut W)

Writes the binary representation into writer.

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<T: Serialize + for<'a> Deserialize<'a>> ContainerBytes for Vec<T>

Source§

fn from_bytes(bytes: Bytes) -> Self

Source§

fn length_in_bytes(&self) -> usize

Source§

fn into_bytes<W: Write>(&self, writer: &mut W)

Implementors§