1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const MAX_COMPONENT_URL_LENGTH: u32 = 2083;
13
14pub const MAX_RESOLUTION_CONTEXT_SIZE: u32 = 8192;
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
19#[repr(u32)]
20pub enum ResolverError {
21 Internal = 1,
23 Io = 2,
25 InvalidArgs = 3,
27 NotSupported = 4,
29 ManifestNotFound = 5,
31 PackageNotFound = 6,
33 NoSpace = 7,
35 ResourceUnavailable = 8,
37 InvalidManifest = 9,
39 ConfigValuesNotFound = 10,
41 AbiRevisionNotFound = 11,
43 InvalidAbiRevision = 12,
45}
46
47impl ResolverError {
48 #[inline]
49 pub fn from_primitive(prim: u32) -> Option<Self> {
50 match prim {
51 1 => Some(Self::Internal),
52 2 => Some(Self::Io),
53 3 => Some(Self::InvalidArgs),
54 4 => Some(Self::NotSupported),
55 5 => Some(Self::ManifestNotFound),
56 6 => Some(Self::PackageNotFound),
57 7 => Some(Self::NoSpace),
58 8 => Some(Self::ResourceUnavailable),
59 9 => Some(Self::InvalidManifest),
60 10 => Some(Self::ConfigValuesNotFound),
61 11 => Some(Self::AbiRevisionNotFound),
62 12 => Some(Self::InvalidAbiRevision),
63 _ => None,
64 }
65 }
66
67 #[inline]
68 pub const fn into_primitive(self) -> u32 {
69 self as u32
70 }
71}
72
73#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct Context {
79 pub bytes: Vec<u8>,
80}
81
82impl fidl::Persistable for Context {}
83
84#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
85pub struct ResolverResolveRequest {
86 pub component_url: String,
87}
88
89impl fidl::Persistable for ResolverResolveRequest {}
90
91#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
92pub struct ResolverResolveWithContextRequest {
93 pub component_url: String,
94 pub context: Context,
95}
96
97impl fidl::Persistable for ResolverResolveWithContextRequest {}
98
99pub mod resolver_ordinals {
100 pub const RESOLVE: u64 = 0x57f9cfe88bf1f2e5;
101 pub const RESOLVE_WITH_CONTEXT: u64 = 0x4d64b0de827070bd;
102}
103
104mod internal {
105 use super::*;
106 unsafe impl fidl::encoding::TypeMarker for ResolverError {
107 type Owned = Self;
108
109 #[inline(always)]
110 fn inline_align(_context: fidl::encoding::Context) -> usize {
111 std::mem::align_of::<u32>()
112 }
113
114 #[inline(always)]
115 fn inline_size(_context: fidl::encoding::Context) -> usize {
116 std::mem::size_of::<u32>()
117 }
118
119 #[inline(always)]
120 fn encode_is_copy() -> bool {
121 true
122 }
123
124 #[inline(always)]
125 fn decode_is_copy() -> bool {
126 false
127 }
128 }
129
130 impl fidl::encoding::ValueTypeMarker for ResolverError {
131 type Borrowed<'a> = Self;
132 #[inline(always)]
133 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
134 *value
135 }
136 }
137
138 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ResolverError {
139 #[inline]
140 unsafe fn encode(
141 self,
142 encoder: &mut fidl::encoding::Encoder<'_, D>,
143 offset: usize,
144 _depth: fidl::encoding::Depth,
145 ) -> fidl::Result<()> {
146 encoder.debug_check_bounds::<Self>(offset);
147 encoder.write_num(self.into_primitive(), offset);
148 Ok(())
149 }
150 }
151
152 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ResolverError {
153 #[inline(always)]
154 fn new_empty() -> Self {
155 Self::Internal
156 }
157
158 #[inline]
159 unsafe fn decode(
160 &mut self,
161 decoder: &mut fidl::encoding::Decoder<'_, D>,
162 offset: usize,
163 _depth: fidl::encoding::Depth,
164 ) -> fidl::Result<()> {
165 decoder.debug_check_bounds::<Self>(offset);
166 let prim = decoder.read_num::<u32>(offset);
167
168 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
169 Ok(())
170 }
171 }
172
173 impl fidl::encoding::ValueTypeMarker for Context {
174 type Borrowed<'a> = &'a Self;
175 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
176 value
177 }
178 }
179
180 unsafe impl fidl::encoding::TypeMarker for Context {
181 type Owned = Self;
182
183 #[inline(always)]
184 fn inline_align(_context: fidl::encoding::Context) -> usize {
185 8
186 }
187
188 #[inline(always)]
189 fn inline_size(_context: fidl::encoding::Context) -> usize {
190 16
191 }
192 }
193
194 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Context, D> for &Context {
195 #[inline]
196 unsafe fn encode(
197 self,
198 encoder: &mut fidl::encoding::Encoder<'_, D>,
199 offset: usize,
200 _depth: fidl::encoding::Depth,
201 ) -> fidl::Result<()> {
202 encoder.debug_check_bounds::<Context>(offset);
203 fidl::encoding::Encode::<Context, D>::encode(
205 (<fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow(
206 &self.bytes,
207 ),),
208 encoder,
209 offset,
210 _depth,
211 )
212 }
213 }
214 unsafe impl<
215 D: fidl::encoding::ResourceDialect,
216 T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 8192>, D>,
217 > fidl::encoding::Encode<Context, D> for (T0,)
218 {
219 #[inline]
220 unsafe fn encode(
221 self,
222 encoder: &mut fidl::encoding::Encoder<'_, D>,
223 offset: usize,
224 depth: fidl::encoding::Depth,
225 ) -> fidl::Result<()> {
226 encoder.debug_check_bounds::<Context>(offset);
227 self.0.encode(encoder, offset + 0, depth)?;
231 Ok(())
232 }
233 }
234
235 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Context {
236 #[inline(always)]
237 fn new_empty() -> Self {
238 Self { bytes: fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, D) }
239 }
240
241 #[inline]
242 unsafe fn decode(
243 &mut self,
244 decoder: &mut fidl::encoding::Decoder<'_, D>,
245 offset: usize,
246 _depth: fidl::encoding::Depth,
247 ) -> fidl::Result<()> {
248 decoder.debug_check_bounds::<Self>(offset);
249 fidl::decode!(fidl::encoding::Vector<u8, 8192>, D, &mut self.bytes, decoder, offset + 0, _depth)?;
251 Ok(())
252 }
253 }
254
255 impl fidl::encoding::ValueTypeMarker for ResolverResolveRequest {
256 type Borrowed<'a> = &'a Self;
257 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
258 value
259 }
260 }
261
262 unsafe impl fidl::encoding::TypeMarker for ResolverResolveRequest {
263 type Owned = Self;
264
265 #[inline(always)]
266 fn inline_align(_context: fidl::encoding::Context) -> usize {
267 8
268 }
269
270 #[inline(always)]
271 fn inline_size(_context: fidl::encoding::Context) -> usize {
272 16
273 }
274 }
275
276 unsafe impl<D: fidl::encoding::ResourceDialect>
277 fidl::encoding::Encode<ResolverResolveRequest, D> for &ResolverResolveRequest
278 {
279 #[inline]
280 unsafe fn encode(
281 self,
282 encoder: &mut fidl::encoding::Encoder<'_, D>,
283 offset: usize,
284 _depth: fidl::encoding::Depth,
285 ) -> fidl::Result<()> {
286 encoder.debug_check_bounds::<ResolverResolveRequest>(offset);
287 fidl::encoding::Encode::<ResolverResolveRequest, D>::encode(
289 (<fidl::encoding::BoundedString<2083> as fidl::encoding::ValueTypeMarker>::borrow(
290 &self.component_url,
291 ),),
292 encoder,
293 offset,
294 _depth,
295 )
296 }
297 }
298 unsafe impl<
299 D: fidl::encoding::ResourceDialect,
300 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<2083>, D>,
301 > fidl::encoding::Encode<ResolverResolveRequest, D> for (T0,)
302 {
303 #[inline]
304 unsafe fn encode(
305 self,
306 encoder: &mut fidl::encoding::Encoder<'_, D>,
307 offset: usize,
308 depth: fidl::encoding::Depth,
309 ) -> fidl::Result<()> {
310 encoder.debug_check_bounds::<ResolverResolveRequest>(offset);
311 self.0.encode(encoder, offset + 0, depth)?;
315 Ok(())
316 }
317 }
318
319 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
320 for ResolverResolveRequest
321 {
322 #[inline(always)]
323 fn new_empty() -> Self {
324 Self { component_url: fidl::new_empty!(fidl::encoding::BoundedString<2083>, D) }
325 }
326
327 #[inline]
328 unsafe fn decode(
329 &mut self,
330 decoder: &mut fidl::encoding::Decoder<'_, D>,
331 offset: usize,
332 _depth: fidl::encoding::Depth,
333 ) -> fidl::Result<()> {
334 decoder.debug_check_bounds::<Self>(offset);
335 fidl::decode!(
337 fidl::encoding::BoundedString<2083>,
338 D,
339 &mut self.component_url,
340 decoder,
341 offset + 0,
342 _depth
343 )?;
344 Ok(())
345 }
346 }
347
348 impl fidl::encoding::ValueTypeMarker for ResolverResolveWithContextRequest {
349 type Borrowed<'a> = &'a Self;
350 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
351 value
352 }
353 }
354
355 unsafe impl fidl::encoding::TypeMarker for ResolverResolveWithContextRequest {
356 type Owned = Self;
357
358 #[inline(always)]
359 fn inline_align(_context: fidl::encoding::Context) -> usize {
360 8
361 }
362
363 #[inline(always)]
364 fn inline_size(_context: fidl::encoding::Context) -> usize {
365 32
366 }
367 }
368
369 unsafe impl<D: fidl::encoding::ResourceDialect>
370 fidl::encoding::Encode<ResolverResolveWithContextRequest, D>
371 for &ResolverResolveWithContextRequest
372 {
373 #[inline]
374 unsafe fn encode(
375 self,
376 encoder: &mut fidl::encoding::Encoder<'_, D>,
377 offset: usize,
378 _depth: fidl::encoding::Depth,
379 ) -> fidl::Result<()> {
380 encoder.debug_check_bounds::<ResolverResolveWithContextRequest>(offset);
381 fidl::encoding::Encode::<ResolverResolveWithContextRequest, D>::encode(
383 (
384 <fidl::encoding::BoundedString<2083> as fidl::encoding::ValueTypeMarker>::borrow(&self.component_url),
385 <Context as fidl::encoding::ValueTypeMarker>::borrow(&self.context),
386 ),
387 encoder, offset, _depth
388 )
389 }
390 }
391 unsafe impl<
392 D: fidl::encoding::ResourceDialect,
393 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<2083>, D>,
394 T1: fidl::encoding::Encode<Context, D>,
395 > fidl::encoding::Encode<ResolverResolveWithContextRequest, D> for (T0, T1)
396 {
397 #[inline]
398 unsafe fn encode(
399 self,
400 encoder: &mut fidl::encoding::Encoder<'_, D>,
401 offset: usize,
402 depth: fidl::encoding::Depth,
403 ) -> fidl::Result<()> {
404 encoder.debug_check_bounds::<ResolverResolveWithContextRequest>(offset);
405 self.0.encode(encoder, offset + 0, depth)?;
409 self.1.encode(encoder, offset + 16, depth)?;
410 Ok(())
411 }
412 }
413
414 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
415 for ResolverResolveWithContextRequest
416 {
417 #[inline(always)]
418 fn new_empty() -> Self {
419 Self {
420 component_url: fidl::new_empty!(fidl::encoding::BoundedString<2083>, D),
421 context: fidl::new_empty!(Context, D),
422 }
423 }
424
425 #[inline]
426 unsafe fn decode(
427 &mut self,
428 decoder: &mut fidl::encoding::Decoder<'_, D>,
429 offset: usize,
430 _depth: fidl::encoding::Depth,
431 ) -> fidl::Result<()> {
432 decoder.debug_check_bounds::<Self>(offset);
433 fidl::decode!(
435 fidl::encoding::BoundedString<2083>,
436 D,
437 &mut self.component_url,
438 decoder,
439 offset + 0,
440 _depth
441 )?;
442 fidl::decode!(Context, D, &mut self.context, decoder, offset + 16, _depth)?;
443 Ok(())
444 }
445 }
446}