pub trait CanonicalDeserialize: Valid {
// Required method
fn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate
) -> Result<Self, SerializationError>;
// Provided methods
fn deserialize_compressed<R: Read>(
reader: R
) -> Result<Self, SerializationError> { ... }
fn deserialize_compressed_unchecked<R: Read>(
reader: R
) -> Result<Self, SerializationError> { ... }
fn deserialize_uncompressed<R: Read>(
reader: R
) -> Result<Self, SerializationError> { ... }
fn deserialize_uncompressed_unchecked<R: Read>(
reader: R
) -> Result<Self, SerializationError> { ... }
}
Expand description
Deserializer in little endian format.
This trait can be derived if all fields of a struct implement
CanonicalDeserialize
and the derive
feature is enabled.
Example
// The `derive` feature must be set for the derivation to work.
use snarkvm_utilities::serialize::*;
#[derive(CanonicalDeserialize)]
struct TestStruct {
a: u64,
b: (u64, (u64, u64)),
}
Required Methods§
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
Provided Methods§
fn deserialize_compressed<R: Read>( reader: R ) -> Result<Self, SerializationError>
fn deserialize_compressed_unchecked<R: Read>( reader: R ) -> Result<Self, SerializationError>
fn deserialize_uncompressed<R: Read>( reader: R ) -> Result<Self, SerializationError>
fn deserialize_uncompressed_unchecked<R: Read>( reader: R ) -> Result<Self, SerializationError>
Implementations on Foreign Types§
source§impl<A, B, C> CanonicalDeserialize for (A, B, C)where
A: CanonicalDeserialize,
B: CanonicalDeserialize,
C: CanonicalDeserialize,
impl<A, B, C> CanonicalDeserialize for (A, B, C)where A: CanonicalDeserialize, B: CanonicalDeserialize, C: CanonicalDeserialize,
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for u16
impl CanonicalDeserialize for u16
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl<T: CanonicalDeserialize + Debug> CanonicalDeserialize for [T; 32]
impl<T: CanonicalDeserialize + Debug> CanonicalDeserialize for [T; 32]
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for u32
impl CanonicalDeserialize for u32
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for String
impl CanonicalDeserialize for String
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl<T: Send + Sync> CanonicalDeserialize for PhantomData<T>
impl<T: Send + Sync> CanonicalDeserialize for PhantomData<T>
fn deserialize_with_mode<R: Read>( _reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for u64
impl CanonicalDeserialize for u64
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for u8
impl CanonicalDeserialize for u8
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl<A, B, C, D> CanonicalDeserialize for (A, B, C, D)where
A: CanonicalDeserialize,
B: CanonicalDeserialize,
C: CanonicalDeserialize,
D: CanonicalDeserialize,
impl<A, B, C, D> CanonicalDeserialize for (A, B, C, D)where A: CanonicalDeserialize, B: CanonicalDeserialize, C: CanonicalDeserialize, D: CanonicalDeserialize,
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
source§impl<T: CanonicalDeserialize> CanonicalDeserialize for Option<T>
impl<T: CanonicalDeserialize> CanonicalDeserialize for Option<T>
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for bool
impl CanonicalDeserialize for bool
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl CanonicalDeserialize for usize
impl CanonicalDeserialize for usize
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate ) -> Result<Self, SerializationError>
source§impl<K, V> CanonicalDeserialize for BTreeMap<K, V>where
K: Ord + CanonicalDeserialize,
V: CanonicalDeserialize,
impl<K, V> CanonicalDeserialize for BTreeMap<K, V>where K: Ord + CanonicalDeserialize, V: CanonicalDeserialize,
source§fn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate
) -> Result<Self, SerializationError>
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate ) -> Result<Self, SerializationError>
Deserializes a BTreeMap
from len(map) || key 1 || value 1 || ... || key n || value n
.