Serializer

Trait Serializer 

Source
pub trait Serializer {
    // Required methods
    fn prepend(&mut self, data: impl AsRef<[u8]>) -> Result<()>;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for serializing data into a byte buffer.

Required Methods§

Source

fn prepend(&mut self, data: impl AsRef<[u8]>) -> Result<()>

Prepends data to the buffer.

§Arguments
  • data - The data to prepend.
§Errors

Returns an error if the operation fails.

Source

fn len(&self) -> usize

Returns the length of the serialized data.

Provided Methods§

Source

fn is_empty(&self) -> bool

Checks if the buffer is empty.

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 Serializer for usize

Source§

fn prepend(&mut self, data: impl AsRef<[u8]>) -> Result<()>

Source§

fn len(&self) -> usize

Implementors§