ark_serialize

Trait CanonicalSerialize

Source
pub trait CanonicalSerialize {
    // Required methods
    fn serialize_with_mode<W: Write>(
        &self,
        writer: W,
        compress: Compress,
    ) -> Result<(), SerializationError>;
    fn serialized_size(&self, compress: Compress) -> usize;

    // Provided methods
    fn serialize_compressed<W: Write>(
        &self,
        writer: W,
    ) -> Result<(), SerializationError> { ... }
    fn compressed_size(&self) -> usize { ... }
    fn serialize_uncompressed<W: Write>(
        &self,
        writer: W,
    ) -> Result<(), SerializationError> { ... }
    fn uncompressed_size(&self) -> usize { ... }
}
Expand description

Serializer in little endian format. This trait can be derived if all fields of a struct implement CanonicalSerialize and the derive feature is enabled.

§Example

// The `derive` feature must be set for the derivation to work.
use ark_serialize::*;

#[derive(CanonicalSerialize)]
struct TestStruct {
    a: u64,
    b: (u64, (u64, u64)),
}

Required Methods§

Source

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

The general serialize method that takes in customization flags.

Source

fn serialized_size(&self, compress: Compress) -> usize

Provided Methods§

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.

Implementations on Foreign Types§

Source§

impl CanonicalSerialize for bool

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for u8

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for u16

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for u32

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for u64

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for ()

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl CanonicalSerialize for usize

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl CanonicalSerialize for String

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl CanonicalSerialize for BigUint

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<'a, T: CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'a, T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<'a, T: CanonicalSerialize> CanonicalSerialize for &'a [T]

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<A> CanonicalSerialize for (A,)

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<A, B> CanonicalSerialize for (A, B)

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<A, B, C> CanonicalSerialize for (A, B, C)

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<A, B, C, D> CanonicalSerialize for (A, B, C, D)

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<A, B, C, D, E> CanonicalSerialize for (A, B, C, D, E)

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<K, V> CanonicalSerialize for BTreeMap<K, V>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Serializes a BTreeMap as len(map) || key 1 || value 1 || ... || key n || value n.

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T> CanonicalSerialize for PhantomData<T>

Source§

fn serialize_with_mode<W: Write>( &self, _writer: W, _compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, _compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Arc<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize> CanonicalSerialize for Option<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize> CanonicalSerialize for [T]

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize> CanonicalSerialize for LinkedList<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize> CanonicalSerialize for VecDeque<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize> CanonicalSerialize for Vec<T>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<T: CanonicalSerialize, const N: usize> CanonicalSerialize for [T; N]

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Source§

fn serialized_size(&self, compress: Compress) -> usize

Source§

impl<V: CanonicalSerialize> CanonicalSerialize for BTreeSet<V>

Source§

fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>

Serializes a BTreeSet as len(set) || value 1 || value 2 || ... || value n.

Source§

fn serialized_size(&self, compress: Compress) -> usize

Implementors§