Trait Serialize

Source
pub trait Serialize: Sized {
    // Required methods
    fn from_bytes(bytes: &[u8]) -> Result<Self>;
    fn to_bytes(&self) -> Vec<u8> ;
}
Expand description

A trait for public types that can be serialized to and from bytes.

Required Methods§

Source

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

Creates an object from a byte slice.

Source

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

Converts the object to a byte 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.

Implementors§