Trait CustomSerializer

Source
pub trait CustomSerializer<T> {
    // Provided methods
    fn to_json_string(&self) -> String
       where Self: Serialize + Sized { ... }
    fn from_json_string(data_string: String) -> T
       where T: for<'a> Deserialize<'a> { ... }
}
Expand description

A trait for custom serialization and deserialization.

Provides methods to convert the implementing type to and from JSON strings.

Provided Methods§

Source

fn to_json_string(&self) -> String
where Self: Serialize + Sized,

Serializes the implementor into a JSON string.

§Errors

Returns an error if serialization fails.

Source

fn from_json_string(data_string: String) -> T
where T: for<'a> Deserialize<'a>,

Deserializes an instance of the implementing type from a JSON string.

§Arguments
  • data_string - A string slice containing the JSON representation.
§Errors

Returns an error if deserialization fails.

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.

Implementors§