Debian Codegraph @

src/keywords/all_of.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/::{ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#, ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#},
4 noderust-analyzer cargo jsonschema 0.37.4 node/::SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
5 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#},
6 typesrust-analyzer cargo jsonschema 0.37.4 types/::JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#,
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 };
9 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#};
10
11 use superrust-analyzer cargo jsonschema 0.37.4 keywords/::CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#;
12
13 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct AllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator# {
14 schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas.: 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
17 impl AllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator# {
18 #[inline]
19 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator]compile().<'a>(
20 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
21 items: &'a [Valuerust-analyzer cargo serde_json 1.0.145 value/Value#],
22 ) -> CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a> {
23 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("allOf");
24 let mut schemas = 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 core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().());
25 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().() {
26 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(idx);
27 let validators = 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().(item))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
28 schemas.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(validators);
29 }
30 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().(AllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator# { schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas. }))
31 }
32 }
33
34 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for AllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator# {
35 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator][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 {
36 self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas..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().(|n| n.is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx))
37 }
38
39 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator][Validate]validate().<'i>(
40 &self,
41 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
42 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
43 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
44 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
45 for schema in &self.schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas. {
46 schema.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().;
47 }
48 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
49 }
50
51 #[allow(clippy::needless_collect)]
52 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator][Validate]iter_errors().<'i>(
53 &self,
54 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
55 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
56 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
57 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
58 let errors: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = self
59 .schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas.
60 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
61 .flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(move |node| node.iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx))
62 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
63 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().())
64 }
65
66 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator][Validate]evaluate().(
67 &self,
68 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
69 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
70 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
71 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
72 let children = self
73 .schemasrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#schemas.
74 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
75 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(move |node| node.evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx))
76 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
77 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::from_childrenrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult]from_children().(children)
78 }
79 }
80
81 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) struct SingleValueAllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator# {
82 noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node.: SchemaNoderust-analyzer cargo jsonschema 0.37.4 node/SchemaNode#,
83 }
84
85 impl SingleValueAllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator# {
86 #[inline]
87 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator]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> {
88 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().("allOf");
89 let ctx = ctx.new_at_locationrust-analyzer cargo jsonschema 0.37.4 compiler/impl#[`Context<'a>`]new_at_location().(0);
90 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().;
91 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().(SingleValueAllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator# { noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node. }))
92 }
93 }
94
95 impl Validaterust-analyzer cargo jsonschema 0.37.4 validator/Validate# for SingleValueAllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator# {
96 fn is_validrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator][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 {
97 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node..is_validrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]is_valid().(instance, ctx)
98 }
99
100 fn validaterust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator][Validate]validate().<'i>(
101 &self,
102 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
103 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
104 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
105 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ValidationErrorrust-analyzer cargo jsonschema 0.37.4 error/ValidationError#<'i>> {
106 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node..validaterust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]validate().(instance, location, ctx)
107 }
108
109 fn iter_errorsrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator][Validate]iter_errors().<'i>(
110 &self,
111 instance: &'i Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
112 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
113 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
114 ) -> ErrorIteratorrust-analyzer cargo jsonschema 0.37.4 error/ErrorIterator#<'i> {
115 self.noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node..iter_errorsrust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode][Validate]iter_errors().(instance, location, ctx)
116 }
117
118 fn evaluaterust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator][Validate]evaluate().(
119 &self,
120 instance: &Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
121 location: &LazyLocationrust-analyzer cargo jsonschema 0.37.4 paths/LazyLocation#,
122 ctx: &mut ValidationContextrust-analyzer cargo jsonschema 0.37.4 validator/ValidationContext#,
123 ) -> EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult# {
124 EvaluationResultrust-analyzer cargo jsonschema 0.37.4 validator/EvaluationResult#::fromrust-analyzer cargo jsonschema 0.37.4 validator/impl#[EvaluationResult][`From<EvaluationNode>`]from().(self.noderust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#node..evaluate_instancerust-analyzer cargo jsonschema 0.37.4 node/impl#[SchemaNode]evaluate_instance().(instance, location, ctx))
125 }
126 }
127
128 #[inline]
129 pub(craterust-analyzer cargo jsonschema 0.37.4 crate/) fn compilerust-analyzer cargo jsonschema 0.37.4 keywords/all_of/compile().<'a>(
130 ctx: &compilerrust-analyzer cargo jsonschema 0.37.4 compiler/::Contextrust-analyzer cargo jsonschema 0.37.4 compiler/Context#,
131 _: &'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#>,
132 schema: &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
133 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<CompilationResultrust-analyzer cargo jsonschema 0.37.4 keywords/CompilationResult#<'a>> {
134 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(items) = schema {
135 if 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][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 {
136 let value = items.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]next().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("Vec is not empty");
137 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(SingleValueAllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/SingleValueAllOfValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[SingleValueAllOfValidator]compile().(ctx, value))
138 } else {
139 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(AllOfValidatorrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/AllOfValidator#::compilerust-analyzer cargo jsonschema 0.37.4 keywords/all_of/impl#[AllOfValidator]compile().(ctx, items))
140 }
141 } else {
142 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(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().(
143 Locationrust-analyzer cargo jsonschema 0.37.4 paths/Location#::newrust-analyzer cargo jsonschema 0.37.4 paths/impl#[Location]new().(),
144 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().(),
145 schema,
146 JsonTyperust-analyzer cargo jsonschema 0.37.4 types/JsonType#::Arrayrust-analyzer cargo jsonschema 0.37.4 types/JsonType#Array#,
147 )))
148 }
149 }
150
151 #[cfg(test)]
152 mod testsrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/tests/ {
153 use craterust-analyzer cargo jsonschema 0.37.4 crate/::tests_utilrust-analyzer cargo jsonschema 0.37.4 tests_util/;
154 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#};
155 use test_caserust-analyzer cargo test-case 3.3.1 crate/::test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:;
156
157 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"allOf": [{"type": "string"}]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(1), "/allOf/0/type")]
158 #[test_caserust-analyzer cargo test-case-macros 3.3.1 test_case:(&jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!({"allOf": [{"type": "integer"}, {"maximum": 5}]}), &jsonrust-analyzer cargo serde_json 1.0.145 macros/json!!(6), "/allOf/1/maximum")]
159 fn locationrust-analyzer cargo jsonschema 0.37.4 keywords/all_of/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) {
160 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);
161 }
162 }