Skip to main content

BlockSerializer

Trait BlockSerializer 

Source
pub trait BlockSerializer {
    // Required methods
    fn serialize(&mut self, data: &[u8]) -> Result<&Vec<u8>, Box<dyn Error>>;
    fn deserialize(&mut self, data: &Vec<u8>) -> Result<(), Box<dyn Error>>;
    fn verify(&self, data: &[u8]) -> bool;
    fn size() -> usize;
    fn read_ahead_size() -> usize;
    fn delete_offset() -> usize;
    fn read_ahead(_buffer: &Vec<u8>) -> Result<i64, Box<dyn Error>>;
}
Expand description

Trait for preparing a DataHeader for writing to stream

Required Methods§

Source

fn serialize(&mut self, data: &[u8]) -> Result<&Vec<u8>, Box<dyn Error>>

Create a vector of data ready to be written

Source

fn deserialize(&mut self, data: &Vec<u8>) -> Result<(), Box<dyn Error>>

Source

fn verify(&self, data: &[u8]) -> bool

Source

fn size() -> usize

size in bytes of the serialized data

Source

fn read_ahead_size() -> usize

Minimum size of data needed to read ahead to next block

Source

fn delete_offset() -> usize

Source

fn read_ahead(_buffer: &Vec<u8>) -> Result<i64, Box<dyn Error>>

gets the amount to seek to next DataHeader

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§