Skip to main content

Fsa

Struct Fsa 

Source
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>

Source

pub fn new(data: D) -> Result<Self, FsaError>

Source

pub fn len(&self) -> u64

Number of keys stored.

Source

pub fn is_empty(&self) -> bool

Source

pub fn state_count(&self) -> u32

Total number of states in the automaton (diagnostics).

Source

pub fn get(&self, key: &[u8]) -> Option<u64>

Look up key.

Source

pub fn contains_prefix(&self, prefix: &[u8]) -> bool

true if any stored key starts with prefix.

Source

pub fn prefix(&self, prefix: &[u8]) -> Vec<(Vec<u8>, u64)>

All (key, value) pairs whose key starts with prefix, sorted.

Source

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.

Source

pub fn iter(&self) -> FsaIter<'_, D>

Lazy iterator over all (key, value) pairs in sorted order.

Source

pub fn range(&self, prefix: &[u8]) -> FsaIter<'_, D>

Lazy iterator over (key, value) pairs whose key starts with prefix, in sorted order. Unlike prefix it allocates no result vector and supports early termination (.take, .find, break).

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.