Struct jtd::ValidationErrorIndicator[][src]

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

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

impl<'a> ValidationErrorIndicator<'a>[src]

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

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

impl<'a> Clone for ValidationErrorIndicator<'a>[src]

impl<'a> Debug for ValidationErrorIndicator<'a>[src]

impl<'a> Eq for ValidationErrorIndicator<'a>[src]

impl<'a> PartialEq<ValidationErrorIndicator<'a>> for ValidationErrorIndicator<'a>[src]

impl<'a> StructuralEq for ValidationErrorIndicator<'a>[src]

impl<'a> StructuralPartialEq for ValidationErrorIndicator<'a>[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.