| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 2 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 3 | errorrust-analyzer cargo jsonschema 0.37.4 error/::ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#, |
| 4 | evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/::{format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location()., Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#, EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#}, |
| 5 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::{BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#, Keywordrust-analyzer cargo jsonschema 0.37.4 keywords/Keyword#}, |
| 6 | pathsrust-analyzer cargo jsonschema 0.37.4 paths/::{LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#}, |
| 7 | threadrust-analyzer cargo jsonschema 0.37.4 thread/::{Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#, SharedWeakrust-analyzer cargo jsonschema 0.37.4 thread/SharedWeak#}, |
| 8 | validatorrust-analyzer cargo jsonschema 0.37.4 validator/::{EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#, Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#, ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#}, |
| 9 | ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, |
| 10 | }; |
| 11 | use referencingrust-analyzer cargo referencing 0.37.4 crate/::Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#; |
| 12 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#; |
| 13 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 14 | cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#, |
| 15 | fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, |
| 16 | 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#, OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#}, |
| 17 | }; |
| 18 | |
| 19 | /// A node in the schema tree, returned by `compiler::compile` |
| 20 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 21 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 22 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#<NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#>, |
| 23 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 24 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path.: 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#>>>, |
| 25 | } |
| 26 | |
| 27 | // Separate type used only during compilation for handling recursive references |
| 28 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 29 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct PendingSchemaNoderust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode# { |
| 30 | cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#<OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#<PendingTargetrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#>>, |
| 31 | } |
| 32 | |
| 33 | #[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:)] |
| 34 | struct PendingTargetrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget# { |
| 35 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#validators.: SharedWeakrust-analyzer cargo jsonschema 0.37.4 thread/SharedWeak#<NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#>, |
| 36 | locationrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 37 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#absolute_path.: 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#>>>, |
| 38 | } |
| 39 | |
| 40 | enum NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators# { |
| 41 | /// The result of compiling a boolean valued schema, e.g |
| 42 | /// |
| 43 | /// ```json |
| 44 | /// { |
| 45 | /// "additionalProperties": false |
| 46 | /// } |
| 47 | /// ``` |
| 48 | /// |
| 49 | /// Here the result of `compiler::compile` called with the `false` value will return a |
| 50 | /// `SchemaNode` with a single `BooleanValidator` as it's `validators`. |
| 51 | Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#> }, |
| 52 | /// The result of compiling a schema which is composed of keywords (almost all schemas) |
| 53 | Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#), |
| 54 | /// The result of compiling a schema which is "array valued", e.g the "dependencies" keyword of |
| 55 | /// draft 7 which can take values which are an array of other property names |
| 56 | Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { |
| 57 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ArrayValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#>, |
| 58 | }, |
| 59 | } |
| 60 | |
| 61 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators# { |
| 62 | fn fmtrust-analyzer cargo jsonschema 0.37.4 node/impl#[NodeValidators][Debug]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# { |
| 63 | match self { |
| 64 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[NodeValidators][Debug]::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { .. } => f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Boolean").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().(), |
| 65 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[NodeValidators][Debug]::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(_) => f.debug_tuplerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_tuple().("Keyword").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugTuple<'a, 'b>`]finish().(), |
| 66 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[NodeValidators][Debug]::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { .. } => f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Array").finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().(), |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | struct KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators# { |
| 72 | /// The keywords on this node which were not recognized by any vocabularies. These are |
| 73 | /// stored so we can later produce them as annotations |
| 74 | unmatched_keywordsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#unmatched_keywords.: 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#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>>, |
| 75 | // We should probably use AHashMap here but it breaks a bunch of tests which assume |
| 76 | // validators are in a particular order |
| 77 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<KeywordValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#>, |
| 78 | } |
| 79 | |
| 80 | struct KeywordValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry# { |
| 81 | validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator.: BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#, |
| 82 | locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 83 | absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#absolute_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#>>>, |
| 84 | } |
| 85 | |
| 86 | struct ArrayValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry# { |
| 87 | validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator.: BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#, |
| 88 | locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#location.: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 89 | absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#absolute_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#>>>, |
| 90 | } |
| 91 | |
| 92 | impl PendingSchemaNoderust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode# { |
| 93 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn newrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]new().() -> Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode] { |
| 94 | PendingSchemaNoderust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode# { |
| 95 | cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(OnceLockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/OnceLock#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]new().()), |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn initializerust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]initialize().(&self, node: &SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#) { |
| 100 | let target = PendingTargetrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget# { |
| 101 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#validators.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::downgraderust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]downgrade().(&node.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.), |
| 102 | locationrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#location.: node.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 103 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#absolute_path.: node.absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 104 | }; |
| 105 | self.cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell. |
| 106 | .setrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]set().(target) |
| 107 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("pending node initialized twice"); |
| 108 | } |
| 109 | |
| 110 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn getrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]get().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#> { |
| 111 | self.cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(PendingTargetrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#::materializerust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingTarget]materialize().) |
| 112 | } |
| 113 | |
| 114 | fn with_noderust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]with_node().<F, R>(&self, f: F) -> R |
| 115 | where |
| 116 | F: FnOncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnOnce#(SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#) -> R, |
| 117 | { |
| 118 | let node = self |
| 119 | .cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell. |
| 120 | .getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/once_lock/impl#[`OnceLock<T>`]get().() |
| 121 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("pending node accessed before initialization") |
| 122 | .materializerust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingTarget]materialize().(); |
| 123 | f(node) |
| 124 | } |
| 125 | |
| 126 | /// Get a unique identifier for this pending node. |
| 127 | /// Uses the address of the inner cell as a stable identifier. |
| 128 | #[inline] |
| 129 | fn node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(&self) -> usize { |
| 130 | Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::as_ptrrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]as_ptr().(&self.cellrust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode#cell.) as usize |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | impl PendingTargetrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget# { |
| 135 | fn materializerust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingTarget]materialize().(&self) -> SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 136 | let validators = self |
| 137 | .validatorsrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#validators. |
| 138 | .upgraderust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Weak<T, A>`]upgrade().() |
| 139 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("pending schema target dropped"); |
| 140 | SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 141 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators., |
| 142 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location.: self.locationrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 143 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path.: self.absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/PendingTarget#absolute_path..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for PendingSchemaNoderust-analyzer cargo jsonschema 0.37.4 node/PendingSchemaNode# { |
| 149 | fn is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 150 | if ctx.enterrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]enter().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance) { |
| 151 | // Cycle detected - this (node, instance) pair is already being validated. |
| 152 | // A pure reference cycle is equivalent to `true` schema. |
| 153 | return true; |
| 154 | } |
| 155 | let result = self.with_noderust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]with_node().(|node| node.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx)); |
| 156 | ctx.exitrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]exit().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance); |
| 157 | result |
| 158 | } |
| 159 | |
| 160 | fn validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode][Validate]validate().<'i>( |
| 161 | &self, |
| 162 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 163 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 164 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 165 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 166 | if ctx.enterrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]enter().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance) { |
| 167 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 168 | } |
| 169 | let result = self.with_noderust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]with_node().(|node| node.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx)); |
| 170 | ctx.exitrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]exit().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance); |
| 171 | result |
| 172 | } |
| 173 | |
| 174 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode][Validate]iter_errors().<'i>( |
| 175 | &self, |
| 176 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 177 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 178 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 179 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 180 | if ctx.enterrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]enter().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance) { |
| 181 | return craterust-analyzer cargo jsonschema 0.37.4 crate/::errorrust-analyzer cargo jsonschema 0.37.4 error/::no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().(); |
| 182 | } |
| 183 | let result = self.with_noderust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]with_node().(|node| node.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx)); |
| 184 | ctx.exitrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]exit().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance); |
| 185 | result |
| 186 | } |
| 187 | |
| 188 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode][Validate]evaluate().( |
| 189 | &self, |
| 190 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 191 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 192 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 193 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 194 | if ctx.enterrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]enter().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance) { |
| 195 | return EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().(); |
| 196 | } |
| 197 | let result = self.with_noderust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]with_node().(|node| node.evaluaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]evaluate().(instance, location, ctx)); |
| 198 | ctx.exitrust-analyzer cargo jsonschema 0.37.4 validator/impl#[ValidationContext]exit().(self.node_idrust-analyzer cargo jsonschema 0.37.4 node/impl#[PendingSchemaNode]node_id().(), instance); |
| 199 | result |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | impl SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 204 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_booleanrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]from_boolean().(ctx: &Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>, validator: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#>) -> SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 205 | SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 206 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location.: ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 207 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path.: ctx.base_urirust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]base_uri().(), |
| 208 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator. }), |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_keywordsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]from_keywords().( |
| 213 | ctx: &Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>, |
| 214 | validators: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Keywordrust-analyzer cargo jsonschema 0.37.4 keywords/Keyword#, BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#)>, |
| 215 | unmatched_keywords: 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#<Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>>, |
| 216 | ) -> SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 217 | let absolute_path = ctx.base_urirust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]base_uri().(); |
| 218 | let validators = validators |
| 219 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 220 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(keyword, validator)| { |
| 221 | let location = ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().(&keyword); |
| 222 | let absolute_location = ctx.absolute_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]absolute_location().(&location); |
| 223 | KeywordValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry# { |
| 224 | validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator., |
| 225 | locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#location., |
| 226 | absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#absolute_location., |
| 227 | } |
| 228 | }) |
| 229 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 230 | SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 231 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location.: ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 232 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path., |
| 233 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators# { |
| 234 | unmatched_keywordsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#unmatched_keywords., |
| 235 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators., |
| 236 | })), |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn from_arrayrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]from_array().(ctx: &Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#<'_>, validators: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#>) -> SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 241 | let absolute_path = ctx.base_urirust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]base_uri().(); |
| 242 | let validators = validators |
| 243 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().() |
| 244 | .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() |
| 245 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(index, validator)| { |
| 246 | let location = ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().joinrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]join().(index); |
| 247 | let absolute_location = ctx.absolute_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]absolute_location().(&location); |
| 248 | ArrayValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry# { |
| 249 | validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator., |
| 250 | locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#location., |
| 251 | absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#absolute_location., |
| 252 | } |
| 253 | }) |
| 254 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 255 | SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 256 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location.: ctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 257 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path., |
| 258 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.: Sharedrust-analyzer cargo jsonschema 0.37.4 thread/Shared#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. }), |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn clone_with_locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]clone_with_location().( |
| 263 | &self, |
| 264 | location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 265 | absolute_path: 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#>>>, |
| 266 | ) -> SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 267 | SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 268 | validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators.: self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), |
| 269 | locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location., |
| 270 | absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path., |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn validatorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]validators().(&self) -> impl ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#> { |
| 275 | match self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().() { |
| 276 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator. } => { |
| 277 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) = validator { |
| 278 | NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#::BooleanValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#BooleanValidators#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(v)) |
| 279 | } else { |
| 280 | NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#::NoValidatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#NoValidator# |
| 281 | } |
| 282 | } |
| 283 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvals) => { |
| 284 | NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#::KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#KeywordValidators#(kvals.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 285 | } |
| 286 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. } => { |
| 287 | NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#::ArrayValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#ArrayValidators#(validators.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().( |
| 293 | &self, |
| 294 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 295 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 296 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 297 | ) -> EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode# { |
| 298 | let instance_location: Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location# = location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(); |
| 299 | let schema_location = format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&self.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location., self.absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()); |
| 300 | match self.evaluaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]evaluate().(instance, location, ctx) { |
| 301 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# { |
| 302 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations., |
| 303 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children., |
| 304 | } => EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 305 | self.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 306 | self.absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 307 | schema_location, |
| 308 | instance_location, |
| 309 | annotations, |
| 310 | children, |
| 311 | ), |
| 312 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Invalidrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid# { |
| 313 | errorsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#errors., |
| 314 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#children., |
| 315 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#annotations., |
| 316 | } => EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 317 | self.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 318 | self.absolute_pathrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#absolute_path..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().(), |
| 319 | schema_location, |
| 320 | instance_location, |
| 321 | annotations, |
| 322 | errors, |
| 323 | children, |
| 324 | ), |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | /// Helper function to evaluate subschemas which already know their locations. |
| 329 | fn evaluate_subschemasrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_subschemas().<'a, I>( |
| 330 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 331 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 332 | subschemas: I, |
| 333 | annotations: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#>, |
| 334 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 335 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# |
| 336 | where |
| 337 | I: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#< |
| 338 | Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = ( |
| 339 | &'a Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#, |
| 340 | Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'a 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#>>>, |
| 341 | &'a BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#, |
| 342 | ), |
| 343 | > + 'a, |
| 344 | { |
| 345 | let (lower_bound, _) = subschemas.size_hintrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#size_hint().(); |
| 346 | let mut children: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#> = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(lower_bound); |
| 347 | let mut invalid = false; |
| 348 | let instance_location: OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#<Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#> = OnceCellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/OnceCell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]new().(); |
| 349 | |
| 350 | for (child_location, absolute_location, validator) in subschemas { |
| 351 | let child_result = validator.evaluaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#evaluate().(instance, location, ctx); |
| 352 | |
| 353 | let schema_location = child_location.clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(); |
| 354 | let absolute_location = absolute_location.clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().(); |
| 355 | let instance_loc = instance_location.get_or_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/once/impl#[`OnceCell<T>`]get_or_init().(|| location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(); |
| 356 | let formatted_schema_location = |
| 357 | format_schema_locationrust-analyzer cargo jsonschema 0.37.4 evaluation/format_schema_location().(&schema_location, absolute_location.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()); |
| 358 | |
| 359 | let child_node = match child_result { |
| 360 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# { |
| 361 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations., |
| 362 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children., |
| 363 | } => EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::validrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]valid().( |
| 364 | schema_location, |
| 365 | absolute_location, |
| 366 | formatted_schema_location, |
| 367 | instance_loc, |
| 368 | annotations, |
| 369 | children, |
| 370 | ), |
| 371 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Invalidrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid# { |
| 372 | errorsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#errors., |
| 373 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#children., |
| 374 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#annotations., |
| 375 | } => { |
| 376 | invalid = true; |
| 377 | EvaluationNoderust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#::invalidrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[EvaluationNode]invalid().( |
| 378 | schema_location, |
| 379 | absolute_location, |
| 380 | formatted_schema_location, |
| 381 | instance_loc, |
| 382 | annotations, |
| 383 | errors, |
| 384 | children, |
| 385 | ) |
| 386 | } |
| 387 | }; |
| 388 | children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(child_node); |
| 389 | } |
| 390 | if invalid { |
| 391 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Invalidrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid# { |
| 392 | errorsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#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().(), |
| 393 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#children., |
| 394 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Invalid#annotations., |
| 395 | } |
| 396 | } else { |
| 397 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# { |
| 398 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations., |
| 399 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children., |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn locationrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]location().(&self) -> &Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location# { |
| 405 | &self.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location. |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode# { |
| 410 | fn is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(&self, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#) -> bool { |
| 411 | match self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().() { |
| 412 | // If we only have one validator then calling it's `is_valid` directly does |
| 413 | // actually save the 20 or so instructions required to call the `slice::Iter::all` |
| 414 | // implementation. Validators at the leaf of a tree are all single node validators so |
| 415 | // this optimization can have significant cumulative benefits |
| 416 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvs) if kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators..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 => { |
| 417 | kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators.[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()..validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator..is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(instance, ctx) |
| 418 | } |
| 419 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvs) => { |
| 420 | for entry in &kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators. { |
| 421 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator..is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(instance, ctx) { |
| 422 | return false; |
| 423 | } |
| 424 | } |
| 425 | true |
| 426 | } |
| 427 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. } => validators |
| 428 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 429 | .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|entry| entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator..is_validrust-analyzer cargo jsonschema 0.37.4 validator/Validate#is_valid().(instance, ctx)), |
| 430 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) } => false, |
| 431 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# } => true, |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | fn validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().<'i>( |
| 436 | &self, |
| 437 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 438 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 439 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 440 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 441 | match self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().() { |
| 442 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvs) => { |
| 443 | for entry in &kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators. { |
| 444 | entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator..validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#validate().(instance, location, ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 445 | } |
| 446 | } |
| 447 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. } => { |
| 448 | for entry in validators { |
| 449 | entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator..validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#validate().(instance, location, ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 450 | } |
| 451 | } |
| 452 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) } => { |
| 453 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::false_schemarust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]false_schema().( |
| 454 | self.locationrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#location..clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(), |
| 455 | location.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 456 | instance, |
| 457 | )); |
| 458 | } |
| 459 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# } => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 460 | } |
| 461 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 462 | } |
| 463 | |
| 464 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().<'i>( |
| 465 | &self, |
| 466 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 467 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 468 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 469 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 470 | match self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().() { |
| 471 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvs) if kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators..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 => kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators.[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(). |
| 472 | .validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator. |
| 473 | .iter_errorsrust-analyzer cargo jsonschema 0.37.4 validator/Validate#iter_errors().(instance, location, ctx), |
| 474 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(kvs) => ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().( |
| 475 | kvs.validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators. |
| 476 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 477 | .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|entry| entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator..iter_errorsrust-analyzer cargo jsonschema 0.37.4 validator/Validate#iter_errors().(instance, location, ctx)) |
| 478 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 479 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 480 | ), |
| 481 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { |
| 482 | validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v), .. |
| 483 | } => v.iter_errorsrust-analyzer cargo jsonschema 0.37.4 validator/Validate#iter_errors().(instance, location, ctx), |
| 484 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { |
| 485 | validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, .. |
| 486 | } => ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/empty/empty().()), |
| 487 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. } => ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().( |
| 488 | validators |
| 489 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 490 | .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(move |entry| entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator..iter_errorsrust-analyzer cargo jsonschema 0.37.4 validator/Validate#iter_errors().(instance, location, ctx)) |
| 491 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>() |
| 492 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 493 | ), |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]evaluate().( |
| 498 | &self, |
| 499 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 500 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 501 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 502 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 503 | match self.validatorsrust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#validators..as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`AsRef<T>`]as_ref().() { |
| 504 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Arrayrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array# { ref validatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Array#validators. } => Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]::evaluate_subschemasrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_subschemas().( |
| 505 | instance, |
| 506 | location, |
| 507 | validators.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|entry| { |
| 508 | ( |
| 509 | &entry.locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#location., |
| 510 | entry.absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#absolute_location..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 511 | &entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator., |
| 512 | ) |
| 513 | }), |
| 514 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 515 | ctx, |
| 516 | ), |
| 517 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Booleanrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean# { ref validatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Boolean#validator. } => { |
| 518 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(validator) = validator { |
| 519 | validator.evaluaterust-analyzer cargo jsonschema 0.37.4 validator/Validate#evaluate().(instance, location, ctx) |
| 520 | } else { |
| 521 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::Validrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid# { |
| 522 | annotationsrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#annotations.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 523 | childrenrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#Valid#children.: 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().(), |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | NodeValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#::Keywordrust-analyzer cargo jsonschema 0.37.4 node/NodeValidators#Keyword#(ref kvals) => { |
| 528 | let KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators# { |
| 529 | ref unmatched_keywordsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#unmatched_keywords., |
| 530 | ref validatorsrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidators#validators., |
| 531 | } = *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().kvals; |
| 532 | let annotations: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#> = unmatched_keywords |
| 533 | .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 534 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::from_arcrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]from_arc().(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(v))); |
| 535 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]::evaluate_subschemasrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_subschemas().( |
| 536 | instance, |
| 537 | location, |
| 538 | validators.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|entry| { |
| 539 | ( |
| 540 | &entry.locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#location., |
| 541 | entry.absolute_locationrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#absolute_location..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().(), |
| 542 | &entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator., |
| 543 | ) |
| 544 | }), |
| 545 | annotations, |
| 546 | ctx, |
| 547 | ) |
| 548 | } |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | enum NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#<'a> { |
| 554 | NoValidatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#NoValidator#, |
| 555 | BooleanValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#BooleanValidators#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::Oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/Once#<&'a BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#>), |
| 556 | KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#KeywordValidators#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, KeywordValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#>), |
| 557 | ArrayValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#ArrayValidators#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::Iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/Iter#<'a, ArrayValidatorEntryrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#>), |
| 558 | } |
| 559 | |
| 560 | impl<'a> Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#<'a> { |
| 561 | type Itemrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]Item# = &'a BoxedValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/BoxedValidator#; |
| 562 | |
| 563 | fn nextrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'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 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> { |
| 564 | match self { |
| 565 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::NoValidatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#NoValidator# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 566 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::BooleanValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#BooleanValidators#(i) => i.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/impl#[`Once<T>`][Iterator]next().(), |
| 567 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#KeywordValidators#(v) => v.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|entry| &entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator.), |
| 568 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::ArrayValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#ArrayValidators#(v) => v.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|entry| &entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator.), |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | fn allrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]all().<F>(&mut self, mut f: F) -> bool |
| 573 | where |
| 574 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]: Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#, |
| 575 | F: FnMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/function/FnMut#(Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#) -> bool, |
| 576 | { |
| 577 | match self { |
| 578 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::NoValidatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#NoValidator# => true, |
| 579 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::BooleanValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#BooleanValidators#(i) => i.allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(f), |
| 580 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#KeywordValidators#(v) => v.allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|entry| f(&entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/KeywordValidatorEntry#validator.)), |
| 581 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'a>`][Iterator]::ArrayValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#ArrayValidators#(v) => v.allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|entry| f(&entry.validatorrust-analyzer cargo jsonschema 0.37.4 node/ArrayValidatorEntry#validator.)), |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | impl ExactSizeIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/exact_size/ExactSizeIterator# for NodeValidatorsIterrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#<'_> { |
| 587 | fn lenrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'_>`][ExactSizeIterator]len().(&self) -> usize { |
| 588 | match self { |
| 589 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'_>`][ExactSizeIterator]::NoValidatorrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#NoValidator# => 0, |
| 590 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'_>`][ExactSizeIterator]::BooleanValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#BooleanValidators#(..) => 1, |
| 591 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'_>`][ExactSizeIterator]::KeywordValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#KeywordValidators#(v) => v.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'_, T>`][ExactSizeIterator]len().(), |
| 592 | Selfrust-analyzer cargo jsonschema 0.37.4 node/impl#[`NodeValidatorsIter<'_>`][ExactSizeIterator]::ArrayValidatorsrust-analyzer cargo jsonschema 0.37.4 node/NodeValidatorsIter#ArrayValidators#(v) => v.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'_, T>`][ExactSizeIterator]len().(), |
| 593 | } |
| 594 | } |
| 595 | } |