Trait TrieKey
pub trait TrieKey: PartialEq + Eq
Trait for types which can be used to key a Radix Trie.
Types that implement this trait should be convertible to a vector of half-bytes (nibbles)
such that no two instances of the type convert to the same vector.
To protect against faulty behaviour, the trie will panic if it finds two distinct keys
of type K which encode to the same Nibblet, so be careful!
If you would like to implement this trait for your own type, you need to implement
either encode_bytes or encode. You only need to implement one of the two.
If you don't implement one, your code will panic as soon you use the trie.
There is no performance penalty for implementing encode_bytes instead of encode,
so it is preferred except in the case where you require half-byte precision.
Many standard types implement this trait already. Integer types are encoded big-endian
by default but can be encoded little-endian using the LittleEndian<T> wrapper type.
Provided Methods
fn encode_bytes(&self) -> Vec<u8>Encode a value as a vector of bytes.
fn encode(&self) -> NibbletEncode a value as a NibbleVec.
Implementors
impl TrieKey for Pathimpl TrieKey for PathBufimpl TrieKey for Stringimpl TrieKey for Vec<i16>impl TrieKey for Vec<i32>impl TrieKey for Vec<i64>impl TrieKey for Vec<isize>impl TrieKey for Vec<u16>impl TrieKey for Vec<u32>impl TrieKey for Vec<u64>impl TrieKey for Vec<u8>impl TrieKey for Vec<usize>impl TrieKey for [u8]impl TrieKey for i16impl TrieKey for i32impl TrieKey for i64impl TrieKey for i8impl TrieKey for isizeimpl TrieKey for strimpl TrieKey for u16impl TrieKey for u32impl TrieKey for u64impl TrieKey for u8impl TrieKey for usizeimpl<T> TrieKey for BigEndian<T> where T: Eq + Copy,impl<T> TrieKey for LittleEndian<T> where T: Eq + Copy,impl<T: ?Sized + TrieKey> TrieKey for &Timpl<T: ?Sized + TrieKey> TrieKey for &mut T