pub struct Fsa<D> { /* private fields */ }Expand description
A read-only minimal-FSA map over a byte container.
Implementations§
Source§impl<D: AsRef<[u8]>> Fsa<D>
impl<D: AsRef<[u8]>> Fsa<D>
pub fn new(data: D) -> Result<Self, FsaError>
pub fn is_empty(&self) -> bool
Sourcepub fn state_count(&self) -> u32
pub fn state_count(&self) -> u32
Total number of states in the automaton (diagnostics).
Sourcepub fn contains_prefix(&self, prefix: &[u8]) -> bool
pub fn contains_prefix(&self, prefix: &[u8]) -> bool
true if any stored key starts with prefix.
Sourcepub fn prefix(&self, prefix: &[u8]) -> Vec<(Vec<u8>, u64)>
pub fn prefix(&self, prefix: &[u8]) -> Vec<(Vec<u8>, u64)>
All (key, value) pairs whose key starts with prefix, sorted.
Sourcepub fn prefix_for_each<F: FnMut(&[u8], u64)>(&self, prefix: &[u8], visit: F)
pub fn prefix_for_each<F: FnMut(&[u8], u64)>(&self, prefix: &[u8], visit: F)
Streaming variant: invoke visit(key, value) for every (key, value)
whose key starts with prefix, in sorted order, without allocating a
result vector. The key slice is valid only for the call. This is the
hot-path entry — a bare-letter prefix can match tens of thousands of
keys, and materializing them all would dominate cost.
Auto Trait Implementations§
impl<D> Freeze for Fsa<D>where
D: Freeze,
impl<D> RefUnwindSafe for Fsa<D>where
D: RefUnwindSafe,
impl<D> Send for Fsa<D>where
D: Send,
impl<D> Sync for Fsa<D>where
D: Sync,
impl<D> Unpin for Fsa<D>where
D: Unpin,
impl<D> UnsafeUnpin for Fsa<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for Fsa<D>where
D: UnwindSafe,
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