Debian Codegraph @

src/keywords/items.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#},
4 evaluationrust-analyzer cargo jsonschema 0.37.4 evaluation/::Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#,
5 keywordsrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#,
6 noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
7 pathsrust-analyzer cargo jsonschema 0.37.4 paths/::LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
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 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#};
12
13 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ItemsArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator# {
14 itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#>,
15 }
16 impl ItemsArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator# {
17 #[inline]
18 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsArrayValidator]compile().<'a>(
19 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
20 schemas: &'a [Valuerust-analyzer cargo serde_json 1.0.145 value/Value#],
21 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
22 let kctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("items");
23 let mut items = 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().(schemas.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
24 for (idx, item) in schemas.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
25 let ictx = kctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx);
26 let validators = compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::compilerust-analyzer cargo jsonschema 0.37.4 compiler/compile().(&ictx, ictx.as_resource_refrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]as_resource_ref().(item))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
27 items.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(validators);
28 }
29 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().(ItemsArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator# { itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items. }))
30 }
31 }
32 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ItemsArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator# {
33 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsArrayValidator][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 {
34 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
35 for (item, node) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(self.itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) {
36 if !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().(item, ctx) {
37 return false;
38 }
39 }
40 true
41 } else {
42 true
43 }
44 }
45
46 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsArrayValidator][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 let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
53 for (idx, (item, node)) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(self.itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
54 node.validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
55 }
56 }
57 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
58 }
59
60 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsArrayValidator][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 let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
67 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().();
68 for (idx, (item, node)) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(self.itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
69 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().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx));
70 }
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/items/impl#[ItemsArrayValidator][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 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
84 let mut children = 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().(self.itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().().minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()));
85 for (idx, (item, node)) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(self.itemsrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#items..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
86 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(node.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx));
87 }
88 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
89 } else {
90 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
91 }
92 }
93 }
94
95 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ItemsObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator# {
96 noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
97 }
98
99 impl ItemsObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator# {
100 #[inline]
101 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator]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> {
102 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("items");
103 let node = 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().;
104 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().(ItemsObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator# { noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node. }))
105 }
106 }
107 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ItemsObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator# {
108 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator][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 {
109 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
110 items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|i| self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(i, ctx))
111 } else {
112 true
113 }
114 }
115
116 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator][Validate]validate().<'i>(
117 &self,
118 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
119 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
120 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
121 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
122 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
123 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
124 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
125 }
126 }
127 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
128 }
129
130 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator][Validate]iter_errors().<'i>(
131 &self,
132 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
133 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
134 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
135 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
136 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
137 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().();
138 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
139 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node..iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx));
140 }
141 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().())
142 } else {
143 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
144 }
145 }
146
147 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator][Validate]evaluate().(
148 &self,
149 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
150 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
151 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
152 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
153 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
154 let mut children = 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().(items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
155 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
156 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#node..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx));
157 }
158 let schema_was_applied = !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().items.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().();
159 let mut result = EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children);
160 result.annotaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]annotate().(Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(schema_was_applied)));
161 result
162 } else {
163 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
164 }
165 }
166 }
167
168 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct ItemsObjectSkipPrefixValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator# {
169 noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
170 skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.: usize,
171 }
172
173 impl ItemsObjectSkipPrefixValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator# {
174 #[inline]
175 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator]compile().<'a>(
176 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
177 skip_prefix: usize,
178 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
179 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
180 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("items");
181 let node = 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().;
182 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().(ItemsObjectSkipPrefixValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator# {
183 noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node.,
184 skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.,
185 }))
186 }
187 }
188
189 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for ItemsObjectSkipPrefixValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator# {
190 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator][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 {
191 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
192 items
193 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
194 .skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.)
195 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#all().(|i| self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(i, ctx))
196 } else {
197 true
198 }
199 }
200
201 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator][Validate]validate().<'i>(
202 &self,
203 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
204 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
205 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
206 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
207 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
208 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
209 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node.
210 .validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.), ctx)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
211 }
212 }
213 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
214 }
215
216 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator][Validate]iter_errors().<'i>(
217 &self,
218 instance: &'i 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 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
222 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
223 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().();
224 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.).enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
225 errors.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node..iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(
226 item,
227 &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.),
228 ctx,
229 ));
230 }
231 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().())
232 } else {
233 no_errorrust-analyzer cargo jsonschema 0.37.4 error/no_error().()
234 }
235 }
236
237 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator][Validate]evaluate().(
238 &self,
239 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
240 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
241 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
242 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
243 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = instance {
244 let mut children = 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().(items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().().saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.));
245 for (idx, item) in items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.) {
246 children.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#node..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(item, &location.pushrust-analyzer cargo jsonschema 0.37.4 paths/impl#[`LazyLocation<'a, '_>`]push().(idx), ctx));
247 }
248 let schema_was_applied = items.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][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().self.skip_prefixrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#skip_prefix.;
249 let mut result = EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children);
250 result.annotaterust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]annotate().(Annotationsrust-analyzer cargo jsonschema 0.37.4 evaluation/Annotations#::newrust-analyzer cargo jsonschema 0.37.4 evaluation/impl#[Annotations]new().(serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(schema_was_applied)));
251 result
252 } else {
253 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::valid_emptyrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]valid_empty().()
254 }
255 }
256 }
257
258 #[inline]
259 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/compile().<'a>(
260 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
261 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#>,
262 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
263 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
264 match schema {
265 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ItemsArrayValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsArrayValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsArrayValidator]compile().(ctx, items)),
266 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(_) | Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Boolrust-analyzer cargo serde_json 1.0.145 value/Value#Bool#(false) => {
267 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(prefix_items)) = parent.getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("prefixItems") {
268 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ItemsObjectSkipPrefixValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectSkipPrefixValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectSkipPrefixValidator]compile().(
269 schema,
270 prefix_items.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(),
271 ctx,
272 ));
273 }
274 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ItemsObjectValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/items/ItemsObjectValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/items/impl#[ItemsObjectValidator]compile().(ctx, schema))
275 }
276 _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
277 }
278 }
279
280 #[cfg(test)]
281 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/items/tests/ {
282 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
283 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#};
284 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
285
286 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"items": false}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([1]), "/items")]
287 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"items": {"type": "string"}}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([1]), "/items/type")]
288 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"prefixItems": [{"type": "string"}]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!([1]), "/prefixItems/0/type")]
289 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/items/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) {
290 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);
291 }
292 }