Trait Deserializable

Source
pub trait Deserializable: Sized {
    // Required method
    fn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>
       where R: ByteReader;

    // Provided method
    fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError> { ... }
}
Expand description

Defines how to deserialize Self from bytes.

Required Methods§

Source

fn read_from<R>(source: &mut R) -> Result<Self, DeserializationError>
where R: ByteReader,

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result.

§Errors

Returns an error if:

  • The source does not contain enough bytes to deserialize Self.
  • Bytes read from the source do not represent a valid value for Self.

Provided Methods§

Source

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result.

§Errors

Returns an error if:

  • The bytes do not contain enough information to deserialize Self.
  • The bytes do not represent a valid value for Self.

Note: if bytes contains more data than needed to deserialize self, no error is returned.

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 Deserializable for NodeMutation

Source§

impl Deserializable for SmtLeaf

Source§

impl Deserializable for u8

Source§

impl Deserializable for u16

Source§

impl Deserializable for u32

Source§

impl Deserializable for u64

Source§

impl Deserializable for u128

Source§

impl Deserializable for ()

Source§

impl Deserializable for usize

Source§

impl Deserializable for String

Source§

impl Deserializable for InOrderIndex

Source§

impl Deserializable for PartialMmr

Source§

impl Deserializable for RootPath

Source§

impl Deserializable for ValuePath

Source§

impl Deserializable for SparseMerklePath

Source§

impl Deserializable for SourceSpan

Source§

impl Deserializable for BaseElement

Source§

impl Deserializable for BaseElement

Source§

impl<B> Deserializable for CubeExtension<B>
where B: ExtensibleField<3>,

Source§

impl<H> Deserializable for BatchMerkleProof<H>
where H: Hasher,

Source§

fn read_from<R>( source: &mut R, ) -> Result<BatchMerkleProof<H>, DeserializationError>
where R: ByteReader,

Parses internal nodes from the provided source, and constructs a batch Merkle proof from these nodes.

§Errors

Returns an error if:

  • source could not be deserialized into a valid set of internal nodes.
Source§

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

Source§

impl<T1> Deserializable for (T1,)
where T1: Deserializable,

Source§

impl<T1, T2> Deserializable for (T1, T2)

Source§

impl<T1, T2, T3> Deserializable for (T1, T2, T3)

Source§

impl<T1, T2, T3, T4> Deserializable for (T1, T2, T3, T4)

Source§

impl<T1, T2, T3, T4, T5> Deserializable for (T1, T2, T3, T4, T5)

Source§

impl<T1, T2, T3, T4, T5, T6> Deserializable for (T1, T2, T3, T4, T5, T6)

Source§

impl<T> Deserializable for Option<T>
where T: Deserializable,

Source§

impl<T> Deserializable for BTreeSet<T>
where T: Deserializable + Ord,

Source§

impl<T> Deserializable for Vec<T>
where T: Deserializable,

Source§

impl<T> Deserializable for LexicographicWord<T>
where T: Into<Word> + From<Word>,

Source§

impl<T> Deserializable for Span<T>
where T: Deserializable,

Source§

impl<T, const C: usize> Deserializable for [T; C]
where T: Deserializable,

Source§

impl<const DEPTH: u8, K, V> Deserializable for MutationSet<DEPTH, K, V>

Source§

fn read_from<R>( source: &mut R, ) -> Result<MutationSet<DEPTH, K, V>, DeserializationError>
where R: ByteReader,

Implementors§