Skip to main content

CanonicalWrite

Trait CanonicalWrite 

Source
pub trait CanonicalWrite {
    // Required method
    fn canonical_write(&self, out: &mut StateHasher);
}
Expand description

Values with one frozen canonical byte representation.

An implementation must be self-delimiting: the shape of its writes (which primitive writes, in what order) may depend only on values it has already written. Write a length (with StateHasher::bytes, StateHasher::sequence or StateHasher::length) before variable-length data, and a tag before an optional value or enum variant. Otherwise distinct values encode alike: if Slot(Option<u32>) writes its u32 only when Some, sequence(&[Slot(None), Slot(Some(5))]) and sequence(&[Slot(Some(5)), Slot(None)]) hash the same.

Required Methods§

Source

fn canonical_write(&self, out: &mut StateHasher)

Writes this value using its documented canonical byte representation.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl CanonicalWrite for bool

Source§

impl CanonicalWrite for i32

Source§

impl CanonicalWrite for i64

Source§

impl CanonicalWrite for u8

Source§

impl CanonicalWrite for u16

Source§

impl CanonicalWrite for u32

Source§

impl CanonicalWrite for u64

Implementors§