| 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/draft4/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 "items": if it’s an array, iterate over it; otherwise, yield one element. |
| 12 | "items" => match value { |
| 13 | 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().()), |
| 14 | _ => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value), |
| 15 | }, |
| 16 | // For "allOf", "anyOf", "oneOf", "prefixItems": if the value is an array, iterate over it. |
| 17 | "allOf" | "anyOf" | "oneOf" | "prefixItems" => { |
| 18 | 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().() { |
| 19 | 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().()) |
| 20 | } else { |
| 21 | SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty# |
| 22 | } |
| 23 | } |
| 24 | // For "$defs", "definitions", "dependentSchemas", "patternProperties", "properties": |
| 25 | // if the value is an object, iterate over its values. |
| 26 | "$defs" | "definitions" | "dependentSchemas" | "patternProperties" | "properties" => { |
| 27 | 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().() { |
| 28 | 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().()) |
| 29 | } else { |
| 30 | SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty# |
| 31 | } |
| 32 | } |
| 33 | // For "dependencies": if the value is an object, iterate over its values filtered to only those that are objects. |
| 34 | "dependencies" => { |
| 35 | 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().() { |
| 36 | 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().()) |
| 37 | } else { |
| 38 | SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty# |
| 39 | } |
| 40 | } |
| 41 | // For "additionalItems" and "additionalProperties", only if the value is an object. |
| 42 | "additionalItems" | "additionalProperties" if value.is_objectrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]is_object().() => { |
| 43 | SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value) |
| 44 | } |
| 45 | // For other keys that were originally in the “single element” group: |
| 46 | "contains" |
| 47 | | "contentSchema" |
| 48 | | "else" |
| 49 | | "if" |
| 50 | | "propertyNames" |
| 51 | | "not" |
| 52 | | "then" |
| 53 | | "unevaluatedItems" |
| 54 | | "unevaluatedProperties" => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Oncerust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Once#(value), |
| 55 | _ => SubresourceIteratorInnerrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#::Emptyrust-analyzer cargo referencing 0.37.4 specification/subresources/SubresourceIteratorInner#Empty#, |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn maybe_in_subresourcerust-analyzer cargo referencing 0.37.4 specification/draft4/maybe_in_subresource().<'r>( |
| 60 | segments: &Segmentsrust-analyzer cargo referencing 0.37.4 segments/Segments#, |
| 61 | resolver: &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, |
| 62 | subresource: &InnerResourcePtrrust-analyzer cargo referencing 0.37.4 resource/InnerResourcePtr#, |
| 63 | ) -> 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#> { |
| 64 | const IN_VALUErust-analyzer cargo referencing 0.37.4 specification/draft4/IN_VALUE.: &[&str] = &["additionalItems", "additionalProperties", "not"]; |
| 65 | const IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/draft4/IN_CHILD.: &[&str] = &[ |
| 66 | "allOf", |
| 67 | "anyOf", |
| 68 | "oneOf", |
| 69 | "definitions", |
| 70 | "patternProperties", |
| 71 | "properties", |
| 72 | ]; |
| 73 | 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().( |
| 74 | segments, |
| 75 | resolver, |
| 76 | subresource, |
| 77 | IN_VALUErust-analyzer cargo referencing 0.37.4 specification/draft4/IN_VALUE., |
| 78 | IN_CHILDrust-analyzer cargo referencing 0.37.4 specification/draft4/IN_CHILD., |
| 79 | ) |
| 80 | } |