Rust · Keys

Keys

use usearch::Key; 3.0.0-rc.1 · 4c3e5023

A Key is a 128-bit identity, rendered as a lowercase dashed UUID. Integer identities park in the low eight bytes, so Key::from(42u64) prints as 00000000-0000-0000-0000-00000000002a.

let key = Key::from(42u64);
let wide = Key::from(0x0123_4567_89ab_cdef_0123_4567_89ab_cdefu128);
let parsed: Key = "00000000-0000-0000-0000-00000000002a".parse()?;
assert_eq!(u64::try_from(parsed), Ok(42));                // refused when the high eight bytes are set
assert_eq!(u128::from(wide), 0x0123_4567_89ab_cdef_0123_4567_89ab_cdef);

Keys need not be unique: an index admits up to values_per_key entries under one, count reports how many it holds, and get returns them all. Key::NIL is the all-zero key.

API

StructKeyA 128-bit entry identity, rendered as a lowercase dashed UUID.1
types.rs:698 ↗
pub struct Key(pub [u8; 16]);

Keys need not be unique: several entries may share one, and count reports how many. Integer identities park in the low eight bytes, so Key::from(42u64) prints as 00000000-0000-0000-0000-00000000002a.

Fields

0[u8; 16]The sixteen identity bytes, most significant first.

Implements

Clone, Copy, Default, StructuralPartialEq, PartialEq, Eq, PartialOrd, Ord, Hash, From<u64>, From<u128>, From<Key>, TryFrom<Key>, FromStr, Display, Debug
NILThe all-zero key.
types.rs:705 ↗
pub const NIL: Key = _;