AccessedSet

Struct AccessedSet 

Source
pub struct AccessedSet(/* private fields */);
Expand description

Tracks accessed fields and extensions with snapshot/rollback support for union parsing.

The internal state is a stack where the last item is always the current working state. Items before it are snapshots (save points) for rollback.

Invariant: stack is never empty.

§Stack visualization

Initial:        [current]
push_snapshot:  [snapshot, current]  (snapshot = copy of current)
modify:         [snapshot, current'] (current' has changes)
restore:        [snapshot, snapshot] (current reset to snapshot)
pop_restore:    [snapshot]           (current removed, snapshot is new current)
pop_no_restore: [current']           (snapshot removed, keep modified current)

Implementations§

Source§

impl AccessedSet

Source

pub fn new() -> Self

Create a new empty set.

Source

pub fn add_field(&self, field: impl Into<String>)

Add a field to the accessed set.

Source

pub fn add_ext(&self, ext: Identifier)

Add an extension to the accessed set.

Source

pub fn has_field(&self, field: &str) -> bool

Check if a field has been accessed.

Source

pub fn has_ext(&self, ext: &Identifier) -> bool

Check if an extension has been accessed.

Source

pub fn push_snapshot(&self)

Push a snapshot (call at start of union parsing). Inserts a copy of current BEFORE current, so current can be modified.

Source

pub fn restore_to_current_snapshot(&self)

Restore current to the snapshot (call when variant fails). Resets current (last) to match the snapshot (second-to-last).

Source

pub fn capture_current_state(&self) -> AccessedSnapshot

Capture the current state (for non-priority variants).

Source

pub fn restore_to_state(&self, state: AccessedSnapshot)

Restore to a previously captured state.

Source

pub fn pop_and_restore(&self)

Pop and restore (call when union fails/ambiguous). Removes current, snapshot becomes new current.

Source

pub fn pop_without_restore(&self)

Pop without restore (call when union succeeds). Removes the snapshot, keeps current.

Trait Implementations§

Source§

impl Clone for AccessedSet

Source§

fn clone(&self) -> AccessedSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AccessedSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AccessedSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.