pub struct HighlightEngine { /* private fields */ }Expand description
A cheap-to-clone, Send + Sync handle to a grammar + theme for off-thread
bulk tokenization. Nothing syntect crosses its surface; SegmentBoundary
and SegmentTokens are opaque. Move clones to worker threads.
Every engine has an identity (shared by its clones), and a cache absorbs
only segments its OWN engine tokenized: obtain it via
crate::Document::highlight_engine / HighlightCache::engine for a
sweep whose results you will absorb, and re-fetch it after a theme or
grammar swap (the swap mints a new engine; the old one’s segments are
refused). HighlightEngine::new builds a standalone engine — for
tokenizing outside any cache (benchmarks, tests, an export pipeline) — whose
segments no cache will absorb.
Implementations§
Source§impl HighlightEngine
impl HighlightEngine
Sourcepub fn new(syntax: SyntaxDef, theme: TokenTheme) -> Self
pub fn new(syntax: SyntaxDef, theme: TokenTheme) -> Self
A standalone engine over an injected grammar + theme (mirrors
Highlighter::new), with a fresh identity.
Sourcepub fn fresh_boundary(&self) -> SegmentBoundary
pub fn fresh_boundary(&self) -> SegmentBoundary
The document-top fresh start state, as a boundary. The coordinator
compares a segment’s guessed Fresh start against a prior segment’s
true end with this: equal => the guess was right, the segment verifies
as-is; unequal => re-run from the true end.