pub struct Dictionary { /* private fields */ }Implementations§
Source§impl Dictionary
impl Dictionary
Sourcepub const fn new(max_entries: usize) -> Self
pub const fn new(max_entries: usize) -> Self
Create an empty dictionary holding at most max_entries phrases
A capacity of 0 is allowed but every add then fails
with ZipError::DictionaryFull
Sourcepub fn add(&mut self, phrase: &[u8]) -> Result<u32, ZipError>
pub fn add(&mut self, phrase: &[u8]) -> Result<u32, ZipError>
Insert phrase (or return the index of an identical existing phrase)
Evicts the oldest phrase when the dictionary is at capacity
§Errors
ZipError::DictionaryFull when the capacity is 0, or when the
arena would exceed the u32 offset range (4 GiB)
pub fn lookup(&self, idx: u32) -> Option<&[u8]>
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for Dictionary
impl Clone for Dictionary
Auto Trait Implementations§
impl Freeze for Dictionary
impl RefUnwindSafe for Dictionary
impl Send for Dictionary
impl Sync for Dictionary
impl Unpin for Dictionary
impl UnsafeUnpin for Dictionary
impl UnwindSafe for Dictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more