pub trait Formatter: Debug {
type Error: Error;
type Serialized;
const ID: &'static str;
// Required methods
fn serialize<T: Serialize>(
&self,
value: &T,
) -> Result<Self::Serialized, Self::Error>;
fn deserialize<T: DeserializeOwned>(
&self,
value: &Self::Serialized,
) -> Result<T, Self::Error>;
}Expand description
A formatter that can serialize data before storing it in a cache and deserialize it after retrieving it from the cache.
Required Associated Constants§
Required Associated Types§
Sourcetype Serialized
type Serialized
The type of serialized data.
Required Methods§
Sourcefn serialize<T: Serialize>(
&self,
value: &T,
) -> Result<Self::Serialized, Self::Error>
fn serialize<T: Serialize>( &self, value: &T, ) -> Result<Self::Serialized, Self::Error>
Serialize a T and return a Self::Serialized.
Sourcefn deserialize<T: DeserializeOwned>(
&self,
value: &Self::Serialized,
) -> Result<T, Self::Error>
fn deserialize<T: DeserializeOwned>( &self, value: &Self::Serialized, ) -> Result<T, Self::Error>
Deserialize a Self::Serialized and return a T.
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§
Source§impl Formatter for JsonFormatter
Available on crate feature serde_json only.
impl Formatter for JsonFormatter
Available on crate feature
serde_json only.