Skip to main content

SessionFormat

Trait SessionFormat 

Source
pub trait SessionFormat: Send + Sync {
    // Required methods
    fn format(&self) -> Format;
    fn serialize(&self, log: &TxLog) -> FormatResult<Vec<u8>>;
    fn deserialize(&self, data: &[u8]) -> FormatResult<TxLog>;
    fn serialize_to_file(&self, log: &TxLog, file: File) -> FormatResult<()>;
    fn deserialize_from_reader(
        &self,
        reader: BufReader<File>,
    ) -> FormatResult<TxLog>;
}
Expand description

Trait for session serialization formats.

Implement this trait to add support for new serialization formats.

Required Methods§

Source

fn format(&self) -> Format

Get the format identifier.

Source

fn serialize(&self, log: &TxLog) -> FormatResult<Vec<u8>>

Serialize a TxLog to bytes.

Source

fn deserialize(&self, data: &[u8]) -> FormatResult<TxLog>

Deserialize a TxLog from bytes.

Source

fn serialize_to_file(&self, log: &TxLog, file: File) -> FormatResult<()>

Serialize directly to a file (more efficient for large logs).

Source

fn deserialize_from_reader( &self, reader: BufReader<File>, ) -> FormatResult<TxLog>

Deserialize directly from a buffered reader.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§