ScannerContext

Struct ScannerContext 

Source
pub struct ScannerContext {
    pub state: ScannerState,
    pub flow_level: usize,
    pub in_key: bool,
    pub in_value: bool,
    pub allow_simple_key: bool,
    pub simple_keys: Vec<Option<Position>>,
}
Expand description

Scanner context manager

Fields§

§state: ScannerState

Current scanner state

§flow_level: usize

Flow level (0 = block context, >0 = flow context)

§in_key: bool

Whether we’re in a key position

§in_value: bool

Whether we’re in a value position

§allow_simple_key: bool

Whether simple keys are allowed

§simple_keys: Vec<Option<Position>>

Stack of simple key positions

Implementations§

Source§

impl ScannerContext

Source

pub fn new() -> Self

Create a new scanner context

Source

pub fn reset(&mut self)

Reset the scanner context

Source

pub fn in_flow(&self) -> bool

Check if we’re in flow context

Source

pub fn in_block(&self) -> bool

Check if we’re in block context

Source

pub fn enter_flow(&mut self)

Enter flow context

Source

pub fn exit_flow(&mut self)

Exit flow context

Source

pub fn save_simple_key(&mut self, position: Position)

Save a simple key position

Source

pub fn clear_simple_key(&mut self)

Clear the current simple key

Source

pub fn simple_key_allowed(&self) -> bool

Check if a simple key is possible

Trait Implementations§

Source§

impl Debug for ScannerContext

Source§

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

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

impl Default for ScannerContext

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> 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, 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.