Skip to main content

Crate fixed_hashmap

Crate fixed_hashmap 

Source
Expand description

A fixed-capacity hashmap for fixed-size byte keys and values.

The map uses caller-provided storage and does not allocate.

use core::mem::MaybeUninit;
use fixed_hashmap::{EntryStorage, FixedMap};

let mut entries: [EntryStorage<2, 2>; 16] =
    core::array::from_fn(|_| MaybeUninit::uninit());
let mut tags = [0; 16];
let mut map = FixedMap::<8, 2, 2>::new(&mut entries, &mut tags).unwrap();
map.insert(*b"hi", *b"ok").unwrap();
assert_eq!(map.get(b"hi"), Some(b"ok"));

Structs§

FastHasher
Fast, non-cryptographic key hasher used by default.
FixedMap
A fixed-capacity hashmap over caller-provided storage.
InsertError
A key-value pair rejected because the map was full.

Enums§

StorageError
Error returned when the backing storage is too small for a map.

Traits§

KeyHasher
Hash strategy used by a fixed map.

Type Aliases§

EntryStorage
Caller-provided, uninitialized storage for one key-value entry.