pub struct Output<'a, 'b> { /* private fields */ }
Expand description

The output format resulting from the application of a schema. This can be converted into various representations based on the definitions in https://json-schema.org/draft/2020-12/json-schema-core.html#rfc.section.12.2

Currently only the “flag” and “basic” output formats are supported

Implementations

Indicates whether the schema was valid, corresponds to the “flag” output format

Output a list of errors and annotations for each element in the schema according to the basic output format. BasicOutput implements serde::Serialize in a manner which conforms to the json core spec so one way to use this is to serialize the BasicOutput and examine the JSON which is produced. However, for rust programs this is not necessary. Instead you can match on the BasicOutput and examine the results. To use this API you’ll need to understand a few things:

Regardless of whether the the schema validation was successful or not the BasicOutput is a sequence of OutputUnits. An OutputUnit is some metadata about where the output is coming from (where in the schema and where in the instance). The difference between the BasicOutput::Valid and BasicOutput::Invalid cases is the value which is associated with each OutputUnit. For Valid outputs the value is an annotation, whilst for Invalid outputs it’s an ErrorDescription (a String really).

Examples
let output: BasicOutput = schema.apply(&instance).basic();
match output {
    BasicOutput::Valid(annotations) => {
        for annotation in annotations {
            println!(
                "Value: {} at path {}",
                annotation.value(),
                annotation.instance_location()
            )
        }
    },
    BasicOutput::Invalid(errors) => {
        for error in errors {
            println!(
                "Error: {} at path {}",
                error.error_description(),
                error.instance_location()
            )
        }
    }
}

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more