pub struct Model<'a> { /* private fields */ }Expand description
Validated EN and RU models.
Implementations§
Source§impl<'a> Model<'a>
impl<'a> Model<'a>
Sourcepub fn parse(bytes: &'a [u8]) -> Result<Self, ModelError>
pub fn parse(bytes: &'a [u8]) -> Result<Self, ModelError>
Parse and validate an asset. The source hash and the frozen alphabets and counts make a different or damaged model fail; they are a consistency check, not authentication, so bytes from outside the build still need their own provenance. Lookups on the result use checked slices.
§Errors
The first structural ModelError found, from the header through the trailing bytes.
Sourcepub fn embedded() -> Result<Model<'static>, ModelError>
pub fn embedded() -> Result<Model<'static>, ModelError>
Validate the asset compiled into this crate. Validation walks the whole asset, so callers should construct it once, outside input callbacks, and keep it.
use keyrill_core::model::Model;
use keyrill_core::session::Mode;
let model = Model::embedded()?;
let hello: Vec<u16> = "hello".encode_utf16().collect();
assert!(model.language(Mode::En).frequency(&hello).is_some());§Errors
A ModelError only if the build embedded a corrupt asset; tools/pack-model.py --check
guards against that.
Sourcepub fn language(&self, mode: Mode) -> &LanguageModel<'a>
pub fn language(&self, mode: Mode) -> &LanguageModel<'a>
The model for the language a mode types.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Model<'a>
impl<'a> RefUnwindSafe for Model<'a>
impl<'a> Send for Model<'a>
impl<'a> Sync for Model<'a>
impl<'a> Unpin for Model<'a>
impl<'a> UnsafeUnpin for Model<'a>
impl<'a> UnwindSafe for Model<'a>
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