use std::convert::Infallible;
pub trait Entry {
type Output;
type Error: std::error::Error;
fn serialize(self) -> Result<Vec<u8>, Self::Error>;
fn deserialize(data: Vec<u8>) -> Result<Self::Output, Self::Error>;
}
impl Entry for Vec<u8> {
type Output = Vec<u8>;
type Error = Infallible;
fn serialize(self) -> Result<Vec<u8>, Self::Error> {
Ok(self)
}
fn deserialize(data: Vec<u8>) -> Result<Self::Output, Self::Error> {
Ok(data)
}
}
impl Entry for &[u8] {
type Output = Vec<u8>;
type Error = Infallible;
fn serialize(self) -> Result<Vec<u8>, Self::Error> {
Ok(self.to_vec())
}
fn deserialize(data: Vec<u8>) -> Result<Self::Output, Self::Error> {
Ok(data)
}
}