pub struct SharedDictionary { /* private fields */ }Expand description
Shared dictionary state that can be cloned cheaply across tokenizers.
Holds the raw dictionary bytes (Arc<DictData>) and a pre-parsed
DoubleArrayTrie (Arc<DoubleArrayTrie>). Creating a new Lexicon
from this struct is a 16-byte Arc::clone + lightweight offset parsing,
not a 150 MB trie copy.
Implementations§
Sourcepub fn new(data: Vec<u8>) -> Result<Self, String>
pub fn new(data: Vec<u8>) -> Result<Self, String>
Build a SharedDictionary from owned (already inhibited) dictionary bytes.
Callers must apply inhibit_connection_in_data before passing data.
Sourcepub fn from_mmap(mmap: Mmap) -> Result<Self, String>
pub fn from_mmap(mmap: Mmap) -> Result<Self, String>
Build a SharedDictionary from a memory-mapped file.
Use this when no connection inhibitions are needed — the OS manages the pages and they can be shared / evicted without heap pressure.
Sourcepub fn create_lexicon(&self) -> (Lexicon, usize)
pub fn create_lexicon(&self) -> (Lexicon, usize)
Create a Lexicon that shares the pre-built trie.
Sourcepub fn create_grammar(&self) -> Result<Grammar, String>
pub fn create_grammar(&self) -> Result<Grammar, String>
Re-parse the grammar section from the shared data.
Sourcepub fn has_synonyms(&self) -> bool
pub fn has_synonyms(&self) -> bool
Whether this dictionary version includes synonym group IDs.