cache_any

Trait Cacheable

Source
pub trait Cacheable: Debug {
    // Required methods
    fn to_bytes(&self) -> Vec<u8>;
    fn from_bytes(bytes: &[u8]) -> Result<Self>
       where Self: Sized;

    // Provided methods
    fn to_hex(&self) -> String { ... }
    fn from_hex(hex: &str) -> Result<Self>
       where Self: Sized { ... }
}
Expand description

used to convert Cacheable to bytes and vice versa.

Required Methods§

Source

fn to_bytes(&self) -> Vec<u8>

Convert Cacheable to bytes.

Source

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Convert bytes to Cacheable.

Provided Methods§

Source

fn to_hex(&self) -> String

Source

fn from_hex(hex: &str) -> Result<Self>
where Self: Sized,

Implementations on Foreign Types§

Source§

impl Cacheable for bool

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for i8

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for i16

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for i32

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for i64

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for i128

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for isize

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for u8

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for u16

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for u32

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for u64

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for u128

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for ()

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(_bytes: &[u8]) -> Result<Self>

Source§

impl Cacheable for usize

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for String

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl Cacheable for Vec<u8>

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Source§

impl<T: Cacheable> Cacheable for Arc<T>

Source§

fn to_bytes(&self) -> Vec<u8>

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized,

Implementors§