Skip to main content

xgrammar/parser/
parser_state_cache_key.rs

1//! The adaptive token-mask cache key of a parser state.
2
3/// Equality/hash over `rule_id`, `sequence_id`, `element_id`, and `sub_element_id` only: the
4/// token mask of a state does not depend on its start position, repeat count, partial
5/// codepoint, budgets, or temperature (mirrors C++ `StateHashForCache`/`StateEqualForCache`).
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
7pub struct ParserStateCacheKey {
8    /// The rule's id.
9    pub rule_id: i32,
10    /// The rule body expression id.
11    pub sequence_id: i32,
12    /// The FSM node.
13    pub element_id: i32,
14    /// The sub element id.
15    pub sub_element_id: i32,
16}