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>
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 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 u8
impl CanonicalDeserialize for u8
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 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 u64
impl CanonicalDeserialize for u64
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 CanonicalDeserialize for String
impl CanonicalDeserialize for String
fn deserialize_with_mode<R: Read>( reader: R, _compress: Compress, _validate: Validate, ) -> Result<Self, SerializationError>
Source§impl<A, B> CanonicalDeserialize for (A, B)where
A: CanonicalDeserialize,
B: CanonicalDeserialize,
impl<A, B> CanonicalDeserialize for (A, B)where
A: CanonicalDeserialize,
B: CanonicalDeserialize,
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate, ) -> Result<Self, SerializationError>
Source§impl<A, B, C> CanonicalDeserialize for (A, B, C)
impl<A, B, C> CanonicalDeserialize for (A, B, C)
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<K, V> CanonicalDeserialize for BTreeMap<K, V>
impl<K, V> CanonicalDeserialize for BTreeMap<K, V>
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
.