Debian Codegraph @

src/resolver.rs

raw symbols SCIP
1 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#;
3
4 use fluent_urirust-analyzer cargo fluent-uri 0.4.1 crate/::Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#;
5 use serde_jsonrust-analyzer cargo serde_json 1.0.145 crate/::Valuerust-analyzer cargo serde_json 1.0.145 value/Value#;
6
7 use craterust-analyzer cargo referencing 0.37.4 crate/::{listrust-analyzer cargo referencing 0.37.4 list/::Listrust-analyzer cargo referencing 0.37.4 list/List#, resourcerust-analyzer cargo referencing 0.37.4 resource/::JsonSchemaResourcerust-analyzer cargo referencing 0.37.4 resource/JsonSchemaResource#, Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#, Errorrust-analyzer cargo referencing 0.37.4 error/Error#, Registryrust-analyzer cargo referencing 0.37.4 registry/Registry#, ResourceRefrust-analyzer cargo referencing 0.37.4 resource/ResourceRef#};
8
9 /// A reference resolver.
10 ///
11 /// Resolves references against the base URI and looks up the result in the registry.
12 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
13 pub struct Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r> {
14 pub(craterust-analyzer cargo referencing 0.37.4 crate/) registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.: &'r Registryrust-analyzer cargo referencing 0.37.4 registry/Registry#,
15 base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>,
16 scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes.: Listrust-analyzer cargo referencing 0.37.4 list/List#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>,
17 }
18
19 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'_> {
20 fn eqrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'_>`][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'_>`][`PartialEq<Self>`]) -> bool {
21 self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri. rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]eq().==rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]eq(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]eq().other.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.
22 }
23 }
24 impl Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# for Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'_> {}
25
26 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'_> {
27 fn fmtrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'_>`][Debug]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#<'_>) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
28 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Resolver")
29 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("base_uri", &self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().())
30 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("scopes", &{
31 let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("[");
32 let mut values = self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..iterrust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`]iter().();
33 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = values.nextrust-analyzer cargo referencing 0.37.4 list/impl#[`Iter<'a, T>`][Iterator]next().() {
34 buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(value.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().());
35 }
36 for value in values {
37 buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(", ");
38 buf.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(value.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().());
39 }
40 buf.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(']');
41 buf
42 })
43 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
44 }
45 }
46
47 impl<'r> Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r> {
48 /// Create a new `Resolver` with the given registry and base URI.
49 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn newrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]new().(registry: &'r Registryrust-analyzer cargo referencing 0.37.4 registry/Registry#, base_uri: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>) -> Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`] {
50 Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`] {
51 registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.,
52 base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.,
53 scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes.: Listrust-analyzer cargo referencing 0.37.4 list/List#::newrust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`]new().(),
54 }
55 }
56 #[must_use]
57 pub fn base_urirust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]base_uri().(&self) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> {
58 self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().()
59 }
60 /// Resolve a reference to the resource it points to.
61 ///
62 /// # Errors
63 ///
64 /// If the reference cannot be resolved or is invalid.
65 pub fn lookuprust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]lookup().(&self, reference: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolvedrust-analyzer cargo referencing 0.37.4 resolver/Resolved#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
66 let (uri, fragment) = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(reference) = reference.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().('#') {
67 (self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(), reference)
68 } else {
69 let (uri, fragment) = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((uri, fragment)) = reference.rsplit_oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]rsplit_once().('#') {
70 (uri, fragment)
71 } else {
72 (reference, "")
73 };
74 let uri = self
75 .registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.
76 .resolve_againstrust-analyzer cargo referencing 0.37.4 registry/impl#[Registry]resolve_against().(&self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..borrowrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<String>`]borrow().(), uri)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
77 (uri, fragment)
78 };
79
80 let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(retrieved) = self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry..resourcesrust-analyzer cargo referencing 0.37.4 registry/Registry#resources..getrust-analyzer cargo ahash 0.8.12 hash_map/impl#[`AHashMap<K, V, S>`]get().(&*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Deref]deref().uri) else {
81 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo referencing 0.37.4 error/Error#::unretrievablerust-analyzer cargo referencing 0.37.4 error/impl#[Error]unretrievable().(
82 uri.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().(),
83 "Retrieving external resources is not supported once the registry is populated"
84 .intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
85 ));
86 };
87
88 if fragment.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('/') {
89 let resolver = self.evolverust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]evolve().(uri);
90 return retrieved.pointerrust-analyzer cargo referencing 0.37.4 resource/impl#[InnerResourcePtr]pointer().(fragment, resolver);
91 }
92
93 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().fragment.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
94 let retrieved = self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry..anchorrust-analyzer cargo referencing 0.37.4 registry/impl#[Registry]anchor().(&uri, fragment)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
95 let resolver = self.evolverust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]evolve().(uri);
96 return retrieved.resolverust-analyzer cargo referencing 0.37.4 anchors/impl#[Anchor]resolve().(resolver);
97 }
98
99 let resolver = self.evolverust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]evolve().(uri);
100 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Resolvedrust-analyzer cargo referencing 0.37.4 resolver/Resolved#::newrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]new().(
101 retrieved.contentsrust-analyzer cargo referencing 0.37.4 resource/impl#[InnerResourcePtr]contents().(),
102 resolver,
103 retrieved.draftrust-analyzer cargo referencing 0.37.4 resource/impl#[InnerResourcePtr]draft().(),
104 ))
105 }
106 /// Resolve a recursive reference.
107 ///
108 /// This method implements the recursive reference resolution algorithm
109 /// as specified in JSON Schema Draft 2019-09.
110 ///
111 /// It starts by resolving "#" and then follows the dynamic scope,
112 /// looking for resources with `$recursiveAnchor: true`.
113 ///
114 /// # Errors
115 ///
116 /// This method can return any error that [`Resolver::lookup`] can return.
117 pub fn lookup_recursive_refrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]lookup_recursive_ref().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Resolvedrust-analyzer cargo referencing 0.37.4 resolver/Resolved#<'r>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
118 let mut resolved = self.lookuprust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]lookup().("#")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
119
120 if let Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(obj) = resolved.contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents. {
121 if obj
122 .getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("$recursiveAnchor")
123 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_boolrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_bool().)
124 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false)
125 {
126 for uri in &self.dynamic_scoperust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]dynamic_scope().() {
127 let next_resolved = self.lookuprust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]lookup().(uri.as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
128
129 match next_resolved.contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents. {
130 Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::Objectrust-analyzer cargo serde_json 1.0.145 value/Value#Object#(next_obj) => {
131 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().next_obj
132 .getrust-analyzer cargo serde_json 1.0.145 map/impl#[`Map<String, Value>`]get().("$recursiveAnchor")
133 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(Valuerust-analyzer cargo serde_json 1.0.145 value/Value#::as_boolrust-analyzer cargo serde_json 1.0.145 value/impl#[Value]as_bool().)
134 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false)
135 {
136 break;
137 }
138 }
139 _ => break,
140 }
141
142 resolved = next_resolved;
143 }
144 }
145 }
146
147 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(resolved)
148 }
149 /// Create a resolver for a subresource.
150 ///
151 /// # Errors
152 ///
153 /// Returns an error if the resource id cannot be resolved against the base URI of this resolver.
154 pub fn in_subresourcerust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource().(&self, subresource: ResourceRefrust-analyzer cargo referencing 0.37.4 resource/ResourceRef#<'_>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`], Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
155 self.in_subresource_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource_inner().(&subresource)
156 }
157
158 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn in_subresource_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]in_subresource_inner().(
159 &self,
160 subresource: &impl JsonSchemaResourcerust-analyzer cargo referencing 0.37.4 resource/JsonSchemaResource#,
161 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`], Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
162 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(id) = subresource.idrust-analyzer cargo referencing 0.37.4 resource/JsonSchemaResource#id().() {
163 let base_uri = self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry..resolve_againstrust-analyzer cargo referencing 0.37.4 registry/impl#[Registry]resolve_against().(&self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..borrowrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<String>`]borrow().(), id)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
164 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver# {
165 registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.: self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.,
166 base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.,
167 scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes.: self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..clonerust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`][Clone]clone().(),
168 })
169 } else {
170 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(self.clonerust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`][Clone]clone().())
171 }
172 }
173 #[must_use]
174 pub fn dynamic_scoperust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]dynamic_scope().(&self) -> Listrust-analyzer cargo referencing 0.37.4 list/List#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>> {
175 self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..clonerust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`][Clone]clone().()
176 }
177 fn evolverust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]evolve().(&self, base_uri: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>) -> Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r> {
178 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..as_strrust-analyzer cargo fluent-uri 0.4.1 imp/impl#[`Uri<T>`]as_str().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().()
179 && (self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..is_emptyrust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`]is_empty().() || base_uri rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]ne().!=rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]ne(). rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][`PartialEq<Self>`]ne().self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.)
180 {
181 Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver# {
182 registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.: self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.,
183 base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.,
184 scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes.: self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..push_frontrust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`]push_front().(self.base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().()),
185 }
186 } else {
187 Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver# {
188 registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.: self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry.,
189 base_urirust-analyzer cargo referencing 0.37.4 resolver/Resolver#base_uri.,
190 scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes.: self.scopesrust-analyzer cargo referencing 0.37.4 resolver/Resolver#scopes..clonerust-analyzer cargo referencing 0.37.4 list/impl#[`List<T>`][Clone]clone().(),
191 }
192 }
193 }
194 /// Resolve a reference against a base.
195 ///
196 /// # Errors
197 ///
198 /// If the reference is invalid.
199 pub fn resolve_againstrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolver<'r>`]resolve_against().(&self, base: &Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<&str>, uri: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Urirust-analyzer cargo fluent-uri 0.4.1 imp/Uri#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>, Errorrust-analyzer cargo referencing 0.37.4 error/Error#> {
200 self.registryrust-analyzer cargo referencing 0.37.4 resolver/Resolver#registry..resolve_againstrust-analyzer cargo referencing 0.37.4 registry/impl#[Registry]resolve_against().(base, uri)
201 }
202 }
203
204 /// A reference resolved to its contents by a [`Resolver`].
205 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
206 pub struct Resolvedrust-analyzer cargo referencing 0.37.4 resolver/Resolved#<'r> {
207 /// The contents of the resolved reference.
208 contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents.: &'r Valuerust-analyzer cargo serde_json 1.0.145 value/Value#,
209 /// The resolver that resolved this reference, which can be used for further resolutions.
210 resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolved#resolver.: Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>,
211 draftrust-analyzer cargo referencing 0.37.4 resolver/Resolved#draft.: Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#,
212 }
213
214 impl<'r> Resolvedrust-analyzer cargo referencing 0.37.4 resolver/Resolved#<'r> {
215 pub(craterust-analyzer cargo referencing 0.37.4 crate/) fn newrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]new().(contents: &'r Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, resolver: Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, draft: Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#) -> Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`] {
216 Selfrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`] {
217 contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents.,
218 resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolved#resolver.,
219 draftrust-analyzer cargo referencing 0.37.4 resolver/Resolved#draft.,
220 }
221 }
222 /// Resolved contents.
223 #[must_use]
224 pub fn contentsrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]contents().(&self) -> &'r Valuerust-analyzer cargo serde_json 1.0.145 value/Value# {
225 self.contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents.
226 }
227 /// Resolver used to resolve this contents.
228 #[must_use]
229 pub fn resolverrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]resolver().(&self) -> &Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r> {
230 &self.resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolved#resolver.
231 }
232 #[must_use]
233 pub fn into_innerrust-analyzer cargo referencing 0.37.4 resolver/impl#[`Resolved<'r>`]into_inner().(self) -> (&'r Valuerust-analyzer cargo serde_json 1.0.145 value/Value#, Resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolver#<'r>, Draftrust-analyzer cargo referencing 0.37.4 specification/Draft#) {
234 (self.contentsrust-analyzer cargo referencing 0.37.4 resolver/Resolved#contents., self.resolverrust-analyzer cargo referencing 0.37.4 resolver/Resolved#resolver., self.draftrust-analyzer cargo referencing 0.37.4 resolver/Resolved#draft.)
235 }
236 }