pub trait Serializable: Sized {
    // Required method
    fn write_into<W>(&self, target: &mut W)
       where W: ByteWriter;

    // Provided methods
    fn to_bytes(&self) -> Vec<u8>  { ... }
    fn write_batch_into<W>(source: &[Self], target: &mut W)
       where W: ByteWriter { ... }
    fn get_size_hint(&self) -> usize { ... }
}
Expand description

Defines how to serialize Self into bytes.

Required Methods§

source

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

Serializes self into bytes and writes these bytes into the target.

Provided Methods§

source

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

Serializes self into a vector of bytes.

source

fn write_batch_into<W>(source: &[Self], target: &mut W)where W: ByteWriter,

Serializes all elements of the source and writes these bytes into the target.

This method does not write any metadata (e.g. number of serialized elements) into the target.

source

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self.

The default implementation returns zero.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Serializable for ()

source§

fn write_into<W>(&self, _target: &mut W)where W: ByteWriter,

source§

impl Serializable for BaseElement

source§

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

source§

impl Serializable for BaseElement

source§

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

source§

impl<B> Serializable for CubeExtension<B>where B: ExtensibleField<3>,

source§

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

source§

impl<T> Serializable for &[T]where T: Serializable,

source§

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

source§

impl<T, const N: usize> Serializable for &[[T; N]]where T: Serializable,

source§

fn write_into<W>(&self, target: &mut W)where W: ByteWriter,

Implementors§