Skip to main content

Node

Struct Node 

Source
pub struct Node<'a> { /* private fields */ }
Expand description

A validator node: the map of options plus what’s needed to read them and recurse.

Passed to each Registry constructor. Custom constructors use its readers (opt_int, flag, child, …) to pull options and build nested validators.

Implementations§

Source§

impl Node<'_>

Source

pub fn error(&self, kind: SchemaErrorKind) -> SchemaError

Build an error anchored at this node.

Source

pub fn req_str(&self, field: &str) -> Result<&str, SchemaError>

Read a required string field.

Source

pub fn opt_str(&self, field: &str) -> Result<Option<&str>, SchemaError>

Read an optional string field.

Source

pub fn opt_int(&self, field: &str) -> Result<Option<isize>, SchemaError>

Read an optional integer field.

Source

pub fn opt_usize(&self, field: &str) -> Result<Option<usize>, SchemaError>

Read an optional non-negative integer field as a usize.

Source

pub fn opt_f64(&self, field: &str) -> Result<Option<f64>, SchemaError>

Read an optional number field (integer or float) as an f64.

Source

pub fn opt_bool(&self, field: &str) -> Result<Option<bool>, SchemaError>

Read an optional boolean field.

Source

pub fn flag(&self, field: &str) -> Result<bool, SchemaError>

Read a boolean field, defaulting to false when absent.

Source

pub fn values(&self, field: &str) -> Result<Vec<Value>, SchemaError>

Read a list field as raw values (used by enum). Absent → empty.

Source

pub fn str_list(&self, field: &str) -> Result<Vec<String>, SchemaError>

Read a list-of-strings field (used by path.extensions, url.schemes). Absent → empty.

Source

pub fn child(&self, field: &str) -> Result<Box<dyn Validator>, SchemaError>

Build a required nested validator from a sub-schema field.

Source

pub fn opt_child( &self, field: &str, ) -> Result<Option<Box<dyn Validator>>, SchemaError>

Build an optional nested validator from a sub-schema field.

Auto Trait Implementations§

§

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

§

impl<'a> !Send for Node<'a>

§

impl<'a> !Sync for Node<'a>

§

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

§

impl<'a> Freeze for Node<'a>

§

impl<'a> Unpin for Node<'a>

§

impl<'a> UnsafeUnpin for Node<'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 = 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.