Trait Serialize

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

Trait for objects that can be serialized to and from bytes

Required Methods§

Source

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

Convert the object to a byte array

Source

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

Create an object from a byte array

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§