pub struct ValidationCtx { /* private fields */ }
Expand description

A context for collecting validation error.

This is responsible for tracking the position in the tree at which a given error is reported.

paths/locations

As validation travels down through the object graph, the path is recorded via appropriate calls to methods like in_table and in_field.

Implementations§

source§

impl ValidationCtx

source

pub fn in_table( &mut self, name: &'static str, f: impl FnOnce(&mut ValidationCtx) )

Run the provided closer in the context of a new table.

Errors reported in the closure will include the provided identifer in their path.

source

pub fn in_field( &mut self, name: &'static str, f: impl FnOnce(&mut ValidationCtx) )

Run the provided closer in the context of a new field.

Errors reported in the closure will be associated with the field.

source

pub fn in_array(&mut self, f: impl FnOnce(&mut ValidationCtx))

Run the provided closer in the context of an array.

source

pub fn array_item(&mut self, f: impl FnOnce(&mut ValidationCtx))

Run the provided closer in the context of a new array item.

This must only be called in a closure passed to in_array.

source

pub fn report(&mut self, msg: impl Display)

Report a new error, associating it with the current path.

Trait Implementations§

source§

impl Clone for ValidationCtx

source§

fn clone(&self) -> ValidationCtx

Returns a copy 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 ValidationCtx

source§

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

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

impl Default for ValidationCtx

source§

fn default() -> ValidationCtx

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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<U, T> ToOwnedObj<U> for Twhere U: FromObjRef<T>,

source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
source§

impl<U, T> ToOwnedTable<U> for Twhere U: FromTableRef<T>,

source§

fn to_owned_table(&self) -> U

source§

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

§

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 Twhere U: TryFrom<T>,

§

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.