Debian Codegraph @

src/specification/draft7.rs

raw symbols SCIP
1 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
2
3 use craterust-analyzer cargo referencing 0.37.4 crate/::{resourcerust-analyzer cargo referencing 0.37.4 resource/::InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#, Errorrust-analyzer cargo referencing 0.37.4 error/Error#, Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#, Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#};
4
5 use superrust-analyzer cargo referencing 0.37.4 specification/::subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/::{selfrust-analyzer cargo referencing 0.37.4 specification/subresources/, SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#};
6
7 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn object_iterrust-analyzer cargo referencing 0.37.4 specification/draft7/object_iter().<'a>(
8 (key, value): (&'a Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, &'a Valuerust-analyzer cargo serde_json 1.0.145 value/Value#),
9 ) -> SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#<'a> {
10 match key.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
11 // For these keys, yield the value once.
12 "additionalItems"
13 | "additionalProperties"
14 | "contains"
15 | "else"
16 | "if"
17 | "not"
18 | "propertyNames"
19 | "then" => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value),
20 // For these keys, if the value is an array, iterate over its items.
21 "allOf" | "anyOf" | "oneOf" => {
22 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arr) = value.as_arrayrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_array().() {
23 // In the old draft, flatten() was used.
24 // Here we simply iterate over the array.
25 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Arrayrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Array#(arr.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().())
26 } else {
27 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#
28 }
29 }
30 // For these keys, if the value is an object, iterate over its values.
31 "definitions" | "patternProperties" | "properties" => {
32 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(obj) = value.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() {
33 // flat_map in the old draft: iterate over the object's values.
34 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Objectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Object#(obj.valuesrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]values().())
35 } else {
36 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#
37 }
38 }
39 // For "items": if it's an array, iterate over its items; otherwise, yield the value once.
40 "items" => match value {
41 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Arrayrust-analyzer cargo serde_json 1.0.145 value/Value#Array#(arr) => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Arrayrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Array#(arr.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()),
42 _ => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value),
43 },
44 // For "dependencies": if the value is an object, iterate over its values filtered to only those that are objects.
45 "dependencies" => {
46 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(obj) = value.as_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_object().() {
47 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::FilteredObjectrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#FilteredObject#(obj.valuesrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]values().())
48 } else {
49 SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#
50 }
51 }
52 // For any other key, yield nothing.
53 _ => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#,
54 }
55 }
56
57 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft7/maybe_in_subresource().<'r>(
58 segments: &Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#,
59 resolver: &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>,
60 subresource: &InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#,
61 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
62 const IN_VALUErust-analyzer cargo referencing 0.37.4 specification/draft7/IN_VALUE.: &[&str] = &[
63 "additionalItems",
64 "additionalProperties",
65 "contains",
66 "else",
67 "if",
68 "not",
69 "propertyNames",
70 "then",
71 ];
72 const IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/draft7/IN_CHILD.: &[&str] = &[
73 "allOf",
74 "anyOf",
75 "oneOf",
76 "definitions",
77 "patternProperties",
78 "properties",
79 ];
80 subresourcesrust-analyzer cargo referencing 0.37.4 specification/subresources/::maybe_in_subresource_with_items_and_dependenciesrust-analyzer cargo referencing 0.37.4 specification/subresources/maybe_in_subresource_with_items_and_dependencies().(
81 segments,
82 resolver,
83 subresource,
84 IN_VALUErust-analyzer cargo referencing 0.37.4 specification/draft7/IN_VALUE.,
85 IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/draft7/IN_CHILD.,
86 )
87 }