#[repr(transparent)]pub struct ZeroTrieExtendedCapacity<Store: ?Sized> { /* private fields */ }
Expand description
A data structure that maps from a large number of byte strings to integers.
For more information, see ZeroTrie
.
Implementations§
Source§impl<Store> ZeroTrieExtendedCapacity<Store>
impl<Store> ZeroTrieExtendedCapacity<Store>
Sourcepub const fn into_zerotrie(self) -> ZeroTrie<Store>
pub const fn into_zerotrie(self) -> ZeroTrie<Store>
Wrap this specific ZeroTrie variant into a ZeroTrie.
Source§impl<Store> ZeroTrieExtendedCapacity<Store>
impl<Store> ZeroTrieExtendedCapacity<Store>
Sourcepub const fn from_store(store: Store) -> Self
pub 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.
Sourcepub fn into_store(self) -> Store
pub fn into_store(self) -> Store
Takes the byte store from this trie.
Sourcepub fn convert_store<X: From<Store>>(self) -> ZeroTrieExtendedCapacity<X>
pub fn convert_store<X: From<Store>>(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));
Source§impl<Store> ZeroTrieExtendedCapacity<Store>
impl<Store> ZeroTrieExtendedCapacity<Store>
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&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());
Sourcepub fn as_borrowed(&self) -> &ZeroTrieExtendedCapacity<[u8]>
pub fn as_borrowed(&self) -> &ZeroTrieExtendedCapacity<[u8]>
Returns this trie as a reference transparent over a byte slice.
Sourcepub fn as_borrowed_slice(&self) -> ZeroTrieExtendedCapacity<&[u8]>
pub fn as_borrowed_slice(&self) -> ZeroTrieExtendedCapacity<&[u8]>
Returns a trie with a store borrowing from this trie.
Source§impl ZeroTrieExtendedCapacity<[u8]>
impl ZeroTrieExtendedCapacity<[u8]>
Sourcepub fn from_bytes(trie: &[u8]) -> &Self
pub 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.
Trait Implementations§
Source§impl<Store> AsRef<ZeroTrieExtendedCapacity<[u8]>> for ZeroTrieExtendedCapacity<Store>
impl<Store> AsRef<ZeroTrieExtendedCapacity<[u8]>> for ZeroTrieExtendedCapacity<Store>
Source§fn as_ref(&self) -> &ZeroTrieExtendedCapacity<[u8]>
fn as_ref(&self) -> &ZeroTrieExtendedCapacity<[u8]>
Source§impl Borrow<ZeroTrieExtendedCapacity<[u8]>> for ZeroTrieExtendedCapacity<&[u8]>
impl Borrow<ZeroTrieExtendedCapacity<[u8]>> for ZeroTrieExtendedCapacity<&[u8]>
Source§impl<Store: Clone + ?Sized> Clone for ZeroTrieExtendedCapacity<Store>
impl<Store: Clone + ?Sized> Clone for ZeroTrieExtendedCapacity<Store>
Source§fn clone(&self) -> ZeroTrieExtendedCapacity<Store>
fn clone(&self) -> ZeroTrieExtendedCapacity<Store>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<Store: Default + ?Sized> Default for ZeroTrieExtendedCapacity<Store>
impl<Store: Default + ?Sized> Default for ZeroTrieExtendedCapacity<Store>
Source§fn default() -> ZeroTrieExtendedCapacity<Store>
fn default() -> ZeroTrieExtendedCapacity<Store>
Source§impl<Store: PartialEq + ?Sized> PartialEq for ZeroTrieExtendedCapacity<Store>
impl<Store: PartialEq + ?Sized> PartialEq for ZeroTrieExtendedCapacity<Store>
Source§fn eq(&self, other: &ZeroTrieExtendedCapacity<Store>) -> bool
fn eq(&self, other: &ZeroTrieExtendedCapacity<Store>) -> bool
self
and other
values to be equal, and is used by ==
.Source§impl<'zf, Store1, Store2> ZeroFrom<'zf, ZeroTrieExtendedCapacity<Store1>> for ZeroTrieExtendedCapacity<Store2>where
Store2: ZeroFrom<'zf, Store1>,
impl<'zf, Store1, Store2> ZeroFrom<'zf, ZeroTrieExtendedCapacity<Store1>> for ZeroTrieExtendedCapacity<Store2>where
Store2: ZeroFrom<'zf, Store1>,
Source§fn zero_from(other: &'zf ZeroTrieExtendedCapacity<Store1>) -> Self
fn zero_from(other: &'zf ZeroTrieExtendedCapacity<Store1>) -> Self
C
into a struct that may retain references into C
.