pub struct UserPrefixDictionary {
pub da: DoubleArrayAhoCorasick<u32>,
pub vals_data: Data,
pub words_idx_data: Data,
pub words_data: Data,
pub is_system: bool,
}Expand description
The user prefix dictionary: a daachorse Aho-Corasick automaton.
The field sequence is byte-for-byte the sequence the pre-v6
PrefixDictionary archived (da, vals_data, words_idx_data,
words_data, is_system). rkyv 0.8 archives structurally, without type
names, so keeping the sequence is what lets every previously-built user
dictionary .bin keep loading. Do not add, remove or reorder fields
without bumping the dictionary format version and rebuilding the committed
.bin fixtures.
Fields§
§da: DoubleArrayAhoCorasick<u32>The Aho-Corasick automaton over surface forms.
vals_data: DataThe values file: WordEntry records back to back.
words_idx_data: DataByte offsets into words_data, one u32 per word id.
words_data: DataWord detail records.
is_system: boolAlways false; retained because the archived field sequence must not
change (see the type-level comment).
Implementations§
Source§impl UserPrefixDictionary
impl UserPrefixDictionary
Sourcepub fn decode_val(&self, val: u32) -> (u32, u32)
pub fn decode_val(&self, val: u32) -> (u32, u32)
Decode the (offset, count) pair stored in the double-array value.
The word-id offset lives in the high 24 bits and the per-surface
variant count in the low 8 bits (up to 255 variants). The legacy 5-bit
encoding was retired in v4.0.0; user .bin files built with v3 must
be rebuilt from CSV.
§Arguments
val- The packed automaton value.
§Returns
The (offset, count) pair.
Sourcepub fn load(
da_data: impl Into<Data>,
vals_data: impl Into<Data>,
words_idx_data: impl Into<Data>,
words_data: impl Into<Data>,
) -> LinderaResult<UserPrefixDictionary>
pub fn load( da_data: impl Into<Data>, vals_data: impl Into<Data>, words_idx_data: impl Into<Data>, words_data: impl Into<Data>, ) -> LinderaResult<UserPrefixDictionary>
Load a UserPrefixDictionary from raw binary data.
The automaton bytes are always run through daachorse’s validating deserializer: user dictionaries come from the filesystem or from callers, never from this crate’s own build pipeline, so there is no trusted path.
§Arguments
da_data- Serialized automaton bytes.vals_data- Values data bytes.words_idx_data- Word index data bytes.words_data- Words data bytes.
§Returns
A UserPrefixDictionary, or an error if deserialization fails.
Trait Implementations§
Source§impl Archive for UserPrefixDictionary
impl Archive for UserPrefixDictionary
Source§type Archived = ArchivedUserPrefixDictionary
type Archived = ArchivedUserPrefixDictionary
Source§type Resolver = UserPrefixDictionaryResolver
type Resolver = UserPrefixDictionaryResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl Clone for UserPrefixDictionary
impl Clone for UserPrefixDictionary
Source§fn clone(&self) -> UserPrefixDictionary
fn clone(&self) -> UserPrefixDictionary
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de> Deserialize<'de> for UserPrefixDictionary
impl<'de> Deserialize<'de> for UserPrefixDictionary
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<__D: Fallible + ?Sized> Deserialize<UserPrefixDictionary, __D> for Archived<UserPrefixDictionary>where
DoubleArrayArchiver: ArchiveWith<DoubleArrayAhoCorasick<u32>> + DeserializeWith<<DoubleArrayArchiver as ArchiveWith<DoubleArrayAhoCorasick<u32>>>::Archived, DoubleArrayAhoCorasick<u32>, __D>,
Data: Archive,
<Data as Archive>::Archived: Deserialize<Data, __D>,
bool: Archive,
<bool as Archive>::Archived: Deserialize<bool, __D>,
impl<__D: Fallible + ?Sized> Deserialize<UserPrefixDictionary, __D> for Archived<UserPrefixDictionary>where
DoubleArrayArchiver: ArchiveWith<DoubleArrayAhoCorasick<u32>> + DeserializeWith<<DoubleArrayArchiver as ArchiveWith<DoubleArrayAhoCorasick<u32>>>::Archived, DoubleArrayAhoCorasick<u32>, __D>,
Data: Archive,
<Data as Archive>::Archived: Deserialize<Data, __D>,
bool: Archive,
<bool as Archive>::Archived: Deserialize<bool, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<UserPrefixDictionary, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<UserPrefixDictionary, <__D as Fallible>::Error>
Source§impl Serialize for UserPrefixDictionary
impl Serialize for UserPrefixDictionary
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for UserPrefixDictionarywhere
DoubleArrayArchiver: SerializeWith<DoubleArrayAhoCorasick<u32>, __S>,
Data: Serialize<__S>,
bool: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for UserPrefixDictionarywhere
DoubleArrayArchiver: SerializeWith<DoubleArrayAhoCorasick<u32>, __S>,
Data: Serialize<__S>,
bool: Serialize<__S>,
Auto Trait Implementations§
impl Freeze for UserPrefixDictionary
impl RefUnwindSafe for UserPrefixDictionary
impl Send for UserPrefixDictionary
impl Sync for UserPrefixDictionary
impl Unpin for UserPrefixDictionary
impl UnsafeUnpin for UserPrefixDictionary
impl UnwindSafe for UserPrefixDictionary
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.