pub struct Engine<'a, S, D>{ /* private fields */ }Expand description
Stateful hanja conversion engine for chunked token streams.
Engine is the low-level streaming surface. Call Engine::push_token for
each incoming token and then Engine::finish once the upstream reader is
exhausted. When the dictionary reports a maximum word length, text chunks are
buffered only at the tail so dictionary matches can cross chunk boundaries
without requiring the whole document in memory. A trailing fallback hanja run
is also kept buffered until a non-convertible boundary or EOF so render modes
that expose annotation spans match one-shot conversion. Dictionaries with an
unknown maximum keep hanja-containing text until a non-convertible boundary
or EOF so long custom entries remain observable.
Implementations§
Source§impl<'a, S, D> Engine<'a, S, D>
impl<'a, S, D> Engine<'a, S, D>
Sourcepub fn with_options(dictionary: &'a D, options: EngineOptions) -> Self
pub fn with_options(dictionary: &'a D, options: EngineOptions) -> Self
Creates a streaming engine with explicit conversion options.
Sourcepub fn push_token(&mut self, token: InputToken<S>) -> Vec<OutputToken<S>>
pub fn push_token(&mut self, token: InputToken<S>) -> Vec<OutputToken<S>>
Pushes one input token and returns output tokens that are now safe to emit.
Sourcepub fn flush(&mut self) -> Vec<OutputToken<S>>
pub fn flush(&mut self) -> Vec<OutputToken<S>>
Flushes all pending text without ending the engine.
Sourcepub fn finish(self) -> Vec<OutputToken<S>>
pub fn finish(self) -> Vec<OutputToken<S>>
Finishes the stream and returns every remaining output token.
Sourcepub fn buffered_chars(&self) -> usize
pub fn buffered_chars(&self) -> usize
Returns the number of Unicode scalar values currently buffered.