fdomain_fuchsia_component_runner/
fdomain_fuchsia_component_runner.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 fdomain_client::fidl::{ControlHandle as _, FDomainFlexibleIntoResult as _, Responder as _};
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9pub use fidl_fuchsia_component_runner__common::*;
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Debug, PartialEq)]
14pub struct ComponentControllerOnPublishDiagnosticsRequest {
15    pub payload: ComponentDiagnostics,
16}
17
18impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
19    for ComponentControllerOnPublishDiagnosticsRequest
20{
21}
22
23#[derive(Debug, PartialEq)]
24pub struct ComponentRunnerStartRequest {
25    pub start_info: ComponentStartInfo,
26    pub controller: fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
27}
28
29impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
30    for ComponentRunnerStartRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct TaskProviderGetJobResponse {
36    pub job: fdomain_client::Job,
37}
38
39impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for TaskProviderGetJobResponse {}
40
41#[derive(Debug, Default, PartialEq)]
42pub struct ComponentControllerOnEscrowRequest {
43    /// Escrow the outgoing directory server endpoint. Whenever the
44    /// component is started, the framework will return this channel via
45    /// [`ComponentStartInfo.outgoing_dir`].
46    pub outgoing_dir: Option<fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>>,
47    /// Escrow some user defined state. Whenever the component is started,
48    /// the framework will return these handles via
49    /// [`ComponentStartInfo.escrowed_dictionary`].
50    ///
51    /// The framework will not wait for any signals on these objects.
52    ///
53    /// ## Example
54    ///
55    /// Let's say a component needs to escrow an event pair that represents
56    /// the result of some expensive calculation. It can create a
57    /// dictionary, put the event pair inside with an appropriate key
58    /// (e.g. `"my_event_pair"`), then check for that entry on startup.
59    /// Note that this is deprecated, please use
60    /// `escrowed_dictionary_handle` instead.
61    pub escrowed_dictionary: Option<fdomain_fuchsia_component_sandbox::DictionaryRef>,
62    /// Escrow some user defined state. Whenever the component is started,
63    /// the framework will return these handles via
64    /// [`ComponentStartInfo.escrowed_dictionary`].
65    ///
66    /// The framework will not wait for any signals on these objects.
67    ///
68    /// ## Example
69    ///
70    /// Let's say a component needs to escrow an event pair that represents
71    /// the result of some expensive calculation. It can create a
72    /// dictionary, put the event pair inside with an appropriate key
73    /// (e.g. `"my_event_pair"`), then check for that entry on startup.
74    pub escrowed_dictionary_handle: Option<fdomain_client::EventPair>,
75    #[doc(hidden)]
76    pub __source_breaking: fidl::marker::SourceBreaking,
77}
78
79impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect>
80    for ComponentControllerOnEscrowRequest
81{
82}
83
84#[derive(Debug, Default, PartialEq)]
85pub struct ComponentDiagnostics {
86    pub tasks: Option<ComponentTasks>,
87    #[doc(hidden)]
88    pub __source_breaking: fidl::marker::SourceBreaking,
89}
90
91impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ComponentDiagnostics {}
92
93/// A single component namespace entry, which describes a namespace mount point
94/// (`path`) and the directory backing it (`directory`). This type is usually
95/// composed inside a vector.  See `ComponentStartInfo.ns` for more details.
96#[derive(Debug, Default, PartialEq)]
97pub struct ComponentNamespaceEntry {
98    /// The mount point for the directory, including a
99    /// leading slash. For example: "/pkg", "/svc", or "/config/data".
100    pub path: Option<String>,
101    /// The directory mounted at the above `path`.
102    pub directory: Option<fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>>,
103    #[doc(hidden)]
104    pub __source_breaking: fidl::marker::SourceBreaking,
105}
106
107impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ComponentNamespaceEntry {}
108
109/// Parameters for starting a new component instance.
110#[derive(Debug, Default, PartialEq)]
111pub struct ComponentStartInfo {
112    /// The URL of the component. Called `resolved_url` instead of just `url`
113    /// for historical reasons.
114    pub resolved_url: Option<String>,
115    /// The component's program declaration.
116    /// This information originates from `ComponentDecl.program`.
117    pub program: Option<fdomain_fuchsia_data::Dictionary>,
118    /// The namespace to provide to the component instance.
119    ///
120    /// A namespace specifies the set of directories that a component instance
121    /// receives at start-up. Through the namespace directories, a component
122    /// may access capabilities available to it. The contents of the namespace
123    /// are mainly determined by the component's `use` declarations but may
124    /// also contain additional capabilities automatically provided by the
125    /// framework.
126    ///
127    /// By convention, a component's namespace typically contains some or all
128    /// of the following directories:
129    ///
130    /// - "/svc": A directory containing services that the component requested
131    ///           to use via its "import" declarations.
132    /// - "/pkg": A directory containing the component's package, including its
133    ///           binaries, libraries, and other assets.
134    ///
135    /// The mount points specified in each entry must be unique and
136    /// non-overlapping. For example, [{"/foo", ..}, {"/foo/bar", ..}] is
137    /// invalid.
138    pub ns: Option<Vec<ComponentNamespaceEntry>>,
139    /// The directory this component serves.
140    pub outgoing_dir: Option<fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>>,
141    /// The directory served by the runner to present runtime information about
142    /// the component. The runner must either serve it, or drop it to avoid
143    /// blocking any consumers indefinitely.
144    pub runtime_dir: Option<fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>>,
145    /// The numbered handles that were passed to the component.
146    ///
147    /// If the component does not support numbered handles, the runner is expected
148    /// to close the handles.
149    pub numbered_handles: Option<Vec<fdomain_fuchsia_process::HandleInfo>>,
150    /// Binary representation of the component's configuration.
151    ///
152    /// # Layout
153    ///
154    /// The first 2 bytes of the data should be interpreted as an unsigned 16-bit
155    /// little-endian integer which denotes the number of bytes following it that
156    /// contain the configuration checksum. After the checksum, all the remaining
157    /// bytes are a persistent FIDL message of a top-level struct. The struct's
158    /// fields match the configuration fields of the component's compiled manifest
159    /// in the same order.
160    pub encoded_config: Option<fdomain_fuchsia_mem::Data>,
161    /// An eventpair that debuggers can use to defer the launch of the component.
162    ///
163    /// For example, ELF runners hold off from creating processes in the component
164    /// until ZX_EVENTPAIR_PEER_CLOSED is signaled on this eventpair. They also
165    /// ensure that runtime_dir is served before waiting on this eventpair.
166    /// ELF debuggers can query the runtime_dir to decide whether to attach before
167    /// they drop the other side of the eventpair, which is sent in the payload of
168    /// the DebugStarted event in fuchsia.component.events.
169    pub break_on_start: Option<fdomain_client::EventPair>,
170    /// An opaque token that represents the component instance.
171    ///
172    /// The `fuchsia.component/Introspector` protocol may be used to get the
173    /// string moniker of the instance from this token.
174    ///
175    /// Runners may publish this token as part of diagnostics information, to
176    /// identify the running component without knowing its moniker.
177    ///
178    /// The token is invalidated when the component instance is destroyed.
179    pub component_instance: Option<fdomain_client::Event>,
180    /// A dictionary containing data and handles that the component has escrowed
181    /// during its previous execution via [`ComponentController.OnEscrow`]. Note
182    /// that this field is considered deprecated, please use
183    /// `escrowed_dictionary_handle` instead.
184    pub escrowed_dictionary: Option<fdomain_fuchsia_component_sandbox::DictionaryRef>,
185    /// A dictionary containing data and handles that the component has escrowed
186    /// during its previous execution via [`ComponentController.OnEscrow`].
187    pub escrowed_dictionary_handle: Option<fdomain_client::EventPair>,
188    #[doc(hidden)]
189    pub __source_breaking: fidl::marker::SourceBreaking,
190}
191
192impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ComponentStartInfo {}
193
194#[derive(Debug, Default, PartialEq)]
195pub struct ComponentStopInfo {
196    /// The component's termination status, as documented on [ComponentRunner] above.
197    ///
198    /// The caller should set this field. If it is absent, the framework will assume
199    /// a value of ZX_OK.
200    pub termination_status: Option<i32>,
201    /// (Optional) The exit code of the component instance.
202    ///
203    /// Runner implementors may map their runtime specific exit code concept
204    /// (such as libc exit status) to this field. Or they may choose to
205    /// leave this blank.
206    pub exit_code: Option<i64>,
207    #[doc(hidden)]
208    pub __source_breaking: fidl::marker::SourceBreaking,
209}
210
211impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ComponentStopInfo {}
212
213#[derive(Debug, Default, PartialEq)]
214pub struct ComponentTasks {
215    pub component_task: Option<Task>,
216    pub parent_task: Option<Task>,
217    #[doc(hidden)]
218    pub __source_breaking: fidl::marker::SourceBreaking,
219}
220
221impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for ComponentTasks {}
222
223#[derive(Debug)]
224pub enum Task {
225    Job(fdomain_client::Job),
226    Process(fdomain_client::Process),
227    Thread(fdomain_client::Thread),
228    #[doc(hidden)]
229    __SourceBreaking {
230        unknown_ordinal: u64,
231    },
232}
233
234/// Pattern that matches an unknown `Task` member.
235#[macro_export]
236macro_rules! TaskUnknown {
237    () => {
238        _
239    };
240}
241
242// Custom PartialEq so that unknown variants are not equal to themselves.
243impl PartialEq for Task {
244    fn eq(&self, other: &Self) -> bool {
245        match (self, other) {
246            (Self::Job(x), Self::Job(y)) => *x == *y,
247            (Self::Process(x), Self::Process(y)) => *x == *y,
248            (Self::Thread(x), Self::Thread(y)) => *x == *y,
249            _ => false,
250        }
251    }
252}
253
254impl Task {
255    #[inline]
256    pub fn ordinal(&self) -> u64 {
257        match *self {
258            Self::Job(_) => 1,
259            Self::Process(_) => 2,
260            Self::Thread(_) => 3,
261            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
262        }
263    }
264
265    #[inline]
266    pub fn unknown_variant_for_testing() -> Self {
267        Self::__SourceBreaking { unknown_ordinal: 0 }
268    }
269
270    #[inline]
271    pub fn is_unknown(&self) -> bool {
272        match self {
273            Self::__SourceBreaking { .. } => true,
274            _ => false,
275        }
276    }
277}
278
279impl fidl::Standalone<fdomain_client::fidl::FDomainResourceDialect> for Task {}
280
281#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
282pub struct ComponentControllerMarker;
283
284impl fdomain_client::fidl::ProtocolMarker for ComponentControllerMarker {
285    type Proxy = ComponentControllerProxy;
286    type RequestStream = ComponentControllerRequestStream;
287
288    const DEBUG_NAME: &'static str = "(anonymous) ComponentController";
289}
290
291pub trait ComponentControllerProxyInterface: Send + Sync {
292    fn r#stop(&self) -> Result<(), fidl::Error>;
293    fn r#kill(&self) -> Result<(), fidl::Error>;
294}
295
296#[derive(Debug, Clone)]
297pub struct ComponentControllerProxy {
298    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
299}
300
301impl fdomain_client::fidl::Proxy for ComponentControllerProxy {
302    type Protocol = ComponentControllerMarker;
303
304    fn from_channel(inner: fdomain_client::Channel) -> Self {
305        Self::new(inner)
306    }
307
308    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
309        self.client.into_channel().map_err(|client| Self { client })
310    }
311
312    fn as_channel(&self) -> &fdomain_client::Channel {
313        self.client.as_channel()
314    }
315}
316
317impl ComponentControllerProxy {
318    /// Create a new Proxy for fuchsia.component.runner/ComponentController.
319    pub fn new(channel: fdomain_client::Channel) -> Self {
320        let protocol_name =
321            <ComponentControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
322        Self { client: fidl::client::Client::new(channel, protocol_name) }
323    }
324
325    /// Get a Stream of events from the remote end of the protocol.
326    ///
327    /// # Panics
328    ///
329    /// Panics if the event stream was already taken.
330    pub fn take_event_stream(&self) -> ComponentControllerEventStream {
331        ComponentControllerEventStream { event_receiver: self.client.take_event_receiver() }
332    }
333
334    /// Request to stop the component instance.
335    ///
336    /// After stopping the component instance, the server should close this
337    /// connection with an epitaph. After the connection
338    /// closes, component manager considers this component instance to be
339    /// Stopped and the component's namespace will be torn down.
340    pub fn r#stop(&self) -> Result<(), fidl::Error> {
341        ComponentControllerProxyInterface::r#stop(self)
342    }
343
344    /// Stop this component instance immediately.
345    ///
346    /// The ComponentRunner must immediately kill the component instance, and
347    /// then close this connection with an epitaph. After the connection
348    /// closes, component manager considers this component instance to be
349    /// Stopped and the component's namespace will be torn down.
350    ///
351    /// In some cases Kill() may be issued before Stop(), but that is not
352    /// guaranteed.
353    pub fn r#kill(&self) -> Result<(), fidl::Error> {
354        ComponentControllerProxyInterface::r#kill(self)
355    }
356}
357
358impl ComponentControllerProxyInterface for ComponentControllerProxy {
359    fn r#stop(&self) -> Result<(), fidl::Error> {
360        self.client.send::<fidl::encoding::EmptyPayload>(
361            (),
362            0x42ad097fa07c1b62,
363            fidl::encoding::DynamicFlags::empty(),
364        )
365    }
366
367    fn r#kill(&self) -> Result<(), fidl::Error> {
368        self.client.send::<fidl::encoding::EmptyPayload>(
369            (),
370            0x3ea62e200a45aeb4,
371            fidl::encoding::DynamicFlags::empty(),
372        )
373    }
374}
375
376pub struct ComponentControllerEventStream {
377    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
378}
379
380impl std::marker::Unpin for ComponentControllerEventStream {}
381
382impl futures::stream::FusedStream for ComponentControllerEventStream {
383    fn is_terminated(&self) -> bool {
384        self.event_receiver.is_terminated()
385    }
386}
387
388impl futures::Stream for ComponentControllerEventStream {
389    type Item = Result<ComponentControllerEvent, fidl::Error>;
390
391    fn poll_next(
392        mut self: std::pin::Pin<&mut Self>,
393        cx: &mut std::task::Context<'_>,
394    ) -> std::task::Poll<Option<Self::Item>> {
395        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
396            &mut self.event_receiver,
397            cx
398        )?) {
399            Some(buf) => std::task::Poll::Ready(Some(ComponentControllerEvent::decode(buf))),
400            None => std::task::Poll::Ready(None),
401        }
402    }
403}
404
405#[derive(Debug)]
406pub enum ComponentControllerEvent {
407    OnPublishDiagnostics {
408        payload: ComponentDiagnostics,
409    },
410    OnEscrow {
411        payload: ComponentControllerOnEscrowRequest,
412    },
413    OnStop {
414        payload: ComponentStopInfo,
415    },
416    #[non_exhaustive]
417    _UnknownEvent {
418        /// Ordinal of the event that was sent.
419        ordinal: u64,
420    },
421}
422
423impl ComponentControllerEvent {
424    #[allow(irrefutable_let_patterns)]
425    pub fn into_on_publish_diagnostics(self) -> Option<ComponentDiagnostics> {
426        if let ComponentControllerEvent::OnPublishDiagnostics { payload } = self {
427            Some((payload))
428        } else {
429            None
430        }
431    }
432    #[allow(irrefutable_let_patterns)]
433    pub fn into_on_escrow(self) -> Option<ComponentControllerOnEscrowRequest> {
434        if let ComponentControllerEvent::OnEscrow { payload } = self {
435            Some((payload))
436        } else {
437            None
438        }
439    }
440    #[allow(irrefutable_let_patterns)]
441    pub fn into_on_stop(self) -> Option<ComponentStopInfo> {
442        if let ComponentControllerEvent::OnStop { payload } = self { Some((payload)) } else { None }
443    }
444
445    /// Decodes a message buffer as a [`ComponentControllerEvent`].
446    fn decode(
447        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
448    ) -> Result<ComponentControllerEvent, fidl::Error> {
449        let (bytes, _handles) = buf.split_mut();
450        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
451        debug_assert_eq!(tx_header.tx_id, 0);
452        match tx_header.ordinal {
453            0x1f16d8c3c49c6947 => {
454                let mut out = fidl::new_empty!(
455                    ComponentControllerOnPublishDiagnosticsRequest,
456                    fdomain_client::fidl::FDomainResourceDialect
457                );
458                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ComponentControllerOnPublishDiagnosticsRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
459                Ok((ComponentControllerEvent::OnPublishDiagnostics { payload: out.payload }))
460            }
461            0xa231349355343fc => {
462                let mut out = fidl::new_empty!(
463                    ComponentControllerOnEscrowRequest,
464                    fdomain_client::fidl::FDomainResourceDialect
465                );
466                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ComponentControllerOnEscrowRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
467                Ok((ComponentControllerEvent::OnEscrow { payload: out }))
468            }
469            0x3bfd24b031878ab2 => {
470                let mut out = fidl::new_empty!(
471                    ComponentStopInfo,
472                    fdomain_client::fidl::FDomainResourceDialect
473                );
474                fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ComponentStopInfo>(&tx_header, _body_bytes, _handles, &mut out)?;
475                Ok((ComponentControllerEvent::OnStop { payload: out }))
476            }
477            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
478                Ok(ComponentControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
479            }
480            _ => Err(fidl::Error::UnknownOrdinal {
481                ordinal: tx_header.ordinal,
482                protocol_name:
483                    <ComponentControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
484            }),
485        }
486    }
487}
488
489/// A Stream of incoming requests for fuchsia.component.runner/ComponentController.
490pub struct ComponentControllerRequestStream {
491    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
492    is_terminated: bool,
493}
494
495impl std::marker::Unpin for ComponentControllerRequestStream {}
496
497impl futures::stream::FusedStream for ComponentControllerRequestStream {
498    fn is_terminated(&self) -> bool {
499        self.is_terminated
500    }
501}
502
503impl fdomain_client::fidl::RequestStream for ComponentControllerRequestStream {
504    type Protocol = ComponentControllerMarker;
505    type ControlHandle = ComponentControllerControlHandle;
506
507    fn from_channel(channel: fdomain_client::Channel) -> Self {
508        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
509    }
510
511    fn control_handle(&self) -> Self::ControlHandle {
512        ComponentControllerControlHandle { inner: self.inner.clone() }
513    }
514
515    fn into_inner(
516        self,
517    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
518    {
519        (self.inner, self.is_terminated)
520    }
521
522    fn from_inner(
523        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
524        is_terminated: bool,
525    ) -> Self {
526        Self { inner, is_terminated }
527    }
528}
529
530impl futures::Stream for ComponentControllerRequestStream {
531    type Item = Result<ComponentControllerRequest, fidl::Error>;
532
533    fn poll_next(
534        mut self: std::pin::Pin<&mut Self>,
535        cx: &mut std::task::Context<'_>,
536    ) -> std::task::Poll<Option<Self::Item>> {
537        let this = &mut *self;
538        if this.inner.check_shutdown(cx) {
539            this.is_terminated = true;
540            return std::task::Poll::Ready(None);
541        }
542        if this.is_terminated {
543            panic!("polled ComponentControllerRequestStream after completion");
544        }
545        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
546            |bytes, handles| {
547                match this.inner.channel().read_etc(cx, bytes, handles) {
548                    std::task::Poll::Ready(Ok(())) => {}
549                    std::task::Poll::Pending => return std::task::Poll::Pending,
550                    std::task::Poll::Ready(Err(None)) => {
551                        this.is_terminated = true;
552                        return std::task::Poll::Ready(None);
553                    }
554                    std::task::Poll::Ready(Err(Some(e))) => {
555                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
556                            e.into(),
557                        ))));
558                    }
559                }
560
561                // A message has been received from the channel
562                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
563
564                std::task::Poll::Ready(Some(match header.ordinal {
565                0x42ad097fa07c1b62 => {
566                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
567                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
568                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
569                    let control_handle = ComponentControllerControlHandle {
570                        inner: this.inner.clone(),
571                    };
572                    Ok(ComponentControllerRequest::Stop {
573                        control_handle,
574                    })
575                }
576                0x3ea62e200a45aeb4 => {
577                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
578                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fdomain_client::fidl::FDomainResourceDialect);
579                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
580                    let control_handle = ComponentControllerControlHandle {
581                        inner: this.inner.clone(),
582                    };
583                    Ok(ComponentControllerRequest::Kill {
584                        control_handle,
585                    })
586                }
587                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
588                    Ok(ComponentControllerRequest::_UnknownMethod {
589                        ordinal: header.ordinal,
590                        control_handle: ComponentControllerControlHandle { inner: this.inner.clone() },
591                        method_type: fidl::MethodType::OneWay,
592                    })
593                }
594                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
595                    this.inner.send_framework_err(
596                        fidl::encoding::FrameworkErr::UnknownMethod,
597                        header.tx_id,
598                        header.ordinal,
599                        header.dynamic_flags(),
600                        (bytes, handles),
601                    )?;
602                    Ok(ComponentControllerRequest::_UnknownMethod {
603                        ordinal: header.ordinal,
604                        control_handle: ComponentControllerControlHandle { inner: this.inner.clone() },
605                        method_type: fidl::MethodType::TwoWay,
606                    })
607                }
608                _ => Err(fidl::Error::UnknownOrdinal {
609                    ordinal: header.ordinal,
610                    protocol_name: <ComponentControllerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
611                }),
612            }))
613            },
614        )
615    }
616}
617
618/// A protocol for binding and controlling the lifetime of a component instance
619/// started using `ComponentRunner.Start()`. The component manager is the
620/// intended direct client of this protocol.
621///
622/// When the controlled component instance terminates or becomes inaccessible
623/// for any reason, the server closes the connection with an epitaph.
624///
625/// # Lifecycle
626///
627/// A component may exist in one of two states: `Started`, or `Stopped`. The
628/// component is `Started` from the time `ComponentRunner.Start()` is called
629/// until the ComponentRunner closes the ComponentController handle. The
630/// component then transitions to `Stopped`.
631///
632/// Component manager uses ComponentController to terminate a component in two
633/// steps:
634///
635/// 1.  Component manager calls `Stop()` to indicate that the ComponentRunner
636///     should stop a component's execution and send the `OnStop` event.
637/// 2.  If after some time the ComponentController is not closed, component
638///     manager calls `Kill()` to indicate that the ComponentRunner must halt a
639///     component's execution immediately, and then send the `OnStop` event.
640///     The component manager may wait some period of time after calling `Kill()`
641///     before sending `OnStop`, but makes no guarantees it will wait or for how long.
642///
643/// Component manager first waits for the ComponentController to close, and
644/// then tears down the namespace it hosts for the stopped component. Component
645/// manager may call `Kill()` without first having called `Stop()`.
646///
647/// Before stopping, a component can optionally use `OnEscrow` to store some
648/// state in the framework, to receive those state again the next time it is
649/// started.
650///
651/// When the component stops, the runner should send an `OnStop` event
652/// instead of just closing the channel, to report the component's termination status
653/// (see below) and (optionally) an exit code. Once the runner has sent `OnStop`
654/// it is free to close [ComponentRunner]; the component framework will close
655/// its end of the channel when it receives this event.
656///
657/// ## Legacy
658///
659/// Instead of sending `OnStop`, it is also legal for a runner to close the channel
660/// with with an epitaph equal to the termination status, but this is a legacy method
661/// for backward compatibility that's no longer recommended.
662///
663/// # Termination status
664///
665/// The termination status indicates the component's final disposition in the eyes of
666/// the runner.
667///
668/// Note that termination status is _not_ synonymous with a component's exit code.
669/// A component's exit code, which is optional for a runner to report, is an
670/// integer that represents the program's own return code. For example, for ELF
671/// components, it is the value returned by main(). The termination status is
672/// the _runner_'s status code for the component's termination, which may capture
673/// failure modes that occur in the context of the runner itself rather than the
674/// program.
675///
676/// The following termination statuses may be sent by the server on error:
677///
678/// - `ZX_OK`: The component exited successfully, typically because the
679///   component was asked to stop or it decided independently to exit.
680/// - `INVALID_ARGUMENTS`:
681///     * `start_info.resolved_url` is not supported by this
682///       runner;
683///     * `start_info` contains missing or invalid arguments.
684/// - `INSTANCE_CANNOT_START`: The runner could not start the component.
685///   For example, a critical part of the program could not be found or
686///   loaded, or the referenced binary was invalid for this runner.
687/// - `RESOURCE_UNAVAILABLE`: The component could not be launched due to
688///   lack of resources.
689/// - `INTERNAL`: An unexpected internal runner error was encountered.
690/// - `INSTANCE_DIED`: The component instance was started but
691///   subsequently terminated with an error.
692/// - Other status codes (e.g. `ZX_ERR_PEER_CLOSED`) may indicate a failure
693///   of the component runner itself. The component manager may respond to such
694///   failures by terminating the component runner's job to ensure system
695///   stability.
696#[derive(Debug)]
697pub enum ComponentControllerRequest {
698    /// Request to stop the component instance.
699    ///
700    /// After stopping the component instance, the server should close this
701    /// connection with an epitaph. After the connection
702    /// closes, component manager considers this component instance to be
703    /// Stopped and the component's namespace will be torn down.
704    Stop { control_handle: ComponentControllerControlHandle },
705    /// Stop this component instance immediately.
706    ///
707    /// The ComponentRunner must immediately kill the component instance, and
708    /// then close this connection with an epitaph. After the connection
709    /// closes, component manager considers this component instance to be
710    /// Stopped and the component's namespace will be torn down.
711    ///
712    /// In some cases Kill() may be issued before Stop(), but that is not
713    /// guaranteed.
714    Kill { control_handle: ComponentControllerControlHandle },
715    /// An interaction was received which does not match any known method.
716    #[non_exhaustive]
717    _UnknownMethod {
718        /// Ordinal of the method that was called.
719        ordinal: u64,
720        control_handle: ComponentControllerControlHandle,
721        method_type: fidl::MethodType,
722    },
723}
724
725impl ComponentControllerRequest {
726    #[allow(irrefutable_let_patterns)]
727    pub fn into_stop(self) -> Option<(ComponentControllerControlHandle)> {
728        if let ComponentControllerRequest::Stop { control_handle } = self {
729            Some((control_handle))
730        } else {
731            None
732        }
733    }
734
735    #[allow(irrefutable_let_patterns)]
736    pub fn into_kill(self) -> Option<(ComponentControllerControlHandle)> {
737        if let ComponentControllerRequest::Kill { control_handle } = self {
738            Some((control_handle))
739        } else {
740            None
741        }
742    }
743
744    /// Name of the method defined in FIDL
745    pub fn method_name(&self) -> &'static str {
746        match *self {
747            ComponentControllerRequest::Stop { .. } => "stop",
748            ComponentControllerRequest::Kill { .. } => "kill",
749            ComponentControllerRequest::_UnknownMethod {
750                method_type: fidl::MethodType::OneWay,
751                ..
752            } => "unknown one-way method",
753            ComponentControllerRequest::_UnknownMethod {
754                method_type: fidl::MethodType::TwoWay,
755                ..
756            } => "unknown two-way method",
757        }
758    }
759}
760
761#[derive(Debug, Clone)]
762pub struct ComponentControllerControlHandle {
763    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
764}
765
766impl fdomain_client::fidl::ControlHandle for ComponentControllerControlHandle {
767    fn shutdown(&self) {
768        self.inner.shutdown()
769    }
770
771    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
772        self.inner.shutdown_with_epitaph(status)
773    }
774
775    fn is_closed(&self) -> bool {
776        self.inner.channel().is_closed()
777    }
778    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
779        self.inner.channel().on_closed()
780    }
781}
782
783impl ComponentControllerControlHandle {
784    pub fn send_on_publish_diagnostics(
785        &self,
786        mut payload: ComponentDiagnostics,
787    ) -> Result<(), fidl::Error> {
788        self.inner.send::<ComponentControllerOnPublishDiagnosticsRequest>(
789            (&mut payload,),
790            0,
791            0x1f16d8c3c49c6947,
792            fidl::encoding::DynamicFlags::empty(),
793        )
794    }
795
796    pub fn send_on_escrow(
797        &self,
798        mut payload: ComponentControllerOnEscrowRequest,
799    ) -> Result<(), fidl::Error> {
800        self.inner.send::<ComponentControllerOnEscrowRequest>(
801            &mut payload,
802            0,
803            0xa231349355343fc,
804            fidl::encoding::DynamicFlags::FLEXIBLE,
805        )
806    }
807
808    pub fn send_on_stop(&self, mut payload: ComponentStopInfo) -> Result<(), fidl::Error> {
809        self.inner.send::<ComponentStopInfo>(
810            &mut payload,
811            0,
812            0x3bfd24b031878ab2,
813            fidl::encoding::DynamicFlags::FLEXIBLE,
814        )
815    }
816}
817
818#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
819pub struct ComponentRunnerMarker;
820
821impl fdomain_client::fidl::ProtocolMarker for ComponentRunnerMarker {
822    type Proxy = ComponentRunnerProxy;
823    type RequestStream = ComponentRunnerRequestStream;
824
825    const DEBUG_NAME: &'static str = "fuchsia.component.runner.ComponentRunner";
826}
827impl fdomain_client::fidl::DiscoverableProtocolMarker for ComponentRunnerMarker {}
828
829pub trait ComponentRunnerProxyInterface: Send + Sync {
830    fn r#start(
831        &self,
832        start_info: ComponentStartInfo,
833        controller: fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
834    ) -> Result<(), fidl::Error>;
835}
836
837#[derive(Debug, Clone)]
838pub struct ComponentRunnerProxy {
839    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
840}
841
842impl fdomain_client::fidl::Proxy for ComponentRunnerProxy {
843    type Protocol = ComponentRunnerMarker;
844
845    fn from_channel(inner: fdomain_client::Channel) -> Self {
846        Self::new(inner)
847    }
848
849    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
850        self.client.into_channel().map_err(|client| Self { client })
851    }
852
853    fn as_channel(&self) -> &fdomain_client::Channel {
854        self.client.as_channel()
855    }
856}
857
858impl ComponentRunnerProxy {
859    /// Create a new Proxy for fuchsia.component.runner/ComponentRunner.
860    pub fn new(channel: fdomain_client::Channel) -> Self {
861        let protocol_name =
862            <ComponentRunnerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
863        Self { client: fidl::client::Client::new(channel, protocol_name) }
864    }
865
866    /// Get a Stream of events from the remote end of the protocol.
867    ///
868    /// # Panics
869    ///
870    /// Panics if the event stream was already taken.
871    pub fn take_event_stream(&self) -> ComponentRunnerEventStream {
872        ComponentRunnerEventStream { event_receiver: self.client.take_event_receiver() }
873    }
874
875    /// Start running a component instance described by `start_info`.
876    ///
877    /// Component manager binds and uses `controller` to control the
878    /// lifetime of the newly started component instance.
879    ///
880    /// Errors are delivered as epitaphs over the `ComponentController`
881    /// protocol. In the event of an error, the runner must ensure that
882    /// resources are cleaned up.
883    pub fn r#start(
884        &self,
885        mut start_info: ComponentStartInfo,
886        mut controller: fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
887    ) -> Result<(), fidl::Error> {
888        ComponentRunnerProxyInterface::r#start(self, start_info, controller)
889    }
890}
891
892impl ComponentRunnerProxyInterface for ComponentRunnerProxy {
893    fn r#start(
894        &self,
895        mut start_info: ComponentStartInfo,
896        mut controller: fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
897    ) -> Result<(), fidl::Error> {
898        self.client.send::<ComponentRunnerStartRequest>(
899            (&mut start_info, controller),
900            0xad5a8c19f25ee09,
901            fidl::encoding::DynamicFlags::empty(),
902        )
903    }
904}
905
906pub struct ComponentRunnerEventStream {
907    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
908}
909
910impl std::marker::Unpin for ComponentRunnerEventStream {}
911
912impl futures::stream::FusedStream for ComponentRunnerEventStream {
913    fn is_terminated(&self) -> bool {
914        self.event_receiver.is_terminated()
915    }
916}
917
918impl futures::Stream for ComponentRunnerEventStream {
919    type Item = Result<ComponentRunnerEvent, fidl::Error>;
920
921    fn poll_next(
922        mut self: std::pin::Pin<&mut Self>,
923        cx: &mut std::task::Context<'_>,
924    ) -> std::task::Poll<Option<Self::Item>> {
925        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
926            &mut self.event_receiver,
927            cx
928        )?) {
929            Some(buf) => std::task::Poll::Ready(Some(ComponentRunnerEvent::decode(buf))),
930            None => std::task::Poll::Ready(None),
931        }
932    }
933}
934
935#[derive(Debug)]
936pub enum ComponentRunnerEvent {
937    #[non_exhaustive]
938    _UnknownEvent {
939        /// Ordinal of the event that was sent.
940        ordinal: u64,
941    },
942}
943
944impl ComponentRunnerEvent {
945    /// Decodes a message buffer as a [`ComponentRunnerEvent`].
946    fn decode(
947        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
948    ) -> Result<ComponentRunnerEvent, fidl::Error> {
949        let (bytes, _handles) = buf.split_mut();
950        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
951        debug_assert_eq!(tx_header.tx_id, 0);
952        match tx_header.ordinal {
953            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
954                Ok(ComponentRunnerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
955            }
956            _ => Err(fidl::Error::UnknownOrdinal {
957                ordinal: tx_header.ordinal,
958                protocol_name:
959                    <ComponentRunnerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
960            }),
961        }
962    }
963}
964
965/// A Stream of incoming requests for fuchsia.component.runner/ComponentRunner.
966pub struct ComponentRunnerRequestStream {
967    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
968    is_terminated: bool,
969}
970
971impl std::marker::Unpin for ComponentRunnerRequestStream {}
972
973impl futures::stream::FusedStream for ComponentRunnerRequestStream {
974    fn is_terminated(&self) -> bool {
975        self.is_terminated
976    }
977}
978
979impl fdomain_client::fidl::RequestStream for ComponentRunnerRequestStream {
980    type Protocol = ComponentRunnerMarker;
981    type ControlHandle = ComponentRunnerControlHandle;
982
983    fn from_channel(channel: fdomain_client::Channel) -> Self {
984        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
985    }
986
987    fn control_handle(&self) -> Self::ControlHandle {
988        ComponentRunnerControlHandle { inner: self.inner.clone() }
989    }
990
991    fn into_inner(
992        self,
993    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
994    {
995        (self.inner, self.is_terminated)
996    }
997
998    fn from_inner(
999        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1000        is_terminated: bool,
1001    ) -> Self {
1002        Self { inner, is_terminated }
1003    }
1004}
1005
1006impl futures::Stream for ComponentRunnerRequestStream {
1007    type Item = Result<ComponentRunnerRequest, fidl::Error>;
1008
1009    fn poll_next(
1010        mut self: std::pin::Pin<&mut Self>,
1011        cx: &mut std::task::Context<'_>,
1012    ) -> std::task::Poll<Option<Self::Item>> {
1013        let this = &mut *self;
1014        if this.inner.check_shutdown(cx) {
1015            this.is_terminated = true;
1016            return std::task::Poll::Ready(None);
1017        }
1018        if this.is_terminated {
1019            panic!("polled ComponentRunnerRequestStream after completion");
1020        }
1021        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1022            |bytes, handles| {
1023                match this.inner.channel().read_etc(cx, bytes, handles) {
1024                    std::task::Poll::Ready(Ok(())) => {}
1025                    std::task::Poll::Pending => return std::task::Poll::Pending,
1026                    std::task::Poll::Ready(Err(None)) => {
1027                        this.is_terminated = true;
1028                        return std::task::Poll::Ready(None);
1029                    }
1030                    std::task::Poll::Ready(Err(Some(e))) => {
1031                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1032                            e.into(),
1033                        ))));
1034                    }
1035                }
1036
1037                // A message has been received from the channel
1038                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1039
1040                std::task::Poll::Ready(Some(match header.ordinal {
1041                0xad5a8c19f25ee09 => {
1042                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1043                    let mut req = fidl::new_empty!(ComponentRunnerStartRequest, fdomain_client::fidl::FDomainResourceDialect);
1044                    fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<ComponentRunnerStartRequest>(&header, _body_bytes, handles, &mut req)?;
1045                    let control_handle = ComponentRunnerControlHandle {
1046                        inner: this.inner.clone(),
1047                    };
1048                    Ok(ComponentRunnerRequest::Start {start_info: req.start_info,
1049controller: req.controller,
1050
1051                        control_handle,
1052                    })
1053                }
1054                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1055                    Ok(ComponentRunnerRequest::_UnknownMethod {
1056                        ordinal: header.ordinal,
1057                        control_handle: ComponentRunnerControlHandle { inner: this.inner.clone() },
1058                        method_type: fidl::MethodType::OneWay,
1059                    })
1060                }
1061                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1062                    this.inner.send_framework_err(
1063                        fidl::encoding::FrameworkErr::UnknownMethod,
1064                        header.tx_id,
1065                        header.ordinal,
1066                        header.dynamic_flags(),
1067                        (bytes, handles),
1068                    )?;
1069                    Ok(ComponentRunnerRequest::_UnknownMethod {
1070                        ordinal: header.ordinal,
1071                        control_handle: ComponentRunnerControlHandle { inner: this.inner.clone() },
1072                        method_type: fidl::MethodType::TwoWay,
1073                    })
1074                }
1075                _ => Err(fidl::Error::UnknownOrdinal {
1076                    ordinal: header.ordinal,
1077                    protocol_name: <ComponentRunnerMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1078                }),
1079            }))
1080            },
1081        )
1082    }
1083}
1084
1085/// A protocol used for running components.
1086///
1087/// This protocol is implemented by components which provide a runtime
1088/// environment for other components.
1089///
1090/// Note: The component manager is the only intended direct client of this
1091/// interface.
1092#[derive(Debug)]
1093pub enum ComponentRunnerRequest {
1094    /// Start running a component instance described by `start_info`.
1095    ///
1096    /// Component manager binds and uses `controller` to control the
1097    /// lifetime of the newly started component instance.
1098    ///
1099    /// Errors are delivered as epitaphs over the `ComponentController`
1100    /// protocol. In the event of an error, the runner must ensure that
1101    /// resources are cleaned up.
1102    Start {
1103        start_info: ComponentStartInfo,
1104        controller: fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1105        control_handle: ComponentRunnerControlHandle,
1106    },
1107    /// An interaction was received which does not match any known method.
1108    #[non_exhaustive]
1109    _UnknownMethod {
1110        /// Ordinal of the method that was called.
1111        ordinal: u64,
1112        control_handle: ComponentRunnerControlHandle,
1113        method_type: fidl::MethodType,
1114    },
1115}
1116
1117impl ComponentRunnerRequest {
1118    #[allow(irrefutable_let_patterns)]
1119    pub fn into_start(
1120        self,
1121    ) -> Option<(
1122        ComponentStartInfo,
1123        fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1124        ComponentRunnerControlHandle,
1125    )> {
1126        if let ComponentRunnerRequest::Start { start_info, controller, control_handle } = self {
1127            Some((start_info, controller, control_handle))
1128        } else {
1129            None
1130        }
1131    }
1132
1133    /// Name of the method defined in FIDL
1134    pub fn method_name(&self) -> &'static str {
1135        match *self {
1136            ComponentRunnerRequest::Start { .. } => "start",
1137            ComponentRunnerRequest::_UnknownMethod {
1138                method_type: fidl::MethodType::OneWay,
1139                ..
1140            } => "unknown one-way method",
1141            ComponentRunnerRequest::_UnknownMethod {
1142                method_type: fidl::MethodType::TwoWay,
1143                ..
1144            } => "unknown two-way method",
1145        }
1146    }
1147}
1148
1149#[derive(Debug, Clone)]
1150pub struct ComponentRunnerControlHandle {
1151    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1152}
1153
1154impl fdomain_client::fidl::ControlHandle for ComponentRunnerControlHandle {
1155    fn shutdown(&self) {
1156        self.inner.shutdown()
1157    }
1158
1159    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1160        self.inner.shutdown_with_epitaph(status)
1161    }
1162
1163    fn is_closed(&self) -> bool {
1164        self.inner.channel().is_closed()
1165    }
1166    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1167        self.inner.channel().on_closed()
1168    }
1169}
1170
1171impl ComponentRunnerControlHandle {}
1172
1173#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1174pub struct TaskProviderMarker;
1175
1176impl fdomain_client::fidl::ProtocolMarker for TaskProviderMarker {
1177    type Proxy = TaskProviderProxy;
1178    type RequestStream = TaskProviderRequestStream;
1179
1180    const DEBUG_NAME: &'static str = "fuchsia.component.runner.TaskProvider";
1181}
1182impl fdomain_client::fidl::DiscoverableProtocolMarker for TaskProviderMarker {}
1183pub type TaskProviderGetJobResult = Result<fdomain_client::Job, i32>;
1184
1185pub trait TaskProviderProxyInterface: Send + Sync {
1186    type GetJobResponseFut: std::future::Future<Output = Result<TaskProviderGetJobResult, fidl::Error>>
1187        + Send;
1188    fn r#get_job(&self) -> Self::GetJobResponseFut;
1189}
1190
1191#[derive(Debug, Clone)]
1192pub struct TaskProviderProxy {
1193    client: fidl::client::Client<fdomain_client::fidl::FDomainResourceDialect>,
1194}
1195
1196impl fdomain_client::fidl::Proxy for TaskProviderProxy {
1197    type Protocol = TaskProviderMarker;
1198
1199    fn from_channel(inner: fdomain_client::Channel) -> Self {
1200        Self::new(inner)
1201    }
1202
1203    fn into_channel(self) -> Result<fdomain_client::Channel, Self> {
1204        self.client.into_channel().map_err(|client| Self { client })
1205    }
1206
1207    fn as_channel(&self) -> &fdomain_client::Channel {
1208        self.client.as_channel()
1209    }
1210}
1211
1212impl TaskProviderProxy {
1213    /// Create a new Proxy for fuchsia.component.runner/TaskProvider.
1214    pub fn new(channel: fdomain_client::Channel) -> Self {
1215        let protocol_name =
1216            <TaskProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME;
1217        Self { client: fidl::client::Client::new(channel, protocol_name) }
1218    }
1219
1220    /// Get a Stream of events from the remote end of the protocol.
1221    ///
1222    /// # Panics
1223    ///
1224    /// Panics if the event stream was already taken.
1225    pub fn take_event_stream(&self) -> TaskProviderEventStream {
1226        TaskProviderEventStream { event_receiver: self.client.take_event_receiver() }
1227    }
1228
1229    /// Returns a job handle for the component requested.
1230    ///
1231    /// On success, returns a handle with the same rights as the runner's.
1232    pub fn r#get_job(
1233        &self,
1234    ) -> fidl::client::QueryResponseFut<
1235        TaskProviderGetJobResult,
1236        fdomain_client::fidl::FDomainResourceDialect,
1237    > {
1238        TaskProviderProxyInterface::r#get_job(self)
1239    }
1240}
1241
1242impl TaskProviderProxyInterface for TaskProviderProxy {
1243    type GetJobResponseFut = fidl::client::QueryResponseFut<
1244        TaskProviderGetJobResult,
1245        fdomain_client::fidl::FDomainResourceDialect,
1246    >;
1247    fn r#get_job(&self) -> Self::GetJobResponseFut {
1248        fn _decode(
1249            mut _buf: Result<<fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1250        ) -> Result<TaskProviderGetJobResult, fidl::Error> {
1251            let _response = fidl::client::decode_transaction_body::<
1252                fidl::encoding::ResultType<TaskProviderGetJobResponse, i32>,
1253                fdomain_client::fidl::FDomainResourceDialect,
1254                0x4c9ca4f4fdece3ad,
1255            >(_buf?)?;
1256            Ok(_response.map(|x| x.job))
1257        }
1258        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, TaskProviderGetJobResult>(
1259            (),
1260            0x4c9ca4f4fdece3ad,
1261            fidl::encoding::DynamicFlags::empty(),
1262            _decode,
1263        )
1264    }
1265}
1266
1267pub struct TaskProviderEventStream {
1268    event_receiver: fidl::client::EventReceiver<fdomain_client::fidl::FDomainResourceDialect>,
1269}
1270
1271impl std::marker::Unpin for TaskProviderEventStream {}
1272
1273impl futures::stream::FusedStream for TaskProviderEventStream {
1274    fn is_terminated(&self) -> bool {
1275        self.event_receiver.is_terminated()
1276    }
1277}
1278
1279impl futures::Stream for TaskProviderEventStream {
1280    type Item = Result<TaskProviderEvent, fidl::Error>;
1281
1282    fn poll_next(
1283        mut self: std::pin::Pin<&mut Self>,
1284        cx: &mut std::task::Context<'_>,
1285    ) -> std::task::Poll<Option<Self::Item>> {
1286        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1287            &mut self.event_receiver,
1288            cx
1289        )?) {
1290            Some(buf) => std::task::Poll::Ready(Some(TaskProviderEvent::decode(buf))),
1291            None => std::task::Poll::Ready(None),
1292        }
1293    }
1294}
1295
1296#[derive(Debug)]
1297pub enum TaskProviderEvent {
1298    #[non_exhaustive]
1299    _UnknownEvent {
1300        /// Ordinal of the event that was sent.
1301        ordinal: u64,
1302    },
1303}
1304
1305impl TaskProviderEvent {
1306    /// Decodes a message buffer as a [`TaskProviderEvent`].
1307    fn decode(
1308        mut buf: <fdomain_client::fidl::FDomainResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1309    ) -> Result<TaskProviderEvent, fidl::Error> {
1310        let (bytes, _handles) = buf.split_mut();
1311        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1312        debug_assert_eq!(tx_header.tx_id, 0);
1313        match tx_header.ordinal {
1314            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1315                Ok(TaskProviderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1316            }
1317            _ => Err(fidl::Error::UnknownOrdinal {
1318                ordinal: tx_header.ordinal,
1319                protocol_name:
1320                    <TaskProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1321            }),
1322        }
1323    }
1324}
1325
1326/// A Stream of incoming requests for fuchsia.component.runner/TaskProvider.
1327pub struct TaskProviderRequestStream {
1328    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1329    is_terminated: bool,
1330}
1331
1332impl std::marker::Unpin for TaskProviderRequestStream {}
1333
1334impl futures::stream::FusedStream for TaskProviderRequestStream {
1335    fn is_terminated(&self) -> bool {
1336        self.is_terminated
1337    }
1338}
1339
1340impl fdomain_client::fidl::RequestStream for TaskProviderRequestStream {
1341    type Protocol = TaskProviderMarker;
1342    type ControlHandle = TaskProviderControlHandle;
1343
1344    fn from_channel(channel: fdomain_client::Channel) -> Self {
1345        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1346    }
1347
1348    fn control_handle(&self) -> Self::ControlHandle {
1349        TaskProviderControlHandle { inner: self.inner.clone() }
1350    }
1351
1352    fn into_inner(
1353        self,
1354    ) -> (::std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>, bool)
1355    {
1356        (self.inner, self.is_terminated)
1357    }
1358
1359    fn from_inner(
1360        inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1361        is_terminated: bool,
1362    ) -> Self {
1363        Self { inner, is_terminated }
1364    }
1365}
1366
1367impl futures::Stream for TaskProviderRequestStream {
1368    type Item = Result<TaskProviderRequest, fidl::Error>;
1369
1370    fn poll_next(
1371        mut self: std::pin::Pin<&mut Self>,
1372        cx: &mut std::task::Context<'_>,
1373    ) -> std::task::Poll<Option<Self::Item>> {
1374        let this = &mut *self;
1375        if this.inner.check_shutdown(cx) {
1376            this.is_terminated = true;
1377            return std::task::Poll::Ready(None);
1378        }
1379        if this.is_terminated {
1380            panic!("polled TaskProviderRequestStream after completion");
1381        }
1382        fidl::encoding::with_tls_decode_buf::<_, fdomain_client::fidl::FDomainResourceDialect>(
1383            |bytes, handles| {
1384                match this.inner.channel().read_etc(cx, bytes, handles) {
1385                    std::task::Poll::Ready(Ok(())) => {}
1386                    std::task::Poll::Pending => return std::task::Poll::Pending,
1387                    std::task::Poll::Ready(Err(None)) => {
1388                        this.is_terminated = true;
1389                        return std::task::Poll::Ready(None);
1390                    }
1391                    std::task::Poll::Ready(Err(Some(e))) => {
1392                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1393                            e.into(),
1394                        ))));
1395                    }
1396                }
1397
1398                // A message has been received from the channel
1399                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1400
1401                std::task::Poll::Ready(Some(match header.ordinal {
1402                    0x4c9ca4f4fdece3ad => {
1403                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1404                        let mut req = fidl::new_empty!(
1405                            fidl::encoding::EmptyPayload,
1406                            fdomain_client::fidl::FDomainResourceDialect
1407                        );
1408                        fidl::encoding::Decoder::<fdomain_client::fidl::FDomainResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1409                        let control_handle =
1410                            TaskProviderControlHandle { inner: this.inner.clone() };
1411                        Ok(TaskProviderRequest::GetJob {
1412                            responder: TaskProviderGetJobResponder {
1413                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1414                                tx_id: header.tx_id,
1415                            },
1416                        })
1417                    }
1418                    _ if header.tx_id == 0
1419                        && header
1420                            .dynamic_flags()
1421                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1422                    {
1423                        Ok(TaskProviderRequest::_UnknownMethod {
1424                            ordinal: header.ordinal,
1425                            control_handle: TaskProviderControlHandle { inner: this.inner.clone() },
1426                            method_type: fidl::MethodType::OneWay,
1427                        })
1428                    }
1429                    _ if header
1430                        .dynamic_flags()
1431                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1432                    {
1433                        this.inner.send_framework_err(
1434                            fidl::encoding::FrameworkErr::UnknownMethod,
1435                            header.tx_id,
1436                            header.ordinal,
1437                            header.dynamic_flags(),
1438                            (bytes, handles),
1439                        )?;
1440                        Ok(TaskProviderRequest::_UnknownMethod {
1441                            ordinal: header.ordinal,
1442                            control_handle: TaskProviderControlHandle { inner: this.inner.clone() },
1443                            method_type: fidl::MethodType::TwoWay,
1444                        })
1445                    }
1446                    _ => Err(fidl::Error::UnknownOrdinal {
1447                        ordinal: header.ordinal,
1448                        protocol_name:
1449                            <TaskProviderMarker as fdomain_client::fidl::ProtocolMarker>::DEBUG_NAME,
1450                    }),
1451                }))
1452            },
1453        )
1454    }
1455}
1456
1457/// Served by runners that want to make a zircon job available through their runtime directory.
1458#[derive(Debug)]
1459pub enum TaskProviderRequest {
1460    /// Returns a job handle for the component requested.
1461    ///
1462    /// On success, returns a handle with the same rights as the runner's.
1463    GetJob { responder: TaskProviderGetJobResponder },
1464    /// An interaction was received which does not match any known method.
1465    #[non_exhaustive]
1466    _UnknownMethod {
1467        /// Ordinal of the method that was called.
1468        ordinal: u64,
1469        control_handle: TaskProviderControlHandle,
1470        method_type: fidl::MethodType,
1471    },
1472}
1473
1474impl TaskProviderRequest {
1475    #[allow(irrefutable_let_patterns)]
1476    pub fn into_get_job(self) -> Option<(TaskProviderGetJobResponder)> {
1477        if let TaskProviderRequest::GetJob { responder } = self { Some((responder)) } else { None }
1478    }
1479
1480    /// Name of the method defined in FIDL
1481    pub fn method_name(&self) -> &'static str {
1482        match *self {
1483            TaskProviderRequest::GetJob { .. } => "get_job",
1484            TaskProviderRequest::_UnknownMethod {
1485                method_type: fidl::MethodType::OneWay, ..
1486            } => "unknown one-way method",
1487            TaskProviderRequest::_UnknownMethod {
1488                method_type: fidl::MethodType::TwoWay, ..
1489            } => "unknown two-way method",
1490        }
1491    }
1492}
1493
1494#[derive(Debug, Clone)]
1495pub struct TaskProviderControlHandle {
1496    inner: std::sync::Arc<fidl::ServeInner<fdomain_client::fidl::FDomainResourceDialect>>,
1497}
1498
1499impl fdomain_client::fidl::ControlHandle for TaskProviderControlHandle {
1500    fn shutdown(&self) {
1501        self.inner.shutdown()
1502    }
1503
1504    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1505        self.inner.shutdown_with_epitaph(status)
1506    }
1507
1508    fn is_closed(&self) -> bool {
1509        self.inner.channel().is_closed()
1510    }
1511    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
1512        self.inner.channel().on_closed()
1513    }
1514}
1515
1516impl TaskProviderControlHandle {}
1517
1518#[must_use = "FIDL methods require a response to be sent"]
1519#[derive(Debug)]
1520pub struct TaskProviderGetJobResponder {
1521    control_handle: std::mem::ManuallyDrop<TaskProviderControlHandle>,
1522    tx_id: u32,
1523}
1524
1525/// Set the the channel to be shutdown (see [`TaskProviderControlHandle::shutdown`])
1526/// if the responder is dropped without sending a response, so that the client
1527/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1528impl std::ops::Drop for TaskProviderGetJobResponder {
1529    fn drop(&mut self) {
1530        self.control_handle.shutdown();
1531        // Safety: drops once, never accessed again
1532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1533    }
1534}
1535
1536impl fdomain_client::fidl::Responder for TaskProviderGetJobResponder {
1537    type ControlHandle = TaskProviderControlHandle;
1538
1539    fn control_handle(&self) -> &TaskProviderControlHandle {
1540        &self.control_handle
1541    }
1542
1543    fn drop_without_shutdown(mut self) {
1544        // Safety: drops once, never accessed again due to mem::forget
1545        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1546        // Prevent Drop from running (which would shut down the channel)
1547        std::mem::forget(self);
1548    }
1549}
1550
1551impl TaskProviderGetJobResponder {
1552    /// Sends a response to the FIDL transaction.
1553    ///
1554    /// Sets the channel to shutdown if an error occurs.
1555    pub fn send(self, mut result: Result<fdomain_client::Job, i32>) -> Result<(), fidl::Error> {
1556        let _result = self.send_raw(result);
1557        if _result.is_err() {
1558            self.control_handle.shutdown();
1559        }
1560        self.drop_without_shutdown();
1561        _result
1562    }
1563
1564    /// Similar to "send" but does not shutdown the channel if an error occurs.
1565    pub fn send_no_shutdown_on_err(
1566        self,
1567        mut result: Result<fdomain_client::Job, i32>,
1568    ) -> Result<(), fidl::Error> {
1569        let _result = self.send_raw(result);
1570        self.drop_without_shutdown();
1571        _result
1572    }
1573
1574    fn send_raw(&self, mut result: Result<fdomain_client::Job, i32>) -> Result<(), fidl::Error> {
1575        self.control_handle
1576            .inner
1577            .send::<fidl::encoding::ResultType<TaskProviderGetJobResponse, i32>>(
1578                result.map(|job| (job,)),
1579                self.tx_id,
1580                0x4c9ca4f4fdece3ad,
1581                fidl::encoding::DynamicFlags::empty(),
1582            )
1583    }
1584}
1585
1586mod internal {
1587    use super::*;
1588
1589    impl fidl::encoding::ResourceTypeMarker for ComponentControllerOnPublishDiagnosticsRequest {
1590        type Borrowed<'a> = &'a mut Self;
1591        fn take_or_borrow<'a>(
1592            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1593        ) -> Self::Borrowed<'a> {
1594            value
1595        }
1596    }
1597
1598    unsafe impl fidl::encoding::TypeMarker for ComponentControllerOnPublishDiagnosticsRequest {
1599        type Owned = Self;
1600
1601        #[inline(always)]
1602        fn inline_align(_context: fidl::encoding::Context) -> usize {
1603            8
1604        }
1605
1606        #[inline(always)]
1607        fn inline_size(_context: fidl::encoding::Context) -> usize {
1608            16
1609        }
1610    }
1611
1612    unsafe impl
1613        fidl::encoding::Encode<
1614            ComponentControllerOnPublishDiagnosticsRequest,
1615            fdomain_client::fidl::FDomainResourceDialect,
1616        > for &mut ComponentControllerOnPublishDiagnosticsRequest
1617    {
1618        #[inline]
1619        unsafe fn encode(
1620            self,
1621            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1622            offset: usize,
1623            _depth: fidl::encoding::Depth,
1624        ) -> fidl::Result<()> {
1625            encoder.debug_check_bounds::<ComponentControllerOnPublishDiagnosticsRequest>(offset);
1626            // Delegate to tuple encoding.
1627            fidl::encoding::Encode::<
1628                ComponentControllerOnPublishDiagnosticsRequest,
1629                fdomain_client::fidl::FDomainResourceDialect,
1630            >::encode(
1631                (<ComponentDiagnostics as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1632                    &mut self.payload,
1633                ),),
1634                encoder,
1635                offset,
1636                _depth,
1637            )
1638        }
1639    }
1640    unsafe impl<
1641        T0: fidl::encoding::Encode<ComponentDiagnostics, fdomain_client::fidl::FDomainResourceDialect>,
1642    >
1643        fidl::encoding::Encode<
1644            ComponentControllerOnPublishDiagnosticsRequest,
1645            fdomain_client::fidl::FDomainResourceDialect,
1646        > for (T0,)
1647    {
1648        #[inline]
1649        unsafe fn encode(
1650            self,
1651            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1652            offset: usize,
1653            depth: fidl::encoding::Depth,
1654        ) -> fidl::Result<()> {
1655            encoder.debug_check_bounds::<ComponentControllerOnPublishDiagnosticsRequest>(offset);
1656            // Zero out padding regions. There's no need to apply masks
1657            // because the unmasked parts will be overwritten by fields.
1658            // Write the fields.
1659            self.0.encode(encoder, offset + 0, depth)?;
1660            Ok(())
1661        }
1662    }
1663
1664    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1665        for ComponentControllerOnPublishDiagnosticsRequest
1666    {
1667        #[inline(always)]
1668        fn new_empty() -> Self {
1669            Self {
1670                payload: fidl::new_empty!(
1671                    ComponentDiagnostics,
1672                    fdomain_client::fidl::FDomainResourceDialect
1673                ),
1674            }
1675        }
1676
1677        #[inline]
1678        unsafe fn decode(
1679            &mut self,
1680            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1681            offset: usize,
1682            _depth: fidl::encoding::Depth,
1683        ) -> fidl::Result<()> {
1684            decoder.debug_check_bounds::<Self>(offset);
1685            // Verify that padding bytes are zero.
1686            fidl::decode!(
1687                ComponentDiagnostics,
1688                fdomain_client::fidl::FDomainResourceDialect,
1689                &mut self.payload,
1690                decoder,
1691                offset + 0,
1692                _depth
1693            )?;
1694            Ok(())
1695        }
1696    }
1697
1698    impl fidl::encoding::ResourceTypeMarker for ComponentRunnerStartRequest {
1699        type Borrowed<'a> = &'a mut Self;
1700        fn take_or_borrow<'a>(
1701            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1702        ) -> Self::Borrowed<'a> {
1703            value
1704        }
1705    }
1706
1707    unsafe impl fidl::encoding::TypeMarker for ComponentRunnerStartRequest {
1708        type Owned = Self;
1709
1710        #[inline(always)]
1711        fn inline_align(_context: fidl::encoding::Context) -> usize {
1712            8
1713        }
1714
1715        #[inline(always)]
1716        fn inline_size(_context: fidl::encoding::Context) -> usize {
1717            24
1718        }
1719    }
1720
1721    unsafe impl
1722        fidl::encoding::Encode<
1723            ComponentRunnerStartRequest,
1724            fdomain_client::fidl::FDomainResourceDialect,
1725        > for &mut ComponentRunnerStartRequest
1726    {
1727        #[inline]
1728        unsafe fn encode(
1729            self,
1730            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1731            offset: usize,
1732            _depth: fidl::encoding::Depth,
1733        ) -> fidl::Result<()> {
1734            encoder.debug_check_bounds::<ComponentRunnerStartRequest>(offset);
1735            // Delegate to tuple encoding.
1736            fidl::encoding::Encode::<
1737                ComponentRunnerStartRequest,
1738                fdomain_client::fidl::FDomainResourceDialect,
1739            >::encode(
1740                (
1741                    <ComponentStartInfo as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1742                        &mut self.start_info,
1743                    ),
1744                    <fidl::encoding::Endpoint<
1745                        fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1746                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1747                        &mut self.controller
1748                    ),
1749                ),
1750                encoder,
1751                offset,
1752                _depth,
1753            )
1754        }
1755    }
1756    unsafe impl<
1757        T0: fidl::encoding::Encode<ComponentStartInfo, fdomain_client::fidl::FDomainResourceDialect>,
1758        T1: fidl::encoding::Encode<
1759                fidl::encoding::Endpoint<
1760                    fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1761                >,
1762                fdomain_client::fidl::FDomainResourceDialect,
1763            >,
1764    >
1765        fidl::encoding::Encode<
1766            ComponentRunnerStartRequest,
1767            fdomain_client::fidl::FDomainResourceDialect,
1768        > for (T0, T1)
1769    {
1770        #[inline]
1771        unsafe fn encode(
1772            self,
1773            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1774            offset: usize,
1775            depth: fidl::encoding::Depth,
1776        ) -> fidl::Result<()> {
1777            encoder.debug_check_bounds::<ComponentRunnerStartRequest>(offset);
1778            // Zero out padding regions. There's no need to apply masks
1779            // because the unmasked parts will be overwritten by fields.
1780            unsafe {
1781                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1782                (ptr as *mut u64).write_unaligned(0);
1783            }
1784            // Write the fields.
1785            self.0.encode(encoder, offset + 0, depth)?;
1786            self.1.encode(encoder, offset + 16, depth)?;
1787            Ok(())
1788        }
1789    }
1790
1791    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1792        for ComponentRunnerStartRequest
1793    {
1794        #[inline(always)]
1795        fn new_empty() -> Self {
1796            Self {
1797                start_info: fidl::new_empty!(
1798                    ComponentStartInfo,
1799                    fdomain_client::fidl::FDomainResourceDialect
1800                ),
1801                controller: fidl::new_empty!(
1802                    fidl::encoding::Endpoint<
1803                        fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1804                    >,
1805                    fdomain_client::fidl::FDomainResourceDialect
1806                ),
1807            }
1808        }
1809
1810        #[inline]
1811        unsafe fn decode(
1812            &mut self,
1813            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1814            offset: usize,
1815            _depth: fidl::encoding::Depth,
1816        ) -> fidl::Result<()> {
1817            decoder.debug_check_bounds::<Self>(offset);
1818            // Verify that padding bytes are zero.
1819            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1820            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1821            let mask = 0xffffffff00000000u64;
1822            let maskedval = padval & mask;
1823            if maskedval != 0 {
1824                return Err(fidl::Error::NonZeroPadding {
1825                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1826                });
1827            }
1828            fidl::decode!(
1829                ComponentStartInfo,
1830                fdomain_client::fidl::FDomainResourceDialect,
1831                &mut self.start_info,
1832                decoder,
1833                offset + 0,
1834                _depth
1835            )?;
1836            fidl::decode!(
1837                fidl::encoding::Endpoint<
1838                    fdomain_client::fidl::ServerEnd<ComponentControllerMarker>,
1839                >,
1840                fdomain_client::fidl::FDomainResourceDialect,
1841                &mut self.controller,
1842                decoder,
1843                offset + 16,
1844                _depth
1845            )?;
1846            Ok(())
1847        }
1848    }
1849
1850    impl fidl::encoding::ResourceTypeMarker for TaskProviderGetJobResponse {
1851        type Borrowed<'a> = &'a mut Self;
1852        fn take_or_borrow<'a>(
1853            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1854        ) -> Self::Borrowed<'a> {
1855            value
1856        }
1857    }
1858
1859    unsafe impl fidl::encoding::TypeMarker for TaskProviderGetJobResponse {
1860        type Owned = Self;
1861
1862        #[inline(always)]
1863        fn inline_align(_context: fidl::encoding::Context) -> usize {
1864            4
1865        }
1866
1867        #[inline(always)]
1868        fn inline_size(_context: fidl::encoding::Context) -> usize {
1869            4
1870        }
1871    }
1872
1873    unsafe impl
1874        fidl::encoding::Encode<
1875            TaskProviderGetJobResponse,
1876            fdomain_client::fidl::FDomainResourceDialect,
1877        > for &mut TaskProviderGetJobResponse
1878    {
1879        #[inline]
1880        unsafe fn encode(
1881            self,
1882            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1883            offset: usize,
1884            _depth: fidl::encoding::Depth,
1885        ) -> fidl::Result<()> {
1886            encoder.debug_check_bounds::<TaskProviderGetJobResponse>(offset);
1887            // Delegate to tuple encoding.
1888            fidl::encoding::Encode::<
1889                TaskProviderGetJobResponse,
1890                fdomain_client::fidl::FDomainResourceDialect,
1891            >::encode(
1892                (<fidl::encoding::HandleType<
1893                    fdomain_client::Job,
1894                    { fidl::ObjectType::JOB.into_raw() },
1895                    2147483648,
1896                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1897                    &mut self.job
1898                ),),
1899                encoder,
1900                offset,
1901                _depth,
1902            )
1903        }
1904    }
1905    unsafe impl<
1906        T0: fidl::encoding::Encode<
1907                fidl::encoding::HandleType<
1908                    fdomain_client::Job,
1909                    { fidl::ObjectType::JOB.into_raw() },
1910                    2147483648,
1911                >,
1912                fdomain_client::fidl::FDomainResourceDialect,
1913            >,
1914    >
1915        fidl::encoding::Encode<
1916            TaskProviderGetJobResponse,
1917            fdomain_client::fidl::FDomainResourceDialect,
1918        > for (T0,)
1919    {
1920        #[inline]
1921        unsafe fn encode(
1922            self,
1923            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1924            offset: usize,
1925            depth: fidl::encoding::Depth,
1926        ) -> fidl::Result<()> {
1927            encoder.debug_check_bounds::<TaskProviderGetJobResponse>(offset);
1928            // Zero out padding regions. There's no need to apply masks
1929            // because the unmasked parts will be overwritten by fields.
1930            // Write the fields.
1931            self.0.encode(encoder, offset + 0, depth)?;
1932            Ok(())
1933        }
1934    }
1935
1936    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
1937        for TaskProviderGetJobResponse
1938    {
1939        #[inline(always)]
1940        fn new_empty() -> Self {
1941            Self {
1942                job: fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
1943            }
1944        }
1945
1946        #[inline]
1947        unsafe fn decode(
1948            &mut self,
1949            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
1950            offset: usize,
1951            _depth: fidl::encoding::Depth,
1952        ) -> fidl::Result<()> {
1953            decoder.debug_check_bounds::<Self>(offset);
1954            // Verify that padding bytes are zero.
1955            fidl::decode!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, &mut self.job, decoder, offset + 0, _depth)?;
1956            Ok(())
1957        }
1958    }
1959
1960    impl ComponentControllerOnEscrowRequest {
1961        #[inline(always)]
1962        fn max_ordinal_present(&self) -> u64 {
1963            if let Some(_) = self.escrowed_dictionary_handle {
1964                return 3;
1965            }
1966            if let Some(_) = self.escrowed_dictionary {
1967                return 2;
1968            }
1969            if let Some(_) = self.outgoing_dir {
1970                return 1;
1971            }
1972            0
1973        }
1974    }
1975
1976    impl fidl::encoding::ResourceTypeMarker for ComponentControllerOnEscrowRequest {
1977        type Borrowed<'a> = &'a mut Self;
1978        fn take_or_borrow<'a>(
1979            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1980        ) -> Self::Borrowed<'a> {
1981            value
1982        }
1983    }
1984
1985    unsafe impl fidl::encoding::TypeMarker for ComponentControllerOnEscrowRequest {
1986        type Owned = Self;
1987
1988        #[inline(always)]
1989        fn inline_align(_context: fidl::encoding::Context) -> usize {
1990            8
1991        }
1992
1993        #[inline(always)]
1994        fn inline_size(_context: fidl::encoding::Context) -> usize {
1995            16
1996        }
1997    }
1998
1999    unsafe impl
2000        fidl::encoding::Encode<
2001            ComponentControllerOnEscrowRequest,
2002            fdomain_client::fidl::FDomainResourceDialect,
2003        > for &mut ComponentControllerOnEscrowRequest
2004    {
2005        unsafe fn encode(
2006            self,
2007            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2008            offset: usize,
2009            mut depth: fidl::encoding::Depth,
2010        ) -> fidl::Result<()> {
2011            encoder.debug_check_bounds::<ComponentControllerOnEscrowRequest>(offset);
2012            // Vector header
2013            let max_ordinal: u64 = self.max_ordinal_present();
2014            encoder.write_num(max_ordinal, offset);
2015            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2016            // Calling encoder.out_of_line_offset(0) is not allowed.
2017            if max_ordinal == 0 {
2018                return Ok(());
2019            }
2020            depth.increment()?;
2021            let envelope_size = 8;
2022            let bytes_len = max_ordinal as usize * envelope_size;
2023            #[allow(unused_variables)]
2024            let offset = encoder.out_of_line_offset(bytes_len);
2025            let mut _prev_end_offset: usize = 0;
2026            if 1 > max_ordinal {
2027                return Ok(());
2028            }
2029
2030            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2031            // are envelope_size bytes.
2032            let cur_offset: usize = (1 - 1) * envelope_size;
2033
2034            // Zero reserved fields.
2035            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2036
2037            // Safety:
2038            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2039            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2040            //   envelope_size bytes, there is always sufficient room.
2041            fidl::encoding::encode_in_envelope_optional::<
2042                fidl::encoding::Endpoint<
2043                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2044                >,
2045                fdomain_client::fidl::FDomainResourceDialect,
2046            >(
2047                self.outgoing_dir.as_mut().map(
2048                    <fidl::encoding::Endpoint<
2049                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2050                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2051                ),
2052                encoder,
2053                offset + cur_offset,
2054                depth,
2055            )?;
2056
2057            _prev_end_offset = cur_offset + envelope_size;
2058            if 2 > max_ordinal {
2059                return Ok(());
2060            }
2061
2062            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2063            // are envelope_size bytes.
2064            let cur_offset: usize = (2 - 1) * envelope_size;
2065
2066            // Zero reserved fields.
2067            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2068
2069            // Safety:
2070            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2071            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2072            //   envelope_size bytes, there is always sufficient room.
2073            fidl::encoding::encode_in_envelope_optional::<fdomain_fuchsia_component_sandbox::DictionaryRef, fdomain_client::fidl::FDomainResourceDialect>(
2074            self.escrowed_dictionary.as_mut().map(<fdomain_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2075            encoder, offset + cur_offset, depth
2076        )?;
2077
2078            _prev_end_offset = cur_offset + envelope_size;
2079            if 3 > max_ordinal {
2080                return Ok(());
2081            }
2082
2083            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2084            // are envelope_size bytes.
2085            let cur_offset: usize = (3 - 1) * envelope_size;
2086
2087            // Zero reserved fields.
2088            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2089
2090            // Safety:
2091            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2092            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2093            //   envelope_size bytes, there is always sufficient room.
2094            fidl::encoding::encode_in_envelope_optional::<
2095                fidl::encoding::HandleType<
2096                    fdomain_client::EventPair,
2097                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2098                    2147483648,
2099                >,
2100                fdomain_client::fidl::FDomainResourceDialect,
2101            >(
2102                self.escrowed_dictionary_handle.as_mut().map(
2103                    <fidl::encoding::HandleType<
2104                        fdomain_client::EventPair,
2105                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2106                        2147483648,
2107                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2108                ),
2109                encoder,
2110                offset + cur_offset,
2111                depth,
2112            )?;
2113
2114            _prev_end_offset = cur_offset + envelope_size;
2115
2116            Ok(())
2117        }
2118    }
2119
2120    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2121        for ComponentControllerOnEscrowRequest
2122    {
2123        #[inline(always)]
2124        fn new_empty() -> Self {
2125            Self::default()
2126        }
2127
2128        unsafe fn decode(
2129            &mut self,
2130            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2131            offset: usize,
2132            mut depth: fidl::encoding::Depth,
2133        ) -> fidl::Result<()> {
2134            decoder.debug_check_bounds::<Self>(offset);
2135            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2136                None => return Err(fidl::Error::NotNullable),
2137                Some(len) => len,
2138            };
2139            // Calling decoder.out_of_line_offset(0) is not allowed.
2140            if len == 0 {
2141                return Ok(());
2142            };
2143            depth.increment()?;
2144            let envelope_size = 8;
2145            let bytes_len = len * envelope_size;
2146            let offset = decoder.out_of_line_offset(bytes_len)?;
2147            // Decode the envelope for each type.
2148            let mut _next_ordinal_to_read = 0;
2149            let mut next_offset = offset;
2150            let end_offset = offset + bytes_len;
2151            _next_ordinal_to_read += 1;
2152            if next_offset >= end_offset {
2153                return Ok(());
2154            }
2155
2156            // Decode unknown envelopes for gaps in ordinals.
2157            while _next_ordinal_to_read < 1 {
2158                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2159                _next_ordinal_to_read += 1;
2160                next_offset += envelope_size;
2161            }
2162
2163            let next_out_of_line = decoder.next_out_of_line();
2164            let handles_before = decoder.remaining_handles();
2165            if let Some((inlined, num_bytes, num_handles)) =
2166                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2167            {
2168                let member_inline_size = <fidl::encoding::Endpoint<
2169                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2170                > as fidl::encoding::TypeMarker>::inline_size(
2171                    decoder.context
2172                );
2173                if inlined != (member_inline_size <= 4) {
2174                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2175                }
2176                let inner_offset;
2177                let mut inner_depth = depth.clone();
2178                if inlined {
2179                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2180                    inner_offset = next_offset;
2181                } else {
2182                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2183                    inner_depth.increment()?;
2184                }
2185                let val_ref = self.outgoing_dir.get_or_insert_with(|| {
2186                    fidl::new_empty!(
2187                        fidl::encoding::Endpoint<
2188                            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2189                        >,
2190                        fdomain_client::fidl::FDomainResourceDialect
2191                    )
2192                });
2193                fidl::decode!(
2194                    fidl::encoding::Endpoint<
2195                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2196                    >,
2197                    fdomain_client::fidl::FDomainResourceDialect,
2198                    val_ref,
2199                    decoder,
2200                    inner_offset,
2201                    inner_depth
2202                )?;
2203                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2204                {
2205                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2206                }
2207                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2208                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2209                }
2210            }
2211
2212            next_offset += envelope_size;
2213            _next_ordinal_to_read += 1;
2214            if next_offset >= end_offset {
2215                return Ok(());
2216            }
2217
2218            // Decode unknown envelopes for gaps in ordinals.
2219            while _next_ordinal_to_read < 2 {
2220                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2221                _next_ordinal_to_read += 1;
2222                next_offset += envelope_size;
2223            }
2224
2225            let next_out_of_line = decoder.next_out_of_line();
2226            let handles_before = decoder.remaining_handles();
2227            if let Some((inlined, num_bytes, num_handles)) =
2228                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2229            {
2230                let member_inline_size = <fdomain_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2231                if inlined != (member_inline_size <= 4) {
2232                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2233                }
2234                let inner_offset;
2235                let mut inner_depth = depth.clone();
2236                if inlined {
2237                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2238                    inner_offset = next_offset;
2239                } else {
2240                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2241                    inner_depth.increment()?;
2242                }
2243                let val_ref = self.escrowed_dictionary.get_or_insert_with(|| {
2244                    fidl::new_empty!(
2245                        fdomain_fuchsia_component_sandbox::DictionaryRef,
2246                        fdomain_client::fidl::FDomainResourceDialect
2247                    )
2248                });
2249                fidl::decode!(
2250                    fdomain_fuchsia_component_sandbox::DictionaryRef,
2251                    fdomain_client::fidl::FDomainResourceDialect,
2252                    val_ref,
2253                    decoder,
2254                    inner_offset,
2255                    inner_depth
2256                )?;
2257                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2258                {
2259                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2260                }
2261                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2262                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2263                }
2264            }
2265
2266            next_offset += envelope_size;
2267            _next_ordinal_to_read += 1;
2268            if next_offset >= end_offset {
2269                return Ok(());
2270            }
2271
2272            // Decode unknown envelopes for gaps in ordinals.
2273            while _next_ordinal_to_read < 3 {
2274                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2275                _next_ordinal_to_read += 1;
2276                next_offset += envelope_size;
2277            }
2278
2279            let next_out_of_line = decoder.next_out_of_line();
2280            let handles_before = decoder.remaining_handles();
2281            if let Some((inlined, num_bytes, num_handles)) =
2282                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2283            {
2284                let member_inline_size = <fidl::encoding::HandleType<
2285                    fdomain_client::EventPair,
2286                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2287                    2147483648,
2288                > as fidl::encoding::TypeMarker>::inline_size(
2289                    decoder.context
2290                );
2291                if inlined != (member_inline_size <= 4) {
2292                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2293                }
2294                let inner_offset;
2295                let mut inner_depth = depth.clone();
2296                if inlined {
2297                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2298                    inner_offset = next_offset;
2299                } else {
2300                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2301                    inner_depth.increment()?;
2302                }
2303                let val_ref =
2304                self.escrowed_dictionary_handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
2305                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2306                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2307                {
2308                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2309                }
2310                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2311                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2312                }
2313            }
2314
2315            next_offset += envelope_size;
2316
2317            // Decode the remaining unknown envelopes.
2318            while next_offset < end_offset {
2319                _next_ordinal_to_read += 1;
2320                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2321                next_offset += envelope_size;
2322            }
2323
2324            Ok(())
2325        }
2326    }
2327
2328    impl ComponentDiagnostics {
2329        #[inline(always)]
2330        fn max_ordinal_present(&self) -> u64 {
2331            if let Some(_) = self.tasks {
2332                return 1;
2333            }
2334            0
2335        }
2336    }
2337
2338    impl fidl::encoding::ResourceTypeMarker for ComponentDiagnostics {
2339        type Borrowed<'a> = &'a mut Self;
2340        fn take_or_borrow<'a>(
2341            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2342        ) -> Self::Borrowed<'a> {
2343            value
2344        }
2345    }
2346
2347    unsafe impl fidl::encoding::TypeMarker for ComponentDiagnostics {
2348        type Owned = Self;
2349
2350        #[inline(always)]
2351        fn inline_align(_context: fidl::encoding::Context) -> usize {
2352            8
2353        }
2354
2355        #[inline(always)]
2356        fn inline_size(_context: fidl::encoding::Context) -> usize {
2357            16
2358        }
2359    }
2360
2361    unsafe impl
2362        fidl::encoding::Encode<ComponentDiagnostics, fdomain_client::fidl::FDomainResourceDialect>
2363        for &mut ComponentDiagnostics
2364    {
2365        unsafe fn encode(
2366            self,
2367            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2368            offset: usize,
2369            mut depth: fidl::encoding::Depth,
2370        ) -> fidl::Result<()> {
2371            encoder.debug_check_bounds::<ComponentDiagnostics>(offset);
2372            // Vector header
2373            let max_ordinal: u64 = self.max_ordinal_present();
2374            encoder.write_num(max_ordinal, offset);
2375            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2376            // Calling encoder.out_of_line_offset(0) is not allowed.
2377            if max_ordinal == 0 {
2378                return Ok(());
2379            }
2380            depth.increment()?;
2381            let envelope_size = 8;
2382            let bytes_len = max_ordinal as usize * envelope_size;
2383            #[allow(unused_variables)]
2384            let offset = encoder.out_of_line_offset(bytes_len);
2385            let mut _prev_end_offset: usize = 0;
2386            if 1 > max_ordinal {
2387                return Ok(());
2388            }
2389
2390            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2391            // are envelope_size bytes.
2392            let cur_offset: usize = (1 - 1) * envelope_size;
2393
2394            // Zero reserved fields.
2395            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2396
2397            // Safety:
2398            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2399            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2400            //   envelope_size bytes, there is always sufficient room.
2401            fidl::encoding::encode_in_envelope_optional::<
2402                ComponentTasks,
2403                fdomain_client::fidl::FDomainResourceDialect,
2404            >(
2405                self.tasks
2406                    .as_mut()
2407                    .map(<ComponentTasks as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2408                encoder,
2409                offset + cur_offset,
2410                depth,
2411            )?;
2412
2413            _prev_end_offset = cur_offset + envelope_size;
2414
2415            Ok(())
2416        }
2417    }
2418
2419    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2420        for ComponentDiagnostics
2421    {
2422        #[inline(always)]
2423        fn new_empty() -> Self {
2424            Self::default()
2425        }
2426
2427        unsafe fn decode(
2428            &mut self,
2429            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2430            offset: usize,
2431            mut depth: fidl::encoding::Depth,
2432        ) -> fidl::Result<()> {
2433            decoder.debug_check_bounds::<Self>(offset);
2434            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2435                None => return Err(fidl::Error::NotNullable),
2436                Some(len) => len,
2437            };
2438            // Calling decoder.out_of_line_offset(0) is not allowed.
2439            if len == 0 {
2440                return Ok(());
2441            };
2442            depth.increment()?;
2443            let envelope_size = 8;
2444            let bytes_len = len * envelope_size;
2445            let offset = decoder.out_of_line_offset(bytes_len)?;
2446            // Decode the envelope for each type.
2447            let mut _next_ordinal_to_read = 0;
2448            let mut next_offset = offset;
2449            let end_offset = offset + bytes_len;
2450            _next_ordinal_to_read += 1;
2451            if next_offset >= end_offset {
2452                return Ok(());
2453            }
2454
2455            // Decode unknown envelopes for gaps in ordinals.
2456            while _next_ordinal_to_read < 1 {
2457                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2458                _next_ordinal_to_read += 1;
2459                next_offset += envelope_size;
2460            }
2461
2462            let next_out_of_line = decoder.next_out_of_line();
2463            let handles_before = decoder.remaining_handles();
2464            if let Some((inlined, num_bytes, num_handles)) =
2465                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2466            {
2467                let member_inline_size =
2468                    <ComponentTasks as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2469                if inlined != (member_inline_size <= 4) {
2470                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2471                }
2472                let inner_offset;
2473                let mut inner_depth = depth.clone();
2474                if inlined {
2475                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2476                    inner_offset = next_offset;
2477                } else {
2478                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2479                    inner_depth.increment()?;
2480                }
2481                let val_ref = self.tasks.get_or_insert_with(|| {
2482                    fidl::new_empty!(ComponentTasks, fdomain_client::fidl::FDomainResourceDialect)
2483                });
2484                fidl::decode!(
2485                    ComponentTasks,
2486                    fdomain_client::fidl::FDomainResourceDialect,
2487                    val_ref,
2488                    decoder,
2489                    inner_offset,
2490                    inner_depth
2491                )?;
2492                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2493                {
2494                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2495                }
2496                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2497                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2498                }
2499            }
2500
2501            next_offset += envelope_size;
2502
2503            // Decode the remaining unknown envelopes.
2504            while next_offset < end_offset {
2505                _next_ordinal_to_read += 1;
2506                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2507                next_offset += envelope_size;
2508            }
2509
2510            Ok(())
2511        }
2512    }
2513
2514    impl ComponentNamespaceEntry {
2515        #[inline(always)]
2516        fn max_ordinal_present(&self) -> u64 {
2517            if let Some(_) = self.directory {
2518                return 2;
2519            }
2520            if let Some(_) = self.path {
2521                return 1;
2522            }
2523            0
2524        }
2525    }
2526
2527    impl fidl::encoding::ResourceTypeMarker for ComponentNamespaceEntry {
2528        type Borrowed<'a> = &'a mut Self;
2529        fn take_or_borrow<'a>(
2530            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2531        ) -> Self::Borrowed<'a> {
2532            value
2533        }
2534    }
2535
2536    unsafe impl fidl::encoding::TypeMarker for ComponentNamespaceEntry {
2537        type Owned = Self;
2538
2539        #[inline(always)]
2540        fn inline_align(_context: fidl::encoding::Context) -> usize {
2541            8
2542        }
2543
2544        #[inline(always)]
2545        fn inline_size(_context: fidl::encoding::Context) -> usize {
2546            16
2547        }
2548    }
2549
2550    unsafe impl
2551        fidl::encoding::Encode<
2552            ComponentNamespaceEntry,
2553            fdomain_client::fidl::FDomainResourceDialect,
2554        > for &mut ComponentNamespaceEntry
2555    {
2556        unsafe fn encode(
2557            self,
2558            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2559            offset: usize,
2560            mut depth: fidl::encoding::Depth,
2561        ) -> fidl::Result<()> {
2562            encoder.debug_check_bounds::<ComponentNamespaceEntry>(offset);
2563            // Vector header
2564            let max_ordinal: u64 = self.max_ordinal_present();
2565            encoder.write_num(max_ordinal, offset);
2566            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2567            // Calling encoder.out_of_line_offset(0) is not allowed.
2568            if max_ordinal == 0 {
2569                return Ok(());
2570            }
2571            depth.increment()?;
2572            let envelope_size = 8;
2573            let bytes_len = max_ordinal as usize * envelope_size;
2574            #[allow(unused_variables)]
2575            let offset = encoder.out_of_line_offset(bytes_len);
2576            let mut _prev_end_offset: usize = 0;
2577            if 1 > max_ordinal {
2578                return Ok(());
2579            }
2580
2581            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2582            // are envelope_size bytes.
2583            let cur_offset: usize = (1 - 1) * envelope_size;
2584
2585            // Zero reserved fields.
2586            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2587
2588            // Safety:
2589            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2590            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2591            //   envelope_size bytes, there is always sufficient room.
2592            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4095>, fdomain_client::fidl::FDomainResourceDialect>(
2593            self.path.as_ref().map(<fidl::encoding::BoundedString<4095> as fidl::encoding::ValueTypeMarker>::borrow),
2594            encoder, offset + cur_offset, depth
2595        )?;
2596
2597            _prev_end_offset = cur_offset + envelope_size;
2598            if 2 > max_ordinal {
2599                return Ok(());
2600            }
2601
2602            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2603            // are envelope_size bytes.
2604            let cur_offset: usize = (2 - 1) * envelope_size;
2605
2606            // Zero reserved fields.
2607            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2608
2609            // Safety:
2610            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2611            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2612            //   envelope_size bytes, there is always sufficient room.
2613            fidl::encoding::encode_in_envelope_optional::<
2614                fidl::encoding::Endpoint<
2615                    fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2616                >,
2617                fdomain_client::fidl::FDomainResourceDialect,
2618            >(
2619                self.directory.as_mut().map(
2620                    <fidl::encoding::Endpoint<
2621                        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2622                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2623                ),
2624                encoder,
2625                offset + cur_offset,
2626                depth,
2627            )?;
2628
2629            _prev_end_offset = cur_offset + envelope_size;
2630
2631            Ok(())
2632        }
2633    }
2634
2635    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
2636        for ComponentNamespaceEntry
2637    {
2638        #[inline(always)]
2639        fn new_empty() -> Self {
2640            Self::default()
2641        }
2642
2643        unsafe fn decode(
2644            &mut self,
2645            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2646            offset: usize,
2647            mut depth: fidl::encoding::Depth,
2648        ) -> fidl::Result<()> {
2649            decoder.debug_check_bounds::<Self>(offset);
2650            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2651                None => return Err(fidl::Error::NotNullable),
2652                Some(len) => len,
2653            };
2654            // Calling decoder.out_of_line_offset(0) is not allowed.
2655            if len == 0 {
2656                return Ok(());
2657            };
2658            depth.increment()?;
2659            let envelope_size = 8;
2660            let bytes_len = len * envelope_size;
2661            let offset = decoder.out_of_line_offset(bytes_len)?;
2662            // Decode the envelope for each type.
2663            let mut _next_ordinal_to_read = 0;
2664            let mut next_offset = offset;
2665            let end_offset = offset + bytes_len;
2666            _next_ordinal_to_read += 1;
2667            if next_offset >= end_offset {
2668                return Ok(());
2669            }
2670
2671            // Decode unknown envelopes for gaps in ordinals.
2672            while _next_ordinal_to_read < 1 {
2673                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2674                _next_ordinal_to_read += 1;
2675                next_offset += envelope_size;
2676            }
2677
2678            let next_out_of_line = decoder.next_out_of_line();
2679            let handles_before = decoder.remaining_handles();
2680            if let Some((inlined, num_bytes, num_handles)) =
2681                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2682            {
2683                let member_inline_size = <fidl::encoding::BoundedString<4095> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2684                if inlined != (member_inline_size <= 4) {
2685                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2686                }
2687                let inner_offset;
2688                let mut inner_depth = depth.clone();
2689                if inlined {
2690                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2691                    inner_offset = next_offset;
2692                } else {
2693                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2694                    inner_depth.increment()?;
2695                }
2696                let val_ref = self.path.get_or_insert_with(|| {
2697                    fidl::new_empty!(
2698                        fidl::encoding::BoundedString<4095>,
2699                        fdomain_client::fidl::FDomainResourceDialect
2700                    )
2701                });
2702                fidl::decode!(
2703                    fidl::encoding::BoundedString<4095>,
2704                    fdomain_client::fidl::FDomainResourceDialect,
2705                    val_ref,
2706                    decoder,
2707                    inner_offset,
2708                    inner_depth
2709                )?;
2710                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2711                {
2712                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2713                }
2714                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2715                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2716                }
2717            }
2718
2719            next_offset += envelope_size;
2720            _next_ordinal_to_read += 1;
2721            if next_offset >= end_offset {
2722                return Ok(());
2723            }
2724
2725            // Decode unknown envelopes for gaps in ordinals.
2726            while _next_ordinal_to_read < 2 {
2727                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2728                _next_ordinal_to_read += 1;
2729                next_offset += envelope_size;
2730            }
2731
2732            let next_out_of_line = decoder.next_out_of_line();
2733            let handles_before = decoder.remaining_handles();
2734            if let Some((inlined, num_bytes, num_handles)) =
2735                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2736            {
2737                let member_inline_size = <fidl::encoding::Endpoint<
2738                    fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2739                > as fidl::encoding::TypeMarker>::inline_size(
2740                    decoder.context
2741                );
2742                if inlined != (member_inline_size <= 4) {
2743                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2744                }
2745                let inner_offset;
2746                let mut inner_depth = depth.clone();
2747                if inlined {
2748                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2749                    inner_offset = next_offset;
2750                } else {
2751                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2752                    inner_depth.increment()?;
2753                }
2754                let val_ref = self.directory.get_or_insert_with(|| {
2755                    fidl::new_empty!(
2756                        fidl::encoding::Endpoint<
2757                            fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2758                        >,
2759                        fdomain_client::fidl::FDomainResourceDialect
2760                    )
2761                });
2762                fidl::decode!(
2763                    fidl::encoding::Endpoint<
2764                        fdomain_client::fidl::ClientEnd<fdomain_fuchsia_io::DirectoryMarker>,
2765                    >,
2766                    fdomain_client::fidl::FDomainResourceDialect,
2767                    val_ref,
2768                    decoder,
2769                    inner_offset,
2770                    inner_depth
2771                )?;
2772                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2773                {
2774                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2775                }
2776                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2777                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2778                }
2779            }
2780
2781            next_offset += envelope_size;
2782
2783            // Decode the remaining unknown envelopes.
2784            while next_offset < end_offset {
2785                _next_ordinal_to_read += 1;
2786                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2787                next_offset += envelope_size;
2788            }
2789
2790            Ok(())
2791        }
2792    }
2793
2794    impl ComponentStartInfo {
2795        #[inline(always)]
2796        fn max_ordinal_present(&self) -> u64 {
2797            if let Some(_) = self.escrowed_dictionary_handle {
2798                return 11;
2799            }
2800            if let Some(_) = self.escrowed_dictionary {
2801                return 10;
2802            }
2803            if let Some(_) = self.component_instance {
2804                return 9;
2805            }
2806            if let Some(_) = self.break_on_start {
2807                return 8;
2808            }
2809            if let Some(_) = self.encoded_config {
2810                return 7;
2811            }
2812            if let Some(_) = self.numbered_handles {
2813                return 6;
2814            }
2815            if let Some(_) = self.runtime_dir {
2816                return 5;
2817            }
2818            if let Some(_) = self.outgoing_dir {
2819                return 4;
2820            }
2821            if let Some(_) = self.ns {
2822                return 3;
2823            }
2824            if let Some(_) = self.program {
2825                return 2;
2826            }
2827            if let Some(_) = self.resolved_url {
2828                return 1;
2829            }
2830            0
2831        }
2832    }
2833
2834    impl fidl::encoding::ResourceTypeMarker for ComponentStartInfo {
2835        type Borrowed<'a> = &'a mut Self;
2836        fn take_or_borrow<'a>(
2837            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2838        ) -> Self::Borrowed<'a> {
2839            value
2840        }
2841    }
2842
2843    unsafe impl fidl::encoding::TypeMarker for ComponentStartInfo {
2844        type Owned = Self;
2845
2846        #[inline(always)]
2847        fn inline_align(_context: fidl::encoding::Context) -> usize {
2848            8
2849        }
2850
2851        #[inline(always)]
2852        fn inline_size(_context: fidl::encoding::Context) -> usize {
2853            16
2854        }
2855    }
2856
2857    unsafe impl
2858        fidl::encoding::Encode<ComponentStartInfo, fdomain_client::fidl::FDomainResourceDialect>
2859        for &mut ComponentStartInfo
2860    {
2861        unsafe fn encode(
2862            self,
2863            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
2864            offset: usize,
2865            mut depth: fidl::encoding::Depth,
2866        ) -> fidl::Result<()> {
2867            encoder.debug_check_bounds::<ComponentStartInfo>(offset);
2868            // Vector header
2869            let max_ordinal: u64 = self.max_ordinal_present();
2870            encoder.write_num(max_ordinal, offset);
2871            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2872            // Calling encoder.out_of_line_offset(0) is not allowed.
2873            if max_ordinal == 0 {
2874                return Ok(());
2875            }
2876            depth.increment()?;
2877            let envelope_size = 8;
2878            let bytes_len = max_ordinal as usize * envelope_size;
2879            #[allow(unused_variables)]
2880            let offset = encoder.out_of_line_offset(bytes_len);
2881            let mut _prev_end_offset: usize = 0;
2882            if 1 > max_ordinal {
2883                return Ok(());
2884            }
2885
2886            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2887            // are envelope_size bytes.
2888            let cur_offset: usize = (1 - 1) * envelope_size;
2889
2890            // Zero reserved fields.
2891            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2892
2893            // Safety:
2894            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2895            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2896            //   envelope_size bytes, there is always sufficient room.
2897            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fdomain_client::fidl::FDomainResourceDialect>(
2898            self.resolved_url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
2899            encoder, offset + cur_offset, depth
2900        )?;
2901
2902            _prev_end_offset = cur_offset + envelope_size;
2903            if 2 > max_ordinal {
2904                return Ok(());
2905            }
2906
2907            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2908            // are envelope_size bytes.
2909            let cur_offset: usize = (2 - 1) * envelope_size;
2910
2911            // Zero reserved fields.
2912            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2913
2914            // Safety:
2915            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2916            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2917            //   envelope_size bytes, there is always sufficient room.
2918            fidl::encoding::encode_in_envelope_optional::<
2919                fdomain_fuchsia_data::Dictionary,
2920                fdomain_client::fidl::FDomainResourceDialect,
2921            >(
2922                self.program.as_ref().map(
2923                    <fdomain_fuchsia_data::Dictionary as fidl::encoding::ValueTypeMarker>::borrow,
2924                ),
2925                encoder,
2926                offset + cur_offset,
2927                depth,
2928            )?;
2929
2930            _prev_end_offset = cur_offset + envelope_size;
2931            if 3 > max_ordinal {
2932                return Ok(());
2933            }
2934
2935            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2936            // are envelope_size bytes.
2937            let cur_offset: usize = (3 - 1) * envelope_size;
2938
2939            // Zero reserved fields.
2940            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2941
2942            // Safety:
2943            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2944            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2945            //   envelope_size bytes, there is always sufficient room.
2946            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<ComponentNamespaceEntry, 32>, fdomain_client::fidl::FDomainResourceDialect>(
2947            self.ns.as_mut().map(<fidl::encoding::Vector<ComponentNamespaceEntry, 32> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
2948            encoder, offset + cur_offset, depth
2949        )?;
2950
2951            _prev_end_offset = cur_offset + envelope_size;
2952            if 4 > max_ordinal {
2953                return Ok(());
2954            }
2955
2956            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2957            // are envelope_size bytes.
2958            let cur_offset: usize = (4 - 1) * envelope_size;
2959
2960            // Zero reserved fields.
2961            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2962
2963            // Safety:
2964            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2965            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2966            //   envelope_size bytes, there is always sufficient room.
2967            fidl::encoding::encode_in_envelope_optional::<
2968                fidl::encoding::Endpoint<
2969                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2970                >,
2971                fdomain_client::fidl::FDomainResourceDialect,
2972            >(
2973                self.outgoing_dir.as_mut().map(
2974                    <fidl::encoding::Endpoint<
2975                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
2976                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2977                ),
2978                encoder,
2979                offset + cur_offset,
2980                depth,
2981            )?;
2982
2983            _prev_end_offset = cur_offset + envelope_size;
2984            if 5 > max_ordinal {
2985                return Ok(());
2986            }
2987
2988            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2989            // are envelope_size bytes.
2990            let cur_offset: usize = (5 - 1) * envelope_size;
2991
2992            // Zero reserved fields.
2993            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2994
2995            // Safety:
2996            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2997            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2998            //   envelope_size bytes, there is always sufficient room.
2999            fidl::encoding::encode_in_envelope_optional::<
3000                fidl::encoding::Endpoint<
3001                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3002                >,
3003                fdomain_client::fidl::FDomainResourceDialect,
3004            >(
3005                self.runtime_dir.as_mut().map(
3006                    <fidl::encoding::Endpoint<
3007                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3008                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3009                ),
3010                encoder,
3011                offset + cur_offset,
3012                depth,
3013            )?;
3014
3015            _prev_end_offset = cur_offset + envelope_size;
3016            if 6 > max_ordinal {
3017                return Ok(());
3018            }
3019
3020            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3021            // are envelope_size bytes.
3022            let cur_offset: usize = (6 - 1) * envelope_size;
3023
3024            // Zero reserved fields.
3025            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3026
3027            // Safety:
3028            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3029            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3030            //   envelope_size bytes, there is always sufficient room.
3031            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<fdomain_fuchsia_process::HandleInfo, 128>, fdomain_client::fidl::FDomainResourceDialect>(
3032            self.numbered_handles.as_mut().map(<fidl::encoding::Vector<fdomain_fuchsia_process::HandleInfo, 128> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3033            encoder, offset + cur_offset, depth
3034        )?;
3035
3036            _prev_end_offset = cur_offset + envelope_size;
3037            if 7 > max_ordinal {
3038                return Ok(());
3039            }
3040
3041            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3042            // are envelope_size bytes.
3043            let cur_offset: usize = (7 - 1) * envelope_size;
3044
3045            // Zero reserved fields.
3046            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3047
3048            // Safety:
3049            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3050            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3051            //   envelope_size bytes, there is always sufficient room.
3052            fidl::encoding::encode_in_envelope_optional::<fdomain_fuchsia_mem::Data, fdomain_client::fidl::FDomainResourceDialect>(
3053            self.encoded_config.as_mut().map(<fdomain_fuchsia_mem::Data as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3054            encoder, offset + cur_offset, depth
3055        )?;
3056
3057            _prev_end_offset = cur_offset + envelope_size;
3058            if 8 > max_ordinal {
3059                return Ok(());
3060            }
3061
3062            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3063            // are envelope_size bytes.
3064            let cur_offset: usize = (8 - 1) * envelope_size;
3065
3066            // Zero reserved fields.
3067            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3068
3069            // Safety:
3070            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3071            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3072            //   envelope_size bytes, there is always sufficient room.
3073            fidl::encoding::encode_in_envelope_optional::<
3074                fidl::encoding::HandleType<
3075                    fdomain_client::EventPair,
3076                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3077                    2147483648,
3078                >,
3079                fdomain_client::fidl::FDomainResourceDialect,
3080            >(
3081                self.break_on_start.as_mut().map(
3082                    <fidl::encoding::HandleType<
3083                        fdomain_client::EventPair,
3084                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3085                        2147483648,
3086                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3087                ),
3088                encoder,
3089                offset + cur_offset,
3090                depth,
3091            )?;
3092
3093            _prev_end_offset = cur_offset + envelope_size;
3094            if 9 > max_ordinal {
3095                return Ok(());
3096            }
3097
3098            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3099            // are envelope_size bytes.
3100            let cur_offset: usize = (9 - 1) * envelope_size;
3101
3102            // Zero reserved fields.
3103            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3104
3105            // Safety:
3106            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3107            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3108            //   envelope_size bytes, there is always sufficient room.
3109            fidl::encoding::encode_in_envelope_optional::<
3110                fidl::encoding::HandleType<
3111                    fdomain_client::Event,
3112                    { fidl::ObjectType::EVENT.into_raw() },
3113                    2147483648,
3114                >,
3115                fdomain_client::fidl::FDomainResourceDialect,
3116            >(
3117                self.component_instance.as_mut().map(
3118                    <fidl::encoding::HandleType<
3119                        fdomain_client::Event,
3120                        { fidl::ObjectType::EVENT.into_raw() },
3121                        2147483648,
3122                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3123                ),
3124                encoder,
3125                offset + cur_offset,
3126                depth,
3127            )?;
3128
3129            _prev_end_offset = cur_offset + envelope_size;
3130            if 10 > max_ordinal {
3131                return Ok(());
3132            }
3133
3134            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3135            // are envelope_size bytes.
3136            let cur_offset: usize = (10 - 1) * envelope_size;
3137
3138            // Zero reserved fields.
3139            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3140
3141            // Safety:
3142            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3143            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3144            //   envelope_size bytes, there is always sufficient room.
3145            fidl::encoding::encode_in_envelope_optional::<fdomain_fuchsia_component_sandbox::DictionaryRef, fdomain_client::fidl::FDomainResourceDialect>(
3146            self.escrowed_dictionary.as_mut().map(<fdomain_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3147            encoder, offset + cur_offset, depth
3148        )?;
3149
3150            _prev_end_offset = cur_offset + envelope_size;
3151            if 11 > max_ordinal {
3152                return Ok(());
3153            }
3154
3155            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3156            // are envelope_size bytes.
3157            let cur_offset: usize = (11 - 1) * envelope_size;
3158
3159            // Zero reserved fields.
3160            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3161
3162            // Safety:
3163            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3164            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3165            //   envelope_size bytes, there is always sufficient room.
3166            fidl::encoding::encode_in_envelope_optional::<
3167                fidl::encoding::HandleType<
3168                    fdomain_client::EventPair,
3169                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3170                    2147483648,
3171                >,
3172                fdomain_client::fidl::FDomainResourceDialect,
3173            >(
3174                self.escrowed_dictionary_handle.as_mut().map(
3175                    <fidl::encoding::HandleType<
3176                        fdomain_client::EventPair,
3177                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3178                        2147483648,
3179                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3180                ),
3181                encoder,
3182                offset + cur_offset,
3183                depth,
3184            )?;
3185
3186            _prev_end_offset = cur_offset + envelope_size;
3187
3188            Ok(())
3189        }
3190    }
3191
3192    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3193        for ComponentStartInfo
3194    {
3195        #[inline(always)]
3196        fn new_empty() -> Self {
3197            Self::default()
3198        }
3199
3200        unsafe fn decode(
3201            &mut self,
3202            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3203            offset: usize,
3204            mut depth: fidl::encoding::Depth,
3205        ) -> fidl::Result<()> {
3206            decoder.debug_check_bounds::<Self>(offset);
3207            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3208                None => return Err(fidl::Error::NotNullable),
3209                Some(len) => len,
3210            };
3211            // Calling decoder.out_of_line_offset(0) is not allowed.
3212            if len == 0 {
3213                return Ok(());
3214            };
3215            depth.increment()?;
3216            let envelope_size = 8;
3217            let bytes_len = len * envelope_size;
3218            let offset = decoder.out_of_line_offset(bytes_len)?;
3219            // Decode the envelope for each type.
3220            let mut _next_ordinal_to_read = 0;
3221            let mut next_offset = offset;
3222            let end_offset = offset + bytes_len;
3223            _next_ordinal_to_read += 1;
3224            if next_offset >= end_offset {
3225                return Ok(());
3226            }
3227
3228            // Decode unknown envelopes for gaps in ordinals.
3229            while _next_ordinal_to_read < 1 {
3230                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3231                _next_ordinal_to_read += 1;
3232                next_offset += envelope_size;
3233            }
3234
3235            let next_out_of_line = decoder.next_out_of_line();
3236            let handles_before = decoder.remaining_handles();
3237            if let Some((inlined, num_bytes, num_handles)) =
3238                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3239            {
3240                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3241                if inlined != (member_inline_size <= 4) {
3242                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3243                }
3244                let inner_offset;
3245                let mut inner_depth = depth.clone();
3246                if inlined {
3247                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3248                    inner_offset = next_offset;
3249                } else {
3250                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3251                    inner_depth.increment()?;
3252                }
3253                let val_ref = self.resolved_url.get_or_insert_with(|| {
3254                    fidl::new_empty!(
3255                        fidl::encoding::BoundedString<4096>,
3256                        fdomain_client::fidl::FDomainResourceDialect
3257                    )
3258                });
3259                fidl::decode!(
3260                    fidl::encoding::BoundedString<4096>,
3261                    fdomain_client::fidl::FDomainResourceDialect,
3262                    val_ref,
3263                    decoder,
3264                    inner_offset,
3265                    inner_depth
3266                )?;
3267                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3268                {
3269                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3270                }
3271                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3272                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3273                }
3274            }
3275
3276            next_offset += envelope_size;
3277            _next_ordinal_to_read += 1;
3278            if next_offset >= end_offset {
3279                return Ok(());
3280            }
3281
3282            // Decode unknown envelopes for gaps in ordinals.
3283            while _next_ordinal_to_read < 2 {
3284                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3285                _next_ordinal_to_read += 1;
3286                next_offset += envelope_size;
3287            }
3288
3289            let next_out_of_line = decoder.next_out_of_line();
3290            let handles_before = decoder.remaining_handles();
3291            if let Some((inlined, num_bytes, num_handles)) =
3292                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3293            {
3294                let member_inline_size =
3295                    <fdomain_fuchsia_data::Dictionary as fidl::encoding::TypeMarker>::inline_size(
3296                        decoder.context,
3297                    );
3298                if inlined != (member_inline_size <= 4) {
3299                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3300                }
3301                let inner_offset;
3302                let mut inner_depth = depth.clone();
3303                if inlined {
3304                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3305                    inner_offset = next_offset;
3306                } else {
3307                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3308                    inner_depth.increment()?;
3309                }
3310                let val_ref = self.program.get_or_insert_with(|| {
3311                    fidl::new_empty!(
3312                        fdomain_fuchsia_data::Dictionary,
3313                        fdomain_client::fidl::FDomainResourceDialect
3314                    )
3315                });
3316                fidl::decode!(
3317                    fdomain_fuchsia_data::Dictionary,
3318                    fdomain_client::fidl::FDomainResourceDialect,
3319                    val_ref,
3320                    decoder,
3321                    inner_offset,
3322                    inner_depth
3323                )?;
3324                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3325                {
3326                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3327                }
3328                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3329                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3330                }
3331            }
3332
3333            next_offset += envelope_size;
3334            _next_ordinal_to_read += 1;
3335            if next_offset >= end_offset {
3336                return Ok(());
3337            }
3338
3339            // Decode unknown envelopes for gaps in ordinals.
3340            while _next_ordinal_to_read < 3 {
3341                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3342                _next_ordinal_to_read += 1;
3343                next_offset += envelope_size;
3344            }
3345
3346            let next_out_of_line = decoder.next_out_of_line();
3347            let handles_before = decoder.remaining_handles();
3348            if let Some((inlined, num_bytes, num_handles)) =
3349                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3350            {
3351                let member_inline_size = <fidl::encoding::Vector<ComponentNamespaceEntry, 32> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3352                if inlined != (member_inline_size <= 4) {
3353                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3354                }
3355                let inner_offset;
3356                let mut inner_depth = depth.clone();
3357                if inlined {
3358                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3359                    inner_offset = next_offset;
3360                } else {
3361                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3362                    inner_depth.increment()?;
3363                }
3364                let val_ref =
3365                self.ns.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<ComponentNamespaceEntry, 32>, fdomain_client::fidl::FDomainResourceDialect));
3366                fidl::decode!(fidl::encoding::Vector<ComponentNamespaceEntry, 32>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3367                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3368                {
3369                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3370                }
3371                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3372                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3373                }
3374            }
3375
3376            next_offset += envelope_size;
3377            _next_ordinal_to_read += 1;
3378            if next_offset >= end_offset {
3379                return Ok(());
3380            }
3381
3382            // Decode unknown envelopes for gaps in ordinals.
3383            while _next_ordinal_to_read < 4 {
3384                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3385                _next_ordinal_to_read += 1;
3386                next_offset += envelope_size;
3387            }
3388
3389            let next_out_of_line = decoder.next_out_of_line();
3390            let handles_before = decoder.remaining_handles();
3391            if let Some((inlined, num_bytes, num_handles)) =
3392                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3393            {
3394                let member_inline_size = <fidl::encoding::Endpoint<
3395                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3396                > as fidl::encoding::TypeMarker>::inline_size(
3397                    decoder.context
3398                );
3399                if inlined != (member_inline_size <= 4) {
3400                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3401                }
3402                let inner_offset;
3403                let mut inner_depth = depth.clone();
3404                if inlined {
3405                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3406                    inner_offset = next_offset;
3407                } else {
3408                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3409                    inner_depth.increment()?;
3410                }
3411                let val_ref = self.outgoing_dir.get_or_insert_with(|| {
3412                    fidl::new_empty!(
3413                        fidl::encoding::Endpoint<
3414                            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3415                        >,
3416                        fdomain_client::fidl::FDomainResourceDialect
3417                    )
3418                });
3419                fidl::decode!(
3420                    fidl::encoding::Endpoint<
3421                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3422                    >,
3423                    fdomain_client::fidl::FDomainResourceDialect,
3424                    val_ref,
3425                    decoder,
3426                    inner_offset,
3427                    inner_depth
3428                )?;
3429                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3430                {
3431                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3432                }
3433                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3434                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3435                }
3436            }
3437
3438            next_offset += envelope_size;
3439            _next_ordinal_to_read += 1;
3440            if next_offset >= end_offset {
3441                return Ok(());
3442            }
3443
3444            // Decode unknown envelopes for gaps in ordinals.
3445            while _next_ordinal_to_read < 5 {
3446                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3447                _next_ordinal_to_read += 1;
3448                next_offset += envelope_size;
3449            }
3450
3451            let next_out_of_line = decoder.next_out_of_line();
3452            let handles_before = decoder.remaining_handles();
3453            if let Some((inlined, num_bytes, num_handles)) =
3454                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3455            {
3456                let member_inline_size = <fidl::encoding::Endpoint<
3457                    fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3458                > as fidl::encoding::TypeMarker>::inline_size(
3459                    decoder.context
3460                );
3461                if inlined != (member_inline_size <= 4) {
3462                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3463                }
3464                let inner_offset;
3465                let mut inner_depth = depth.clone();
3466                if inlined {
3467                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3468                    inner_offset = next_offset;
3469                } else {
3470                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3471                    inner_depth.increment()?;
3472                }
3473                let val_ref = self.runtime_dir.get_or_insert_with(|| {
3474                    fidl::new_empty!(
3475                        fidl::encoding::Endpoint<
3476                            fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3477                        >,
3478                        fdomain_client::fidl::FDomainResourceDialect
3479                    )
3480                });
3481                fidl::decode!(
3482                    fidl::encoding::Endpoint<
3483                        fdomain_client::fidl::ServerEnd<fdomain_fuchsia_io::DirectoryMarker>,
3484                    >,
3485                    fdomain_client::fidl::FDomainResourceDialect,
3486                    val_ref,
3487                    decoder,
3488                    inner_offset,
3489                    inner_depth
3490                )?;
3491                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3492                {
3493                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3494                }
3495                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3496                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3497                }
3498            }
3499
3500            next_offset += envelope_size;
3501            _next_ordinal_to_read += 1;
3502            if next_offset >= end_offset {
3503                return Ok(());
3504            }
3505
3506            // Decode unknown envelopes for gaps in ordinals.
3507            while _next_ordinal_to_read < 6 {
3508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3509                _next_ordinal_to_read += 1;
3510                next_offset += envelope_size;
3511            }
3512
3513            let next_out_of_line = decoder.next_out_of_line();
3514            let handles_before = decoder.remaining_handles();
3515            if let Some((inlined, num_bytes, num_handles)) =
3516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3517            {
3518                let member_inline_size = <fidl::encoding::Vector<
3519                    fdomain_fuchsia_process::HandleInfo,
3520                    128,
3521                > as fidl::encoding::TypeMarker>::inline_size(
3522                    decoder.context
3523                );
3524                if inlined != (member_inline_size <= 4) {
3525                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3526                }
3527                let inner_offset;
3528                let mut inner_depth = depth.clone();
3529                if inlined {
3530                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3531                    inner_offset = next_offset;
3532                } else {
3533                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3534                    inner_depth.increment()?;
3535                }
3536                let val_ref =
3537                self.numbered_handles.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fdomain_fuchsia_process::HandleInfo, 128>, fdomain_client::fidl::FDomainResourceDialect));
3538                fidl::decode!(fidl::encoding::Vector<fdomain_fuchsia_process::HandleInfo, 128>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3539                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3540                {
3541                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3542                }
3543                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3544                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3545                }
3546            }
3547
3548            next_offset += envelope_size;
3549            _next_ordinal_to_read += 1;
3550            if next_offset >= end_offset {
3551                return Ok(());
3552            }
3553
3554            // Decode unknown envelopes for gaps in ordinals.
3555            while _next_ordinal_to_read < 7 {
3556                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3557                _next_ordinal_to_read += 1;
3558                next_offset += envelope_size;
3559            }
3560
3561            let next_out_of_line = decoder.next_out_of_line();
3562            let handles_before = decoder.remaining_handles();
3563            if let Some((inlined, num_bytes, num_handles)) =
3564                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3565            {
3566                let member_inline_size =
3567                    <fdomain_fuchsia_mem::Data as fidl::encoding::TypeMarker>::inline_size(
3568                        decoder.context,
3569                    );
3570                if inlined != (member_inline_size <= 4) {
3571                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3572                }
3573                let inner_offset;
3574                let mut inner_depth = depth.clone();
3575                if inlined {
3576                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3577                    inner_offset = next_offset;
3578                } else {
3579                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3580                    inner_depth.increment()?;
3581                }
3582                let val_ref = self.encoded_config.get_or_insert_with(|| {
3583                    fidl::new_empty!(
3584                        fdomain_fuchsia_mem::Data,
3585                        fdomain_client::fidl::FDomainResourceDialect
3586                    )
3587                });
3588                fidl::decode!(
3589                    fdomain_fuchsia_mem::Data,
3590                    fdomain_client::fidl::FDomainResourceDialect,
3591                    val_ref,
3592                    decoder,
3593                    inner_offset,
3594                    inner_depth
3595                )?;
3596                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3597                {
3598                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3599                }
3600                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3601                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3602                }
3603            }
3604
3605            next_offset += envelope_size;
3606            _next_ordinal_to_read += 1;
3607            if next_offset >= end_offset {
3608                return Ok(());
3609            }
3610
3611            // Decode unknown envelopes for gaps in ordinals.
3612            while _next_ordinal_to_read < 8 {
3613                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3614                _next_ordinal_to_read += 1;
3615                next_offset += envelope_size;
3616            }
3617
3618            let next_out_of_line = decoder.next_out_of_line();
3619            let handles_before = decoder.remaining_handles();
3620            if let Some((inlined, num_bytes, num_handles)) =
3621                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3622            {
3623                let member_inline_size = <fidl::encoding::HandleType<
3624                    fdomain_client::EventPair,
3625                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3626                    2147483648,
3627                > as fidl::encoding::TypeMarker>::inline_size(
3628                    decoder.context
3629                );
3630                if inlined != (member_inline_size <= 4) {
3631                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3632                }
3633                let inner_offset;
3634                let mut inner_depth = depth.clone();
3635                if inlined {
3636                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3637                    inner_offset = next_offset;
3638                } else {
3639                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3640                    inner_depth.increment()?;
3641                }
3642                let val_ref =
3643                self.break_on_start.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
3644                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3645                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3646                {
3647                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3648                }
3649                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3650                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3651                }
3652            }
3653
3654            next_offset += envelope_size;
3655            _next_ordinal_to_read += 1;
3656            if next_offset >= end_offset {
3657                return Ok(());
3658            }
3659
3660            // Decode unknown envelopes for gaps in ordinals.
3661            while _next_ordinal_to_read < 9 {
3662                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3663                _next_ordinal_to_read += 1;
3664                next_offset += envelope_size;
3665            }
3666
3667            let next_out_of_line = decoder.next_out_of_line();
3668            let handles_before = decoder.remaining_handles();
3669            if let Some((inlined, num_bytes, num_handles)) =
3670                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3671            {
3672                let member_inline_size = <fidl::encoding::HandleType<
3673                    fdomain_client::Event,
3674                    { fidl::ObjectType::EVENT.into_raw() },
3675                    2147483648,
3676                > as fidl::encoding::TypeMarker>::inline_size(
3677                    decoder.context
3678                );
3679                if inlined != (member_inline_size <= 4) {
3680                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3681                }
3682                let inner_offset;
3683                let mut inner_depth = depth.clone();
3684                if inlined {
3685                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3686                    inner_offset = next_offset;
3687                } else {
3688                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3689                    inner_depth.increment()?;
3690                }
3691                let val_ref =
3692                self.component_instance.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
3693                fidl::decode!(fidl::encoding::HandleType<fdomain_client::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3694                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3695                {
3696                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3697                }
3698                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3699                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3700                }
3701            }
3702
3703            next_offset += envelope_size;
3704            _next_ordinal_to_read += 1;
3705            if next_offset >= end_offset {
3706                return Ok(());
3707            }
3708
3709            // Decode unknown envelopes for gaps in ordinals.
3710            while _next_ordinal_to_read < 10 {
3711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3712                _next_ordinal_to_read += 1;
3713                next_offset += envelope_size;
3714            }
3715
3716            let next_out_of_line = decoder.next_out_of_line();
3717            let handles_before = decoder.remaining_handles();
3718            if let Some((inlined, num_bytes, num_handles)) =
3719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3720            {
3721                let member_inline_size = <fdomain_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3722                if inlined != (member_inline_size <= 4) {
3723                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3724                }
3725                let inner_offset;
3726                let mut inner_depth = depth.clone();
3727                if inlined {
3728                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3729                    inner_offset = next_offset;
3730                } else {
3731                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3732                    inner_depth.increment()?;
3733                }
3734                let val_ref = self.escrowed_dictionary.get_or_insert_with(|| {
3735                    fidl::new_empty!(
3736                        fdomain_fuchsia_component_sandbox::DictionaryRef,
3737                        fdomain_client::fidl::FDomainResourceDialect
3738                    )
3739                });
3740                fidl::decode!(
3741                    fdomain_fuchsia_component_sandbox::DictionaryRef,
3742                    fdomain_client::fidl::FDomainResourceDialect,
3743                    val_ref,
3744                    decoder,
3745                    inner_offset,
3746                    inner_depth
3747                )?;
3748                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3749                {
3750                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3751                }
3752                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3753                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3754                }
3755            }
3756
3757            next_offset += envelope_size;
3758            _next_ordinal_to_read += 1;
3759            if next_offset >= end_offset {
3760                return Ok(());
3761            }
3762
3763            // Decode unknown envelopes for gaps in ordinals.
3764            while _next_ordinal_to_read < 11 {
3765                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3766                _next_ordinal_to_read += 1;
3767                next_offset += envelope_size;
3768            }
3769
3770            let next_out_of_line = decoder.next_out_of_line();
3771            let handles_before = decoder.remaining_handles();
3772            if let Some((inlined, num_bytes, num_handles)) =
3773                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3774            {
3775                let member_inline_size = <fidl::encoding::HandleType<
3776                    fdomain_client::EventPair,
3777                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3778                    2147483648,
3779                > as fidl::encoding::TypeMarker>::inline_size(
3780                    decoder.context
3781                );
3782                if inlined != (member_inline_size <= 4) {
3783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3784                }
3785                let inner_offset;
3786                let mut inner_depth = depth.clone();
3787                if inlined {
3788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3789                    inner_offset = next_offset;
3790                } else {
3791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3792                    inner_depth.increment()?;
3793                }
3794                let val_ref =
3795                self.escrowed_dictionary_handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect));
3796                fidl::decode!(fidl::encoding::HandleType<fdomain_client::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3797                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3798                {
3799                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3800                }
3801                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3802                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3803                }
3804            }
3805
3806            next_offset += envelope_size;
3807
3808            // Decode the remaining unknown envelopes.
3809            while next_offset < end_offset {
3810                _next_ordinal_to_read += 1;
3811                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3812                next_offset += envelope_size;
3813            }
3814
3815            Ok(())
3816        }
3817    }
3818
3819    impl ComponentStopInfo {
3820        #[inline(always)]
3821        fn max_ordinal_present(&self) -> u64 {
3822            if let Some(_) = self.exit_code {
3823                return 2;
3824            }
3825            if let Some(_) = self.termination_status {
3826                return 1;
3827            }
3828            0
3829        }
3830    }
3831
3832    impl fidl::encoding::ResourceTypeMarker for ComponentStopInfo {
3833        type Borrowed<'a> = &'a mut Self;
3834        fn take_or_borrow<'a>(
3835            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3836        ) -> Self::Borrowed<'a> {
3837            value
3838        }
3839    }
3840
3841    unsafe impl fidl::encoding::TypeMarker for ComponentStopInfo {
3842        type Owned = Self;
3843
3844        #[inline(always)]
3845        fn inline_align(_context: fidl::encoding::Context) -> usize {
3846            8
3847        }
3848
3849        #[inline(always)]
3850        fn inline_size(_context: fidl::encoding::Context) -> usize {
3851            16
3852        }
3853    }
3854
3855    unsafe impl
3856        fidl::encoding::Encode<ComponentStopInfo, fdomain_client::fidl::FDomainResourceDialect>
3857        for &mut ComponentStopInfo
3858    {
3859        unsafe fn encode(
3860            self,
3861            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3862            offset: usize,
3863            mut depth: fidl::encoding::Depth,
3864        ) -> fidl::Result<()> {
3865            encoder.debug_check_bounds::<ComponentStopInfo>(offset);
3866            // Vector header
3867            let max_ordinal: u64 = self.max_ordinal_present();
3868            encoder.write_num(max_ordinal, offset);
3869            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3870            // Calling encoder.out_of_line_offset(0) is not allowed.
3871            if max_ordinal == 0 {
3872                return Ok(());
3873            }
3874            depth.increment()?;
3875            let envelope_size = 8;
3876            let bytes_len = max_ordinal as usize * envelope_size;
3877            #[allow(unused_variables)]
3878            let offset = encoder.out_of_line_offset(bytes_len);
3879            let mut _prev_end_offset: usize = 0;
3880            if 1 > max_ordinal {
3881                return Ok(());
3882            }
3883
3884            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3885            // are envelope_size bytes.
3886            let cur_offset: usize = (1 - 1) * envelope_size;
3887
3888            // Zero reserved fields.
3889            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3890
3891            // Safety:
3892            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3893            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3894            //   envelope_size bytes, there is always sufficient room.
3895            fidl::encoding::encode_in_envelope_optional::<
3896                i32,
3897                fdomain_client::fidl::FDomainResourceDialect,
3898            >(
3899                self.termination_status
3900                    .as_ref()
3901                    .map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
3902                encoder,
3903                offset + cur_offset,
3904                depth,
3905            )?;
3906
3907            _prev_end_offset = cur_offset + envelope_size;
3908            if 2 > max_ordinal {
3909                return Ok(());
3910            }
3911
3912            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3913            // are envelope_size bytes.
3914            let cur_offset: usize = (2 - 1) * envelope_size;
3915
3916            // Zero reserved fields.
3917            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3918
3919            // Safety:
3920            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3921            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3922            //   envelope_size bytes, there is always sufficient room.
3923            fidl::encoding::encode_in_envelope_optional::<
3924                i64,
3925                fdomain_client::fidl::FDomainResourceDialect,
3926            >(
3927                self.exit_code.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
3928                encoder,
3929                offset + cur_offset,
3930                depth,
3931            )?;
3932
3933            _prev_end_offset = cur_offset + envelope_size;
3934
3935            Ok(())
3936        }
3937    }
3938
3939    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
3940        for ComponentStopInfo
3941    {
3942        #[inline(always)]
3943        fn new_empty() -> Self {
3944            Self::default()
3945        }
3946
3947        unsafe fn decode(
3948            &mut self,
3949            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
3950            offset: usize,
3951            mut depth: fidl::encoding::Depth,
3952        ) -> fidl::Result<()> {
3953            decoder.debug_check_bounds::<Self>(offset);
3954            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3955                None => return Err(fidl::Error::NotNullable),
3956                Some(len) => len,
3957            };
3958            // Calling decoder.out_of_line_offset(0) is not allowed.
3959            if len == 0 {
3960                return Ok(());
3961            };
3962            depth.increment()?;
3963            let envelope_size = 8;
3964            let bytes_len = len * envelope_size;
3965            let offset = decoder.out_of_line_offset(bytes_len)?;
3966            // Decode the envelope for each type.
3967            let mut _next_ordinal_to_read = 0;
3968            let mut next_offset = offset;
3969            let end_offset = offset + bytes_len;
3970            _next_ordinal_to_read += 1;
3971            if next_offset >= end_offset {
3972                return Ok(());
3973            }
3974
3975            // Decode unknown envelopes for gaps in ordinals.
3976            while _next_ordinal_to_read < 1 {
3977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3978                _next_ordinal_to_read += 1;
3979                next_offset += envelope_size;
3980            }
3981
3982            let next_out_of_line = decoder.next_out_of_line();
3983            let handles_before = decoder.remaining_handles();
3984            if let Some((inlined, num_bytes, num_handles)) =
3985                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3986            {
3987                let member_inline_size =
3988                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3989                if inlined != (member_inline_size <= 4) {
3990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3991                }
3992                let inner_offset;
3993                let mut inner_depth = depth.clone();
3994                if inlined {
3995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3996                    inner_offset = next_offset;
3997                } else {
3998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3999                    inner_depth.increment()?;
4000                }
4001                let val_ref = self.termination_status.get_or_insert_with(|| {
4002                    fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect)
4003                });
4004                fidl::decode!(
4005                    i32,
4006                    fdomain_client::fidl::FDomainResourceDialect,
4007                    val_ref,
4008                    decoder,
4009                    inner_offset,
4010                    inner_depth
4011                )?;
4012                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4013                {
4014                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4015                }
4016                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4017                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4018                }
4019            }
4020
4021            next_offset += envelope_size;
4022            _next_ordinal_to_read += 1;
4023            if next_offset >= end_offset {
4024                return Ok(());
4025            }
4026
4027            // Decode unknown envelopes for gaps in ordinals.
4028            while _next_ordinal_to_read < 2 {
4029                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4030                _next_ordinal_to_read += 1;
4031                next_offset += envelope_size;
4032            }
4033
4034            let next_out_of_line = decoder.next_out_of_line();
4035            let handles_before = decoder.remaining_handles();
4036            if let Some((inlined, num_bytes, num_handles)) =
4037                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4038            {
4039                let member_inline_size =
4040                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4041                if inlined != (member_inline_size <= 4) {
4042                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4043                }
4044                let inner_offset;
4045                let mut inner_depth = depth.clone();
4046                if inlined {
4047                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4048                    inner_offset = next_offset;
4049                } else {
4050                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4051                    inner_depth.increment()?;
4052                }
4053                let val_ref = self.exit_code.get_or_insert_with(|| {
4054                    fidl::new_empty!(i64, fdomain_client::fidl::FDomainResourceDialect)
4055                });
4056                fidl::decode!(
4057                    i64,
4058                    fdomain_client::fidl::FDomainResourceDialect,
4059                    val_ref,
4060                    decoder,
4061                    inner_offset,
4062                    inner_depth
4063                )?;
4064                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4065                {
4066                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4067                }
4068                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4069                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4070                }
4071            }
4072
4073            next_offset += envelope_size;
4074
4075            // Decode the remaining unknown envelopes.
4076            while next_offset < end_offset {
4077                _next_ordinal_to_read += 1;
4078                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4079                next_offset += envelope_size;
4080            }
4081
4082            Ok(())
4083        }
4084    }
4085
4086    impl ComponentTasks {
4087        #[inline(always)]
4088        fn max_ordinal_present(&self) -> u64 {
4089            if let Some(_) = self.parent_task {
4090                return 2;
4091            }
4092            if let Some(_) = self.component_task {
4093                return 1;
4094            }
4095            0
4096        }
4097    }
4098
4099    impl fidl::encoding::ResourceTypeMarker for ComponentTasks {
4100        type Borrowed<'a> = &'a mut Self;
4101        fn take_or_borrow<'a>(
4102            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4103        ) -> Self::Borrowed<'a> {
4104            value
4105        }
4106    }
4107
4108    unsafe impl fidl::encoding::TypeMarker for ComponentTasks {
4109        type Owned = Self;
4110
4111        #[inline(always)]
4112        fn inline_align(_context: fidl::encoding::Context) -> usize {
4113            8
4114        }
4115
4116        #[inline(always)]
4117        fn inline_size(_context: fidl::encoding::Context) -> usize {
4118            16
4119        }
4120    }
4121
4122    unsafe impl fidl::encoding::Encode<ComponentTasks, fdomain_client::fidl::FDomainResourceDialect>
4123        for &mut ComponentTasks
4124    {
4125        unsafe fn encode(
4126            self,
4127            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4128            offset: usize,
4129            mut depth: fidl::encoding::Depth,
4130        ) -> fidl::Result<()> {
4131            encoder.debug_check_bounds::<ComponentTasks>(offset);
4132            // Vector header
4133            let max_ordinal: u64 = self.max_ordinal_present();
4134            encoder.write_num(max_ordinal, offset);
4135            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4136            // Calling encoder.out_of_line_offset(0) is not allowed.
4137            if max_ordinal == 0 {
4138                return Ok(());
4139            }
4140            depth.increment()?;
4141            let envelope_size = 8;
4142            let bytes_len = max_ordinal as usize * envelope_size;
4143            #[allow(unused_variables)]
4144            let offset = encoder.out_of_line_offset(bytes_len);
4145            let mut _prev_end_offset: usize = 0;
4146            if 1 > max_ordinal {
4147                return Ok(());
4148            }
4149
4150            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4151            // are envelope_size bytes.
4152            let cur_offset: usize = (1 - 1) * envelope_size;
4153
4154            // Zero reserved fields.
4155            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4156
4157            // Safety:
4158            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4159            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4160            //   envelope_size bytes, there is always sufficient room.
4161            fidl::encoding::encode_in_envelope_optional::<
4162                Task,
4163                fdomain_client::fidl::FDomainResourceDialect,
4164            >(
4165                self.component_task
4166                    .as_mut()
4167                    .map(<Task as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4168                encoder,
4169                offset + cur_offset,
4170                depth,
4171            )?;
4172
4173            _prev_end_offset = cur_offset + envelope_size;
4174            if 2 > max_ordinal {
4175                return Ok(());
4176            }
4177
4178            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4179            // are envelope_size bytes.
4180            let cur_offset: usize = (2 - 1) * envelope_size;
4181
4182            // Zero reserved fields.
4183            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4184
4185            // Safety:
4186            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4187            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4188            //   envelope_size bytes, there is always sufficient room.
4189            fidl::encoding::encode_in_envelope_optional::<
4190                Task,
4191                fdomain_client::fidl::FDomainResourceDialect,
4192            >(
4193                self.parent_task
4194                    .as_mut()
4195                    .map(<Task as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4196                encoder,
4197                offset + cur_offset,
4198                depth,
4199            )?;
4200
4201            _prev_end_offset = cur_offset + envelope_size;
4202
4203            Ok(())
4204        }
4205    }
4206
4207    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for ComponentTasks {
4208        #[inline(always)]
4209        fn new_empty() -> Self {
4210            Self::default()
4211        }
4212
4213        unsafe fn decode(
4214            &mut self,
4215            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4216            offset: usize,
4217            mut depth: fidl::encoding::Depth,
4218        ) -> fidl::Result<()> {
4219            decoder.debug_check_bounds::<Self>(offset);
4220            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4221                None => return Err(fidl::Error::NotNullable),
4222                Some(len) => len,
4223            };
4224            // Calling decoder.out_of_line_offset(0) is not allowed.
4225            if len == 0 {
4226                return Ok(());
4227            };
4228            depth.increment()?;
4229            let envelope_size = 8;
4230            let bytes_len = len * envelope_size;
4231            let offset = decoder.out_of_line_offset(bytes_len)?;
4232            // Decode the envelope for each type.
4233            let mut _next_ordinal_to_read = 0;
4234            let mut next_offset = offset;
4235            let end_offset = offset + bytes_len;
4236            _next_ordinal_to_read += 1;
4237            if next_offset >= end_offset {
4238                return Ok(());
4239            }
4240
4241            // Decode unknown envelopes for gaps in ordinals.
4242            while _next_ordinal_to_read < 1 {
4243                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4244                _next_ordinal_to_read += 1;
4245                next_offset += envelope_size;
4246            }
4247
4248            let next_out_of_line = decoder.next_out_of_line();
4249            let handles_before = decoder.remaining_handles();
4250            if let Some((inlined, num_bytes, num_handles)) =
4251                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4252            {
4253                let member_inline_size =
4254                    <Task as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4255                if inlined != (member_inline_size <= 4) {
4256                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4257                }
4258                let inner_offset;
4259                let mut inner_depth = depth.clone();
4260                if inlined {
4261                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4262                    inner_offset = next_offset;
4263                } else {
4264                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4265                    inner_depth.increment()?;
4266                }
4267                let val_ref = self.component_task.get_or_insert_with(|| {
4268                    fidl::new_empty!(Task, fdomain_client::fidl::FDomainResourceDialect)
4269                });
4270                fidl::decode!(
4271                    Task,
4272                    fdomain_client::fidl::FDomainResourceDialect,
4273                    val_ref,
4274                    decoder,
4275                    inner_offset,
4276                    inner_depth
4277                )?;
4278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4279                {
4280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4281                }
4282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4284                }
4285            }
4286
4287            next_offset += envelope_size;
4288            _next_ordinal_to_read += 1;
4289            if next_offset >= end_offset {
4290                return Ok(());
4291            }
4292
4293            // Decode unknown envelopes for gaps in ordinals.
4294            while _next_ordinal_to_read < 2 {
4295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4296                _next_ordinal_to_read += 1;
4297                next_offset += envelope_size;
4298            }
4299
4300            let next_out_of_line = decoder.next_out_of_line();
4301            let handles_before = decoder.remaining_handles();
4302            if let Some((inlined, num_bytes, num_handles)) =
4303                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4304            {
4305                let member_inline_size =
4306                    <Task as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4307                if inlined != (member_inline_size <= 4) {
4308                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4309                }
4310                let inner_offset;
4311                let mut inner_depth = depth.clone();
4312                if inlined {
4313                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4314                    inner_offset = next_offset;
4315                } else {
4316                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4317                    inner_depth.increment()?;
4318                }
4319                let val_ref = self.parent_task.get_or_insert_with(|| {
4320                    fidl::new_empty!(Task, fdomain_client::fidl::FDomainResourceDialect)
4321                });
4322                fidl::decode!(
4323                    Task,
4324                    fdomain_client::fidl::FDomainResourceDialect,
4325                    val_ref,
4326                    decoder,
4327                    inner_offset,
4328                    inner_depth
4329                )?;
4330                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4331                {
4332                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4333                }
4334                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4335                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4336                }
4337            }
4338
4339            next_offset += envelope_size;
4340
4341            // Decode the remaining unknown envelopes.
4342            while next_offset < end_offset {
4343                _next_ordinal_to_read += 1;
4344                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4345                next_offset += envelope_size;
4346            }
4347
4348            Ok(())
4349        }
4350    }
4351
4352    impl fidl::encoding::ResourceTypeMarker for Task {
4353        type Borrowed<'a> = &'a mut Self;
4354        fn take_or_borrow<'a>(
4355            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4356        ) -> Self::Borrowed<'a> {
4357            value
4358        }
4359    }
4360
4361    unsafe impl fidl::encoding::TypeMarker for Task {
4362        type Owned = Self;
4363
4364        #[inline(always)]
4365        fn inline_align(_context: fidl::encoding::Context) -> usize {
4366            8
4367        }
4368
4369        #[inline(always)]
4370        fn inline_size(_context: fidl::encoding::Context) -> usize {
4371            16
4372        }
4373    }
4374
4375    unsafe impl fidl::encoding::Encode<Task, fdomain_client::fidl::FDomainResourceDialect>
4376        for &mut Task
4377    {
4378        #[inline]
4379        unsafe fn encode(
4380            self,
4381            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4382            offset: usize,
4383            _depth: fidl::encoding::Depth,
4384        ) -> fidl::Result<()> {
4385            encoder.debug_check_bounds::<Task>(offset);
4386            encoder.write_num::<u64>(self.ordinal(), offset);
4387            match self {
4388                Task::Job(ref mut val) => fidl::encoding::encode_in_envelope::<
4389                    fidl::encoding::HandleType<
4390                        fdomain_client::Job,
4391                        { fidl::ObjectType::JOB.into_raw() },
4392                        2147483648,
4393                    >,
4394                    fdomain_client::fidl::FDomainResourceDialect,
4395                >(
4396                    <fidl::encoding::HandleType<
4397                        fdomain_client::Job,
4398                        { fidl::ObjectType::JOB.into_raw() },
4399                        2147483648,
4400                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4401                        val
4402                    ),
4403                    encoder,
4404                    offset + 8,
4405                    _depth,
4406                ),
4407                Task::Process(ref mut val) => fidl::encoding::encode_in_envelope::<
4408                    fidl::encoding::HandleType<
4409                        fdomain_client::Process,
4410                        { fidl::ObjectType::PROCESS.into_raw() },
4411                        2147483648,
4412                    >,
4413                    fdomain_client::fidl::FDomainResourceDialect,
4414                >(
4415                    <fidl::encoding::HandleType<
4416                        fdomain_client::Process,
4417                        { fidl::ObjectType::PROCESS.into_raw() },
4418                        2147483648,
4419                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4420                        val
4421                    ),
4422                    encoder,
4423                    offset + 8,
4424                    _depth,
4425                ),
4426                Task::Thread(ref mut val) => fidl::encoding::encode_in_envelope::<
4427                    fidl::encoding::HandleType<
4428                        fdomain_client::Thread,
4429                        { fidl::ObjectType::THREAD.into_raw() },
4430                        2147483648,
4431                    >,
4432                    fdomain_client::fidl::FDomainResourceDialect,
4433                >(
4434                    <fidl::encoding::HandleType<
4435                        fdomain_client::Thread,
4436                        { fidl::ObjectType::THREAD.into_raw() },
4437                        2147483648,
4438                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4439                        val
4440                    ),
4441                    encoder,
4442                    offset + 8,
4443                    _depth,
4444                ),
4445                Task::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
4446            }
4447        }
4448    }
4449
4450    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect> for Task {
4451        #[inline(always)]
4452        fn new_empty() -> Self {
4453            Self::__SourceBreaking { unknown_ordinal: 0 }
4454        }
4455
4456        #[inline]
4457        unsafe fn decode(
4458            &mut self,
4459            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
4460            offset: usize,
4461            mut depth: fidl::encoding::Depth,
4462        ) -> fidl::Result<()> {
4463            decoder.debug_check_bounds::<Self>(offset);
4464            #[allow(unused_variables)]
4465            let next_out_of_line = decoder.next_out_of_line();
4466            let handles_before = decoder.remaining_handles();
4467            let (ordinal, inlined, num_bytes, num_handles) =
4468                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
4469
4470            let member_inline_size = match ordinal {
4471                1 => <fidl::encoding::HandleType<
4472                    fdomain_client::Job,
4473                    { fidl::ObjectType::JOB.into_raw() },
4474                    2147483648,
4475                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4476                2 => <fidl::encoding::HandleType<
4477                    fdomain_client::Process,
4478                    { fidl::ObjectType::PROCESS.into_raw() },
4479                    2147483648,
4480                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4481                3 => <fidl::encoding::HandleType<
4482                    fdomain_client::Thread,
4483                    { fidl::ObjectType::THREAD.into_raw() },
4484                    2147483648,
4485                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4486                0 => return Err(fidl::Error::UnknownUnionTag),
4487                _ => num_bytes as usize,
4488            };
4489
4490            if inlined != (member_inline_size <= 4) {
4491                return Err(fidl::Error::InvalidInlineBitInEnvelope);
4492            }
4493            let _inner_offset;
4494            if inlined {
4495                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
4496                _inner_offset = offset + 8;
4497            } else {
4498                depth.increment()?;
4499                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4500            }
4501            match ordinal {
4502                1 => {
4503                    #[allow(irrefutable_let_patterns)]
4504                    if let Task::Job(_) = self {
4505                        // Do nothing, read the value into the object
4506                    } else {
4507                        // Initialize `self` to the right variant
4508                        *self = Task::Job(
4509                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
4510                        );
4511                    }
4512                    #[allow(irrefutable_let_patterns)]
4513                    if let Task::Job(ref mut val) = self {
4514                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Job, { fidl::ObjectType::JOB.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
4515                    } else {
4516                        unreachable!()
4517                    }
4518                }
4519                2 => {
4520                    #[allow(irrefutable_let_patterns)]
4521                    if let Task::Process(_) = self {
4522                        // Do nothing, read the value into the object
4523                    } else {
4524                        // Initialize `self` to the right variant
4525                        *self = Task::Process(
4526                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
4527                        );
4528                    }
4529                    #[allow(irrefutable_let_patterns)]
4530                    if let Task::Process(ref mut val) = self {
4531                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
4532                    } else {
4533                        unreachable!()
4534                    }
4535                }
4536                3 => {
4537                    #[allow(irrefutable_let_patterns)]
4538                    if let Task::Thread(_) = self {
4539                        // Do nothing, read the value into the object
4540                    } else {
4541                        // Initialize `self` to the right variant
4542                        *self = Task::Thread(
4543                            fidl::new_empty!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect),
4544                        );
4545                    }
4546                    #[allow(irrefutable_let_patterns)]
4547                    if let Task::Thread(ref mut val) = self {
4548                        fidl::decode!(fidl::encoding::HandleType<fdomain_client::Thread, { fidl::ObjectType::THREAD.into_raw() }, 2147483648>, fdomain_client::fidl::FDomainResourceDialect, val, decoder, _inner_offset, depth)?;
4549                    } else {
4550                        unreachable!()
4551                    }
4552                }
4553                #[allow(deprecated)]
4554                ordinal => {
4555                    for _ in 0..num_handles {
4556                        decoder.drop_next_handle()?;
4557                    }
4558                    *self = Task::__SourceBreaking { unknown_ordinal: ordinal };
4559                }
4560            }
4561            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
4562                return Err(fidl::Error::InvalidNumBytesInEnvelope);
4563            }
4564            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4565                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4566            }
4567            Ok(())
4568        }
4569    }
4570}