Skip to main content

CustomSerializer

Trait CustomSerializer 

Source
pub trait CustomSerializer: Send + Sync {
    // Required methods
    fn serialize(&self, data: &[u8]) -> Result<Vec<u8>>;
    fn deserialize(&self, data: &[u8]) -> Result<Vec<u8>>;
    fn format_name(&self) -> &str;

    // Provided methods
    fn format_version(&self) -> &str { ... }
    fn magic_bytes(&self) -> Option<&[u8]> { ... }
    fn supports_zero_copy(&self) -> bool { ... }
    fn validate_schema(&self, _schema: &[u8], _data: &[u8]) -> Result<bool> { ... }
    fn stats(&self) -> SerializerStats { ... }
}
Expand description

Custom serializer trait

Required Methods§

Source

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

Serialize data to bytes

Source

fn deserialize(&self, data: &[u8]) -> Result<Vec<u8>>

Deserialize bytes to data

Source

fn format_name(&self) -> &str

Get format name

Provided Methods§

Source

fn format_version(&self) -> &str

Get format version

Source

fn magic_bytes(&self) -> Option<&[u8]>

Get magic bytes for format detection

Source

fn supports_zero_copy(&self) -> bool

Supports zero-copy deserialization

Source

fn validate_schema(&self, _schema: &[u8], _data: &[u8]) -> Result<bool>

Validate schema (optional)

Source

fn stats(&self) -> SerializerStats

Get serialization statistics

Implementors§