Trait BinarySerializable

Source
pub trait BinarySerializable: Sized {
    // Provided methods
    fn to_binary(&self) -> Result<Vec<u8>, Error>
       where Self: Serialize { ... }
    fn from_binary(data: &[u8]) -> Result<Self, Error>
       where Self: DeserializeOwned { ... }
}
Expand description

Trait for binary serialization/deserialization

Provided Methods§

Source

fn to_binary(&self) -> Result<Vec<u8>, Error>
where Self: Serialize,

Serialize to binary format

Source

fn from_binary(data: &[u8]) -> Result<Self, Error>
where Self: DeserializeOwned,

Deserialize from binary format

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§