pub struct StructuredMatcher { /* private fields */ }Expand description
A mutable matcher with independent sequence state.
Implementations§
Source§impl StructuredMatcher
impl StructuredMatcher
Sourcepub fn new(
program: Arc<StructuredProgram>,
) -> Result<Self, StructuredMatcherError>
pub fn new( program: Arc<StructuredProgram>, ) -> Result<Self, StructuredMatcherError>
Constructs a matcher from an already compiled program.
Sourcepub fn backend_name(&self) -> &'static str
pub fn backend_name(&self) -> &'static str
Runtime backend selected for this matcher.
Sourcepub fn is_accepting(&self) -> bool
pub fn is_accepting(&self) -> bool
Whether the current state accepts a complete document.
Sourcepub fn retained_session_bytes(&self) -> usize
pub fn retained_session_bytes(&self) -> usize
Bytes currently retained by this sequence’s mutable backend state.
Sourcepub fn peak_session_bytes(&self) -> usize
pub fn peak_session_bytes(&self) -> usize
Peak charged session bytes observed by this matcher.
Sourcepub fn advance(
&mut self,
token_bytes: &[u8],
) -> Result<bool, StructuredMatcherError>
pub fn advance( &mut self, token_bytes: &[u8], ) -> Result<bool, StructuredMatcherError>
Atomically commits a whole tokenizer token.
Sourcepub fn allowed_mask_from_records<'a>(
&mut self,
mask_vocab_size: usize,
records: impl Iterator<Item = (&'a [u8], &'a [u32])>,
) -> Result<Bitmask, StructuredMatcherError>
pub fn allowed_mask_from_records<'a>( &mut self, mask_vocab_size: usize, records: impl Iterator<Item = (&'a [u8], &'a [u32])>, ) -> Result<Bitmask, StructuredMatcherError>
Computes a mask by speculatively feeding each candidate through one reusable state.
Sourcepub fn write_record_mask_words_into<'a>(
&mut self,
mask_vocab_size: usize,
records: impl Iterator<Item = (&'a [u8], &'a [u32])>,
out: &mut [u32],
) -> Result<(), StructuredMatcherError>
pub fn write_record_mask_words_into<'a>( &mut self, mask_vocab_size: usize, records: impl Iterator<Item = (&'a [u8], &'a [u32])>, out: &mut [u32], ) -> Result<(), StructuredMatcherError>
Clears and fills a packed u32-word mask by scanning vocabulary records, without an
intermediate byte buffer. O(1) additional allocation beyond out.
Sourcepub fn write_record_mask_le_bytes_into<'a>(
&mut self,
mask_vocab_size: usize,
records: impl Iterator<Item = (&'a [u8], &'a [u32])>,
out: &mut [u8],
) -> Result<(), StructuredMatcherError>
pub fn write_record_mask_le_bytes_into<'a>( &mut self, mask_vocab_size: usize, records: impl Iterator<Item = (&'a [u8], &'a [u32])>, out: &mut [u8], ) -> Result<(), StructuredMatcherError>
Clears and fills a little-endian packed mask by scanning vocabulary records.
Sourcepub fn write_mask_le_bytes_into(
&mut self,
vocabulary: &VocabularyHandle,
trie: Option<&BoundByteTrie>,
out: &mut [u8],
) -> Result<(), StructuredMatcherError>
pub fn write_mask_le_bytes_into( &mut self, vocabulary: &VocabularyHandle, trie: Option<&BoundByteTrie>, out: &mut [u8], ) -> Result<(), StructuredMatcherError>
Clears and fills a little-endian packed mask without allocating a temporary Bitmask.