[][src]Trait radix_trie::TrieKey

pub trait TrieKey: PartialEq + Eq {
    fn encode_bytes(&self) -> Vec<u8> { ... }
fn encode(&self) -> Nibblet { ... } }

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) -> Nibblet

Encode a value as a NibbleVec.

Loading content...

Implementations on Foreign Types

impl TrieKey for Vec<u8>[src]

impl TrieKey for [u8][src]

impl TrieKey for String[src]

impl TrieKey for str[src]

impl<'a, T: ?Sized + TrieKey> TrieKey for &'a T[src]

impl<'a, T: ?Sized + TrieKey> TrieKey for &'a mut T[src]

impl TrieKey for i8[src]

impl TrieKey for u8[src]

impl TrieKey for PathBuf[src]

impl TrieKey for Path[src]

impl<T> TrieKey for LittleEndian<T> where
    T: Eq + Copy
[src]

impl<T> TrieKey for BigEndian<T> where
    T: Eq + Copy
[src]

impl TrieKey for u16[src]

impl TrieKey for u32[src]

impl TrieKey for u64[src]

impl TrieKey for i16[src]

impl TrieKey for i32[src]

impl TrieKey for i64[src]

impl TrieKey for usize[src]

impl TrieKey for isize[src]

impl TrieKey for Vec<u16>[src]

impl TrieKey for Vec<u32>[src]

impl TrieKey for Vec<u64>[src]

impl TrieKey for Vec<i16>[src]

impl TrieKey for Vec<i32>[src]

impl TrieKey for Vec<i64>[src]

impl TrieKey for Vec<usize>[src]

impl TrieKey for Vec<isize>[src]

Loading content...

Implementors

Loading content...