Skip to main content

State

Struct State 

Source
pub struct State<'a> {
    pub path_arr: &'a [PathPart],
    pub key: &'a str,
    pub value: &'a Value,
    pub node: &'a Node,
    pub parent_is_array: bool,
    pub is_match: bool,
    pub ctx: &'a mut Context,
    pub absent: bool,
    pub check_name: &'a str,
    /* private fields */
}
Expand description

What a custom validator sees: where it is, what it is looking at.

Fields§

§path_arr: &'a [PathPart]

The path from the root, the current key last: array indices as indices, keys as keys.

§key: &'a str

The immediate key or index.

§value: &'a Value

The value under validation.

§node: &'a Node

The node of the value.

§parent_is_array: bool

Whether the parent is an array (an index) or an object (a property).

§is_match: bool

True on a matches or valid call: nothing is produced.

§ctx: &'a mut Context§absent: bool

The value is missing, rather than present and null.

§check_name: &'a str

The name of the validator running, for check "<name>" failed.

Implementations§

Source§

impl<'a> State<'a>

Source

pub fn path_str(&self) -> String

The path as dotted text.

Source

pub fn path_keys(&self) -> Vec<String>

The path as keys, every index as its digits.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for State<'a>

§

impl<'a> !UnwindSafe for State<'a>

§

impl<'a> Freeze for State<'a>

§

impl<'a> Send for State<'a>

§

impl<'a> Sync for State<'a>

§

impl<'a> Unpin for State<'a>

§

impl<'a> UnsafeUnpin for State<'a>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.