Debian Codegraph @

src/keywords/dependencies.rs

raw symbols SCIP
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#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#},
4 keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::{requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/, unique_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unique_items/, 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#, Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#},
7 typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#,
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 };
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 DependenciesValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator# {
13 dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#)>,
14 }
15
16 impl DependenciesValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator# {
17 #[inline]
18 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
19 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(map) = schema {
20 let kctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("dependencies");
21 let mut dependencies = 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().(map.lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().());
22 for (key, subschema) in map {
23 let ctx = kctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
24 let s =
25 match subschema {
26 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(_) => {
27 let validators = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/::compile_with_pathrust-analyzer cargo jsonschema 0.37.4 keywords/required/compile_with_path().(
28 subschema,
29 kctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
30 )
31 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("The required validator compilation does not return None")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().];
32 SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#::from_arrayrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]from_array().(&kctx, validators)
33 }
34 _ => 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().(subschema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
35 };
36 dependencies.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), s));
37 }
38 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().(DependenciesValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator# { dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies. }))
39 } else {
40 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().(
41 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
42 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().(),
43 schema,
44 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Objectrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Object#,
45 ))
46 }
47 }
48 }
49
50 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for DependenciesValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator# {
51 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator][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 {
52 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
53 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies. {
54 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().node.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
55 return false;
56 }
57 }
58 true
59 } else {
60 true
61 }
62 }
63
64 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator][Validate]validate().<'i>(
65 &self,
66 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
67 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
68 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
69 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
70 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
71 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies. {
72 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
73 dependency.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
74 }
75 }
76 }
77 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
78 }
79
80 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator][Validate]iter_errors().<'i>(
81 &self,
82 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
83 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
84 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
85 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
86 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
87 let mut 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().();
88 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies. {
89 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
90 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(node.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx));
91 }
92 }
93 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().())
94 } else {
95 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
96 }
97 }
98
99 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator][Validate]evaluate().(
100 &self,
101 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
102 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
103 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
104 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
105 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
106 let mut 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().();
107 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#dependencies. {
108 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
109 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(dependency.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx));
110 }
111 }
112 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
113 } else {
114 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
115 }
116 }
117 }
118
119 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct DependentRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator# {
120 dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#)>,
121 }
122
123 impl DependentRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator# {
124 #[inline]
125 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
126 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(map) = schema {
127 let kctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("dependentRequired");
128 let mut dependencies = 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().(map.lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().());
129 for (key, subschema) in map {
130 let ictx = kctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
131 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(dependency_array) = subschema {
132 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().unique_itemsrust-analyzer cargo jsonschema 0.37.4 keywords/unique_items/::is_uniquerust-analyzer cargo jsonschema 0.37.4 keywords/unique_items/is_unique().(dependency_array) {
133 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#::unique_itemsrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]unique_items().(
134 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
135 ictx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
136 subschema,
137 ));
138 }
139 let validators =
140 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
141 requiredrust-analyzer cargo jsonschema 0.37.4 keywords/required/::compile_with_pathrust-analyzer cargo jsonschema 0.37.4 keywords/required/compile_with_path().(subschema, kctx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().())
142 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().(
143 "The required validator compilation does not return None",
144 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
145 ];
146 dependencies.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#::from_arrayrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]from_array().(&kctx, validators)));
147 } else {
148 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#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().(
149 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
150 ictx.locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]location().().clonerust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location][Clone]clone().(),
151 subschema,
152 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Arrayrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Array#,
153 ));
154 }
155 }
156 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().(DependentRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator# { dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies. }))
157 } else {
158 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().(
159 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
160 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().(),
161 schema,
162 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Objectrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Object#,
163 ))
164 }
165 }
166 }
167 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for DependentRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator# {
168 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator][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 {
169 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
170 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies. {
171 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().node.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
172 return false;
173 }
174 }
175 true
176 } else {
177 true
178 }
179 }
180
181 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator][Validate]validate().<'i>(
182 &self,
183 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
184 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
185 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
186 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
187 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
188 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies. {
189 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
190 dependency.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
191 }
192 }
193 }
194 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
195 }
196
197 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator][Validate]iter_errors().<'i>(
198 &self,
199 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
200 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
201 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
202 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
203 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
204 let mut 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().();
205 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies. {
206 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
207 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(node.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx));
208 }
209 }
210 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().())
211 } else {
212 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
213 }
214 }
215
216 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator][Validate]evaluate().(
217 &self,
218 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
219 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
220 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
221 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
222 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
223 let mut 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().();
224 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#dependencies. {
225 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
226 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(dependency.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx));
227 }
228 }
229 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
230 } else {
231 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
232 }
233 }
234 }
235
236 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct DependentSchemasValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator# {
237 dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#)>,
238 }
239 impl DependentSchemasValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator# {
240 #[inline]
241 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator]compile().<'a>(ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#, schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
242 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(map) = schema {
243 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("dependentSchemas");
244 let mut dependencies = 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().(map.lenrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]len().());
245 for (key, subschema) in map {
246 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().());
247 let schema_nodes = 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().(subschema))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
248 dependencies.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((key.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), schema_nodes));
249 }
250 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().(DependentSchemasValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator# { dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies. }))
251 } else {
252 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#::single_type_errorrust-analyzer cargo jsonschema 0.37.4 error/impl#[`ValidationError<'a>`]single_type_error().(
253 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
254 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().(),
255 schema,
256 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Objectrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Object#,
257 ))
258 }
259 }
260 }
261 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for DependentSchemasValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator# {
262 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator][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 {
263 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
264 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies. {
265 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().node.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx) {
266 return false;
267 }
268 }
269 true
270 } else {
271 true
272 }
273 }
274
275 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator][Validate]validate().<'i>(
276 &self,
277 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
278 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
279 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
280 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
281 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
282 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies. {
283 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
284 dependency.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
285 }
286 }
287 }
288 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
289 }
290
291 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator][Validate]iter_errors().<'i>(
292 &self,
293 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
294 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
295 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
296 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
297 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
298 let mut 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().();
299 for (property, node) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies. {
300 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
301 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(node.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx));
302 }
303 }
304 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().())
305 } else {
306 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
307 }
308 }
309
310 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator][Validate]evaluate().(
311 &self,
312 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
313 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
314 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
315 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
316 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(item) = instance {
317 let mut 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().();
318 for (property, dependency) in &self.dependenciesrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#dependencies. {
319 if item.contains_keyrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]contains_key().(property) {
320 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(dependency.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx));
321 }
322 }
323 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
324 } else {
325 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
326 }
327 }
328 }
329
330 #[inline]
331 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/compile().<'a>(
332 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
333 _: &'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#>,
334 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
335 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
336 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DependenciesValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependenciesValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependenciesValidator]compile().(ctx, schema))
337 }
338 #[inline]
339 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_dependent_requiredrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/compile_dependent_required().<'a>(
340 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
341 _: &'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#>,
342 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
343 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
344 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DependentRequiredValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentRequiredValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentRequiredValidator]compile().(ctx, schema))
345 }
346 #[inline]
347 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compile_dependent_schemasrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/compile_dependent_schemas().<'a>(
348 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
349 _: &'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#>,
350 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
351 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
352 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(DependentSchemasValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/DependentSchemasValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/impl#[DependentSchemasValidator]compile().(ctx, schema))
353 }
354 #[cfg(test)]
355 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/tests/ {
356 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
357 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#};
358 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
359
360 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"dependencies": {"bar": ["foo"]}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"bar": 1}), "/dependencies")]
361 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"dependencies": {"bar": {"type": "string"}}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"bar": 1}), "/dependencies/bar/type")]
362 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/dependencies/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) {
363 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);
364 }
365 }