Skip to main content

Dict

Struct Dict 

Source
pub struct Dict<D> { /* private fields */ }
Expand description

Read-only two-level dictionary over a byte container.

Implementations§

Source§

impl<D: AsRef<[u8]>> Dict<D>

Source

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

Source

pub fn len(&self) -> u64

Number of distinct codes.

Source

pub fn is_empty(&self) -> bool

Source

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

Items for an exact code, in stored (value-desc) order. Empty if the code is absent. Allocates a Vec; hot paths should prefer the allocation-free get_for_each.

Source

pub fn get_for_each<F: FnMut(&[u8], u64)>(&self, code: &[u8], visit: F)

Streaming variant of get: invoke visit(item, value) for each item of an exact code with no result allocation and no per-item copy (the item slice is valid only for the call). This is the per-keystroke entry the IME dict layer should use.

Source

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

true if any code starts with prefix.

Source

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

All (code, item, value) triples whose code starts with prefix, codes in sorted order, items in stored order within each code.

Source

pub fn prefix_for_each<F: FnMut(&[u8], &[u8], u64)>( &self, prefix: &[u8], visit: F, )

Streaming variant of prefix: invoke visit(code, item, value) per item without materializing the result — the hot path (a bare-letter code prefix can match tens of thousands of items). The code and item slices are valid only for the call.

Auto Trait Implementations§

§

impl<D> Freeze for Dict<D>
where D: Freeze,

§

impl<D> RefUnwindSafe for Dict<D>
where D: RefUnwindSafe,

§

impl<D> Send for Dict<D>
where D: Send,

§

impl<D> Sync for Dict<D>
where D: Sync,

§

impl<D> Unpin for Dict<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for Dict<D>
where D: UnsafeUnpin,

§

impl<D> UnwindSafe for Dict<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.