pub trait StableHasher {
type Out;
type Addr: FieldAddress;
type Bytes: AsRef<[u8]>;
// Required methods
fn new() -> Self;
fn write(&mut self, field_address: Self::Addr, bytes: &[u8]);
fn mixin(&mut self, other: &Self);
fn finish(&self) -> Self::Out;
fn to_bytes(&self) -> Self::Bytes;
fn from_bytes(bytes: Self::Bytes) -> Self;
// Provided method
fn unmix(&mut self, _other: &Self) { ... }
}Expand description
Like Hasher, but consistent across:
- builds (independent of rustc version or std implementation details)
- platforms (eg: 32 bit & 64 bit, x68 and ARM)
- processes (multiple runs of the same program)
Required Associated Types§
Sourcetype Addr: FieldAddress
type Addr: FieldAddress
The type used when identifying where a value is located in a struct
Required Methods§
Sourcefn from_bytes(bytes: Self::Bytes) -> Self
fn from_bytes(bytes: Self::Bytes) -> Self
Deserialize
Provided Methods§
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.