Encode

Trait Encode 

Source
pub trait Encode: Clone {
    const SIZE: DataSize;

    // Required methods
    fn encode(&self) -> Cow<'_, [u8]>;
    fn decode(data: Cow<'_, [u8]>) -> MemoryResult<Self>
       where Self: Sized;
    fn size(&self) -> MSize;
}
Expand description

This trait defines the encoding and decoding behaviour for data types used in the DBMS canister.

Required Associated Constants§

Required Methods§

Source

fn encode(&self) -> Cow<'_, [u8]>

Encodes the data type into a vector of bytes.

Source

fn decode(data: Cow<'_, [u8]>) -> MemoryResult<Self>
where Self: Sized,

Decodes the data type from a slice of bytes.

Source

fn size(&self) -> MSize

Returns the size in bytes of the encoded data type.

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.

Implementors§