| 1 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::{ |
| 2 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/, |
| 3 | errorrust-analyzer cargo jsonschema 0.37.4 error/::{no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error()., ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#}, |
| 4 | keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#, |
| 5 | noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 6 | pathsrust-analyzer cargo jsonschema 0.37.4 paths/::LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 7 | 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#}, |
| 8 | ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#, |
| 9 | }; |
| 10 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{Maprust-analyzer cargo serde_json 1.0.145 map/Map#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 11 | |
| 12 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct IfThenValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator# { |
| 13 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 14 | then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 15 | } |
| 16 | |
| 17 | impl IfThenValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator# { |
| 18 | #[inline] |
| 19 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator]compile().<'a>( |
| 20 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 21 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 22 | then_schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 23 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 24 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(IfThenValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator# { |
| 25 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema.: { |
| 26 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("if"); |
| 27 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 28 | }, |
| 29 | then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema.: { |
| 30 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("then"); |
| 31 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(then_schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 32 | }, |
| 33 | })) |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for IfThenValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator# { |
| 38 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator][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 { |
| 39 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 40 | self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) |
| 41 | } else { |
| 42 | true |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator][Validate]validate().<'i>( |
| 47 | &self, |
| 48 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 49 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 50 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 51 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 52 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 53 | self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx) |
| 54 | } else { |
| 55 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | #[allow(clippy::needless_collect)] |
| 60 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator][Validate]iter_errors().<'i>( |
| 61 | &self, |
| 62 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 63 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 64 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 65 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 66 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 67 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self |
| 68 | .then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema. |
| 69 | .iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx) |
| 70 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 71 | ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(errors.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 72 | } else { |
| 73 | no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().() |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator][Validate]evaluate().( |
| 78 | &self, |
| 79 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 80 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 81 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 82 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 83 | let if_node = self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 84 | if if_node.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid. { |
| 85 | let then_node = self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#then_schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 86 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![if_node, then_node]) |
| 87 | } else { |
| 88 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().() |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct IfElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator# { |
| 94 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 95 | else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 96 | } |
| 97 | |
| 98 | impl IfElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator# { |
| 99 | #[inline] |
| 100 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator]compile().<'a>( |
| 101 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 102 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 103 | else_schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 104 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 105 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(IfElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator# { |
| 106 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema.: { |
| 107 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("if"); |
| 108 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 109 | }, |
| 110 | else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema.: { |
| 111 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("else"); |
| 112 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(else_schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 113 | }, |
| 114 | })) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for IfElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator# { |
| 119 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator][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 { |
| 120 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 121 | true |
| 122 | } else { |
| 123 | self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator][Validate]validate().<'i>( |
| 128 | &self, |
| 129 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 130 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 131 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 132 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 133 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 134 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 135 | } else { |
| 136 | self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx) |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | #[allow(clippy::needless_collect)] |
| 141 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator][Validate]iter_errors().<'i>( |
| 142 | &self, |
| 143 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 144 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 145 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 146 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 147 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 148 | no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().() |
| 149 | } else { |
| 150 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self |
| 151 | .else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema. |
| 152 | .iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx) |
| 153 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 154 | ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(errors.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator][Validate]evaluate().( |
| 159 | &self, |
| 160 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 161 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 162 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 163 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 164 | let if_node = self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 165 | if if_node.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid. { |
| 166 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![if_node]) |
| 167 | } else { |
| 168 | let else_node = self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#else_schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 169 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![else_node]) |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct IfThenElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator# { |
| 175 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 176 | then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 177 | else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#, |
| 178 | } |
| 179 | |
| 180 | impl IfThenElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator# { |
| 181 | #[inline] |
| 182 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator]compile().<'a>( |
| 183 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 184 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 185 | then_schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 186 | else_schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 187 | ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> { |
| 188 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(IfThenElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator# { |
| 189 | schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema.: { |
| 190 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("if"); |
| 191 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 192 | }, |
| 193 | then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema.: { |
| 194 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("then"); |
| 195 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(then_schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 196 | }, |
| 197 | else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema.: { |
| 198 | let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("else"); |
| 199 | compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ctx, ctx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(else_schema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). |
| 200 | }, |
| 201 | })) |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for IfThenElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator# { |
| 206 | fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator][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 { |
| 207 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 208 | self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) |
| 209 | } else { |
| 210 | self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator][Validate]validate().<'i>( |
| 215 | &self, |
| 216 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 217 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 218 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 219 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> { |
| 220 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 221 | self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx) |
| 222 | } else { |
| 223 | self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | #[allow(clippy::needless_collect)] |
| 228 | fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator][Validate]iter_errors().<'i>( |
| 229 | &self, |
| 230 | instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 231 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 232 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 233 | ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> { |
| 234 | if self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) { |
| 235 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self |
| 236 | .then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema. |
| 237 | .iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx) |
| 238 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 239 | ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(errors.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 240 | } else { |
| 241 | let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self |
| 242 | .else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema. |
| 243 | .iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx) |
| 244 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(); |
| 245 | ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#::from_iteratorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ErrorIterator<'a>`]from_iterator().(errors.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()) |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator][Validate]evaluate().( |
| 250 | &self, |
| 251 | instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 252 | location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#, |
| 253 | ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#, |
| 254 | ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# { |
| 255 | let if_node = self.schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 256 | if if_node.validrust-analyzer cargo jsonschema 0.37.4 evaluation/EvaluationNode#valid. { |
| 257 | let then_node = self.then_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#then_schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 258 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![if_node, then_node]) |
| 259 | } else { |
| 260 | let else_node = self.else_schemarust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#else_schema..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx); |
| 261 | EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![else_node]) |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | #[inline] |
| 267 | pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/compile().<'a>( |
| 268 | ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, |
| 269 | parent: &'a Maprust-analyzer cargo serde_json 1.0.145 map/Map#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#>, |
| 270 | schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, |
| 271 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> { |
| 272 | let then = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("then"); |
| 273 | let else_ = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("else"); |
| 274 | match (then, else_) { |
| 275 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(then_schema), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(else_schema)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IfThenElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenElseValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenElseValidator]compile().( |
| 276 | ctx, |
| 277 | schema, |
| 278 | then_schema, |
| 279 | else_schema, |
| 280 | )), |
| 281 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(else_schema)) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IfElseValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfElseValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfElseValidator]compile().(ctx, schema, else_schema)), |
| 282 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(then_schema), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(IfThenValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/if_/IfThenValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/if_/impl#[IfThenValidator]compile().(ctx, schema, then_schema)), |
| 283 | (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | #[cfg(test)] |
| 288 | mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/if_/tests/ { |
| 289 | use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/; |
| 290 | use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::{jsonrust-analyzer cargo serde_json 1.0.145 macros/json!, Valuerust-analyzer cargo serde_json 1.0.145 value/Value#}; |
| 291 | use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:; |
| 292 | |
| 293 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"if": {"minimum": 0}, "else": {"multipleOf": 2}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1), "/else/multipleOf")] |
| 294 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"if": {"minimum": 0}, "then": {"multipleOf": 2}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3), "/then/multipleOf")] |
| 295 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"if": {"minimum": 0}, "then": {"multipleOf": 2}, "else": {"multipleOf": 2}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1), "/else/multipleOf")] |
| 296 | #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"if": {"minimum": 0}, "then": {"multipleOf": 2}, "else": {"multipleOf": 2}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(3), "/then/multipleOf")] |
| 297 | fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/if_/tests/location().(schema: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, expected: &str) { |
| 298 | tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/::assert_schema_locationrust-analyzer cargo jsonschema 0.37.4 tests_util/assert_schema_location().(schema, instance, expected); |
| 299 | } |
| 300 | } |