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 Resource
s
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§
Sourcefn ser(&self) -> Result<String, SerializationError>
fn ser(&self) -> Result<String, SerializationError>
Serializes the object to a string.
Sourcefn de(bytes: &str) -> Result<Self, SerializationError>
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.