Struct ZeroTrieExtendedCapacity

struct ZeroTrieExtendedCapacity<Store: ?Sized> { ... }

A data structure that maps from a large number of byte strings to integers.

For more information, see ZeroTrie.

Implementations

impl ZeroTrieExtendedCapacity<[u8]>

fn from_bytes(trie: &[u8]) -> &Self

Casts from a byte slice to a reference to a trie with the same lifetime.

If the bytes are not a valid trie, unexpected behavior may occur.

impl<Store> ZeroTrieExtendedCapacity<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) -> bool

Returns true if the trie is empty.

fn byte_len(self: &Self) -> usize

Returns the size of the trie in number of bytes.

To get the number of keys in the trie, use .iter().count():

use zerotrie::ZeroTrieExtendedCapacity;

// A trie with two values: "abc" and "abcdef"
let trie: &ZeroTrieExtendedCapacity<[u8]> = ZeroTrieExtendedCapacity::from_bytes(b"abc\x80def\x81");

assert_eq!(8, trie.byte_len());
assert_eq!(2, trie.iter().count());
fn as_bytes(self: &Self) -> &[u8]

Returns the bytes contained in the underlying store.

fn as_borrowed(self: &Self) -> &ZeroTrieExtendedCapacity<[u8]>

Returns this trie as a reference transparent over a byte slice.

fn as_borrowed_slice(self: &Self) -> ZeroTrieExtendedCapacity<&[u8]>

Returns a trie with a store borrowing from this trie.

impl<Store> ZeroTrieExtendedCapacity<Store>

const fn from_store(store: Store) -> Self

Create a trie directly from a store.

If the store does not contain valid bytes, unexpected behavior may occur.

fn into_store(self: Self) -> Store

Takes the byte store from this trie.

fn convert_store<X: From<Store>>(self: Self) -> ZeroTrieExtendedCapacity<X>

Converts this trie's store to a different store implementing the From trait.

For example, use this to change ZeroTrieExtendedCapacity<Vec<u8>> to ZeroTrieExtendedCapacity<Cow<[u8]>>.

Examples

use std::borrow::Cow;
use zerotrie::ZeroTrieExtendedCapacity;

let trie: ZeroTrieExtendedCapacity<Vec<u8>> = ZeroTrieExtendedCapacity::from_bytes(b"abc\x85").to_owned();
let cow: ZeroTrieExtendedCapacity<Cow<[u8]>> = trie.convert_store();

assert_eq!(cow.get(b"abc"), Some(5));

impl<Store> ZeroTrieExtendedCapacity<Store>

const fn into_zerotrie(self: Self) -> ZeroTrie<Store>

Wrap this specific ZeroTrie variant into a ZeroTrie.

impl Borrow for ZeroTrieExtendedCapacity<&[u8]>

fn borrow(self: &Self) -> &ZeroTrieExtendedCapacity<[u8]>

impl<'zf, Store1, Store2> ZeroFrom for ZeroTrieExtendedCapacity<Store2>

fn zero_from(other: &'zf ZeroTrieExtendedCapacity<Store1>) -> Self

impl<Store> AsRef for ZeroTrieExtendedCapacity<Store>

fn as_ref(self: &Self) -> &ZeroTrieExtendedCapacity<[u8]>

impl<Store> Freeze for ZeroTrieExtendedCapacity<Store>

impl<Store> RefUnwindSafe for ZeroTrieExtendedCapacity<Store>

impl<Store> Send for ZeroTrieExtendedCapacity<Store>

impl<Store> Sync for ZeroTrieExtendedCapacity<Store>

impl<Store> Unpin for ZeroTrieExtendedCapacity<Store>

impl<Store> UnsafeUnpin for ZeroTrieExtendedCapacity<Store>

impl<Store> UnwindSafe for ZeroTrieExtendedCapacity<Store>

impl<Store: $crate::clone::Clone + ?Sized> Clone for ZeroTrieExtendedCapacity<Store>

fn clone(self: &Self) -> ZeroTrieExtendedCapacity<Store>

impl<Store: $crate::cmp::Eq + ?Sized> Eq for ZeroTrieExtendedCapacity<Store>

impl<Store: $crate::cmp::PartialEq + ?Sized> PartialEq for ZeroTrieExtendedCapacity<Store>

fn eq(self: &Self, other: &ZeroTrieExtendedCapacity<Store>) -> bool

impl<Store: $crate::default::Default + ?Sized> Default for ZeroTrieExtendedCapacity<Store>

fn default() -> ZeroTrieExtendedCapacity<Store>

impl<Store: $crate::fmt::Debug + ?Sized> Debug for ZeroTrieExtendedCapacity<Store>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<Store: $crate::marker::Copy + ?Sized> Copy for ZeroTrieExtendedCapacity<Store>

impl<Store: ?Sized> StructuralPartialEq for ZeroTrieExtendedCapacity<Store>

impl<T> Any for ZeroTrieExtendedCapacity<Store>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ZeroTrieExtendedCapacity<Store>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ZeroTrieExtendedCapacity<Store>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for ZeroTrieExtendedCapacity<Store>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ErasedDestructor for ZeroTrieExtendedCapacity<Store>

impl<T> From for ZeroTrieExtendedCapacity<Store>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ZeroTrieExtendedCapacity<Store>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for ZeroTrieExtendedCapacity<Store>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ZeroTrieExtendedCapacity<Store>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ZeroTrieExtendedCapacity<Store>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>