fidl_fuchsia_component_resolution/
fidl_fuchsia_component_resolution.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_component_resolution_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ResolverResolveWithContextResponse {
16    pub component: Component,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for ResolverResolveWithContextResponse
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct ResolverResolveResponse {
26    pub component: Component,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ResolverResolveResponse {}
30
31/// A component is a unit of executable software.
32///
33/// This object provides the component's declaration, access to its package's
34/// content, and relevant metadata as resolved `fuchsia.component.resolution.Resolver`.
35#[derive(Debug, Default, PartialEq)]
36pub struct Component {
37    /// The resolved URL of the component.
38    /// This is the canonical URL obtained by the component resolver after
39    /// following redirects and resolving relative paths.
40    pub url: Option<String>,
41    /// Binary representation of the component's declaration (`fuchsia.component.decl.Component`).
42    /// This information is typically obtained from the component's manifest
43    /// or generated by the component resolver.
44    pub decl: Option<fidl_fuchsia_mem::Data>,
45    /// The package that contains the component.
46    /// By convention, the component's package is mapped to "/pkg" in its
47    /// namespace at runtime.
48    ///
49    /// This is null if the component is not represented as a package.
50    /// In that case, it is the runner's responsibility to load the component's
51    /// resource from the `resolved_url`.  This mechanism is used for web
52    /// applications.
53    ///
54    /// Most runners, including but not limited to the builtin ELF runner,
55    /// require the package's directory connection to have OPEN_RIGHT_EXECUTABLE
56    /// rights in order to run the resolved component.
57    pub package: Option<Package>,
58    /// Binary representation of the component's configuration values
59    /// (`fuchsia.component.config.ValuesData`).
60    pub config_values: Option<fidl_fuchsia_mem::Data>,
61    /// The context used to resolve `component_url`s relative to this
62    /// component. Pass this value to `Resolver::ResolveWithContext()` when
63    /// resolving a component URL that _may_ be relative to this `Component`.
64    ///
65    /// The `resolution_context` is an opaque value (from the perspective of
66    /// component resolution) that is provided by a component `Resolver` to save
67    /// with a parent `Component`.
68    ///
69    /// `Resolver`s that can resolve relative path component URLs, via
70    /// `ResolveWithContext`, should return a `resolution_context` from both
71    /// `Resolve` and `ResolveWithContext`. Relative path component URLs can
72    /// only be resolved via `ResolveWithContext`, which requires a valid
73    /// resolution `Context`.
74    pub resolution_context: Option<Context>,
75    /// The target ABI revision of the resolved component.
76    pub abi_revision: Option<u64>,
77    #[doc(hidden)]
78    pub __source_breaking: fidl::marker::SourceBreaking,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Component {}
82
83/// A package is a signed collection of immutable files.
84///
85/// This object provides access to a package's content and relevant metadata.
86#[derive(Debug, Default, PartialEq)]
87pub struct Package {
88    /// The URL of the package itself.
89    pub url: Option<String>,
90    /// The package's content directory.
91    pub directory: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>>,
92    #[doc(hidden)]
93    pub __source_breaking: fidl::marker::SourceBreaking,
94}
95
96impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Package {}
97
98#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
99pub struct ResolverMarker;
100
101impl fidl::endpoints::ProtocolMarker for ResolverMarker {
102    type Proxy = ResolverProxy;
103    type RequestStream = ResolverRequestStream;
104    #[cfg(target_os = "fuchsia")]
105    type SynchronousProxy = ResolverSynchronousProxy;
106
107    const DEBUG_NAME: &'static str = "fuchsia.component.resolution.Resolver";
108}
109impl fidl::endpoints::DiscoverableProtocolMarker for ResolverMarker {}
110pub type ResolverResolveResult = Result<Component, ResolverError>;
111pub type ResolverResolveWithContextResult = Result<Component, ResolverError>;
112
113pub trait ResolverProxyInterface: Send + Sync {
114    type ResolveResponseFut: std::future::Future<Output = Result<ResolverResolveResult, fidl::Error>>
115        + Send;
116    fn r#resolve(&self, component_url: &str) -> Self::ResolveResponseFut;
117    type ResolveWithContextResponseFut: std::future::Future<Output = Result<ResolverResolveWithContextResult, fidl::Error>>
118        + Send;
119    fn r#resolve_with_context(
120        &self,
121        component_url: &str,
122        context: &Context,
123    ) -> Self::ResolveWithContextResponseFut;
124}
125#[derive(Debug)]
126#[cfg(target_os = "fuchsia")]
127pub struct ResolverSynchronousProxy {
128    client: fidl::client::sync::Client,
129}
130
131#[cfg(target_os = "fuchsia")]
132impl fidl::endpoints::SynchronousProxy for ResolverSynchronousProxy {
133    type Proxy = ResolverProxy;
134    type Protocol = ResolverMarker;
135
136    fn from_channel(inner: fidl::Channel) -> Self {
137        Self::new(inner)
138    }
139
140    fn into_channel(self) -> fidl::Channel {
141        self.client.into_channel()
142    }
143
144    fn as_channel(&self) -> &fidl::Channel {
145        self.client.as_channel()
146    }
147}
148
149#[cfg(target_os = "fuchsia")]
150impl ResolverSynchronousProxy {
151    pub fn new(channel: fidl::Channel) -> Self {
152        let protocol_name = <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
153        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
154    }
155
156    pub fn into_channel(self) -> fidl::Channel {
157        self.client.into_channel()
158    }
159
160    /// Waits until an event arrives and returns it. It is safe for other
161    /// threads to make concurrent requests while waiting for an event.
162    pub fn wait_for_event(
163        &self,
164        deadline: zx::MonotonicInstant,
165    ) -> Result<ResolverEvent, fidl::Error> {
166        ResolverEvent::decode(self.client.wait_for_event(deadline)?)
167    }
168
169    /// Resolves a component with the given absolute URL.
170    ///
171    /// `component_url` is the unescaped URL of the component to resolve.
172    ///
173    /// If successful, returns information about the component
174    /// that was resolved.
175    ///
176    /// On failure, returns a `ResolverError` error.
177    pub fn r#resolve(
178        &self,
179        mut component_url: &str,
180        ___deadline: zx::MonotonicInstant,
181    ) -> Result<ResolverResolveResult, fidl::Error> {
182        let _response = self.client.send_query::<
183            ResolverResolveRequest,
184            fidl::encoding::ResultType<ResolverResolveResponse, ResolverError>,
185        >(
186            (component_url,),
187            0x57f9cfe88bf1f2e5,
188            fidl::encoding::DynamicFlags::empty(),
189            ___deadline,
190        )?;
191        Ok(_response.map(|x| x.component))
192    }
193
194    /// Resolves a component with the absolute or relative URL. If relative, the
195    /// component will be resolved relative to the supplied `context`.
196    ///
197    /// `component_url` is the unescaped URL of the component to resolve, the
198    /// format of which can be either:
199    ///
200    ///   * a fully-qualified absolute component URL; or
201    ///   * a subpackaged-component reference, prefixed by a URI relative
202    ///     path to its containing subpackage (for example,
203    ///     `child_package#meta/some_component.cm`)
204    ///
205    /// `context` is the `resolution_context` of a previously-resolved
206    /// `Component`, providing the context for resoving a relative URL.
207    pub fn r#resolve_with_context(
208        &self,
209        mut component_url: &str,
210        mut context: &Context,
211        ___deadline: zx::MonotonicInstant,
212    ) -> Result<ResolverResolveWithContextResult, fidl::Error> {
213        let _response = self.client.send_query::<
214            ResolverResolveWithContextRequest,
215            fidl::encoding::ResultType<ResolverResolveWithContextResponse, ResolverError>,
216        >(
217            (component_url, context,),
218            0x4d64b0de827070bd,
219            fidl::encoding::DynamicFlags::empty(),
220            ___deadline,
221        )?;
222        Ok(_response.map(|x| x.component))
223    }
224}
225
226#[cfg(target_os = "fuchsia")]
227impl From<ResolverSynchronousProxy> for zx::Handle {
228    fn from(value: ResolverSynchronousProxy) -> Self {
229        value.into_channel().into()
230    }
231}
232
233#[cfg(target_os = "fuchsia")]
234impl From<fidl::Channel> for ResolverSynchronousProxy {
235    fn from(value: fidl::Channel) -> Self {
236        Self::new(value)
237    }
238}
239
240#[derive(Debug, Clone)]
241pub struct ResolverProxy {
242    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
243}
244
245impl fidl::endpoints::Proxy for ResolverProxy {
246    type Protocol = ResolverMarker;
247
248    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
249        Self::new(inner)
250    }
251
252    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
253        self.client.into_channel().map_err(|client| Self { client })
254    }
255
256    fn as_channel(&self) -> &::fidl::AsyncChannel {
257        self.client.as_channel()
258    }
259}
260
261impl ResolverProxy {
262    /// Create a new Proxy for fuchsia.component.resolution/Resolver.
263    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
264        let protocol_name = <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
265        Self { client: fidl::client::Client::new(channel, protocol_name) }
266    }
267
268    /// Get a Stream of events from the remote end of the protocol.
269    ///
270    /// # Panics
271    ///
272    /// Panics if the event stream was already taken.
273    pub fn take_event_stream(&self) -> ResolverEventStream {
274        ResolverEventStream { event_receiver: self.client.take_event_receiver() }
275    }
276
277    /// Resolves a component with the given absolute URL.
278    ///
279    /// `component_url` is the unescaped URL of the component to resolve.
280    ///
281    /// If successful, returns information about the component
282    /// that was resolved.
283    ///
284    /// On failure, returns a `ResolverError` error.
285    pub fn r#resolve(
286        &self,
287        mut component_url: &str,
288    ) -> fidl::client::QueryResponseFut<
289        ResolverResolveResult,
290        fidl::encoding::DefaultFuchsiaResourceDialect,
291    > {
292        ResolverProxyInterface::r#resolve(self, component_url)
293    }
294
295    /// Resolves a component with the absolute or relative URL. If relative, the
296    /// component will be resolved relative to the supplied `context`.
297    ///
298    /// `component_url` is the unescaped URL of the component to resolve, the
299    /// format of which can be either:
300    ///
301    ///   * a fully-qualified absolute component URL; or
302    ///   * a subpackaged-component reference, prefixed by a URI relative
303    ///     path to its containing subpackage (for example,
304    ///     `child_package#meta/some_component.cm`)
305    ///
306    /// `context` is the `resolution_context` of a previously-resolved
307    /// `Component`, providing the context for resoving a relative URL.
308    pub fn r#resolve_with_context(
309        &self,
310        mut component_url: &str,
311        mut context: &Context,
312    ) -> fidl::client::QueryResponseFut<
313        ResolverResolveWithContextResult,
314        fidl::encoding::DefaultFuchsiaResourceDialect,
315    > {
316        ResolverProxyInterface::r#resolve_with_context(self, component_url, context)
317    }
318}
319
320impl ResolverProxyInterface for ResolverProxy {
321    type ResolveResponseFut = fidl::client::QueryResponseFut<
322        ResolverResolveResult,
323        fidl::encoding::DefaultFuchsiaResourceDialect,
324    >;
325    fn r#resolve(&self, mut component_url: &str) -> Self::ResolveResponseFut {
326        fn _decode(
327            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
328        ) -> Result<ResolverResolveResult, fidl::Error> {
329            let _response = fidl::client::decode_transaction_body::<
330                fidl::encoding::ResultType<ResolverResolveResponse, ResolverError>,
331                fidl::encoding::DefaultFuchsiaResourceDialect,
332                0x57f9cfe88bf1f2e5,
333            >(_buf?)?;
334            Ok(_response.map(|x| x.component))
335        }
336        self.client.send_query_and_decode::<ResolverResolveRequest, ResolverResolveResult>(
337            (component_url,),
338            0x57f9cfe88bf1f2e5,
339            fidl::encoding::DynamicFlags::empty(),
340            _decode,
341        )
342    }
343
344    type ResolveWithContextResponseFut = fidl::client::QueryResponseFut<
345        ResolverResolveWithContextResult,
346        fidl::encoding::DefaultFuchsiaResourceDialect,
347    >;
348    fn r#resolve_with_context(
349        &self,
350        mut component_url: &str,
351        mut context: &Context,
352    ) -> Self::ResolveWithContextResponseFut {
353        fn _decode(
354            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
355        ) -> Result<ResolverResolveWithContextResult, fidl::Error> {
356            let _response = fidl::client::decode_transaction_body::<
357                fidl::encoding::ResultType<ResolverResolveWithContextResponse, ResolverError>,
358                fidl::encoding::DefaultFuchsiaResourceDialect,
359                0x4d64b0de827070bd,
360            >(_buf?)?;
361            Ok(_response.map(|x| x.component))
362        }
363        self.client.send_query_and_decode::<
364            ResolverResolveWithContextRequest,
365            ResolverResolveWithContextResult,
366        >(
367            (component_url, context,),
368            0x4d64b0de827070bd,
369            fidl::encoding::DynamicFlags::empty(),
370            _decode,
371        )
372    }
373}
374
375pub struct ResolverEventStream {
376    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
377}
378
379impl std::marker::Unpin for ResolverEventStream {}
380
381impl futures::stream::FusedStream for ResolverEventStream {
382    fn is_terminated(&self) -> bool {
383        self.event_receiver.is_terminated()
384    }
385}
386
387impl futures::Stream for ResolverEventStream {
388    type Item = Result<ResolverEvent, fidl::Error>;
389
390    fn poll_next(
391        mut self: std::pin::Pin<&mut Self>,
392        cx: &mut std::task::Context<'_>,
393    ) -> std::task::Poll<Option<Self::Item>> {
394        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
395            &mut self.event_receiver,
396            cx
397        )?) {
398            Some(buf) => std::task::Poll::Ready(Some(ResolverEvent::decode(buf))),
399            None => std::task::Poll::Ready(None),
400        }
401    }
402}
403
404#[derive(Debug)]
405pub enum ResolverEvent {
406    #[non_exhaustive]
407    _UnknownEvent {
408        /// Ordinal of the event that was sent.
409        ordinal: u64,
410    },
411}
412
413impl ResolverEvent {
414    /// Decodes a message buffer as a [`ResolverEvent`].
415    fn decode(
416        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
417    ) -> Result<ResolverEvent, fidl::Error> {
418        let (bytes, _handles) = buf.split_mut();
419        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
420        debug_assert_eq!(tx_header.tx_id, 0);
421        match tx_header.ordinal {
422            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
423                Ok(ResolverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
424            }
425            _ => Err(fidl::Error::UnknownOrdinal {
426                ordinal: tx_header.ordinal,
427                protocol_name: <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
428            }),
429        }
430    }
431}
432
433/// A Stream of incoming requests for fuchsia.component.resolution/Resolver.
434pub struct ResolverRequestStream {
435    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
436    is_terminated: bool,
437}
438
439impl std::marker::Unpin for ResolverRequestStream {}
440
441impl futures::stream::FusedStream for ResolverRequestStream {
442    fn is_terminated(&self) -> bool {
443        self.is_terminated
444    }
445}
446
447impl fidl::endpoints::RequestStream for ResolverRequestStream {
448    type Protocol = ResolverMarker;
449    type ControlHandle = ResolverControlHandle;
450
451    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
452        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
453    }
454
455    fn control_handle(&self) -> Self::ControlHandle {
456        ResolverControlHandle { inner: self.inner.clone() }
457    }
458
459    fn into_inner(
460        self,
461    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
462    {
463        (self.inner, self.is_terminated)
464    }
465
466    fn from_inner(
467        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
468        is_terminated: bool,
469    ) -> Self {
470        Self { inner, is_terminated }
471    }
472}
473
474impl futures::Stream for ResolverRequestStream {
475    type Item = Result<ResolverRequest, fidl::Error>;
476
477    fn poll_next(
478        mut self: std::pin::Pin<&mut Self>,
479        cx: &mut std::task::Context<'_>,
480    ) -> std::task::Poll<Option<Self::Item>> {
481        let this = &mut *self;
482        if this.inner.check_shutdown(cx) {
483            this.is_terminated = true;
484            return std::task::Poll::Ready(None);
485        }
486        if this.is_terminated {
487            panic!("polled ResolverRequestStream after completion");
488        }
489        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
490            |bytes, handles| {
491                match this.inner.channel().read_etc(cx, bytes, handles) {
492                    std::task::Poll::Ready(Ok(())) => {}
493                    std::task::Poll::Pending => return std::task::Poll::Pending,
494                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
495                        this.is_terminated = true;
496                        return std::task::Poll::Ready(None);
497                    }
498                    std::task::Poll::Ready(Err(e)) => {
499                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
500                            e.into(),
501                        ))))
502                    }
503                }
504
505                // A message has been received from the channel
506                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
507
508                std::task::Poll::Ready(Some(match header.ordinal {
509                    0x57f9cfe88bf1f2e5 => {
510                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
511                        let mut req = fidl::new_empty!(
512                            ResolverResolveRequest,
513                            fidl::encoding::DefaultFuchsiaResourceDialect
514                        );
515                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ResolverResolveRequest>(&header, _body_bytes, handles, &mut req)?;
516                        let control_handle = ResolverControlHandle { inner: this.inner.clone() };
517                        Ok(ResolverRequest::Resolve {
518                            component_url: req.component_url,
519
520                            responder: ResolverResolveResponder {
521                                control_handle: std::mem::ManuallyDrop::new(control_handle),
522                                tx_id: header.tx_id,
523                            },
524                        })
525                    }
526                    0x4d64b0de827070bd => {
527                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
528                        let mut req = fidl::new_empty!(
529                            ResolverResolveWithContextRequest,
530                            fidl::encoding::DefaultFuchsiaResourceDialect
531                        );
532                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ResolverResolveWithContextRequest>(&header, _body_bytes, handles, &mut req)?;
533                        let control_handle = ResolverControlHandle { inner: this.inner.clone() };
534                        Ok(ResolverRequest::ResolveWithContext {
535                            component_url: req.component_url,
536                            context: req.context,
537
538                            responder: ResolverResolveWithContextResponder {
539                                control_handle: std::mem::ManuallyDrop::new(control_handle),
540                                tx_id: header.tx_id,
541                            },
542                        })
543                    }
544                    _ if header.tx_id == 0
545                        && header
546                            .dynamic_flags()
547                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
548                    {
549                        Ok(ResolverRequest::_UnknownMethod {
550                            ordinal: header.ordinal,
551                            control_handle: ResolverControlHandle { inner: this.inner.clone() },
552                            method_type: fidl::MethodType::OneWay,
553                        })
554                    }
555                    _ if header
556                        .dynamic_flags()
557                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
558                    {
559                        this.inner.send_framework_err(
560                            fidl::encoding::FrameworkErr::UnknownMethod,
561                            header.tx_id,
562                            header.ordinal,
563                            header.dynamic_flags(),
564                            (bytes, handles),
565                        )?;
566                        Ok(ResolverRequest::_UnknownMethod {
567                            ordinal: header.ordinal,
568                            control_handle: ResolverControlHandle { inner: this.inner.clone() },
569                            method_type: fidl::MethodType::TwoWay,
570                        })
571                    }
572                    _ => Err(fidl::Error::UnknownOrdinal {
573                        ordinal: header.ordinal,
574                        protocol_name:
575                            <ResolverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
576                    }),
577                }))
578            },
579        )
580    }
581}
582
583/// An interface for resolving a URL to a component.
584///
585/// This interface is implemented by components that provide support
586/// for loading components with a particular URL scheme.   For example,
587/// the Fuchsia package component resolver exposes a service with this
588/// interface to resolve component URLs using the "fuchsia-pkg://" scheme.
589///
590/// To use a resolver to resolve URLs within your realm, register it
591/// in your realm's manifest.
592///
593/// Note: The component manager is the only intended direct client of this
594/// interface.
595#[derive(Debug)]
596pub enum ResolverRequest {
597    /// Resolves a component with the given absolute URL.
598    ///
599    /// `component_url` is the unescaped URL of the component to resolve.
600    ///
601    /// If successful, returns information about the component
602    /// that was resolved.
603    ///
604    /// On failure, returns a `ResolverError` error.
605    Resolve { component_url: String, responder: ResolverResolveResponder },
606    /// Resolves a component with the absolute or relative URL. If relative, the
607    /// component will be resolved relative to the supplied `context`.
608    ///
609    /// `component_url` is the unescaped URL of the component to resolve, the
610    /// format of which can be either:
611    ///
612    ///   * a fully-qualified absolute component URL; or
613    ///   * a subpackaged-component reference, prefixed by a URI relative
614    ///     path to its containing subpackage (for example,
615    ///     `child_package#meta/some_component.cm`)
616    ///
617    /// `context` is the `resolution_context` of a previously-resolved
618    /// `Component`, providing the context for resoving a relative URL.
619    ResolveWithContext {
620        component_url: String,
621        context: Context,
622        responder: ResolverResolveWithContextResponder,
623    },
624    /// An interaction was received which does not match any known method.
625    #[non_exhaustive]
626    _UnknownMethod {
627        /// Ordinal of the method that was called.
628        ordinal: u64,
629        control_handle: ResolverControlHandle,
630        method_type: fidl::MethodType,
631    },
632}
633
634impl ResolverRequest {
635    #[allow(irrefutable_let_patterns)]
636    pub fn into_resolve(self) -> Option<(String, ResolverResolveResponder)> {
637        if let ResolverRequest::Resolve { component_url, responder } = self {
638            Some((component_url, responder))
639        } else {
640            None
641        }
642    }
643
644    #[allow(irrefutable_let_patterns)]
645    pub fn into_resolve_with_context(
646        self,
647    ) -> Option<(String, Context, ResolverResolveWithContextResponder)> {
648        if let ResolverRequest::ResolveWithContext { component_url, context, responder } = self {
649            Some((component_url, context, responder))
650        } else {
651            None
652        }
653    }
654
655    /// Name of the method defined in FIDL
656    pub fn method_name(&self) -> &'static str {
657        match *self {
658            ResolverRequest::Resolve { .. } => "resolve",
659            ResolverRequest::ResolveWithContext { .. } => "resolve_with_context",
660            ResolverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
661                "unknown one-way method"
662            }
663            ResolverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
664                "unknown two-way method"
665            }
666        }
667    }
668}
669
670#[derive(Debug, Clone)]
671pub struct ResolverControlHandle {
672    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
673}
674
675impl fidl::endpoints::ControlHandle for ResolverControlHandle {
676    fn shutdown(&self) {
677        self.inner.shutdown()
678    }
679    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
680        self.inner.shutdown_with_epitaph(status)
681    }
682
683    fn is_closed(&self) -> bool {
684        self.inner.channel().is_closed()
685    }
686    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
687        self.inner.channel().on_closed()
688    }
689
690    #[cfg(target_os = "fuchsia")]
691    fn signal_peer(
692        &self,
693        clear_mask: zx::Signals,
694        set_mask: zx::Signals,
695    ) -> Result<(), zx_status::Status> {
696        use fidl::Peered;
697        self.inner.channel().signal_peer(clear_mask, set_mask)
698    }
699}
700
701impl ResolverControlHandle {}
702
703#[must_use = "FIDL methods require a response to be sent"]
704#[derive(Debug)]
705pub struct ResolverResolveResponder {
706    control_handle: std::mem::ManuallyDrop<ResolverControlHandle>,
707    tx_id: u32,
708}
709
710/// Set the the channel to be shutdown (see [`ResolverControlHandle::shutdown`])
711/// if the responder is dropped without sending a response, so that the client
712/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
713impl std::ops::Drop for ResolverResolveResponder {
714    fn drop(&mut self) {
715        self.control_handle.shutdown();
716        // Safety: drops once, never accessed again
717        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
718    }
719}
720
721impl fidl::endpoints::Responder for ResolverResolveResponder {
722    type ControlHandle = ResolverControlHandle;
723
724    fn control_handle(&self) -> &ResolverControlHandle {
725        &self.control_handle
726    }
727
728    fn drop_without_shutdown(mut self) {
729        // Safety: drops once, never accessed again due to mem::forget
730        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
731        // Prevent Drop from running (which would shut down the channel)
732        std::mem::forget(self);
733    }
734}
735
736impl ResolverResolveResponder {
737    /// Sends a response to the FIDL transaction.
738    ///
739    /// Sets the channel to shutdown if an error occurs.
740    pub fn send(self, mut result: Result<Component, ResolverError>) -> Result<(), fidl::Error> {
741        let _result = self.send_raw(result);
742        if _result.is_err() {
743            self.control_handle.shutdown();
744        }
745        self.drop_without_shutdown();
746        _result
747    }
748
749    /// Similar to "send" but does not shutdown the channel if an error occurs.
750    pub fn send_no_shutdown_on_err(
751        self,
752        mut result: Result<Component, ResolverError>,
753    ) -> Result<(), fidl::Error> {
754        let _result = self.send_raw(result);
755        self.drop_without_shutdown();
756        _result
757    }
758
759    fn send_raw(&self, mut result: Result<Component, ResolverError>) -> Result<(), fidl::Error> {
760        self.control_handle
761            .inner
762            .send::<fidl::encoding::ResultType<ResolverResolveResponse, ResolverError>>(
763                result.as_mut().map_err(|e| *e).map(|component| (component,)),
764                self.tx_id,
765                0x57f9cfe88bf1f2e5,
766                fidl::encoding::DynamicFlags::empty(),
767            )
768    }
769}
770
771#[must_use = "FIDL methods require a response to be sent"]
772#[derive(Debug)]
773pub struct ResolverResolveWithContextResponder {
774    control_handle: std::mem::ManuallyDrop<ResolverControlHandle>,
775    tx_id: u32,
776}
777
778/// Set the the channel to be shutdown (see [`ResolverControlHandle::shutdown`])
779/// if the responder is dropped without sending a response, so that the client
780/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
781impl std::ops::Drop for ResolverResolveWithContextResponder {
782    fn drop(&mut self) {
783        self.control_handle.shutdown();
784        // Safety: drops once, never accessed again
785        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
786    }
787}
788
789impl fidl::endpoints::Responder for ResolverResolveWithContextResponder {
790    type ControlHandle = ResolverControlHandle;
791
792    fn control_handle(&self) -> &ResolverControlHandle {
793        &self.control_handle
794    }
795
796    fn drop_without_shutdown(mut self) {
797        // Safety: drops once, never accessed again due to mem::forget
798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
799        // Prevent Drop from running (which would shut down the channel)
800        std::mem::forget(self);
801    }
802}
803
804impl ResolverResolveWithContextResponder {
805    /// Sends a response to the FIDL transaction.
806    ///
807    /// Sets the channel to shutdown if an error occurs.
808    pub fn send(self, mut result: Result<Component, ResolverError>) -> Result<(), fidl::Error> {
809        let _result = self.send_raw(result);
810        if _result.is_err() {
811            self.control_handle.shutdown();
812        }
813        self.drop_without_shutdown();
814        _result
815    }
816
817    /// Similar to "send" but does not shutdown the channel if an error occurs.
818    pub fn send_no_shutdown_on_err(
819        self,
820        mut result: Result<Component, ResolverError>,
821    ) -> Result<(), fidl::Error> {
822        let _result = self.send_raw(result);
823        self.drop_without_shutdown();
824        _result
825    }
826
827    fn send_raw(&self, mut result: Result<Component, ResolverError>) -> Result<(), fidl::Error> {
828        self.control_handle.inner.send::<fidl::encoding::ResultType<
829            ResolverResolveWithContextResponse,
830            ResolverError,
831        >>(
832            result.as_mut().map_err(|e| *e).map(|component| (component,)),
833            self.tx_id,
834            0x4d64b0de827070bd,
835            fidl::encoding::DynamicFlags::empty(),
836        )
837    }
838}
839
840mod internal {
841    use super::*;
842
843    impl fidl::encoding::ResourceTypeMarker for ResolverResolveWithContextResponse {
844        type Borrowed<'a> = &'a mut Self;
845        fn take_or_borrow<'a>(
846            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
847        ) -> Self::Borrowed<'a> {
848            value
849        }
850    }
851
852    unsafe impl fidl::encoding::TypeMarker for ResolverResolveWithContextResponse {
853        type Owned = Self;
854
855        #[inline(always)]
856        fn inline_align(_context: fidl::encoding::Context) -> usize {
857            8
858        }
859
860        #[inline(always)]
861        fn inline_size(_context: fidl::encoding::Context) -> usize {
862            16
863        }
864    }
865
866    unsafe impl
867        fidl::encoding::Encode<
868            ResolverResolveWithContextResponse,
869            fidl::encoding::DefaultFuchsiaResourceDialect,
870        > for &mut ResolverResolveWithContextResponse
871    {
872        #[inline]
873        unsafe fn encode(
874            self,
875            encoder: &mut fidl::encoding::Encoder<
876                '_,
877                fidl::encoding::DefaultFuchsiaResourceDialect,
878            >,
879            offset: usize,
880            _depth: fidl::encoding::Depth,
881        ) -> fidl::Result<()> {
882            encoder.debug_check_bounds::<ResolverResolveWithContextResponse>(offset);
883            // Delegate to tuple encoding.
884            fidl::encoding::Encode::<
885                ResolverResolveWithContextResponse,
886                fidl::encoding::DefaultFuchsiaResourceDialect,
887            >::encode(
888                (<Component as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
889                    &mut self.component,
890                ),),
891                encoder,
892                offset,
893                _depth,
894            )
895        }
896    }
897    unsafe impl<T0: fidl::encoding::Encode<Component, fidl::encoding::DefaultFuchsiaResourceDialect>>
898        fidl::encoding::Encode<
899            ResolverResolveWithContextResponse,
900            fidl::encoding::DefaultFuchsiaResourceDialect,
901        > for (T0,)
902    {
903        #[inline]
904        unsafe fn encode(
905            self,
906            encoder: &mut fidl::encoding::Encoder<
907                '_,
908                fidl::encoding::DefaultFuchsiaResourceDialect,
909            >,
910            offset: usize,
911            depth: fidl::encoding::Depth,
912        ) -> fidl::Result<()> {
913            encoder.debug_check_bounds::<ResolverResolveWithContextResponse>(offset);
914            // Zero out padding regions. There's no need to apply masks
915            // because the unmasked parts will be overwritten by fields.
916            // Write the fields.
917            self.0.encode(encoder, offset + 0, depth)?;
918            Ok(())
919        }
920    }
921
922    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
923        for ResolverResolveWithContextResponse
924    {
925        #[inline(always)]
926        fn new_empty() -> Self {
927            Self {
928                component: fidl::new_empty!(
929                    Component,
930                    fidl::encoding::DefaultFuchsiaResourceDialect
931                ),
932            }
933        }
934
935        #[inline]
936        unsafe fn decode(
937            &mut self,
938            decoder: &mut fidl::encoding::Decoder<
939                '_,
940                fidl::encoding::DefaultFuchsiaResourceDialect,
941            >,
942            offset: usize,
943            _depth: fidl::encoding::Depth,
944        ) -> fidl::Result<()> {
945            decoder.debug_check_bounds::<Self>(offset);
946            // Verify that padding bytes are zero.
947            fidl::decode!(
948                Component,
949                fidl::encoding::DefaultFuchsiaResourceDialect,
950                &mut self.component,
951                decoder,
952                offset + 0,
953                _depth
954            )?;
955            Ok(())
956        }
957    }
958
959    impl fidl::encoding::ResourceTypeMarker for ResolverResolveResponse {
960        type Borrowed<'a> = &'a mut Self;
961        fn take_or_borrow<'a>(
962            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
963        ) -> Self::Borrowed<'a> {
964            value
965        }
966    }
967
968    unsafe impl fidl::encoding::TypeMarker for ResolverResolveResponse {
969        type Owned = Self;
970
971        #[inline(always)]
972        fn inline_align(_context: fidl::encoding::Context) -> usize {
973            8
974        }
975
976        #[inline(always)]
977        fn inline_size(_context: fidl::encoding::Context) -> usize {
978            16
979        }
980    }
981
982    unsafe impl
983        fidl::encoding::Encode<
984            ResolverResolveResponse,
985            fidl::encoding::DefaultFuchsiaResourceDialect,
986        > for &mut ResolverResolveResponse
987    {
988        #[inline]
989        unsafe fn encode(
990            self,
991            encoder: &mut fidl::encoding::Encoder<
992                '_,
993                fidl::encoding::DefaultFuchsiaResourceDialect,
994            >,
995            offset: usize,
996            _depth: fidl::encoding::Depth,
997        ) -> fidl::Result<()> {
998            encoder.debug_check_bounds::<ResolverResolveResponse>(offset);
999            // Delegate to tuple encoding.
1000            fidl::encoding::Encode::<
1001                ResolverResolveResponse,
1002                fidl::encoding::DefaultFuchsiaResourceDialect,
1003            >::encode(
1004                (<Component as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1005                    &mut self.component,
1006                ),),
1007                encoder,
1008                offset,
1009                _depth,
1010            )
1011        }
1012    }
1013    unsafe impl<T0: fidl::encoding::Encode<Component, fidl::encoding::DefaultFuchsiaResourceDialect>>
1014        fidl::encoding::Encode<
1015            ResolverResolveResponse,
1016            fidl::encoding::DefaultFuchsiaResourceDialect,
1017        > for (T0,)
1018    {
1019        #[inline]
1020        unsafe fn encode(
1021            self,
1022            encoder: &mut fidl::encoding::Encoder<
1023                '_,
1024                fidl::encoding::DefaultFuchsiaResourceDialect,
1025            >,
1026            offset: usize,
1027            depth: fidl::encoding::Depth,
1028        ) -> fidl::Result<()> {
1029            encoder.debug_check_bounds::<ResolverResolveResponse>(offset);
1030            // Zero out padding regions. There's no need to apply masks
1031            // because the unmasked parts will be overwritten by fields.
1032            // Write the fields.
1033            self.0.encode(encoder, offset + 0, depth)?;
1034            Ok(())
1035        }
1036    }
1037
1038    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1039        for ResolverResolveResponse
1040    {
1041        #[inline(always)]
1042        fn new_empty() -> Self {
1043            Self {
1044                component: fidl::new_empty!(
1045                    Component,
1046                    fidl::encoding::DefaultFuchsiaResourceDialect
1047                ),
1048            }
1049        }
1050
1051        #[inline]
1052        unsafe fn decode(
1053            &mut self,
1054            decoder: &mut fidl::encoding::Decoder<
1055                '_,
1056                fidl::encoding::DefaultFuchsiaResourceDialect,
1057            >,
1058            offset: usize,
1059            _depth: fidl::encoding::Depth,
1060        ) -> fidl::Result<()> {
1061            decoder.debug_check_bounds::<Self>(offset);
1062            // Verify that padding bytes are zero.
1063            fidl::decode!(
1064                Component,
1065                fidl::encoding::DefaultFuchsiaResourceDialect,
1066                &mut self.component,
1067                decoder,
1068                offset + 0,
1069                _depth
1070            )?;
1071            Ok(())
1072        }
1073    }
1074
1075    impl Component {
1076        #[inline(always)]
1077        fn max_ordinal_present(&self) -> u64 {
1078            if let Some(_) = self.abi_revision {
1079                return 6;
1080            }
1081            if let Some(_) = self.resolution_context {
1082                return 5;
1083            }
1084            if let Some(_) = self.config_values {
1085                return 4;
1086            }
1087            if let Some(_) = self.package {
1088                return 3;
1089            }
1090            if let Some(_) = self.decl {
1091                return 2;
1092            }
1093            if let Some(_) = self.url {
1094                return 1;
1095            }
1096            0
1097        }
1098    }
1099
1100    impl fidl::encoding::ResourceTypeMarker for Component {
1101        type Borrowed<'a> = &'a mut Self;
1102        fn take_or_borrow<'a>(
1103            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1104        ) -> Self::Borrowed<'a> {
1105            value
1106        }
1107    }
1108
1109    unsafe impl fidl::encoding::TypeMarker for Component {
1110        type Owned = Self;
1111
1112        #[inline(always)]
1113        fn inline_align(_context: fidl::encoding::Context) -> usize {
1114            8
1115        }
1116
1117        #[inline(always)]
1118        fn inline_size(_context: fidl::encoding::Context) -> usize {
1119            16
1120        }
1121    }
1122
1123    unsafe impl fidl::encoding::Encode<Component, fidl::encoding::DefaultFuchsiaResourceDialect>
1124        for &mut Component
1125    {
1126        unsafe fn encode(
1127            self,
1128            encoder: &mut fidl::encoding::Encoder<
1129                '_,
1130                fidl::encoding::DefaultFuchsiaResourceDialect,
1131            >,
1132            offset: usize,
1133            mut depth: fidl::encoding::Depth,
1134        ) -> fidl::Result<()> {
1135            encoder.debug_check_bounds::<Component>(offset);
1136            // Vector header
1137            let max_ordinal: u64 = self.max_ordinal_present();
1138            encoder.write_num(max_ordinal, offset);
1139            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1140            // Calling encoder.out_of_line_offset(0) is not allowed.
1141            if max_ordinal == 0 {
1142                return Ok(());
1143            }
1144            depth.increment()?;
1145            let envelope_size = 8;
1146            let bytes_len = max_ordinal as usize * envelope_size;
1147            #[allow(unused_variables)]
1148            let offset = encoder.out_of_line_offset(bytes_len);
1149            let mut _prev_end_offset: usize = 0;
1150            if 1 > max_ordinal {
1151                return Ok(());
1152            }
1153
1154            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1155            // are envelope_size bytes.
1156            let cur_offset: usize = (1 - 1) * envelope_size;
1157
1158            // Zero reserved fields.
1159            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1160
1161            // Safety:
1162            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1163            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1164            //   envelope_size bytes, there is always sufficient room.
1165            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<2083>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1166            self.url.as_ref().map(<fidl::encoding::BoundedString<2083> as fidl::encoding::ValueTypeMarker>::borrow),
1167            encoder, offset + cur_offset, depth
1168        )?;
1169
1170            _prev_end_offset = cur_offset + envelope_size;
1171            if 2 > max_ordinal {
1172                return Ok(());
1173            }
1174
1175            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1176            // are envelope_size bytes.
1177            let cur_offset: usize = (2 - 1) * envelope_size;
1178
1179            // Zero reserved fields.
1180            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1181
1182            // Safety:
1183            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1184            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1185            //   envelope_size bytes, there is always sufficient room.
1186            fidl::encoding::encode_in_envelope_optional::<
1187                fidl_fuchsia_mem::Data,
1188                fidl::encoding::DefaultFuchsiaResourceDialect,
1189            >(
1190                self.decl.as_mut().map(
1191                    <fidl_fuchsia_mem::Data as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1192                ),
1193                encoder,
1194                offset + cur_offset,
1195                depth,
1196            )?;
1197
1198            _prev_end_offset = cur_offset + envelope_size;
1199            if 3 > max_ordinal {
1200                return Ok(());
1201            }
1202
1203            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1204            // are envelope_size bytes.
1205            let cur_offset: usize = (3 - 1) * envelope_size;
1206
1207            // Zero reserved fields.
1208            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1209
1210            // Safety:
1211            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1212            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1213            //   envelope_size bytes, there is always sufficient room.
1214            fidl::encoding::encode_in_envelope_optional::<
1215                Package,
1216                fidl::encoding::DefaultFuchsiaResourceDialect,
1217            >(
1218                self.package
1219                    .as_mut()
1220                    .map(<Package as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1221                encoder,
1222                offset + cur_offset,
1223                depth,
1224            )?;
1225
1226            _prev_end_offset = cur_offset + envelope_size;
1227            if 4 > max_ordinal {
1228                return Ok(());
1229            }
1230
1231            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1232            // are envelope_size bytes.
1233            let cur_offset: usize = (4 - 1) * envelope_size;
1234
1235            // Zero reserved fields.
1236            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1237
1238            // Safety:
1239            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1240            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1241            //   envelope_size bytes, there is always sufficient room.
1242            fidl::encoding::encode_in_envelope_optional::<
1243                fidl_fuchsia_mem::Data,
1244                fidl::encoding::DefaultFuchsiaResourceDialect,
1245            >(
1246                self.config_values.as_mut().map(
1247                    <fidl_fuchsia_mem::Data as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1248                ),
1249                encoder,
1250                offset + cur_offset,
1251                depth,
1252            )?;
1253
1254            _prev_end_offset = cur_offset + envelope_size;
1255            if 5 > max_ordinal {
1256                return Ok(());
1257            }
1258
1259            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1260            // are envelope_size bytes.
1261            let cur_offset: usize = (5 - 1) * envelope_size;
1262
1263            // Zero reserved fields.
1264            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1265
1266            // Safety:
1267            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1268            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1269            //   envelope_size bytes, there is always sufficient room.
1270            fidl::encoding::encode_in_envelope_optional::<
1271                Context,
1272                fidl::encoding::DefaultFuchsiaResourceDialect,
1273            >(
1274                self.resolution_context
1275                    .as_ref()
1276                    .map(<Context as fidl::encoding::ValueTypeMarker>::borrow),
1277                encoder,
1278                offset + cur_offset,
1279                depth,
1280            )?;
1281
1282            _prev_end_offset = cur_offset + envelope_size;
1283            if 6 > max_ordinal {
1284                return Ok(());
1285            }
1286
1287            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1288            // are envelope_size bytes.
1289            let cur_offset: usize = (6 - 1) * envelope_size;
1290
1291            // Zero reserved fields.
1292            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1293
1294            // Safety:
1295            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1296            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1297            //   envelope_size bytes, there is always sufficient room.
1298            fidl::encoding::encode_in_envelope_optional::<
1299                u64,
1300                fidl::encoding::DefaultFuchsiaResourceDialect,
1301            >(
1302                self.abi_revision.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1303                encoder,
1304                offset + cur_offset,
1305                depth,
1306            )?;
1307
1308            _prev_end_offset = cur_offset + envelope_size;
1309
1310            Ok(())
1311        }
1312    }
1313
1314    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Component {
1315        #[inline(always)]
1316        fn new_empty() -> Self {
1317            Self::default()
1318        }
1319
1320        unsafe fn decode(
1321            &mut self,
1322            decoder: &mut fidl::encoding::Decoder<
1323                '_,
1324                fidl::encoding::DefaultFuchsiaResourceDialect,
1325            >,
1326            offset: usize,
1327            mut depth: fidl::encoding::Depth,
1328        ) -> fidl::Result<()> {
1329            decoder.debug_check_bounds::<Self>(offset);
1330            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1331                None => return Err(fidl::Error::NotNullable),
1332                Some(len) => len,
1333            };
1334            // Calling decoder.out_of_line_offset(0) is not allowed.
1335            if len == 0 {
1336                return Ok(());
1337            };
1338            depth.increment()?;
1339            let envelope_size = 8;
1340            let bytes_len = len * envelope_size;
1341            let offset = decoder.out_of_line_offset(bytes_len)?;
1342            // Decode the envelope for each type.
1343            let mut _next_ordinal_to_read = 0;
1344            let mut next_offset = offset;
1345            let end_offset = offset + bytes_len;
1346            _next_ordinal_to_read += 1;
1347            if next_offset >= end_offset {
1348                return Ok(());
1349            }
1350
1351            // Decode unknown envelopes for gaps in ordinals.
1352            while _next_ordinal_to_read < 1 {
1353                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1354                _next_ordinal_to_read += 1;
1355                next_offset += envelope_size;
1356            }
1357
1358            let next_out_of_line = decoder.next_out_of_line();
1359            let handles_before = decoder.remaining_handles();
1360            if let Some((inlined, num_bytes, num_handles)) =
1361                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1362            {
1363                let member_inline_size = <fidl::encoding::BoundedString<2083> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1364                if inlined != (member_inline_size <= 4) {
1365                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1366                }
1367                let inner_offset;
1368                let mut inner_depth = depth.clone();
1369                if inlined {
1370                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1371                    inner_offset = next_offset;
1372                } else {
1373                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1374                    inner_depth.increment()?;
1375                }
1376                let val_ref = self.url.get_or_insert_with(|| {
1377                    fidl::new_empty!(
1378                        fidl::encoding::BoundedString<2083>,
1379                        fidl::encoding::DefaultFuchsiaResourceDialect
1380                    )
1381                });
1382                fidl::decode!(
1383                    fidl::encoding::BoundedString<2083>,
1384                    fidl::encoding::DefaultFuchsiaResourceDialect,
1385                    val_ref,
1386                    decoder,
1387                    inner_offset,
1388                    inner_depth
1389                )?;
1390                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1391                {
1392                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1393                }
1394                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1395                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1396                }
1397            }
1398
1399            next_offset += envelope_size;
1400            _next_ordinal_to_read += 1;
1401            if next_offset >= end_offset {
1402                return Ok(());
1403            }
1404
1405            // Decode unknown envelopes for gaps in ordinals.
1406            while _next_ordinal_to_read < 2 {
1407                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1408                _next_ordinal_to_read += 1;
1409                next_offset += envelope_size;
1410            }
1411
1412            let next_out_of_line = decoder.next_out_of_line();
1413            let handles_before = decoder.remaining_handles();
1414            if let Some((inlined, num_bytes, num_handles)) =
1415                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1416            {
1417                let member_inline_size =
1418                    <fidl_fuchsia_mem::Data as fidl::encoding::TypeMarker>::inline_size(
1419                        decoder.context,
1420                    );
1421                if inlined != (member_inline_size <= 4) {
1422                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1423                }
1424                let inner_offset;
1425                let mut inner_depth = depth.clone();
1426                if inlined {
1427                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1428                    inner_offset = next_offset;
1429                } else {
1430                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1431                    inner_depth.increment()?;
1432                }
1433                let val_ref = self.decl.get_or_insert_with(|| {
1434                    fidl::new_empty!(
1435                        fidl_fuchsia_mem::Data,
1436                        fidl::encoding::DefaultFuchsiaResourceDialect
1437                    )
1438                });
1439                fidl::decode!(
1440                    fidl_fuchsia_mem::Data,
1441                    fidl::encoding::DefaultFuchsiaResourceDialect,
1442                    val_ref,
1443                    decoder,
1444                    inner_offset,
1445                    inner_depth
1446                )?;
1447                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1448                {
1449                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1450                }
1451                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1452                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1453                }
1454            }
1455
1456            next_offset += envelope_size;
1457            _next_ordinal_to_read += 1;
1458            if next_offset >= end_offset {
1459                return Ok(());
1460            }
1461
1462            // Decode unknown envelopes for gaps in ordinals.
1463            while _next_ordinal_to_read < 3 {
1464                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1465                _next_ordinal_to_read += 1;
1466                next_offset += envelope_size;
1467            }
1468
1469            let next_out_of_line = decoder.next_out_of_line();
1470            let handles_before = decoder.remaining_handles();
1471            if let Some((inlined, num_bytes, num_handles)) =
1472                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1473            {
1474                let member_inline_size =
1475                    <Package as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1476                if inlined != (member_inline_size <= 4) {
1477                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1478                }
1479                let inner_offset;
1480                let mut inner_depth = depth.clone();
1481                if inlined {
1482                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1483                    inner_offset = next_offset;
1484                } else {
1485                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1486                    inner_depth.increment()?;
1487                }
1488                let val_ref = self.package.get_or_insert_with(|| {
1489                    fidl::new_empty!(Package, fidl::encoding::DefaultFuchsiaResourceDialect)
1490                });
1491                fidl::decode!(
1492                    Package,
1493                    fidl::encoding::DefaultFuchsiaResourceDialect,
1494                    val_ref,
1495                    decoder,
1496                    inner_offset,
1497                    inner_depth
1498                )?;
1499                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1500                {
1501                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1502                }
1503                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1504                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1505                }
1506            }
1507
1508            next_offset += envelope_size;
1509            _next_ordinal_to_read += 1;
1510            if next_offset >= end_offset {
1511                return Ok(());
1512            }
1513
1514            // Decode unknown envelopes for gaps in ordinals.
1515            while _next_ordinal_to_read < 4 {
1516                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1517                _next_ordinal_to_read += 1;
1518                next_offset += envelope_size;
1519            }
1520
1521            let next_out_of_line = decoder.next_out_of_line();
1522            let handles_before = decoder.remaining_handles();
1523            if let Some((inlined, num_bytes, num_handles)) =
1524                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1525            {
1526                let member_inline_size =
1527                    <fidl_fuchsia_mem::Data as fidl::encoding::TypeMarker>::inline_size(
1528                        decoder.context,
1529                    );
1530                if inlined != (member_inline_size <= 4) {
1531                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1532                }
1533                let inner_offset;
1534                let mut inner_depth = depth.clone();
1535                if inlined {
1536                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1537                    inner_offset = next_offset;
1538                } else {
1539                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1540                    inner_depth.increment()?;
1541                }
1542                let val_ref = self.config_values.get_or_insert_with(|| {
1543                    fidl::new_empty!(
1544                        fidl_fuchsia_mem::Data,
1545                        fidl::encoding::DefaultFuchsiaResourceDialect
1546                    )
1547                });
1548                fidl::decode!(
1549                    fidl_fuchsia_mem::Data,
1550                    fidl::encoding::DefaultFuchsiaResourceDialect,
1551                    val_ref,
1552                    decoder,
1553                    inner_offset,
1554                    inner_depth
1555                )?;
1556                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1557                {
1558                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1559                }
1560                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1561                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1562                }
1563            }
1564
1565            next_offset += envelope_size;
1566            _next_ordinal_to_read += 1;
1567            if next_offset >= end_offset {
1568                return Ok(());
1569            }
1570
1571            // Decode unknown envelopes for gaps in ordinals.
1572            while _next_ordinal_to_read < 5 {
1573                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1574                _next_ordinal_to_read += 1;
1575                next_offset += envelope_size;
1576            }
1577
1578            let next_out_of_line = decoder.next_out_of_line();
1579            let handles_before = decoder.remaining_handles();
1580            if let Some((inlined, num_bytes, num_handles)) =
1581                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1582            {
1583                let member_inline_size =
1584                    <Context as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1585                if inlined != (member_inline_size <= 4) {
1586                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1587                }
1588                let inner_offset;
1589                let mut inner_depth = depth.clone();
1590                if inlined {
1591                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1592                    inner_offset = next_offset;
1593                } else {
1594                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1595                    inner_depth.increment()?;
1596                }
1597                let val_ref = self.resolution_context.get_or_insert_with(|| {
1598                    fidl::new_empty!(Context, fidl::encoding::DefaultFuchsiaResourceDialect)
1599                });
1600                fidl::decode!(
1601                    Context,
1602                    fidl::encoding::DefaultFuchsiaResourceDialect,
1603                    val_ref,
1604                    decoder,
1605                    inner_offset,
1606                    inner_depth
1607                )?;
1608                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1609                {
1610                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1611                }
1612                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1613                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1614                }
1615            }
1616
1617            next_offset += envelope_size;
1618            _next_ordinal_to_read += 1;
1619            if next_offset >= end_offset {
1620                return Ok(());
1621            }
1622
1623            // Decode unknown envelopes for gaps in ordinals.
1624            while _next_ordinal_to_read < 6 {
1625                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1626                _next_ordinal_to_read += 1;
1627                next_offset += envelope_size;
1628            }
1629
1630            let next_out_of_line = decoder.next_out_of_line();
1631            let handles_before = decoder.remaining_handles();
1632            if let Some((inlined, num_bytes, num_handles)) =
1633                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1634            {
1635                let member_inline_size =
1636                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1637                if inlined != (member_inline_size <= 4) {
1638                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1639                }
1640                let inner_offset;
1641                let mut inner_depth = depth.clone();
1642                if inlined {
1643                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1644                    inner_offset = next_offset;
1645                } else {
1646                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1647                    inner_depth.increment()?;
1648                }
1649                let val_ref = self.abi_revision.get_or_insert_with(|| {
1650                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
1651                });
1652                fidl::decode!(
1653                    u64,
1654                    fidl::encoding::DefaultFuchsiaResourceDialect,
1655                    val_ref,
1656                    decoder,
1657                    inner_offset,
1658                    inner_depth
1659                )?;
1660                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1661                {
1662                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1663                }
1664                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1665                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1666                }
1667            }
1668
1669            next_offset += envelope_size;
1670
1671            // Decode the remaining unknown envelopes.
1672            while next_offset < end_offset {
1673                _next_ordinal_to_read += 1;
1674                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1675                next_offset += envelope_size;
1676            }
1677
1678            Ok(())
1679        }
1680    }
1681
1682    impl Package {
1683        #[inline(always)]
1684        fn max_ordinal_present(&self) -> u64 {
1685            if let Some(_) = self.directory {
1686                return 2;
1687            }
1688            if let Some(_) = self.url {
1689                return 1;
1690            }
1691            0
1692        }
1693    }
1694
1695    impl fidl::encoding::ResourceTypeMarker for Package {
1696        type Borrowed<'a> = &'a mut Self;
1697        fn take_or_borrow<'a>(
1698            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1699        ) -> Self::Borrowed<'a> {
1700            value
1701        }
1702    }
1703
1704    unsafe impl fidl::encoding::TypeMarker for Package {
1705        type Owned = Self;
1706
1707        #[inline(always)]
1708        fn inline_align(_context: fidl::encoding::Context) -> usize {
1709            8
1710        }
1711
1712        #[inline(always)]
1713        fn inline_size(_context: fidl::encoding::Context) -> usize {
1714            16
1715        }
1716    }
1717
1718    unsafe impl fidl::encoding::Encode<Package, fidl::encoding::DefaultFuchsiaResourceDialect>
1719        for &mut Package
1720    {
1721        unsafe fn encode(
1722            self,
1723            encoder: &mut fidl::encoding::Encoder<
1724                '_,
1725                fidl::encoding::DefaultFuchsiaResourceDialect,
1726            >,
1727            offset: usize,
1728            mut depth: fidl::encoding::Depth,
1729        ) -> fidl::Result<()> {
1730            encoder.debug_check_bounds::<Package>(offset);
1731            // Vector header
1732            let max_ordinal: u64 = self.max_ordinal_present();
1733            encoder.write_num(max_ordinal, offset);
1734            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1735            // Calling encoder.out_of_line_offset(0) is not allowed.
1736            if max_ordinal == 0 {
1737                return Ok(());
1738            }
1739            depth.increment()?;
1740            let envelope_size = 8;
1741            let bytes_len = max_ordinal as usize * envelope_size;
1742            #[allow(unused_variables)]
1743            let offset = encoder.out_of_line_offset(bytes_len);
1744            let mut _prev_end_offset: usize = 0;
1745            if 1 > max_ordinal {
1746                return Ok(());
1747            }
1748
1749            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1750            // are envelope_size bytes.
1751            let cur_offset: usize = (1 - 1) * envelope_size;
1752
1753            // Zero reserved fields.
1754            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1755
1756            // Safety:
1757            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1758            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1759            //   envelope_size bytes, there is always sufficient room.
1760            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<2083>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1761            self.url.as_ref().map(<fidl::encoding::BoundedString<2083> as fidl::encoding::ValueTypeMarker>::borrow),
1762            encoder, offset + cur_offset, depth
1763        )?;
1764
1765            _prev_end_offset = cur_offset + envelope_size;
1766            if 2 > max_ordinal {
1767                return Ok(());
1768            }
1769
1770            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1771            // are envelope_size bytes.
1772            let cur_offset: usize = (2 - 1) * envelope_size;
1773
1774            // Zero reserved fields.
1775            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1776
1777            // Safety:
1778            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1779            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1780            //   envelope_size bytes, there is always sufficient room.
1781            fidl::encoding::encode_in_envelope_optional::<
1782                fidl::encoding::Endpoint<
1783                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1784                >,
1785                fidl::encoding::DefaultFuchsiaResourceDialect,
1786            >(
1787                self.directory.as_mut().map(
1788                    <fidl::encoding::Endpoint<
1789                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1790                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1791                ),
1792                encoder,
1793                offset + cur_offset,
1794                depth,
1795            )?;
1796
1797            _prev_end_offset = cur_offset + envelope_size;
1798
1799            Ok(())
1800        }
1801    }
1802
1803    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Package {
1804        #[inline(always)]
1805        fn new_empty() -> Self {
1806            Self::default()
1807        }
1808
1809        unsafe fn decode(
1810            &mut self,
1811            decoder: &mut fidl::encoding::Decoder<
1812                '_,
1813                fidl::encoding::DefaultFuchsiaResourceDialect,
1814            >,
1815            offset: usize,
1816            mut depth: fidl::encoding::Depth,
1817        ) -> fidl::Result<()> {
1818            decoder.debug_check_bounds::<Self>(offset);
1819            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1820                None => return Err(fidl::Error::NotNullable),
1821                Some(len) => len,
1822            };
1823            // Calling decoder.out_of_line_offset(0) is not allowed.
1824            if len == 0 {
1825                return Ok(());
1826            };
1827            depth.increment()?;
1828            let envelope_size = 8;
1829            let bytes_len = len * envelope_size;
1830            let offset = decoder.out_of_line_offset(bytes_len)?;
1831            // Decode the envelope for each type.
1832            let mut _next_ordinal_to_read = 0;
1833            let mut next_offset = offset;
1834            let end_offset = offset + bytes_len;
1835            _next_ordinal_to_read += 1;
1836            if next_offset >= end_offset {
1837                return Ok(());
1838            }
1839
1840            // Decode unknown envelopes for gaps in ordinals.
1841            while _next_ordinal_to_read < 1 {
1842                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1843                _next_ordinal_to_read += 1;
1844                next_offset += envelope_size;
1845            }
1846
1847            let next_out_of_line = decoder.next_out_of_line();
1848            let handles_before = decoder.remaining_handles();
1849            if let Some((inlined, num_bytes, num_handles)) =
1850                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1851            {
1852                let member_inline_size = <fidl::encoding::BoundedString<2083> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1853                if inlined != (member_inline_size <= 4) {
1854                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1855                }
1856                let inner_offset;
1857                let mut inner_depth = depth.clone();
1858                if inlined {
1859                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1860                    inner_offset = next_offset;
1861                } else {
1862                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1863                    inner_depth.increment()?;
1864                }
1865                let val_ref = self.url.get_or_insert_with(|| {
1866                    fidl::new_empty!(
1867                        fidl::encoding::BoundedString<2083>,
1868                        fidl::encoding::DefaultFuchsiaResourceDialect
1869                    )
1870                });
1871                fidl::decode!(
1872                    fidl::encoding::BoundedString<2083>,
1873                    fidl::encoding::DefaultFuchsiaResourceDialect,
1874                    val_ref,
1875                    decoder,
1876                    inner_offset,
1877                    inner_depth
1878                )?;
1879                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1880                {
1881                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1882                }
1883                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1884                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1885                }
1886            }
1887
1888            next_offset += envelope_size;
1889            _next_ordinal_to_read += 1;
1890            if next_offset >= end_offset {
1891                return Ok(());
1892            }
1893
1894            // Decode unknown envelopes for gaps in ordinals.
1895            while _next_ordinal_to_read < 2 {
1896                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1897                _next_ordinal_to_read += 1;
1898                next_offset += envelope_size;
1899            }
1900
1901            let next_out_of_line = decoder.next_out_of_line();
1902            let handles_before = decoder.remaining_handles();
1903            if let Some((inlined, num_bytes, num_handles)) =
1904                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1905            {
1906                let member_inline_size = <fidl::encoding::Endpoint<
1907                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1908                > as fidl::encoding::TypeMarker>::inline_size(
1909                    decoder.context
1910                );
1911                if inlined != (member_inline_size <= 4) {
1912                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1913                }
1914                let inner_offset;
1915                let mut inner_depth = depth.clone();
1916                if inlined {
1917                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1918                    inner_offset = next_offset;
1919                } else {
1920                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1921                    inner_depth.increment()?;
1922                }
1923                let val_ref = self.directory.get_or_insert_with(|| {
1924                    fidl::new_empty!(
1925                        fidl::encoding::Endpoint<
1926                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1927                        >,
1928                        fidl::encoding::DefaultFuchsiaResourceDialect
1929                    )
1930                });
1931                fidl::decode!(
1932                    fidl::encoding::Endpoint<
1933                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::DirectoryMarker>,
1934                    >,
1935                    fidl::encoding::DefaultFuchsiaResourceDialect,
1936                    val_ref,
1937                    decoder,
1938                    inner_offset,
1939                    inner_depth
1940                )?;
1941                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1942                {
1943                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1944                }
1945                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1946                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1947                }
1948            }
1949
1950            next_offset += envelope_size;
1951
1952            // Decode the remaining unknown envelopes.
1953            while next_offset < end_offset {
1954                _next_ordinal_to_read += 1;
1955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1956                next_offset += envelope_size;
1957            }
1958
1959            Ok(())
1960        }
1961    }
1962}