Trait Serializable

Source
pub trait Serializable: Sized {
    // Required methods
    fn ser(&self) -> Result<String, SerializationError>;
    fn de(bytes: &str) -> Result<Self, SerializationError>;
}
Expand description

Describes an object that can be serialized to or from a supported format Currently those are JSON and Cbor

This is primarily used for serializing and deserializing Resources so they can begin on the server and be resolved on the client, but can be used for any data that needs to be serialized/deserialized.

This trait is intended to abstract over various serialization crates, as selected between by the crate features serde (default), serde-lite, and miniserde.

Required Methods§

Source

fn ser(&self) -> Result<String, SerializationError>

Serializes the object to a string.

Source

fn de(bytes: &str) -> Result<Self, SerializationError>

Deserializes the object from some bytes.

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§