/// Trait for objects that are cacheable. pub trait Cacheable { fn from_bytes(bytes: &[u8]) -> Option where Self: Sized; fn to_bytes(&self) -> Option>; } impl Cacheable for Vec { fn from_bytes(bytes: &[u8]) -> Option { Some(Vec::from(bytes)) } fn to_bytes(&self) -> Option> { Some(self.to_vec()) } } impl Cacheable for Option> { fn from_bytes(bytes: &[u8]) -> Option { Some(Some(Vec::from(bytes))) } fn to_bytes(&self) -> Option> { self.clone() } }