pub struct FlattenContext { /* private fields */ }Expand description
Context for flatten parsing - wraps AccessedSet with snapshot/rollback support.
When parsing flattened types, all levels share a single AccessedSet owned
by the root parser. Child parsers add to this shared set, and only the root
parser actually validates with deny_unknown_fields().
§Example
// Root parser owns the accessed set
let mut rec1 = ctx.parse_record()?; // accessed = {} (owned)
rec1.field("a"); // accessed = {a}
// Child parser shares and adds to the same set
let ctx2 = rec1.flatten();
let mut rec2 = ctx2.parse_record()?; // shares accessed via Rc
rec2.field("b"); // accessed = {a, b}
rec2.deny_unknown_fields()?; // NO-OP (child)
rec1.field("c"); // accessed = {a, b, c}
rec1.deny_unknown_fields()?; // VALIDATES (root)Implementations§
Source§impl FlattenContext
impl FlattenContext
Sourcepub fn new(accessed: AccessedSet, scope: ParserScope) -> Self
pub fn new(accessed: AccessedSet, scope: ParserScope) -> Self
Create a FlattenContext from an existing AccessedSet with the given scope.
Sourcepub fn scope(&self) -> ParserScope
pub fn scope(&self) -> ParserScope
Get the parser scope.
Sourcepub fn accessed_set(&self) -> &AccessedSet
pub fn accessed_set(&self) -> &AccessedSet
Get the underlying AccessedSet (for sharing with RecordParser).
Sourcepub fn add_ext(&self, ext: Identifier)
pub fn add_ext(&self, ext: Identifier)
Add an extension to the accessed set.
Sourcepub fn has_ext(&self, ext: &Identifier) -> bool
pub fn has_ext(&self, ext: &Identifier) -> bool
Check if an extension has been accessed.
Sourcepub fn push_snapshot(&self)
pub fn push_snapshot(&self)
Push snapshot (at start of union parsing).
Sourcepub fn restore_to_current_snapshot(&self)
pub fn restore_to_current_snapshot(&self)
Restore to current snapshot (when variant fails).
Sourcepub fn capture_current_state(&self) -> AccessedSnapshot
pub fn capture_current_state(&self) -> AccessedSnapshot
Capture current state (for non-priority variants).
Sourcepub fn restore_to_state(&self, state: AccessedSnapshot)
pub fn restore_to_state(&self, state: AccessedSnapshot)
Restore to a captured state (when selecting a non-priority variant).
Sourcepub fn pop_and_restore(&self)
pub fn pop_and_restore(&self)
Pop and restore (when union fails/ambiguous).
Sourcepub fn pop_without_restore(&self)
pub fn pop_without_restore(&self)
Pop without restore (when union succeeds).
Trait Implementations§
Source§impl Clone for FlattenContext
impl Clone for FlattenContext
Source§fn clone(&self) -> FlattenContext
fn clone(&self) -> FlattenContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more