| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{pathsrust-analyzer cargo jsonschema 0.37.4 paths/::Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#}; |
| 2 | use ahashrust-analyzer cargo ahash 0.8.12 crate/::AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#; |
| 3 | use referencingrust-analyzer cargo referencing 0.37.4 crate/::Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#; |
| 4 | use serderust-analyzer cargo serde 1.0.228 crate/::{ |
| 5 | serrust-analyzer cargo serde_core 1.0.228 ser/::{SerializeMaprust-analyzer cargo serde_core 1.0.228 ser/SerializeMap#, SerializeSeqrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#, SerializeStructrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#}, |
| 6 | Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#, |
| 7 | }; |
| 8 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#}; |
| 9 | |
| 10 | /// Annotations associated with an output unit. |
| 11 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 12 | pub struct Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>); |
| 13 | |
| 14 | impl Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations# { |
| 15 | /// Create a new `Annotations` instance. |
| 16 | #[must_use] |
| 17 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(v: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations] { |
| 18 | Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(v)) |
| 19 | } |
| 20 | |
| 21 | /// Create a new `Annotations` instance from an Arc. |
| 22 | #[must_use] |
| 23 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_arcrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]from_arc().(v: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations] { |
| 24 | Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#(v) |
| 25 | } |
| 26 | |
| 27 | /// Returns the inner [`serde_json::Value`] of the annotation. |
| 28 | #[inline] |
| 29 | #[must_use] |
| 30 | pub fn into_innerrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]into_inner().(self) -> serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value# { |
| 31 | Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::try_unwraprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]try_unwrap().(self.0rust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#0.).unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or_else().(|arc| (*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().arc).clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().()) |
| 32 | } |
| 33 | |
| 34 | /// The `serde_json::Value` of the annotation. |
| 35 | #[must_use] |
| 36 | pub fn valuerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]value().(&self) -> &serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value# { |
| 37 | &self.0rust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#0. |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | impl serderust-analyzer cargo serde 1.0.228 crate/::Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations# { |
| 42 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 43 | where |
| 44 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 45 | { |
| 46 | self.0rust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#0..serializerust-analyzer cargo serde_json 1.0.145 value/ser/impl#[Value][Serialize]serialize().(serializer) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// Description of a validation error used within evaluation outputs. |
| 51 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)] |
| 52 | pub struct ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 53 | keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#keyword.: &'static str, |
| 54 | messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 55 | } |
| 56 | |
| 57 | impl ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 58 | #[inline] |
| 59 | #[must_use] |
| 60 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().(keyword: &'static str, message: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription] { |
| 61 | Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription] { keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#keyword., messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message. } |
| 62 | } |
| 63 | |
| 64 | /// Create an `ErrorDescription` from a `ValidationError`. |
| 65 | #[inline] |
| 66 | #[must_use] |
| 67 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_validation_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]from_validation_error().(e: &ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'_>) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription] { |
| 68 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 69 | keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#keyword.: e.kindrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]kind().().keywordrust-analyzer cargo jsonschema 0.37.4 error/impl#[ValidationErrorKind]keyword().(), |
| 70 | messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message.: e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /// Returns the keyword associated with this error. |
| 75 | #[inline] |
| 76 | #[must_use] |
| 77 | pub fn keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]keyword().(&self) -> &'static str { |
| 78 | self.keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#keyword. |
| 79 | } |
| 80 | |
| 81 | /// Returns the inner [`String`] of the error description. |
| 82 | #[inline] |
| 83 | #[must_use] |
| 84 | pub fn into_innerrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]into_inner().(self) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 85 | self.messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message. |
| 86 | } |
| 87 | |
| 88 | /// Returns the message of the error description. |
| 89 | #[inline] |
| 90 | #[must_use] |
| 91 | pub fn messagerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]message().(&self) -> &str { |
| 92 | &self.messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message. |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 97 | fn fmtrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 98 | f.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().(&self.messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message.) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)] |
| 103 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 104 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#keyword_location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 105 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#absolute_keyword_location.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>>, |
| 106 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<str>, |
| 107 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 108 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.: bool, |
| 109 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#>, |
| 110 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#>, |
| 111 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#>, |
| 112 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#>, |
| 113 | } |
| 114 | |
| 115 | impl EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 116 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 117 | keyword_location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 118 | absolute_keyword_location: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>>, |
| 119 | schema_location: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<str>>, |
| 120 | instance_location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 121 | annotations: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#>, |
| 122 | children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#>, |
| 123 | ) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode] { |
| 124 | let schema_location = schema_location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 125 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 126 | keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#keyword_location., |
| 127 | absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#absolute_keyword_location., |
| 128 | schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location., |
| 129 | instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location., |
| 130 | validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.: true, |
| 131 | annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations., |
| 132 | dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 133 | errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 134 | childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children., |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 139 | keyword_location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 140 | absolute_keyword_location: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>>, |
| 141 | schema_location: impl Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<str>>, |
| 142 | instance_location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 143 | annotations: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#>, |
| 144 | errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#>, |
| 145 | children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#>, |
| 146 | ) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode] { |
| 147 | let schema_location = schema_location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 148 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 149 | keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#keyword_location., |
| 150 | absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#absolute_keyword_location., |
| 151 | schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location., |
| 152 | instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location., |
| 153 | validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.: false, |
| 154 | annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 155 | dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations.: annotations, |
| 156 | errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors., |
| 157 | childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children., |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /// Result of evaluating a JSON instance against a schema. |
| 163 | /// |
| 164 | /// This type provides access to structured output formats as defined in the |
| 165 | /// [JSON Schema specification](https://json-schema.org/draft/2020-12/json-schema-core#name-output-structure). |
| 166 | /// |
| 167 | /// # Output Formats |
| 168 | /// |
| 169 | /// The evaluation result can be accessed in three standard formats: |
| 170 | /// |
| 171 | /// - **Flag**: Simple boolean validity indicator via [`flag()`](Self::flag) |
| 172 | /// - **List**: Flat list of all evaluation units via [`list()`](Self::list) |
| 173 | /// - **Hierarchical**: Nested tree structure via [`hierarchical()`](Self::hierarchical) |
| 174 | /// |
| 175 | /// All formats are serializable to JSON using `serde_json`. |
| 176 | /// |
| 177 | /// # Examples |
| 178 | /// |
| 179 | /// ```rust |
| 180 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 181 | /// use serde_json::json; |
| 182 | /// |
| 183 | /// let schema = json!({"type": "string", "minLength": 3}); |
| 184 | /// let validator = jsonschema::validator_for(&schema)?; |
| 185 | /// |
| 186 | /// // Evaluate an instance |
| 187 | /// let instance = json!("ab"); |
| 188 | /// let evaluation = validator.evaluate(&instance); |
| 189 | /// |
| 190 | /// // Check validity with flag format |
| 191 | /// let flag = evaluation.flag(); |
| 192 | /// assert!(!flag.valid); |
| 193 | /// |
| 194 | /// // Get structured output as JSON |
| 195 | /// let list_output = serde_json::to_value(evaluation.list())?; |
| 196 | /// println!("{}", serde_json::to_string_pretty(&list_output)?); |
| 197 | /// |
| 198 | /// // Iterate over errors |
| 199 | /// for error in evaluation.iter_errors() { |
| 200 | /// println!("Error at {}: {}", error.instance_location, error.error); |
| 201 | /// } |
| 202 | /// # Ok(()) |
| 203 | /// # } |
| 204 | /// ``` |
| 205 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 206 | pub struct Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation# { |
| 207 | rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root.: EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 208 | } |
| 209 | |
| 210 | impl Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation# { |
| 211 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root: EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation] { |
| 212 | Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation# { rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root. } |
| 213 | } |
| 214 | /// Returns the flag output format. |
| 215 | /// |
| 216 | /// This is the simplest output format, containing only a boolean indicating |
| 217 | /// whether the instance is valid according to the schema. |
| 218 | /// |
| 219 | /// # Examples |
| 220 | /// |
| 221 | /// ```rust |
| 222 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 223 | /// use serde_json::json; |
| 224 | /// |
| 225 | /// let schema = json!({"type": "number"}); |
| 226 | /// let validator = jsonschema::validator_for(&schema)?; |
| 227 | /// |
| 228 | /// let evaluation = validator.evaluate(&json!(42)); |
| 229 | /// let flag = evaluation.flag(); |
| 230 | /// assert!(flag.valid); |
| 231 | /// |
| 232 | /// let evaluation = validator.evaluate(&json!("not a number")); |
| 233 | /// let flag = evaluation.flag(); |
| 234 | /// assert!(!flag.valid); |
| 235 | /// # Ok(()) |
| 236 | /// # } |
| 237 | /// ``` |
| 238 | #[must_use] |
| 239 | pub fn flagrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]flag().(&self) -> FlagOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput# { |
| 240 | FlagOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput# { |
| 241 | validrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput#valid.: self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root..validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid., |
| 242 | } |
| 243 | } |
| 244 | /// Returns the list output format. |
| 245 | /// |
| 246 | /// This format provides a flat list of all evaluation units, where each unit |
| 247 | /// contains information about a specific validation step including its location, |
| 248 | /// validity, annotations, and errors. |
| 249 | /// |
| 250 | /// # Examples |
| 251 | /// |
| 252 | /// ```rust |
| 253 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 254 | /// use serde_json::json; |
| 255 | /// |
| 256 | /// let schema = json!({ |
| 257 | /// "type": "array", |
| 258 | /// "prefixItems": [{"type": "string"}], |
| 259 | /// "items": {"type": "integer"} |
| 260 | /// }); |
| 261 | /// let validator = jsonschema::validator_for(&schema)?; |
| 262 | /// let evaluation = validator.evaluate(&json!(["hello", "oops"])); |
| 263 | /// |
| 264 | /// assert_eq!( |
| 265 | /// serde_json::to_value(evaluation.list())?, |
| 266 | /// json!({ |
| 267 | /// "valid": false, |
| 268 | /// "details": [ |
| 269 | /// {"evaluationPath": "", "instanceLocation": "", "schemaLocation": "", "valid": false}, |
| 270 | /// { |
| 271 | /// "valid": false, |
| 272 | /// "evaluationPath": "/items", |
| 273 | /// "instanceLocation": "", |
| 274 | /// "schemaLocation": "/items", |
| 275 | /// "droppedAnnotations": true |
| 276 | /// }, |
| 277 | /// { |
| 278 | /// "valid": false, |
| 279 | /// "evaluationPath": "/items", |
| 280 | /// "instanceLocation": "/1", |
| 281 | /// "schemaLocation": "/items" |
| 282 | /// }, |
| 283 | /// { |
| 284 | /// "valid": false, |
| 285 | /// "evaluationPath": "/items/type", |
| 286 | /// "instanceLocation": "/1", |
| 287 | /// "schemaLocation": "/items/type", |
| 288 | /// "errors": {"type": "\"oops\" is not of type \"integer\""} |
| 289 | /// }, |
| 290 | /// { |
| 291 | /// "valid": true, |
| 292 | /// "evaluationPath": "/prefixItems", |
| 293 | /// "instanceLocation": "", |
| 294 | /// "schemaLocation": "/prefixItems", |
| 295 | /// "annotations": 0 |
| 296 | /// }, |
| 297 | /// { |
| 298 | /// "valid": true, |
| 299 | /// "evaluationPath": "/prefixItems/0", |
| 300 | /// "instanceLocation": "/0", |
| 301 | /// "schemaLocation": "/prefixItems/0" |
| 302 | /// }, |
| 303 | /// { |
| 304 | /// "valid": true, |
| 305 | /// "evaluationPath": "/prefixItems/0/type", |
| 306 | /// "instanceLocation": "/0", |
| 307 | /// "schemaLocation": "/prefixItems/0/type" |
| 308 | /// }, |
| 309 | /// { |
| 310 | /// "valid": true, |
| 311 | /// "evaluationPath": "/type", |
| 312 | /// "instanceLocation": "", |
| 313 | /// "schemaLocation": "/type" |
| 314 | /// } |
| 315 | /// ] |
| 316 | /// }) |
| 317 | /// ); |
| 318 | /// # Ok(()) |
| 319 | /// # } |
| 320 | /// ``` |
| 321 | #[must_use] |
| 322 | pub fn listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().(&self) -> ListOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#<'_> { |
| 323 | ListOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput# { rootrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#root.: &self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root. } |
| 324 | } |
| 325 | /// Returns the hierarchical output format. |
| 326 | /// |
| 327 | /// This format represents the evaluation as a tree structure that mirrors the |
| 328 | /// schema's logical structure. Each node contains its validation result along |
| 329 | /// with nested child nodes representing sub-schema evaluations. |
| 330 | /// |
| 331 | /// # Examples |
| 332 | /// |
| 333 | /// ```rust |
| 334 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 335 | /// use serde_json::json; |
| 336 | /// |
| 337 | /// let schema = json!({ |
| 338 | /// "type": "array", |
| 339 | /// "prefixItems": [{"type": "string"}], |
| 340 | /// "items": {"type": "integer"} |
| 341 | /// }); |
| 342 | /// let validator = jsonschema::validator_for(&schema)?; |
| 343 | /// let evaluation = validator.evaluate(&json!(["hello", "oops"])); |
| 344 | /// |
| 345 | /// assert_eq!( |
| 346 | /// serde_json::to_value(evaluation.hierarchical())?, |
| 347 | /// json!({ |
| 348 | /// "valid": false, |
| 349 | /// "evaluationPath": "", |
| 350 | /// "schemaLocation": "", |
| 351 | /// "instanceLocation": "", |
| 352 | /// "details": [ |
| 353 | /// { |
| 354 | /// "valid": false, |
| 355 | /// "evaluationPath": "/items", |
| 356 | /// "instanceLocation": "", |
| 357 | /// "schemaLocation": "/items", |
| 358 | /// "droppedAnnotations": true, |
| 359 | /// "details": [ |
| 360 | /// { |
| 361 | /// "valid": false, |
| 362 | /// "evaluationPath": "/items", |
| 363 | /// "instanceLocation": "/1", |
| 364 | /// "schemaLocation": "/items", |
| 365 | /// "details": [ |
| 366 | /// { |
| 367 | /// "valid": false, |
| 368 | /// "evaluationPath": "/items/type", |
| 369 | /// "instanceLocation": "/1", |
| 370 | /// "schemaLocation": "/items/type", |
| 371 | /// "errors": {"type": "\"oops\" is not of type \"integer\""} |
| 372 | /// } |
| 373 | /// ] |
| 374 | /// } |
| 375 | /// ] |
| 376 | /// }, |
| 377 | /// { |
| 378 | /// "valid": true, |
| 379 | /// "evaluationPath": "/prefixItems", |
| 380 | /// "instanceLocation": "", |
| 381 | /// "schemaLocation": "/prefixItems", |
| 382 | /// "annotations": 0, |
| 383 | /// "details": [ |
| 384 | /// { |
| 385 | /// "valid": true, |
| 386 | /// "evaluationPath": "/prefixItems/0", |
| 387 | /// "instanceLocation": "/0", |
| 388 | /// "schemaLocation": "/prefixItems/0", |
| 389 | /// "details": [ |
| 390 | /// { |
| 391 | /// "valid": true, |
| 392 | /// "evaluationPath": "/prefixItems/0/type", |
| 393 | /// "instanceLocation": "/0", |
| 394 | /// "schemaLocation": "/prefixItems/0/type" |
| 395 | /// } |
| 396 | /// ] |
| 397 | /// } |
| 398 | /// ] |
| 399 | /// }, |
| 400 | /// { |
| 401 | /// "valid": true, |
| 402 | /// "evaluationPath": "/type", |
| 403 | /// "instanceLocation": "", |
| 404 | /// "schemaLocation": "/type" |
| 405 | /// } |
| 406 | /// ] |
| 407 | /// }) |
| 408 | /// ); |
| 409 | /// # Ok(()) |
| 410 | /// # } |
| 411 | /// ``` |
| 412 | #[must_use] |
| 413 | pub fn hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]hierarchical().(&self) -> HierarchicalOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#<'_> { |
| 414 | HierarchicalOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput# { rootrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#root.: &self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root. } |
| 415 | } |
| 416 | /// Returns an iterator over all annotations produced during evaluation. |
| 417 | /// |
| 418 | /// Annotations are metadata emitted by keywords during successful validation. |
| 419 | /// They can be used to collect information about which parts of a schema |
| 420 | /// matched the instance. |
| 421 | /// |
| 422 | /// # Examples |
| 423 | /// |
| 424 | /// ```rust |
| 425 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 426 | /// use serde_json::json; |
| 427 | /// |
| 428 | /// let schema = json!({ |
| 429 | /// "type": "object", |
| 430 | /// "properties": {"name": {"type": "string"}, "age": {"type": "number", "minimum": 0}}, |
| 431 | /// "required": ["name"] |
| 432 | /// }); |
| 433 | /// let validator = jsonschema::validator_for(&schema)?; |
| 434 | /// let evaluation = validator.evaluate(&json!({"name": "Alice", "age": 30})); |
| 435 | /// |
| 436 | /// let entries: Vec<_> = evaluation.iter_annotations().collect(); |
| 437 | /// assert_eq!(entries.len(), 1); |
| 438 | /// assert_eq!(entries[0].schema_location, "/properties"); |
| 439 | /// assert_eq!(entries[0].instance_location.as_str(), ""); |
| 440 | /// assert_eq!(entries[0].annotations.value(), &json!(["age", "name"])); |
| 441 | /// # Ok(()) |
| 442 | /// # } |
| 443 | /// ``` |
| 444 | #[must_use] |
| 445 | pub fn iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().(&self) -> AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#<'_> { |
| 446 | AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`]new().(&self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root.) |
| 447 | } |
| 448 | /// Returns an iterator over all errors produced during evaluation. |
| 449 | /// |
| 450 | /// Each error entry contains information about a validation failure, |
| 451 | /// including its location in both the schema and instance. |
| 452 | /// |
| 453 | /// # Examples |
| 454 | /// |
| 455 | /// ```rust |
| 456 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 457 | /// use serde_json::json; |
| 458 | /// |
| 459 | /// let schema = json!({ |
| 460 | /// "type": "object", |
| 461 | /// "required": ["name"], |
| 462 | /// "properties": { |
| 463 | /// "age": {"type": "number"} |
| 464 | /// } |
| 465 | /// }); |
| 466 | /// let validator = jsonschema::validator_for(&schema)?; |
| 467 | /// let evaluation = validator.evaluate(&json!({"name": "Bob", "age": "oops"})); |
| 468 | /// |
| 469 | /// let errors: Vec<_> = evaluation.iter_errors().collect(); |
| 470 | /// assert_eq!(errors.len(), 1); |
| 471 | /// assert_eq!(errors[0].schema_location, "/properties/age/type"); |
| 472 | /// assert_eq!(errors[0].instance_location.as_str(), "/age"); |
| 473 | /// assert_eq!(errors[0].error.to_string(), "\"oops\" is not of type \"number\""); |
| 474 | /// # Ok(()) |
| 475 | /// # } |
| 476 | /// ``` |
| 477 | #[must_use] |
| 478 | pub fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().(&self) -> ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#<'_> { |
| 479 | ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`]new().(&self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#root.) |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | /// Flag output format containing only a validity indicator. |
| 484 | /// |
| 485 | /// This is the simplest output format defined in the JSON Schema specification. |
| 486 | /// It contains only a single boolean field indicating whether validation succeeded. |
| 487 | /// |
| 488 | /// # JSON Structure |
| 489 | /// |
| 490 | /// ```json |
| 491 | /// { |
| 492 | /// "valid": true |
| 493 | /// } |
| 494 | /// ``` |
| 495 | /// |
| 496 | /// # Examples |
| 497 | /// |
| 498 | /// ```rust |
| 499 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 500 | /// use serde_json::json; |
| 501 | /// |
| 502 | /// let schema = json!({"type": "string"}); |
| 503 | /// let validator = jsonschema::validator_for(&schema)?; |
| 504 | /// let evaluation = validator.evaluate(&json!("hello")); |
| 505 | /// |
| 506 | /// let flag = evaluation.flag(); |
| 507 | /// assert_eq!(flag.valid, true); |
| 508 | /// |
| 509 | /// let output = serde_json::to_value(flag)?; |
| 510 | /// assert_eq!(output, json!({"valid": true})); |
| 511 | /// # Ok(()) |
| 512 | /// # } |
| 513 | /// ``` |
| 514 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:)] |
| 515 | pub struct FlagOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput# { |
| 516 | /// Whether the instance is valid according to the schema. |
| 517 | pub validrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput#valid.: bool, |
| 518 | } |
| 519 | |
| 520 | /// List output format providing a flat list of evaluation units. |
| 521 | /// |
| 522 | /// This format represents the evaluation result as a flat sequence where each |
| 523 | /// entry corresponds to a validation step. Each unit includes its evaluation path, |
| 524 | /// schema location, instance location, validity, and any annotations or errors. |
| 525 | /// |
| 526 | /// See [`Evaluation::list`] for an example JSON payload produced by this type. |
| 527 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 528 | pub struct ListOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#<'a> { |
| 529 | rootrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#root.: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 530 | } |
| 531 | |
| 532 | /// Hierarchical output format providing a tree structure of evaluation results. |
| 533 | /// |
| 534 | /// This format represents the evaluation as a nested tree that mirrors the logical |
| 535 | /// structure of the schema. Each node contains validation results and child nodes |
| 536 | /// representing nested sub-schema evaluations. |
| 537 | /// |
| 538 | /// See [`Evaluation::hierarchical`] for an example JSON payload produced by this type. |
| 539 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 540 | pub struct HierarchicalOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#<'a> { |
| 541 | rootrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#root.: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 542 | } |
| 543 | |
| 544 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for ListOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#<'_> { |
| 545 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ListOutput<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 546 | where |
| 547 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 548 | { |
| 549 | serialize_listrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_list().(self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/ListOutput#root., serializer) |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for HierarchicalOutputrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#<'_> { |
| 554 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`HierarchicalOutput<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 555 | where |
| 556 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 557 | { |
| 558 | serialize_hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_hierarchical().(self.rootrust-analyzer cargo jsonschema 0.37.4 evaluation/HierarchicalOutput#root., serializer) |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | fn serialize_listrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_list().<S>(root: &EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 563 | where |
| 564 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 565 | { |
| 566 | let mut state = serializer.serialize_structrust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_struct().("ListOutput", 2)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 567 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("valid", &root.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 568 | let mut entries = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 569 | collect_list_entriesrust-analyzer cargo jsonschema 0.37.4 evaluation/collect_list_entries().(root, &mut entries); |
| 570 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("details", &entries)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 571 | state.endrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#end().() |
| 572 | } |
| 573 | |
| 574 | fn serialize_hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_hierarchical().<S>(root: &EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 575 | where |
| 576 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 577 | { |
| 578 | serialize_unitrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_unit().(root, serializer, true) |
| 579 | } |
| 580 | |
| 581 | fn collect_list_entriesrust-analyzer cargo jsonschema 0.37.4 evaluation/collect_list_entries().<'a>(node: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, out: &mut Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#<'a>>) { |
| 582 | // Note: The spec says "Output units which do not contain errors or annotations SHOULD be |
| 583 | // excluded" but the official test suite includes all nodes. We include all nodes to match |
| 584 | // the reference implementation and test suite expectations. |
| 585 | out.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ListEntry<'a>`]new().(node)); |
| 586 | for child in &node.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children. { |
| 587 | collect_list_entriesrust-analyzer cargo jsonschema 0.37.4 evaluation/collect_list_entries().(child, out); |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | fn serialize_unitrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_unit().<S>( |
| 592 | node: &EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 593 | serializer: S, |
| 594 | include_children: bool, |
| 595 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 596 | where |
| 597 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 598 | { |
| 599 | let mut state = serializer.serialize_structrust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_struct().("OutputUnit", 7)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 600 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("valid", &node.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 601 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("evaluationPath", node.keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#keyword_location..as_strrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]as_str().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 602 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("schemaLocation", node.schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 603 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("instanceLocation", node.instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location..as_strrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]as_str().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 604 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotations) = &node.annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations. { |
| 605 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("annotations", annotations)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 606 | } |
| 607 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotations) = &node.dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations. { |
| 608 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("droppedAnnotations", annotations)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 609 | } |
| 610 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().node.errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 611 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().("errors", &ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#(&node.errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors.))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 612 | } |
| 613 | if include_children && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().node.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 614 | state.serialize_fieldrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#serialize_field().( |
| 615 | "details", |
| 616 | &DetailsSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer# { |
| 617 | childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#children.: &node.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children., |
| 618 | }, |
| 619 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 620 | } |
| 621 | state.endrust-analyzer cargo serde_core 1.0.228 ser/SerializeStruct#end().() |
| 622 | } |
| 623 | |
| 624 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().( |
| 625 | location: &Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 626 | absolute: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>>, |
| 627 | ) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<str> { |
| 628 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(uri) = absolute { |
| 629 | let base = uri.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().(); |
| 630 | if base.containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().('#') { |
| 631 | Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<str>`][`From<&str>`]from().(base) |
| 632 | } else if location.as_strrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]as_str().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() { |
| 633 | Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<str>`][`From<String>`]from().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{base}#")) |
| 634 | } else { |
| 635 | Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<str>`][`From<String>`]from().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{base}#{}", location.as_strrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]as_str().())) |
| 636 | } |
| 637 | } else { |
| 638 | location.as_arcrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]as_arc().() |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | struct ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#<'a> { |
| 643 | noderust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#node.: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 644 | } |
| 645 | |
| 646 | impl<'a> ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#<'a> { |
| 647 | fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ListEntry<'a>`]new().(node: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ListEntry<'a>`] { |
| 648 | ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry# { noderust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#node. } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for ListEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#<'_> { |
| 653 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ListEntry<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 654 | where |
| 655 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 656 | { |
| 657 | serialize_unitrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_unit().(self.noderust-analyzer cargo jsonschema 0.37.4 evaluation/ListEntry#node., serializer, false) |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | struct DetailsSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#<'a> { |
| 662 | childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#children.: &'a [EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#], |
| 663 | } |
| 664 | |
| 665 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for DetailsSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#<'_> { |
| 666 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`DetailsSerializer<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 667 | where |
| 668 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 669 | { |
| 670 | let mut seq = serializer.serialize_seqrust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_seq().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#children..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 671 | for child in self.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/DetailsSerializer#children. { |
| 672 | seq.serialize_elementrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#serialize_element().(&SeqEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry# { noderust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry#node.: child })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 673 | } |
| 674 | seq.endrust-analyzer cargo serde_core 1.0.228 ser/SerializeSeq#end().() |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | struct SeqEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry#<'a> { |
| 679 | noderust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry#node.: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, |
| 680 | } |
| 681 | |
| 682 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for SeqEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry#<'_> { |
| 683 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`SeqEntry<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 684 | where |
| 685 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 686 | { |
| 687 | serialize_unitrust-analyzer cargo jsonschema 0.37.4 evaluation/serialize_unit().(self.noderust-analyzer cargo jsonschema 0.37.4 evaluation/SeqEntry#node., serializer, true) |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | /// Entry describing annotations emitted by a keyword during evaluation. |
| 692 | /// |
| 693 | /// Annotations are metadata produced by keywords during successful validation. |
| 694 | /// They provide additional information about which schema keywords matched |
| 695 | /// and what values they produced. |
| 696 | /// |
| 697 | /// # Examples |
| 698 | /// |
| 699 | /// ```rust |
| 700 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 701 | /// use serde_json::json; |
| 702 | /// |
| 703 | /// let schema = json!({ |
| 704 | /// "type": "object", |
| 705 | /// "properties": { |
| 706 | /// "name": {"type": "string"}, |
| 707 | /// "age": {"type": "number"} |
| 708 | /// } |
| 709 | /// }); |
| 710 | /// let validator = jsonschema::validator_for(&schema)?; |
| 711 | /// let instance = json!({"name": "Alice", "age": 30}); |
| 712 | /// let evaluation = validator.evaluate(&instance); |
| 713 | /// let entry = evaluation.iter_annotations().next().unwrap(); |
| 714 | /// assert_eq!(entry.schema_location, "/properties"); |
| 715 | /// assert_eq!(entry.instance_location.as_str(), ""); |
| 716 | /// assert_eq!(entry.annotations.value(), &json!(["age", "name"])); |
| 717 | /// # Ok(()) |
| 718 | /// # } |
| 719 | /// ``` |
| 720 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 721 | pub struct AnnotationEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#<'a> { |
| 722 | /// The JSON Pointer to the schema keyword that produced the annotation. |
| 723 | pub schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location.: &'a str, |
| 724 | /// The absolute URI of the keyword location, if available. |
| 725 | pub absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#absolute_keyword_location.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>, |
| 726 | /// The JSON Pointer to the instance location being validated. |
| 727 | pub instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#instance_location.: &'a Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 728 | /// The annotations produced by the keyword. |
| 729 | pub annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#annotations.: &'a Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#, |
| 730 | } |
| 731 | |
| 732 | /// Entry describing errors emitted by a keyword during evaluation. |
| 733 | /// |
| 734 | /// Error entries contain information about validation failures, including |
| 735 | /// the locations in both the schema and instance where the error occurred. |
| 736 | /// |
| 737 | /// # Examples |
| 738 | /// |
| 739 | /// ```rust |
| 740 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 741 | /// use serde_json::json; |
| 742 | /// |
| 743 | /// let schema = json!({ |
| 744 | /// "type": "object", |
| 745 | /// "required": ["name"], |
| 746 | /// "properties": { |
| 747 | /// "age": {"type": "number"} |
| 748 | /// } |
| 749 | /// }); |
| 750 | /// let validator = jsonschema::validator_for(&schema)?; |
| 751 | /// let instance = json!({"age": "oops"}); |
| 752 | /// let evaluation = validator.evaluate(&instance); |
| 753 | /// let entry = evaluation.iter_errors().next().unwrap(); |
| 754 | /// assert_eq!(entry.schema_location, "/properties/age/type"); |
| 755 | /// assert_eq!(entry.instance_location.as_str(), "/age"); |
| 756 | /// assert_eq!(entry.error.to_string(), "\"oops\" is not of type \"number\""); |
| 757 | /// # Ok(()) |
| 758 | /// # } |
| 759 | /// ``` |
| 760 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 761 | pub struct ErrorEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#<'a> { |
| 762 | /// The JSON Pointer to the schema keyword that produced the error. |
| 763 | pub schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#schema_location.: &'a str, |
| 764 | /// The absolute URI of the keyword location, if available. |
| 765 | pub absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#absolute_keyword_location.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>, |
| 766 | /// The JSON Pointer to the instance location that failed validation. |
| 767 | pub instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#instance_location.: &'a Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 768 | /// The error description. |
| 769 | pub errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error.: &'a ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#, |
| 770 | } |
| 771 | |
| 772 | struct NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#<'a> { |
| 773 | stackrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#stack.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#>, |
| 774 | } |
| 775 | |
| 776 | impl<'a> NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#<'a> { |
| 777 | fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`]new().(root: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`] { |
| 778 | NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter# { stackrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#stack.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![root] } |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#<'a> { |
| 783 | type Itemrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`][Iterator]Item# = &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#; |
| 784 | |
| 785 | fn nextrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 786 | let node = self.stackrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#stack..poprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]pop().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Try]branch().; |
| 787 | for child in node.childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#children..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() { |
| 788 | self.stackrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#stack..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child); |
| 789 | } |
| 790 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | /// Iterator over annotations produced during evaluation. |
| 795 | /// |
| 796 | /// This iterator traverses the evaluation tree and yields [`AnnotationEntry`] |
| 797 | /// for each node that produced annotations during validation. |
| 798 | /// |
| 799 | /// Annotations are only present for nodes where validation succeeded. |
| 800 | /// |
| 801 | /// # Examples |
| 802 | /// |
| 803 | /// ```rust |
| 804 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 805 | /// use serde_json::json; |
| 806 | /// |
| 807 | /// let schema = json!({ |
| 808 | /// "type": "object", |
| 809 | /// "properties": { |
| 810 | /// "name": {"type": "string"}, |
| 811 | /// "age": {"type": "number"} |
| 812 | /// } |
| 813 | /// }); |
| 814 | /// let validator = jsonschema::validator_for(&schema)?; |
| 815 | /// let evaluation = validator.evaluate(&json!({"name": "Alice", "age": 30})); |
| 816 | /// |
| 817 | /// let annotations: Vec<_> = evaluation.iter_annotations().collect(); |
| 818 | /// assert_eq!(annotations.len(), 1); |
| 819 | /// assert_eq!(annotations[0].instance_location.as_str(), ""); |
| 820 | /// assert_eq!(annotations[0].annotations.value(), &json!(["age", "name"])); |
| 821 | /// # Ok(()) |
| 822 | /// # } |
| 823 | /// ``` |
| 824 | pub struct AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#<'a> { |
| 825 | nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#nodes.: NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#<'a>, |
| 826 | } |
| 827 | |
| 828 | impl<'a> AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#<'a> { |
| 829 | fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`]new().(root: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`] { |
| 830 | AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter# { |
| 831 | nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#nodes.: NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`]new().(root), |
| 832 | } |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for AnnotationIterrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#<'a> { |
| 837 | type Itemrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`][Iterator]Item# = AnnotationEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#<'a>; |
| 838 | |
| 839 | fn nextrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`AnnotationIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 840 | for node in self.nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationIter#nodes..by_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#by_ref().() { |
| 841 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotations) = node.annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() { |
| 842 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AnnotationEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry# { |
| 843 | schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location.: &node.schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location., |
| 844 | absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#absolute_keyword_location.: node.absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#absolute_keyword_location..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), |
| 845 | instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#instance_location.: &node.instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location., |
| 846 | annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#annotations., |
| 847 | }); |
| 848 | } |
| 849 | } |
| 850 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | /// Iterator over errors produced during evaluation. |
| 855 | /// |
| 856 | /// This iterator traverses the evaluation tree and yields [`ErrorEntry`] |
| 857 | /// for each error encountered during validation. |
| 858 | /// |
| 859 | /// Nodes can have multiple errors, and this iterator will yield all of them |
| 860 | /// in depth-first order. |
| 861 | /// |
| 862 | /// # Examples |
| 863 | /// |
| 864 | /// ```rust |
| 865 | /// # fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 866 | /// use serde_json::json; |
| 867 | /// |
| 868 | /// let schema = json!({ |
| 869 | /// "type": "object", |
| 870 | /// "required": ["name"], |
| 871 | /// "properties": { |
| 872 | /// "name": {"type": "string"}, |
| 873 | /// "age": {"type": "number", "minimum": 0} |
| 874 | /// } |
| 875 | /// }); |
| 876 | /// let validator = jsonschema::validator_for(&schema)?; |
| 877 | /// let evaluation = validator.evaluate(&json!({"age": -5})); |
| 878 | /// |
| 879 | /// let errors: Vec<_> = evaluation.iter_errors().collect(); |
| 880 | /// assert_eq!(errors.len(), 2); |
| 881 | /// assert_eq!(errors[0].instance_location.as_str(), "/age"); |
| 882 | /// assert_eq!(errors[0].schema_location, "/properties/age/minimum"); |
| 883 | /// assert_eq!(errors[1].schema_location, "/required"); |
| 884 | /// # Ok(()) |
| 885 | /// # } |
| 886 | /// ``` |
| 887 | pub struct ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#<'a> { |
| 888 | nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#nodes.: NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#<'a>, |
| 889 | currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(&'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#, usize)>, |
| 890 | } |
| 891 | |
| 892 | impl<'a> ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#<'a> { |
| 893 | fn newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`]new().(root: &'a EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`] { |
| 894 | ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter# { |
| 895 | nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#nodes.: NodeIterrust-analyzer cargo jsonschema 0.37.4 evaluation/NodeIter#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`]new().(root), |
| 896 | currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 897 | } |
| 898 | } |
| 899 | } |
| 900 | |
| 901 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for ErrorIterrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#<'a> { |
| 902 | type Itemrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`][Iterator]Item# = ErrorEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#<'a>; |
| 903 | |
| 904 | fn nextrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 905 | loop { |
| 906 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((node, idx)) = self.currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current. { |
| 907 | if idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().node.errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() { |
| 908 | let entry = ErrorEntryrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry# { |
| 909 | schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#schema_location.: &node.schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#schema_location., |
| 910 | absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#absolute_keyword_location.: node.absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#absolute_keyword_location..as_derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_deref().(), |
| 911 | instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#instance_location.: &node.instance_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#instance_location., |
| 912 | errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error.: &node.errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 913 | }; |
| 914 | self.currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((node, idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)); |
| 915 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry); |
| 916 | } |
| 917 | self.currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current. = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#; |
| 918 | } |
| 919 | |
| 920 | match self.nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#nodes..nextrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`NodeIter<'a>`][Iterator]next().() { |
| 921 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(node) => { |
| 922 | if node.errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#errors..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() { |
| 923 | continue; |
| 924 | } |
| 925 | self.currentrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorIter#current. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((node, 0)); |
| 926 | } |
| 927 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 928 | } |
| 929 | } |
| 930 | } |
| 931 | } |
| 932 | |
| 933 | struct ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#<'a>(&'a [ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#]); |
| 934 | |
| 935 | impl Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# for ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#<'_> { |
| 936 | fn serializerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[`ErrorEntriesSerializer<'_>`][Serialize]serialize().<S>(&self, serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> |
| 937 | where |
| 938 | S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#, |
| 939 | { |
| 940 | let mut grouped: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(&'static str, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>)> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(); |
| 941 | let mut indexes: AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#<&'static str, usize> = AHashMaprust-analyzer cargo ahash 0.8.12 hash_map/AHashMap#::newrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V>`]new().(); |
| 942 | |
| 943 | for error in self.0rust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#0. { |
| 944 | let keyword = error.keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]keyword().(); |
| 945 | let msg = error.messagerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]message().(); |
| 946 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&idx) = indexes.getrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]get().(keyword) { |
| 947 | grouped[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().idx]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut()..1.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(msg); |
| 948 | } else { |
| 949 | indexes.insertrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]insert().(keyword, grouped.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()); |
| 950 | grouped.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((keyword, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![msg])); |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | let mut map = serializer.serialize_maprust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_map().(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(grouped.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 955 | for (keyword, messages) in grouped { |
| 956 | if messages.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 { |
| 957 | map.serialize_entryrust-analyzer cargo serde_core 1.0.228 ser/SerializeMap#serialize_entry().(keyword, messages[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 958 | } else { |
| 959 | map.serialize_entryrust-analyzer cargo serde_core 1.0.228 ser/SerializeMap#serialize_entry().(keyword, &messages)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 960 | } |
| 961 | } |
| 962 | map.endrust-analyzer cargo serde_core 1.0.228 ser/SerializeMap#end().() |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | #[cfg(test)] |
| 967 | mod testsrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/ { |
| 968 | use superrust-analyzer cargo jsonschema 0.37.4 evaluation/::*; |
| 969 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!; |
| 970 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 971 | |
| 972 | fn locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().() -> Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location# { |
| 973 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().() |
| 974 | } |
| 975 | |
| 976 | fn annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(value: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations# { |
| 977 | Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(value) |
| 978 | } |
| 979 | |
| 980 | impl ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 981 | fn from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().(s: &str) -> Selfrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription] { |
| 982 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription# { |
| 983 | keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#keyword.: "error", |
| 984 | messagerust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#message.: s.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 985 | } |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | fn leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().(schema: &str, ann: serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 990 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 991 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 992 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 993 | schema.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 994 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 995 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(ann)), |
| 996 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 997 | ) |
| 998 | } |
| 999 | |
| 1000 | fn leaf_with_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_error().(schema: &str, msg: &str) -> EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 1001 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1002 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1003 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1004 | schema.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1005 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1006 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1007 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().(msg)], |
| 1008 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1009 | ) |
| 1010 | } |
| 1011 | |
| 1012 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1013 | fn iter_annotations_visits_all_nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/iter_annotations_visits_all_nodes().() { |
| 1014 | let child = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/child", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"k": "v"})); |
| 1015 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1016 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1017 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1018 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1019 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1020 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"root": true}))), |
| 1021 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![child], |
| 1022 | ); |
| 1023 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1024 | let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1025 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 1026 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/root"); |
| 1027 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/child"); |
| 1028 | } |
| 1029 | |
| 1030 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1031 | fn iter_errors_visits_all_nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/iter_errors_visits_all_nodes().() { |
| 1032 | let child = leaf_with_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_error().("/child", "boom"); |
| 1033 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1034 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1035 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1036 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1037 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1038 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1039 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("root error")], |
| 1040 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![child], |
| 1041 | ); |
| 1042 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1043 | let entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1044 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 1045 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "root error"); |
| 1046 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "boom"); |
| 1047 | } |
| 1048 | |
| 1049 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1050 | fn flag_output_validrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/flag_output_valid().() { |
| 1051 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().(locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 1052 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1053 | let flag = evaluation.flagrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]flag().(); |
| 1054 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(flag.validrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput#valid.); |
| 1055 | } |
| 1056 | |
| 1057 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1058 | fn flag_output_invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/flag_output_invalid().() { |
| 1059 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1060 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1061 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1062 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1063 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1064 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1065 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("error")], |
| 1066 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1067 | ); |
| 1068 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1069 | let flag = evaluation.flagrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]flag().(); |
| 1070 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().flag.validrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput#valid.); |
| 1071 | } |
| 1072 | |
| 1073 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1074 | fn flag_output_serializationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/flag_output_serialization().() { |
| 1075 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().(locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 1076 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1077 | let flag = evaluation.flagrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]flag().(); |
| 1078 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(flag).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1079 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized, jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"valid": true})); |
| 1080 | } |
| 1081 | |
| 1082 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1083 | fn list_output_serialization_validrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/list_output_serialization_valid().() { |
| 1084 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().(locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "#".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 1085 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1086 | let list = evaluation.listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().(); |
| 1087 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(list).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1088 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1089 | serialized, |
| 1090 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1091 | "valid": true, |
| 1092 | "details": [ |
| 1093 | { |
| 1094 | "valid": true, |
| 1095 | "evaluationPath": "", |
| 1096 | "schemaLocation": "#", |
| 1097 | "instanceLocation": "" |
| 1098 | } |
| 1099 | ] |
| 1100 | }) |
| 1101 | ); |
| 1102 | } |
| 1103 | |
| 1104 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1105 | fn list_output_serialization_with_childrenrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/list_output_serialization_with_children().() { |
| 1106 | let child1 = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/child1", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"key": "value"})); |
| 1107 | let child2 = leaf_with_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_error().("/child2", "child error"); |
| 1108 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1109 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1110 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1111 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1112 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1113 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"root": true}))), |
| 1114 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![child1, child2], |
| 1115 | ); |
| 1116 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1117 | let list = evaluation.listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().(); |
| 1118 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(list).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1119 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1120 | serialized, |
| 1121 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1122 | "valid": true, |
| 1123 | "details": [ |
| 1124 | { |
| 1125 | "valid": true, |
| 1126 | "evaluationPath": "", |
| 1127 | "schemaLocation": "/root", |
| 1128 | "instanceLocation": "", |
| 1129 | "annotations": {"root": true} |
| 1130 | }, |
| 1131 | { |
| 1132 | "valid": true, |
| 1133 | "evaluationPath": "", |
| 1134 | "schemaLocation": "/child1", |
| 1135 | "instanceLocation": "", |
| 1136 | "annotations": {"key": "value"} |
| 1137 | }, |
| 1138 | { |
| 1139 | "valid": false, |
| 1140 | "evaluationPath": "", |
| 1141 | "schemaLocation": "/child2", |
| 1142 | "instanceLocation": "", |
| 1143 | "errors": {"error": "child error"} |
| 1144 | } |
| 1145 | ] |
| 1146 | }) |
| 1147 | ); |
| 1148 | } |
| 1149 | |
| 1150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1151 | fn hierarchical_output_serializationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/hierarchical_output_serialization().() { |
| 1152 | let child = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/child", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"nested": "data"})); |
| 1153 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1154 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1155 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1156 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1157 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1158 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"root": "annotation"}))), |
| 1159 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![child], |
| 1160 | ); |
| 1161 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1162 | let hierarchical = evaluation.hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]hierarchical().(); |
| 1163 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(hierarchical).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1164 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1165 | serialized, |
| 1166 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1167 | "valid": true, |
| 1168 | "evaluationPath": "", |
| 1169 | "schemaLocation": "/root", |
| 1170 | "instanceLocation": "", |
| 1171 | "annotations": {"root": "annotation"}, |
| 1172 | "details": [ |
| 1173 | { |
| 1174 | "valid": true, |
| 1175 | "evaluationPath": "", |
| 1176 | "schemaLocation": "/child", |
| 1177 | "instanceLocation": "", |
| 1178 | "annotations": {"nested": "data"} |
| 1179 | } |
| 1180 | ] |
| 1181 | }) |
| 1182 | ); |
| 1183 | } |
| 1184 | |
| 1185 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1186 | fn outputs_include_errors_and_dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/outputs_include_errors_and_dropped_annotations().() { |
| 1187 | let invalid_child = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1188 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1189 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1190 | "/items/type".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1191 | Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().(1usize), |
| 1192 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1193 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("child error")], |
| 1194 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1195 | ); |
| 1196 | let prefix_child = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/prefix", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(0)); |
| 1197 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1198 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1199 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1200 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1201 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1202 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"dropped": true}))), |
| 1203 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("root failure")], |
| 1204 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![invalid_child, prefix_child], |
| 1205 | ); |
| 1206 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1207 | let list = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(evaluation.listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1208 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1209 | list, |
| 1210 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1211 | "valid": false, |
| 1212 | "details": [ |
| 1213 | { |
| 1214 | "valid": false, |
| 1215 | "evaluationPath": "", |
| 1216 | "schemaLocation": "/root", |
| 1217 | "instanceLocation": "", |
| 1218 | "droppedAnnotations": {"dropped": true}, |
| 1219 | "errors": {"error": "root failure"} |
| 1220 | }, |
| 1221 | { |
| 1222 | "valid": false, |
| 1223 | "evaluationPath": "", |
| 1224 | "schemaLocation": "/items/type", |
| 1225 | "instanceLocation": "/1", |
| 1226 | "errors": {"error": "child error"} |
| 1227 | }, |
| 1228 | { |
| 1229 | "valid": true, |
| 1230 | "evaluationPath": "", |
| 1231 | "schemaLocation": "/prefix", |
| 1232 | "instanceLocation": "", |
| 1233 | "annotations": 0 |
| 1234 | } |
| 1235 | ] |
| 1236 | }) |
| 1237 | ); |
| 1238 | let hierarchical = |
| 1239 | serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(evaluation.hierarchicalrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]hierarchical().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1240 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1241 | hierarchical, |
| 1242 | jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1243 | "valid": false, |
| 1244 | "evaluationPath": "", |
| 1245 | "schemaLocation": "/root", |
| 1246 | "instanceLocation": "", |
| 1247 | "droppedAnnotations": {"dropped": true}, |
| 1248 | "errors": {"error": "root failure"}, |
| 1249 | "details": [ |
| 1250 | { |
| 1251 | "valid": false, |
| 1252 | "evaluationPath": "", |
| 1253 | "schemaLocation": "/items/type", |
| 1254 | "instanceLocation": "/1", |
| 1255 | "errors": {"error": "child error"} |
| 1256 | }, |
| 1257 | { |
| 1258 | "valid": true, |
| 1259 | "evaluationPath": "", |
| 1260 | "schemaLocation": "/prefix", |
| 1261 | "instanceLocation": "", |
| 1262 | "annotations": 0 |
| 1263 | } |
| 1264 | ] |
| 1265 | }) |
| 1266 | ); |
| 1267 | } |
| 1268 | |
| 1269 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1270 | fn empty_evaluation_treerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/empty_evaluation_tree().() { |
| 1271 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().(locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 1272 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1273 | |
| 1274 | // No annotations |
| 1275 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 0); |
| 1276 | // No errors |
| 1277 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(evaluation.iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().(), 0); |
| 1278 | |
| 1279 | let flag = evaluation.flagrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]flag().(); |
| 1280 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(flag.validrust-analyzer cargo jsonschema 0.37.4 evaluation/FlagOutput#valid.); |
| 1281 | } |
| 1282 | |
| 1283 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1284 | fn deep_nestingrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/deep_nesting().() { |
| 1285 | // Create a deeply nested tree: root -> level1 -> level2 -> level3 |
| 1286 | let level3 = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/level3", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"level": 3})); |
| 1287 | let level2 = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1288 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1289 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1290 | "/level2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1291 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1292 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"level": 2}))), |
| 1293 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![level3], |
| 1294 | ); |
| 1295 | let level1 = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1296 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1297 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1298 | "/level1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1299 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1300 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"level": 1}))), |
| 1301 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![level2], |
| 1302 | ); |
| 1303 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1304 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1305 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1306 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1307 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1308 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"level": 0}))), |
| 1309 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![level1], |
| 1310 | ); |
| 1311 | |
| 1312 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1313 | let annotations: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1314 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4); |
| 1315 | |
| 1316 | // Check depth-first order |
| 1317 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/root"); |
| 1318 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/level1"); |
| 1319 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/level2"); |
| 1320 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().3]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/level3"); |
| 1321 | } |
| 1322 | |
| 1323 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1324 | fn wide_treerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/wide_tree().() { |
| 1325 | // Create a wide tree with many siblings |
| 1326 | let children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = (0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#10) |
| 1327 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|i| leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("/child{i}"), jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"index": i}))) |
| 1328 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1329 | |
| 1330 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1331 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1332 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1333 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1334 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1335 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"root": true}))), |
| 1336 | children, |
| 1337 | ); |
| 1338 | |
| 1339 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1340 | let annotations: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1341 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 11); // root + 10 children |
| 1342 | } |
| 1343 | |
| 1344 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1345 | fn multiple_errors_per_noderust-analyzer cargo jsonschema 0.37.4 evaluation/tests/multiple_errors_per_node().() { |
| 1346 | let errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1347 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("error 1"), |
| 1348 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("error 2"), |
| 1349 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("error 3"), |
| 1350 | ]; |
| 1351 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1352 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1353 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1354 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1355 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1356 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1357 | errors, |
| 1358 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1359 | ); |
| 1360 | |
| 1361 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1362 | let error_entries: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1363 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error_entries.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 3); |
| 1364 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "error 1"); |
| 1365 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "error 2"); |
| 1366 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(error_entries[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().2]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..errorrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#error..to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "error 3"); |
| 1367 | } |
| 1368 | |
| 1369 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1370 | fn mixed_valid_and_invalid_nodesrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/mixed_valid_and_invalid_nodes().() { |
| 1371 | let valid_child = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/valid", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"ok": true})); |
| 1372 | let invalid_child = leaf_with_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_error().("/invalid", "failed"); |
| 1373 | |
| 1374 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1375 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1376 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1377 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1378 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1379 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"attempted": true}))), |
| 1380 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("root failed")], |
| 1381 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![valid_child, invalid_child], |
| 1382 | ); |
| 1383 | |
| 1384 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1385 | |
| 1386 | // Should have 1 annotation (from valid child only; root has dropped annotations) |
| 1387 | let annotations: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1388 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1389 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/valid"); |
| 1390 | |
| 1391 | // Should have 2 errors (root + invalid child) |
| 1392 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1393 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 1394 | } |
| 1395 | |
| 1396 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1397 | fn annotations_iterator_skips_nodes_without_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotations_iterator_skips_nodes_without_annotations().() { |
| 1398 | let no_annotation = |
| 1399 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().(locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, "/no_ann".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()); |
| 1400 | let with_annotation = leaf_with_annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_annotation().("/with_ann", jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"present": true})); |
| 1401 | |
| 1402 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1403 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1404 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1405 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1406 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1407 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1408 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![no_annotation, with_annotation], |
| 1409 | ); |
| 1410 | |
| 1411 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1412 | let annotations: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1413 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1414 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#schema_location., "/with_ann"); |
| 1415 | } |
| 1416 | |
| 1417 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1418 | fn errors_iterator_skips_nodes_without_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/errors_iterator_skips_nodes_without_errors().() { |
| 1419 | let no_error = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1420 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1421 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1422 | "/no_error".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1423 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1424 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"ok": true}))), |
| 1425 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1426 | ); |
| 1427 | let with_error = leaf_with_errorrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/leaf_with_error().("/with_error", "failed"); |
| 1428 | |
| 1429 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1430 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1431 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1432 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1433 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1434 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1435 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![no_error, with_error], |
| 1436 | ); |
| 1437 | |
| 1438 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1439 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_errorsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_errors().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1440 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 1441 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntry#schema_location., "/with_error"); |
| 1442 | } |
| 1443 | |
| 1444 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1445 | fn error_entries_serialization_emptyrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/error_entries_serialization_empty().() { |
| 1446 | let entries = ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#(&[]); |
| 1447 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(&entries).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1448 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().()); |
| 1449 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().(), 0); |
| 1450 | } |
| 1451 | |
| 1452 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1453 | fn error_entries_serialization_singlerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/error_entries_serialization_single().() { |
| 1454 | let errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("test error")]; |
| 1455 | let entries = ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#(&errors); |
| 1456 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(&entries).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1457 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().()); |
| 1458 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().(), 1); |
| 1459 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("error").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1460 | } |
| 1461 | |
| 1462 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1463 | fn error_entries_serialization_multiplerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/error_entries_serialization_multiple().() { |
| 1464 | let errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1465 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("alpha", "error 1".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1466 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("beta", "error 2".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1467 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("gamma", "error 3".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1468 | ]; |
| 1469 | let entries = ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#(&errors); |
| 1470 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(&entries).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1471 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(serialized.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().(), 3); |
| 1472 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("alpha").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1473 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("beta").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1474 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(serialized.getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("gamma").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1475 | } |
| 1476 | |
| 1477 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1478 | fn error_entries_serialization_preserves_duplicatesrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/error_entries_serialization_preserves_duplicates().() { |
| 1479 | let errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1480 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("required", "\"foo\" is required".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1481 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("required", "\"bar\" is required".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1482 | ]; |
| 1483 | let entries = ErrorEntriesSerializerrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorEntriesSerializer#(&errors); |
| 1484 | let serialized = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(&entries).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1485 | let value = serialized |
| 1486 | .getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("required") |
| 1487 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("required keyword present") |
| 1488 | .as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().() |
| 1489 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("multiple errors serialized as array"); |
| 1490 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 1491 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "\"foo\" is required"); |
| 1492 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(value[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "\"bar\" is required"); |
| 1493 | } |
| 1494 | |
| 1495 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1496 | fn list_output_preserves_multiple_errors_per_keywordrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/list_output_preserves_multiple_errors_per_keyword().() { |
| 1497 | let errors = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 1498 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("required", "\"foo\" is required".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1499 | ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]new().("required", "\"bar\" is required".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 1500 | ]; |
| 1501 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1502 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1503 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1504 | "/required".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1505 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1506 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1507 | errors, |
| 1508 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1509 | ); |
| 1510 | |
| 1511 | let evaluation = Evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/Evaluation#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]new().(root); |
| 1512 | let list = serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::to_valuerust-analyzer cargo serde_json 1.0.145 value/to_value().(evaluation.listrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]list().()).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("serialization succeeds"); |
| 1513 | let root_unit = list |
| 1514 | .getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("details") |
| 1515 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|value| value.as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().()) |
| 1516 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|details| details.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().()) |
| 1517 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("list output contains root unit"); |
| 1518 | let errors = root_unit |
| 1519 | .getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("errors") |
| 1520 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|errors| errors.getrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]get().("required")) |
| 1521 | .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|value| value.as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().()) |
| 1522 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("errors serialized as array"); |
| 1523 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 2); |
| 1524 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "\"foo\" is required"); |
| 1525 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(errors[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., "\"bar\" is required"); |
| 1526 | } |
| 1527 | |
| 1528 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1529 | fn format_schema_location_without_absoluterust-analyzer cargo jsonschema 0.37.4 evaluation/tests/format_schema_location_without_absolute().() { |
| 1530 | let location = Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("properties").joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("name"); |
| 1531 | let formatted = format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&location, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); |
| 1532 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatted.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().(), "/properties/name"); |
| 1533 | } |
| 1534 | |
| 1535 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1536 | fn format_schema_location_with_absolute_no_fragmentrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/format_schema_location_with_absolute_no_fragment().() { |
| 1537 | let location = Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("properties"); |
| 1538 | let uri = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().( |
| 1539 | Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://example.com/schema.json") |
| 1540 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 1541 | .to_ownedrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<&str>`]to_owned().(), |
| 1542 | ); |
| 1543 | let formatted = format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&location, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&uri)); |
| 1544 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1545 | formatted.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().(), |
| 1546 | "http://example.com/schema.json#/properties" |
| 1547 | ); |
| 1548 | } |
| 1549 | |
| 1550 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1551 | fn format_schema_location_with_absolute_empty_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/format_schema_location_with_absolute_empty_location().() { |
| 1552 | let location = Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(); |
| 1553 | let uri = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().( |
| 1554 | Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://example.com/schema.json") |
| 1555 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 1556 | .to_ownedrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<&str>`]to_owned().(), |
| 1557 | ); |
| 1558 | let formatted = format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&location, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&uri)); |
| 1559 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(formatted.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().(), "http://example.com/schema.json#"); |
| 1560 | } |
| 1561 | |
| 1562 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1563 | fn format_schema_location_with_absolute_existing_fragmentrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/format_schema_location_with_absolute_existing_fragment().() { |
| 1564 | let location = Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().("properties"); |
| 1565 | let uri = Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().( |
| 1566 | Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#::parserust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]parse().("http://example.com/schema.json#/defs/myDef") |
| 1567 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 1568 | .to_ownedrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<&str>`]to_owned().(), |
| 1569 | ); |
| 1570 | let formatted = format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&location, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&uri)); |
| 1571 | // When URI already contains a fragment, use it as-is |
| 1572 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1573 | formatted.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().(), |
| 1574 | "http://example.com/schema.json#/defs/myDef" |
| 1575 | ); |
| 1576 | } |
| 1577 | |
| 1578 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1579 | fn dropped_annotations_on_invalid_noderust-analyzer cargo jsonschema 0.37.4 evaluation/tests/dropped_annotations_on_invalid_node().() { |
| 1580 | let annotations = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"dropped": true}))); |
| 1581 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 1582 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1583 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1584 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1585 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1586 | annotations.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 1587 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().("failed")], |
| 1588 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1589 | ); |
| 1590 | |
| 1591 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().root.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.); |
| 1592 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(root.annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 1593 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(root.dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1594 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1595 | root.dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1596 | annotations.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 1597 | ); |
| 1598 | } |
| 1599 | |
| 1600 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1601 | fn valid_node_has_no_dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/valid_node_has_no_dropped_annotations().() { |
| 1602 | let annotations = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(annotationrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotation().(jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"kept": true}))); |
| 1603 | let root = EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 1604 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1605 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 1606 | "/root".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), |
| 1607 | locrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/loc().(), |
| 1608 | annotations.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 1609 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().(), |
| 1610 | ); |
| 1611 | |
| 1612 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(root.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid.); |
| 1613 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(root.annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 1614 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(root.dropped_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#dropped_annotations..is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 1615 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 1616 | root.annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#annotations..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 1617 | annotations.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 1618 | ); |
| 1619 | } |
| 1620 | |
| 1621 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1622 | fn absolute_keyword_location_populated_with_idrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/absolute_keyword_location_populated_with_id().() { |
| 1623 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!; |
| 1624 | |
| 1625 | // Schema with $id should populate absoluteKeywordLocation |
| 1626 | let schema = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({ |
| 1627 | "$id": "https://example.com/schema", |
| 1628 | "type": "object", |
| 1629 | "properties": { |
| 1630 | "name": {"type": "string"} |
| 1631 | } |
| 1632 | }); |
| 1633 | |
| 1634 | let validator = craterust-analyzer cargo jsonschema 0.37.4 crate/::validator_forrust-analyzer cargo jsonschema 0.37.4 validator_for().(&schema).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("schema compiles"); |
| 1635 | let evaluation = validator.evaluaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[Validator]evaluate().(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"name": "test"})); |
| 1636 | |
| 1637 | // Verify that absoluteKeywordLocation is populated for nodes |
| 1638 | let annotations: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = evaluation.iter_annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Evaluation]iter_annotations().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 1639 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().annotations.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 1640 | |
| 1641 | // At least one annotation should have an absolute keyword location |
| 1642 | let with_absolute = annotations |
| 1643 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 1644 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|a| a.absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#absolute_keyword_location..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()) |
| 1645 | .countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().(); |
| 1646 | |
| 1647 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(with_absolute >rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). 0); |
| 1648 | |
| 1649 | // Verify the absolute locations start with the schema's $id |
| 1650 | for annotation in annotations |
| 1651 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 1652 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|a| a.absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#absolute_keyword_location..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()) |
| 1653 | { |
| 1654 | let uri_str = annotation.absolute_keyword_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/AnnotationEntry#absolute_keyword_location..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().(); |
| 1655 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(uri_str.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("https://example.com/schema")); |
| 1656 | } |
| 1657 | } |
| 1658 | |
| 1659 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1660 | fn annotations_value_returns_referencerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotations_value_returns_reference().() { |
| 1661 | let expected = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"key": "value"}); |
| 1662 | let annotations = Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(expected.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().()); |
| 1663 | |
| 1664 | // value() should return a reference to the inner value |
| 1665 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(annotations.valuerust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]value().(), &expected); |
| 1666 | } |
| 1667 | |
| 1668 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1669 | fn annotations_into_inner_consumes_and_returns_valuerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/annotations_into_inner_consumes_and_returns_value().() { |
| 1670 | let expected = jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"key": "value", "nested": {"array": [1, 2, 3]}}); |
| 1671 | let annotations = Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(expected.clonerust-analyzer cargo serde_json 1.0.145 value/impl#[Value][Clone]clone().()); |
| 1672 | |
| 1673 | // into_inner() should consume self and return the owned value |
| 1674 | let inner = annotations.into_innerrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]into_inner().(); |
| 1675 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(inner, expected); |
| 1676 | } |
| 1677 | |
| 1678 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 1679 | fn error_description_into_inner_consumes_and_returns_messagerust-analyzer cargo jsonschema 0.37.4 evaluation/tests/error_description_into_inner_consumes_and_returns_message().() { |
| 1680 | let expected_message = "test error message"; |
| 1681 | let error = ErrorDescriptionrust-analyzer cargo jsonschema 0.37.4 evaluation/ErrorDescription#::from_stringrust-analyzer cargo jsonschema 0.37.4 evaluation/tests/impl#[ErrorDescription]from_string().(expected_message); |
| 1682 | |
| 1683 | // into_inner() should consume self and return the owned message |
| 1684 | let message = error.into_innerrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[ErrorDescription]into_inner().(); |
| 1685 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(message, expected_message); |
| 1686 | } |
| 1687 | } |