Skip to main content

Serializable

Trait Serializable 

Source
pub trait Serializable {
    // Required methods
    fn serialize(&self) -> Result<Buffer, Error>;
    fn deserialize(data: &[u8]) -> Result<Self, Error>
       where Self: Sized;

    // Provided method
    fn serialize_to<W: Write>(&self, writer: W) -> Result<(), Error> { ... }
}
Expand description

A helper trait for something which can be serialized to protobufs.

Required Methods§

Source

fn serialize(&self) -> Result<Buffer, Error>

Serialize the object to a buffer.

Source

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

Parse the provided data in the protobuf format.

Provided Methods§

Source

fn serialize_to<W: Write>(&self, writer: W) -> Result<(), Error>

Helper for serializing to anything which implements Write.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§