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§
Sourcefn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress,
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
The general serialize method that takes in customization flags.
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
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
impl CanonicalSerialize for bool
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for u8
impl CanonicalSerialize for u8
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for u16
impl CanonicalSerialize for u16
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for u32
impl CanonicalSerialize for u32
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for u64
impl CanonicalSerialize for u64
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for ()
impl CanonicalSerialize for ()
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl CanonicalSerialize for usize
impl CanonicalSerialize for usize
fn serialize_with_mode<W: Write>( &self, writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl CanonicalSerialize for String
impl CanonicalSerialize for String
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl CanonicalSerialize for BigUint
impl CanonicalSerialize for BigUint
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<'a, T: CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'a, T>
impl<'a, T: CanonicalSerialize + ToOwned> CanonicalSerialize for Cow<'a, T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<'a, T: CanonicalSerialize> CanonicalSerialize for &'a [T]
impl<'a, T: CanonicalSerialize> CanonicalSerialize for &'a [T]
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<A> CanonicalSerialize for (A,)where
A: CanonicalSerialize,
impl<A> CanonicalSerialize for (A,)where
A: CanonicalSerialize,
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<A, B> CanonicalSerialize for (A, B)where
A: CanonicalSerialize,
B: CanonicalSerialize,
impl<A, B> CanonicalSerialize for (A, B)where
A: CanonicalSerialize,
B: CanonicalSerialize,
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<A, B, C> CanonicalSerialize for (A, B, C)
impl<A, B, C> CanonicalSerialize for (A, B, C)
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<A, B, C, D> CanonicalSerialize for (A, B, C, D)
impl<A, B, C, D> CanonicalSerialize for (A, B, C, D)
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<A, B, C, D, E> CanonicalSerialize for (A, B, C, D, E)where
A: CanonicalSerialize,
B: CanonicalSerialize,
C: CanonicalSerialize,
D: CanonicalSerialize,
E: CanonicalSerialize,
impl<A, B, C, D, E> CanonicalSerialize for (A, B, C, D, E)where
A: CanonicalSerialize,
B: CanonicalSerialize,
C: CanonicalSerialize,
D: CanonicalSerialize,
E: CanonicalSerialize,
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<K, V> CanonicalSerialize for BTreeMap<K, V>where
K: CanonicalSerialize,
V: CanonicalSerialize,
impl<K, V> CanonicalSerialize for BTreeMap<K, V>where
K: CanonicalSerialize,
V: CanonicalSerialize,
Source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress,
) -> Result<(), SerializationError>
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
.
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T> CanonicalSerialize for PhantomData<T>
impl<T> CanonicalSerialize for PhantomData<T>
fn serialize_with_mode<W: Write>( &self, _writer: W, _compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, _compress: Compress) -> usize
Source§impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T>
impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Rc<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Arc<T>
impl<T: CanonicalSerialize + ToOwned> CanonicalSerialize for Arc<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize> CanonicalSerialize for Option<T>
impl<T: CanonicalSerialize> CanonicalSerialize for Option<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize> CanonicalSerialize for [T]
impl<T: CanonicalSerialize> CanonicalSerialize for [T]
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize> CanonicalSerialize for LinkedList<T>
impl<T: CanonicalSerialize> CanonicalSerialize for LinkedList<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize> CanonicalSerialize for VecDeque<T>
impl<T: CanonicalSerialize> CanonicalSerialize for VecDeque<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize> CanonicalSerialize for Vec<T>
impl<T: CanonicalSerialize> CanonicalSerialize for Vec<T>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<T: CanonicalSerialize, const N: usize> CanonicalSerialize for [T; N]
impl<T: CanonicalSerialize, const N: usize> CanonicalSerialize for [T; N]
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
Source§impl<V: CanonicalSerialize> CanonicalSerialize for BTreeSet<V>
impl<V: CanonicalSerialize> CanonicalSerialize for BTreeSet<V>
Source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress,
) -> Result<(), SerializationError>
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
.