linera_views::common

Trait CustomSerialize

Source
pub trait CustomSerialize: Sized {
    // Required methods
    fn to_custom_bytes(&self) -> Result<Vec<u8>, ViewError>;
    fn from_custom_bytes(short_key: &[u8]) -> Result<Self, ViewError>;
}
Expand description

Sometimes we need a serialization that is different from the usual one and for example preserves order. {to/from}_custom_bytes has to be coherent with the Borrow trait.

Required Methods§

Source

fn to_custom_bytes(&self) -> Result<Vec<u8>, ViewError>

Serializes the value

Source

fn from_custom_bytes(short_key: &[u8]) -> Result<Self, ViewError>

Deserialize the vector

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.

Implementations on Foreign Types§

Source§

impl CustomSerialize for u128

Implementors§