Trait KeyBase

Source
pub trait KeyBase {
    // Required methods
    fn len(&self) -> usize;
    fn hash<H: Hasher>(&self, state: &mut H);

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait for keys that can be used for hashing.

Required Methods§

Source

fn len(&self) -> usize

Returns the length of the key in bytes.

Source

fn hash<H: Hasher>(&self, state: &mut H)

Hashes the key. It should not include the structure of the key, only the data. E.g. ([1, 2], [3, 4]) should hash the same as [1, 2, 3, 4].

Provided Methods§

Source

fn is_empty(&self) -> bool

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 KeyBase for &[u8]

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Source§

impl KeyBase for u8

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Source§

impl KeyBase for Vec<u8>

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Source§

impl<A: KeyBase, B: KeyBase> KeyBase for (A, B)

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Source§

impl<T: KeyBase> KeyBase for &T

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Source§

impl<const N: usize> KeyBase for [u8; N]

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Implementors§