Skip to main content

Serializer

Trait Serializer 

Source
pub trait Serializer {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn serialize<T: Serialize>(&self, data: &T) -> Result<String>;
    fn deserialize<T: DeserializeOwned>(&self, data: &str) -> Result<T>;
    fn extension(&self) -> &'static str;
}
Expand description

Serialization abstraction for different formats

§Synchronous Version

This trait provides synchronous operations for serialization.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

The error type returned by serialization operations

Required Methods§

Source

fn serialize<T: Serialize>(&self, data: &T) -> Result<String>

Serialize data to string

Source

fn deserialize<T: DeserializeOwned>(&self, data: &str) -> Result<T>

Deserialize data from string

Source

fn extension(&self) -> &'static str

Get file extension for this format

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§