pub struct AnnotationEntry<'a> {
pub schema_location: &'a str,
pub absolute_keyword_location: Option<&'a Uri<String>>,
pub instance_location: &'a Location,
pub annotations: &'a Annotations,
}Expand description
Entry describing annotations emitted by a keyword during evaluation.
Annotations are metadata produced by keywords during successful validation. They provide additional information about which schema keywords matched and what values they produced.
§Examples
use serde_json::json;
let schema = json!({
"type": "object",
"properties": {
"name": {"type": "string"},
"age": {"type": "number"}
}
});
let validator = jsonschema::validator_for(&schema)?;
let instance = json!({"name": "Alice", "age": 30});
let evaluation = validator.evaluate(&instance);
let entry = evaluation.iter_annotations().next().unwrap();
assert_eq!(entry.schema_location, "/properties");
assert_eq!(entry.instance_location.as_str(), "");
let mut annotation_names: Vec<_> = entry
.annotations
.value()
.as_array()
.expect("annotation should be an array")
.iter()
.map(|value| value.as_str().expect("annotation items should be strings"))
.collect();
annotation_names.sort_unstable();
assert_eq!(annotation_names, vec!["age", "name"]);Fields§
§schema_location: &'a strThe JSON Pointer to the schema keyword that produced the annotation.
absolute_keyword_location: Option<&'a Uri<String>>The absolute URI of the keyword location, if available.
instance_location: &'a LocationThe JSON Pointer to the instance location being validated.
annotations: &'a AnnotationsThe annotations produced by the keyword.
Trait Implementations§
Source§impl<'a> Clone for AnnotationEntry<'a>
impl<'a> Clone for AnnotationEntry<'a>
Source§fn clone(&self) -> AnnotationEntry<'a>
fn clone(&self) -> AnnotationEntry<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for AnnotationEntry<'a>
Auto Trait Implementations§
impl<'a> Freeze for AnnotationEntry<'a>
impl<'a> RefUnwindSafe for AnnotationEntry<'a>
impl<'a> Send for AnnotationEntry<'a>
impl<'a> Sync for AnnotationEntry<'a>
impl<'a> Unpin for AnnotationEntry<'a>
impl<'a> UnsafeUnpin for AnnotationEntry<'a>
impl<'a> UnwindSafe for AnnotationEntry<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more