pub trait SequenceSerializer<E>: Sized {
    // Required methods
    fn serialized_size(n: usize) -> usize;
    fn new<W: Write>(dst: &mut W) -> Result<Self>;
    fn write<W: Write>(&mut self, dst: &mut W, e: E) -> Result<()>;
    fn finish<W: Write>(self, dst: &mut W) -> Result<()>;
}
Expand description

A way to serialize a sequence of elements.

The [Serializer::from_bytes] and [Serializer::to_bytes] methods for require that elements serialize and deserialize to the byte boundary. For algebraic structures like crate::field::F2, where each element can be represented in only one bit, using the to_bytes and from_bytes methods is 8x less efficient than just sending each bit of the elements.

To enable more efficient communication, we can use the SequenceSerializer and SequenceDeserializer types to enable stateful serialization and deserialization.

Required Methods§

source

fn serialized_size(n: usize) -> usize

The exact number of bytes that will be written if n elements are serialized.

source

fn new<W: Write>(dst: &mut W) -> Result<Self>

Construct a new serializer

source

fn write<W: Write>(&mut self, dst: &mut W, e: E) -> Result<()>

Write a new element.

source

fn finish<W: Write>(self, dst: &mut W) -> Result<()>

This must be called to flush all outstanding elements.

Object Safety§

This trait is not object safe.

Implementors§