Struct ZeroTrie
struct ZeroTrie<Store>(_)
A data structure that compactly maps from byte sequences to integers.
There are several variants of ZeroTrie which are very similar but are optimized
for different use cases:
ZeroTrieSimpleAsciiis the most compact structure. Very fast for small data. Only stores ASCII-encoded strings. Can be const-constructed!ZeroTriePerfectHashis also compact, but it also supports arbitrary binary strings. It also scales better to large data. Cannot be const-constructed.ZeroTrieExtendedCapacitycan be used if more than 2^32 bytes are required.
You can create a ZeroTrie directly, in which case the most appropriate
backing implementation will be chosen.
Backing Store
The data structure has a flexible backing data store. The only requirement for most
functionality is that it implement AsRef<[u8]>. All of the following are valid
ZeroTrie types:
ZeroTrie<[u8]>(dynamically sized type: must be stored in a reference or Box)ZeroTrie<&[u8]>(borrows its data from a u8 buffer)ZeroTrie<Vec<u8>>(fully owned data)ZeroTrie<ZeroVec<u8>>(the recommended borrowed-or-owned signature)Cow<ZeroTrie<[u8]>>(another borrowed-or-owned signature)ZeroTrie<Cow<[u8]>>(another borrowed-or-owned signature)
Examples
use LiteMap;
use ZeroTrie;
let mut map = new_vec;
map.insert;
map.insert;
map.insert;
let trie = try_from?;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
# Ok::
Implementations
impl<Store> ZeroTrie<Store>
fn get<K>(self: &Self, key: K) -> Option<usize> where K: AsRef<[u8]>Queries the trie for a string.
fn is_empty(self: &Self) -> boolReturns
trueif the trie is empty.fn byte_len(self: &Self) -> usizeReturns the size of the trie in number of bytes.
To get the number of keys in the trie, use
.iter().count().
impl<Store> ZeroTrie<Store>
fn into_store(self: Self) -> StoreTakes the byte store from this trie.
fn convert_store<NewStore>(self: Self) -> ZeroTrie<NewStore> where NewStore: From<Store>Converts this trie's store to a different store implementing the
Fromtrait.For example, use this to change
ZeroTrie<Vec<u8>>toZeroTrie<Cow<[u8]>>.
impl<'a, Store> Yokeable for ZeroTrie<Store>
fn transform(self: &Self) -> &<Self as >::Outputfn transform_owned(self: Self) -> <Self as >::Outputunsafe fn make(this: <Self as >::Output) -> Selffn transform_mut<F>(self: &'a mut Self, f: F) where F: 'static + for<'b> FnOnce(&'b mut <Self as >::Output)
impl<'zf, Store1, Store2> ZeroFrom for ZeroTrie<Store2>
fn zero_from(other: &'zf ZeroTrie<Store1>) -> Self
impl<Store> Freeze for ZeroTrie<Store>
impl<Store> RefUnwindSafe for ZeroTrie<Store>
impl<Store> Send for ZeroTrie<Store>
impl<Store> StructuralPartialEq for ZeroTrie<Store>
impl<Store> Sync for ZeroTrie<Store>
impl<Store> Unpin for ZeroTrie<Store>
impl<Store> UnsafeUnpin for ZeroTrie<Store>
impl<Store> UnwindSafe for ZeroTrie<Store>
impl<Store: $crate::clone::Clone> Clone for ZeroTrie<Store>
fn clone(self: &Self) -> ZeroTrie<Store>
impl<Store: $crate::cmp::Eq> Eq for ZeroTrie<Store>
impl<Store: $crate::cmp::PartialEq> PartialEq for ZeroTrie<Store>
fn eq(self: &Self, other: &ZeroTrie<Store>) -> bool
impl<Store: $crate::fmt::Debug> Debug for ZeroTrie<Store>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<Store: $crate::marker::Copy> Copy for ZeroTrie<Store>
impl<T> Any for ZeroTrie<Store>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ZeroTrie<Store>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ZeroTrie<Store>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for ZeroTrie<Store>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> ErasedDestructor for ZeroTrie<Store>
impl<T> From for ZeroTrie<Store>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ZeroTrie<Store>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for ZeroTrie<Store>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ZeroTrie<Store>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ZeroTrie<Store>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>