pub trait Serializer:
Send
+ Sync
+ Clone
+ 'static {
// Required methods
fn name(&self) -> &str;
fn serialize<T>(&self, value: &T) -> Result<Vec<u8>, CacheError>
where T: Serialize;
fn deserialize<T>(&self, bytes: &[u8]) -> Result<T, CacheError>
where T: DeserializeOwned;
}Expand description
Trait for pluggable serialization formats
Implement this trait to add custom serialization formats. Built-in implementations: JSON, MessagePack, Bincode.
Required Methods§
Sourcefn serialize<T>(&self, value: &T) -> Result<Vec<u8>, CacheError>where
T: Serialize,
fn serialize<T>(&self, value: &T) -> Result<Vec<u8>, CacheError>where
T: Serialize,
Serialize a value to bytes
Sourcefn deserialize<T>(&self, bytes: &[u8]) -> Result<T, CacheError>where
T: DeserializeOwned,
fn deserialize<T>(&self, bytes: &[u8]) -> Result<T, CacheError>where
T: DeserializeOwned,
Deserialize bytes to a value
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.