ValidationErrorIndicator

Struct ValidationErrorIndicator 

Source
pub struct ValidationErrorIndicator<'a> {
    pub instance_path: Vec<Cow<'a, str>>,
    pub schema_path: Vec<Cow<'a, str>>,
}
Expand description

A single validation error returned by validate().

This type has Indicator at the end of its name to emphasize that it is not a Rust error. It is an ordinary struct, and corresponds to the concept of a validation error indicator in the JSON Typedef specification. See RFC8927, Section 3.2.

In order to avoid unncessary allocations, this struct uses std::borrow::Cow instead of String directly. If you would prefer not to have to deal with that, and are OK with copying all the data out of this struct, then use into_owned_paths to convert instances of this type into a pair of plain old Vec<String>s.

Fields§

§instance_path: Vec<Cow<'a, str>>

A path to the part of the instance that was rejected.

§schema_path: Vec<Cow<'a, str>>

A path to the part of the schema that rejected the instance.

Implementations§

Source§

impl<'a> ValidationErrorIndicator<'a>

Source

pub fn into_owned_paths(self) -> (Vec<String>, Vec<String>)

Converts this struct into a instance_path and schema_path pair.

This is a convenience function for those who don’t want to manipulate std::borrow::Cow.

use std::borrow::Cow;

let indicator = jtd::ValidationErrorIndicator {
    instance_path: vec![Cow::Borrowed("foo")],
    schema_path: vec![Cow::Owned("bar".to_owned())],
};

let (instance_path, schema_path) = indicator.into_owned_paths();
assert_eq!(vec!["foo".to_owned()], instance_path);
assert_eq!(vec!["bar".to_owned()], schema_path);

Trait Implementations§

Source§

impl<'a> Clone for ValidationErrorIndicator<'a>

Source§

fn clone(&self) -> ValidationErrorIndicator<'a>

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<'a> Debug for ValidationErrorIndicator<'a>

Source§

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

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

impl<'a> PartialEq for ValidationErrorIndicator<'a>

Source§

fn eq(&self, other: &ValidationErrorIndicator<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for ValidationErrorIndicator<'a>

Source§

impl<'a> StructuralPartialEq for ValidationErrorIndicator<'a>

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.