fidl_fuchsia_driver_framework/
fidl_fuchsia_driver_framework.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_driver_framework__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct DriverStartRequest {
16    pub start_args: DriverStartArgs,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverStartRequest {}
20
21#[derive(Debug, PartialEq)]
22pub struct NodeAddChildRequest {
23    pub args: NodeAddArgs,
24    pub controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
25    pub node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
26}
27
28impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddChildRequest {}
29
30#[derive(Debug, Default, PartialEq)]
31pub struct DevfsAddArgs {
32    /// This is the connector to be installed in devfs.
33    /// `Connect()` will be called when a client connects to this node in the filesystem.
34    /// Optional: If this is not provided then an empty node will appear in devfs.
35    pub connector: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>>,
36    /// This is the class name for installing this node in devfs.
37    /// The node will be placed within /dev/class/{class_name}.
38    /// If `class_name` does not exist under /dev/class/ it will be created.
39    /// Optional: If this is not provided then the node will only be added via topological path.
40    pub class_name: Option<String>,
41    /// This is a vmo of inspect data that will be installed in devfs.
42    /// Optional: If this is not provided then the devfs's inspect data will be empty.
43    pub inspect: Option<fidl::Vmo>,
44    /// The connection types that are supported by the |connector| given.
45    /// The driver framework should handle connection types that are not supported by the
46    /// connector.
47    /// If not provided, only the device type is assumed as supported by the connector.
48    pub connector_supports: Option<fidl_fuchsia_device_fs::ConnectionType>,
49    /// This is the controller connector to be installed in devfs.
50    /// `Connect()` will be called when a client connects to the device_controller connection
51    /// for this node in the filesystem.
52    /// Optional: If this is not provided then the Node will handle the connection natively.
53    /// This option should only be used by the compat shim or in tests
54    pub controller_connector:
55        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>>,
56    #[doc(hidden)]
57    pub __source_breaking: fidl::marker::SourceBreaking,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevfsAddArgs {}
61
62/// Arguments for starting a driver.
63#[derive(Debug, Default, PartialEq)]
64pub struct DriverStartArgs {
65    /// Node that the driver is bound to.
66    pub node: Option<fidl::endpoints::ClientEnd<NodeMarker>>,
67    /// Symbols provided to the driver, for |node|. These come from the driver
68    /// that added |node|, and are filtered to the symbols requested in the bind
69    /// program.
70    pub symbols: Option<Vec<NodeSymbol>>,
71    /// URL of the package containing the driver. This is purely informational,
72    /// used only to provide data for inspect.
73    pub url: Option<String>,
74    /// Information about the driver to start. Currently, we support the
75    /// following entries:
76    ///   1. "binary": a string containing the package-relative path to the
77    ///      driver binary.
78    ///   2. "colocate" (optional): a string containing "true" or "false"
79    ///      specifying whether the driver should be colocated in the same
80    ///      driver host as the driver that added |node|. If not specified, the
81    ///      driver will be launched in a new driver host.
82    ///   3. "default_dispatcher_opts" (optional): an array of strings specifying
83    ///      the options for creating the default dispatcher. A string can be one
84    ///      of the following:
85    ///      * `allow_sync_calls`: allows synchronous calls to be done on the
86    ///      default dispatcher's thread.
87    ///   4. "default_dispatcher_scheduler_role" (optional): the scheduler role to
88    ///      set for the default dispatcher created for the driver.
89    pub program: Option<fidl_fuchsia_data::Dictionary>,
90    /// Incoming namespace provided to the driver.
91    pub incoming: Option<Vec<fidl_fuchsia_component_runner::ComponentNamespaceEntry>>,
92    /// Outgoing directory served by the driver.
93    pub outgoing_dir: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
94    /// Configuration passed to the driver.
95    pub config: Option<fidl::Vmo>,
96    /// The name of the node the driver is bound to.
97    pub node_name: Option<String>,
98    /// Node properties of the node the driver is bound to.
99    /// If the node is non-composite then the "default" entry will contain the
100    /// node's own properties.
101    /// If the node is a composite then there is an entry for each of its parents
102    /// and the "default" entry will reference the primary composite parent
103    /// node's properties. The composite parent node's properties are those that
104    /// were provided in the composite node specification and not the original
105    /// properties of the parent.
106    pub node_properties: Option<Vec<NodePropertyEntry>>,
107    /// Node offers of the node the driver is bound to.
108    pub node_offers: Option<Vec<Offer>>,
109    /// Provides a token representing this node which can be exchanged with the
110    /// driver framework to discern additional information about this node.
111    pub node_token: Option<fidl::Event>,
112    pub node_properties_2: Option<Vec<NodePropertyEntry2>>,
113    /// Root VMAR the driver is mapped into. All child mappings should be placed into this VMAR
114    /// if they want to have the same scheduler profile applied to them.
115    pub vmar: Option<fidl::Vmar>,
116    #[doc(hidden)]
117    pub __source_breaking: fidl::marker::SourceBreaking,
118}
119
120impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverStartArgs {}
121
122/// Arguments for adding a node.
123#[derive(Debug, Default, PartialEq)]
124pub struct NodeAddArgs {
125    /// Name of the node.
126    pub name: Option<String>,
127    /// Functions to provide to the driver that is bound to this node.
128    pub symbols: Option<Vec<NodeSymbol>>,
129    /// Properties of the node. Deprecated: all new usages should set properties2 and leave
130    /// this field blank.
131    pub properties: Option<Vec<NodeProperty>>,
132    /// The arguments for how this node should be added to devfs.
133    pub devfs_args: Option<DevfsAddArgs>,
134    /// Capabilities to offer to the driver that is bound to this node.
135    /// The driver must ensure these capabilities are added to its outgoing directory
136    /// before adding the child node.
137    pub offers2: Option<Vec<Offer>>,
138    /// Information that feeds into a structured bus topology for the device. It should
139    /// only be specified by bus drivers, ideally those which are included by default.
140    pub bus_info: Option<BusInfo>,
141    /// Properties of the node. If set, the `properties` field must be blank. Otherwise,
142    /// adding the node will return an error.
143    pub properties2: Option<Vec<NodeProperty2>>,
144    /// This can be used to provide additional offers, through a dictionary, to the driver that is
145    /// bound to this node. Unlike |offers2|, any capabilities available through this dictionary
146    /// are opaque to the driver framework.
147    /// All capabilities directly in the dictionary MUST be mutually exclusive from the offers in
148    /// offers2.
149    pub offers_dictionary: Option<fidl_fuchsia_component_sandbox::DictionaryRef>,
150    #[doc(hidden)]
151    pub __source_breaking: fidl::marker::SourceBreaking,
152}
153
154impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddArgs {}
155
156#[derive(Debug, Default, PartialEq)]
157pub struct NodeControllerOnBindRequest {
158    /// Provides a token representing this node which can be exchanged with the
159    /// driver framework to discern additional information about this node.
160    pub node_token: Option<fidl::Event>,
161    #[doc(hidden)]
162    pub __source_breaking: fidl::marker::SourceBreaking,
163}
164
165impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
166    for NodeControllerOnBindRequest
167{
168}
169
170#[derive(Debug)]
171pub enum DriverResult {
172    /// The token that belongs to the node that a driver has started successfully on.
173    DriverStartedNodeToken(fidl::Event),
174    /// The node failed to find a matching driver or composite spec.
175    MatchError(i32),
176    /// The driver that bound to the node failed to start successfully.
177    StartError(i32),
178    #[doc(hidden)]
179    __SourceBreaking { unknown_ordinal: u64 },
180}
181
182/// Pattern that matches an unknown `DriverResult` member.
183#[macro_export]
184macro_rules! DriverResultUnknown {
185    () => {
186        _
187    };
188}
189
190// Custom PartialEq so that unknown variants are not equal to themselves.
191impl PartialEq for DriverResult {
192    fn eq(&self, other: &Self) -> bool {
193        match (self, other) {
194            (Self::DriverStartedNodeToken(x), Self::DriverStartedNodeToken(y)) => *x == *y,
195            (Self::MatchError(x), Self::MatchError(y)) => *x == *y,
196            (Self::StartError(x), Self::StartError(y)) => *x == *y,
197            _ => false,
198        }
199    }
200}
201
202impl DriverResult {
203    #[inline]
204    pub fn ordinal(&self) -> u64 {
205        match *self {
206            Self::DriverStartedNodeToken(_) => 1,
207            Self::MatchError(_) => 2,
208            Self::StartError(_) => 3,
209            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
210        }
211    }
212
213    #[inline]
214    pub fn unknown_variant_for_testing() -> Self {
215        Self::__SourceBreaking { unknown_ordinal: 0 }
216    }
217
218    #[inline]
219    pub fn is_unknown(&self) -> bool {
220        match self {
221            Self::__SourceBreaking { .. } => true,
222            _ => false,
223        }
224    }
225}
226
227impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverResult {}
228
229#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
230pub struct CompositeNodeManagerMarker;
231
232impl fidl::endpoints::ProtocolMarker for CompositeNodeManagerMarker {
233    type Proxy = CompositeNodeManagerProxy;
234    type RequestStream = CompositeNodeManagerRequestStream;
235    #[cfg(target_os = "fuchsia")]
236    type SynchronousProxy = CompositeNodeManagerSynchronousProxy;
237
238    const DEBUG_NAME: &'static str = "fuchsia.driver.framework.CompositeNodeManager";
239}
240impl fidl::endpoints::DiscoverableProtocolMarker for CompositeNodeManagerMarker {}
241pub type CompositeNodeManagerAddSpecResult = Result<(), CompositeNodeSpecError>;
242
243pub trait CompositeNodeManagerProxyInterface: Send + Sync {
244    type AddSpecResponseFut: std::future::Future<Output = Result<CompositeNodeManagerAddSpecResult, fidl::Error>>
245        + Send;
246    fn r#add_spec(&self, payload: &CompositeNodeSpec) -> Self::AddSpecResponseFut;
247}
248#[derive(Debug)]
249#[cfg(target_os = "fuchsia")]
250pub struct CompositeNodeManagerSynchronousProxy {
251    client: fidl::client::sync::Client,
252}
253
254#[cfg(target_os = "fuchsia")]
255impl fidl::endpoints::SynchronousProxy for CompositeNodeManagerSynchronousProxy {
256    type Proxy = CompositeNodeManagerProxy;
257    type Protocol = CompositeNodeManagerMarker;
258
259    fn from_channel(inner: fidl::Channel) -> Self {
260        Self::new(inner)
261    }
262
263    fn into_channel(self) -> fidl::Channel {
264        self.client.into_channel()
265    }
266
267    fn as_channel(&self) -> &fidl::Channel {
268        self.client.as_channel()
269    }
270}
271
272#[cfg(target_os = "fuchsia")]
273impl CompositeNodeManagerSynchronousProxy {
274    pub fn new(channel: fidl::Channel) -> Self {
275        let protocol_name =
276            <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
277        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
278    }
279
280    pub fn into_channel(self) -> fidl::Channel {
281        self.client.into_channel()
282    }
283
284    /// Waits until an event arrives and returns it. It is safe for other
285    /// threads to make concurrent requests while waiting for an event.
286    pub fn wait_for_event(
287        &self,
288        deadline: zx::MonotonicInstant,
289    ) -> Result<CompositeNodeManagerEvent, fidl::Error> {
290        CompositeNodeManagerEvent::decode(self.client.wait_for_event(deadline)?)
291    }
292
293    /// Adds the given composite node specification to the driver framework.
294    pub fn r#add_spec(
295        &self,
296        mut payload: &CompositeNodeSpec,
297        ___deadline: zx::MonotonicInstant,
298    ) -> Result<CompositeNodeManagerAddSpecResult, fidl::Error> {
299        let _response =
300            self.client
301                .send_query::<CompositeNodeSpec, fidl::encoding::FlexibleResultType<
302                    fidl::encoding::EmptyStruct,
303                    CompositeNodeSpecError,
304                >>(
305                    payload,
306                    0x524e353c8130cc74,
307                    fidl::encoding::DynamicFlags::FLEXIBLE,
308                    ___deadline,
309                )?
310                .into_result::<CompositeNodeManagerMarker>("add_spec")?;
311        Ok(_response.map(|x| x))
312    }
313}
314
315#[cfg(target_os = "fuchsia")]
316impl From<CompositeNodeManagerSynchronousProxy> for zx::Handle {
317    fn from(value: CompositeNodeManagerSynchronousProxy) -> Self {
318        value.into_channel().into()
319    }
320}
321
322#[cfg(target_os = "fuchsia")]
323impl From<fidl::Channel> for CompositeNodeManagerSynchronousProxy {
324    fn from(value: fidl::Channel) -> Self {
325        Self::new(value)
326    }
327}
328
329#[cfg(target_os = "fuchsia")]
330impl fidl::endpoints::FromClient for CompositeNodeManagerSynchronousProxy {
331    type Protocol = CompositeNodeManagerMarker;
332
333    fn from_client(value: fidl::endpoints::ClientEnd<CompositeNodeManagerMarker>) -> Self {
334        Self::new(value.into_channel())
335    }
336}
337
338#[derive(Debug, Clone)]
339pub struct CompositeNodeManagerProxy {
340    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
341}
342
343impl fidl::endpoints::Proxy for CompositeNodeManagerProxy {
344    type Protocol = CompositeNodeManagerMarker;
345
346    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
347        Self::new(inner)
348    }
349
350    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
351        self.client.into_channel().map_err(|client| Self { client })
352    }
353
354    fn as_channel(&self) -> &::fidl::AsyncChannel {
355        self.client.as_channel()
356    }
357}
358
359impl CompositeNodeManagerProxy {
360    /// Create a new Proxy for fuchsia.driver.framework/CompositeNodeManager.
361    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
362        let protocol_name =
363            <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
364        Self { client: fidl::client::Client::new(channel, protocol_name) }
365    }
366
367    /// Get a Stream of events from the remote end of the protocol.
368    ///
369    /// # Panics
370    ///
371    /// Panics if the event stream was already taken.
372    pub fn take_event_stream(&self) -> CompositeNodeManagerEventStream {
373        CompositeNodeManagerEventStream { event_receiver: self.client.take_event_receiver() }
374    }
375
376    /// Adds the given composite node specification to the driver framework.
377    pub fn r#add_spec(
378        &self,
379        mut payload: &CompositeNodeSpec,
380    ) -> fidl::client::QueryResponseFut<
381        CompositeNodeManagerAddSpecResult,
382        fidl::encoding::DefaultFuchsiaResourceDialect,
383    > {
384        CompositeNodeManagerProxyInterface::r#add_spec(self, payload)
385    }
386}
387
388impl CompositeNodeManagerProxyInterface for CompositeNodeManagerProxy {
389    type AddSpecResponseFut = fidl::client::QueryResponseFut<
390        CompositeNodeManagerAddSpecResult,
391        fidl::encoding::DefaultFuchsiaResourceDialect,
392    >;
393    fn r#add_spec(&self, mut payload: &CompositeNodeSpec) -> Self::AddSpecResponseFut {
394        fn _decode(
395            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
396        ) -> Result<CompositeNodeManagerAddSpecResult, fidl::Error> {
397            let _response = fidl::client::decode_transaction_body::<
398                fidl::encoding::FlexibleResultType<
399                    fidl::encoding::EmptyStruct,
400                    CompositeNodeSpecError,
401                >,
402                fidl::encoding::DefaultFuchsiaResourceDialect,
403                0x524e353c8130cc74,
404            >(_buf?)?
405            .into_result::<CompositeNodeManagerMarker>("add_spec")?;
406            Ok(_response.map(|x| x))
407        }
408        self.client.send_query_and_decode::<CompositeNodeSpec, CompositeNodeManagerAddSpecResult>(
409            payload,
410            0x524e353c8130cc74,
411            fidl::encoding::DynamicFlags::FLEXIBLE,
412            _decode,
413        )
414    }
415}
416
417pub struct CompositeNodeManagerEventStream {
418    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
419}
420
421impl std::marker::Unpin for CompositeNodeManagerEventStream {}
422
423impl futures::stream::FusedStream for CompositeNodeManagerEventStream {
424    fn is_terminated(&self) -> bool {
425        self.event_receiver.is_terminated()
426    }
427}
428
429impl futures::Stream for CompositeNodeManagerEventStream {
430    type Item = Result<CompositeNodeManagerEvent, fidl::Error>;
431
432    fn poll_next(
433        mut self: std::pin::Pin<&mut Self>,
434        cx: &mut std::task::Context<'_>,
435    ) -> std::task::Poll<Option<Self::Item>> {
436        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
437            &mut self.event_receiver,
438            cx
439        )?) {
440            Some(buf) => std::task::Poll::Ready(Some(CompositeNodeManagerEvent::decode(buf))),
441            None => std::task::Poll::Ready(None),
442        }
443    }
444}
445
446#[derive(Debug)]
447pub enum CompositeNodeManagerEvent {
448    #[non_exhaustive]
449    _UnknownEvent {
450        /// Ordinal of the event that was sent.
451        ordinal: u64,
452    },
453}
454
455impl CompositeNodeManagerEvent {
456    /// Decodes a message buffer as a [`CompositeNodeManagerEvent`].
457    fn decode(
458        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
459    ) -> Result<CompositeNodeManagerEvent, fidl::Error> {
460        let (bytes, _handles) = buf.split_mut();
461        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
462        debug_assert_eq!(tx_header.tx_id, 0);
463        match tx_header.ordinal {
464            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
465                Ok(CompositeNodeManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
466            }
467            _ => Err(fidl::Error::UnknownOrdinal {
468                ordinal: tx_header.ordinal,
469                protocol_name:
470                    <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
471            }),
472        }
473    }
474}
475
476/// A Stream of incoming requests for fuchsia.driver.framework/CompositeNodeManager.
477pub struct CompositeNodeManagerRequestStream {
478    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
479    is_terminated: bool,
480}
481
482impl std::marker::Unpin for CompositeNodeManagerRequestStream {}
483
484impl futures::stream::FusedStream for CompositeNodeManagerRequestStream {
485    fn is_terminated(&self) -> bool {
486        self.is_terminated
487    }
488}
489
490impl fidl::endpoints::RequestStream for CompositeNodeManagerRequestStream {
491    type Protocol = CompositeNodeManagerMarker;
492    type ControlHandle = CompositeNodeManagerControlHandle;
493
494    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
495        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
496    }
497
498    fn control_handle(&self) -> Self::ControlHandle {
499        CompositeNodeManagerControlHandle { inner: self.inner.clone() }
500    }
501
502    fn into_inner(
503        self,
504    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
505    {
506        (self.inner, self.is_terminated)
507    }
508
509    fn from_inner(
510        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
511        is_terminated: bool,
512    ) -> Self {
513        Self { inner, is_terminated }
514    }
515}
516
517impl futures::Stream for CompositeNodeManagerRequestStream {
518    type Item = Result<CompositeNodeManagerRequest, fidl::Error>;
519
520    fn poll_next(
521        mut self: std::pin::Pin<&mut Self>,
522        cx: &mut std::task::Context<'_>,
523    ) -> std::task::Poll<Option<Self::Item>> {
524        let this = &mut *self;
525        if this.inner.check_shutdown(cx) {
526            this.is_terminated = true;
527            return std::task::Poll::Ready(None);
528        }
529        if this.is_terminated {
530            panic!("polled CompositeNodeManagerRequestStream after completion");
531        }
532        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
533            |bytes, handles| {
534                match this.inner.channel().read_etc(cx, bytes, handles) {
535                    std::task::Poll::Ready(Ok(())) => {}
536                    std::task::Poll::Pending => return std::task::Poll::Pending,
537                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
538                        this.is_terminated = true;
539                        return std::task::Poll::Ready(None);
540                    }
541                    std::task::Poll::Ready(Err(e)) => {
542                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
543                            e.into(),
544                        ))));
545                    }
546                }
547
548                // A message has been received from the channel
549                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
550
551                std::task::Poll::Ready(Some(match header.ordinal {
552                0x524e353c8130cc74 => {
553                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
554                    let mut req = fidl::new_empty!(CompositeNodeSpec, fidl::encoding::DefaultFuchsiaResourceDialect);
555                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CompositeNodeSpec>(&header, _body_bytes, handles, &mut req)?;
556                    let control_handle = CompositeNodeManagerControlHandle {
557                        inner: this.inner.clone(),
558                    };
559                    Ok(CompositeNodeManagerRequest::AddSpec {payload: req,
560                        responder: CompositeNodeManagerAddSpecResponder {
561                            control_handle: std::mem::ManuallyDrop::new(control_handle),
562                            tx_id: header.tx_id,
563                        },
564                    })
565                }
566                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
567                    Ok(CompositeNodeManagerRequest::_UnknownMethod {
568                        ordinal: header.ordinal,
569                        control_handle: CompositeNodeManagerControlHandle { inner: this.inner.clone() },
570                        method_type: fidl::MethodType::OneWay,
571                    })
572                }
573                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
574                    this.inner.send_framework_err(
575                        fidl::encoding::FrameworkErr::UnknownMethod,
576                        header.tx_id,
577                        header.ordinal,
578                        header.dynamic_flags(),
579                        (bytes, handles),
580                    )?;
581                    Ok(CompositeNodeManagerRequest::_UnknownMethod {
582                        ordinal: header.ordinal,
583                        control_handle: CompositeNodeManagerControlHandle { inner: this.inner.clone() },
584                        method_type: fidl::MethodType::TwoWay,
585                    })
586                }
587                _ => Err(fidl::Error::UnknownOrdinal {
588                    ordinal: header.ordinal,
589                    protocol_name: <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
590                }),
591            }))
592            },
593        )
594    }
595}
596
597/// Protocol through which board drivers can create composite node specs.
598///
599/// Composite node specs are created at runtime to dynamically bridge the
600/// static bind rules of a composite driver with the dynamic bind properties
601/// of nodes in the system so that the driver bind rules are more generic and reusable.
602#[derive(Debug)]
603pub enum CompositeNodeManagerRequest {
604    /// Adds the given composite node specification to the driver framework.
605    AddSpec { payload: CompositeNodeSpec, responder: CompositeNodeManagerAddSpecResponder },
606    /// An interaction was received which does not match any known method.
607    #[non_exhaustive]
608    _UnknownMethod {
609        /// Ordinal of the method that was called.
610        ordinal: u64,
611        control_handle: CompositeNodeManagerControlHandle,
612        method_type: fidl::MethodType,
613    },
614}
615
616impl CompositeNodeManagerRequest {
617    #[allow(irrefutable_let_patterns)]
618    pub fn into_add_spec(
619        self,
620    ) -> Option<(CompositeNodeSpec, CompositeNodeManagerAddSpecResponder)> {
621        if let CompositeNodeManagerRequest::AddSpec { payload, responder } = self {
622            Some((payload, responder))
623        } else {
624            None
625        }
626    }
627
628    /// Name of the method defined in FIDL
629    pub fn method_name(&self) -> &'static str {
630        match *self {
631            CompositeNodeManagerRequest::AddSpec { .. } => "add_spec",
632            CompositeNodeManagerRequest::_UnknownMethod {
633                method_type: fidl::MethodType::OneWay,
634                ..
635            } => "unknown one-way method",
636            CompositeNodeManagerRequest::_UnknownMethod {
637                method_type: fidl::MethodType::TwoWay,
638                ..
639            } => "unknown two-way method",
640        }
641    }
642}
643
644#[derive(Debug, Clone)]
645pub struct CompositeNodeManagerControlHandle {
646    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
647}
648
649impl fidl::endpoints::ControlHandle for CompositeNodeManagerControlHandle {
650    fn shutdown(&self) {
651        self.inner.shutdown()
652    }
653    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
654        self.inner.shutdown_with_epitaph(status)
655    }
656
657    fn is_closed(&self) -> bool {
658        self.inner.channel().is_closed()
659    }
660    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
661        self.inner.channel().on_closed()
662    }
663
664    #[cfg(target_os = "fuchsia")]
665    fn signal_peer(
666        &self,
667        clear_mask: zx::Signals,
668        set_mask: zx::Signals,
669    ) -> Result<(), zx_status::Status> {
670        use fidl::Peered;
671        self.inner.channel().signal_peer(clear_mask, set_mask)
672    }
673}
674
675impl CompositeNodeManagerControlHandle {}
676
677#[must_use = "FIDL methods require a response to be sent"]
678#[derive(Debug)]
679pub struct CompositeNodeManagerAddSpecResponder {
680    control_handle: std::mem::ManuallyDrop<CompositeNodeManagerControlHandle>,
681    tx_id: u32,
682}
683
684/// Set the the channel to be shutdown (see [`CompositeNodeManagerControlHandle::shutdown`])
685/// if the responder is dropped without sending a response, so that the client
686/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
687impl std::ops::Drop for CompositeNodeManagerAddSpecResponder {
688    fn drop(&mut self) {
689        self.control_handle.shutdown();
690        // Safety: drops once, never accessed again
691        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
692    }
693}
694
695impl fidl::endpoints::Responder for CompositeNodeManagerAddSpecResponder {
696    type ControlHandle = CompositeNodeManagerControlHandle;
697
698    fn control_handle(&self) -> &CompositeNodeManagerControlHandle {
699        &self.control_handle
700    }
701
702    fn drop_without_shutdown(mut self) {
703        // Safety: drops once, never accessed again due to mem::forget
704        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
705        // Prevent Drop from running (which would shut down the channel)
706        std::mem::forget(self);
707    }
708}
709
710impl CompositeNodeManagerAddSpecResponder {
711    /// Sends a response to the FIDL transaction.
712    ///
713    /// Sets the channel to shutdown if an error occurs.
714    pub fn send(self, mut result: Result<(), CompositeNodeSpecError>) -> Result<(), fidl::Error> {
715        let _result = self.send_raw(result);
716        if _result.is_err() {
717            self.control_handle.shutdown();
718        }
719        self.drop_without_shutdown();
720        _result
721    }
722
723    /// Similar to "send" but does not shutdown the channel if an error occurs.
724    pub fn send_no_shutdown_on_err(
725        self,
726        mut result: Result<(), CompositeNodeSpecError>,
727    ) -> Result<(), fidl::Error> {
728        let _result = self.send_raw(result);
729        self.drop_without_shutdown();
730        _result
731    }
732
733    fn send_raw(&self, mut result: Result<(), CompositeNodeSpecError>) -> Result<(), fidl::Error> {
734        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
735            fidl::encoding::EmptyStruct,
736            CompositeNodeSpecError,
737        >>(
738            fidl::encoding::FlexibleResult::new(result),
739            self.tx_id,
740            0x524e353c8130cc74,
741            fidl::encoding::DynamicFlags::FLEXIBLE,
742        )
743    }
744}
745
746#[cfg(feature = "driver")]
747#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
748pub struct DriverMarker;
749
750#[cfg(feature = "driver")]
751impl fidl_driver::endpoints::DriverProtocolMarker for DriverMarker {
752    const DEBUG_NAME: &'static str = "(anonymous) Driver";
753}
754pub type DriverStartResult = Result<(), i32>;
755
756/// This protocol is used by the Driver Framework's Driver Host to communicate various messages and
757/// lifecycle hooks to the driver. The connection for this protocol is established through the
758/// |DriverRegistration| defined in the `driver_symbols` library.
759///
760/// Once the driver has closed its server end, the Driver Framework will initiate the shutdown
761/// of all dispatchers belonging to this driver.
762
763#[cfg(feature = "driver")]
764#[derive(Debug)]
765pub enum DriverRequest {
766    /// Starts the driver with the given |start_args|.
767    ///
768    /// Drivers should finish their initial setup and enumeration before returning from |Start|.
769    /// In particular they should enumerate all currently available nodes by utilizing
770    /// `fuchsia.driver.framework/Node.AddChild` and waiting for all calls to be completed.
771    ///
772    /// The Framework will not consider the driver to be started until this call has returned
773    /// successfully. Therefore a driver will not have |Stop| called on it until after it has
774    /// replied to |Start| successfully.
775    ///
776    /// If a driver returns an error, it will not have |Stop| called on it before the
777    /// Driver Framework initiates shutdown of the driver's dispatchers. Therefore it should have
778    /// performed all necessary cleanup before returning an error.
779    Start { start_args: DriverStartArgs, responder: DriverStartResponder },
780    /// Stops the driver. To stop, the driver should teardown any resources it set up in or after
781    /// |Start|. This is a one-way FIDL method. When the driver has completed stopping, it should
782    /// close its server end. Asynchronous operations should fully complete before closing
783    /// the server end.
784    Stop {},
785    /// An interaction was received which does not match any known method.
786    #[non_exhaustive]
787    _UnknownMethod {
788        /// Ordinal of the method that was called.
789        ordinal: u64,
790        method_type: fidl::MethodType,
791    },
792}
793
794#[cfg(feature = "driver")]
795impl DriverRequest {
796    #[allow(irrefutable_let_patterns)]
797    pub fn into_start(self) -> Option<(DriverStartArgs, DriverStartResponder)> {
798        if let DriverRequest::Start { start_args, responder } = self {
799            Some((start_args, responder))
800        } else {
801            None
802        }
803    }
804
805    #[allow(irrefutable_let_patterns)]
806    pub fn into_stop(self) -> Option<()> {
807        if let DriverRequest::Stop {} = self { Some(()) } else { None }
808    }
809
810    pub fn new_start(self, start_args: DriverStartArgs, tx_id: u32) -> Self {
811        Self::Start { start_args, responder: DriverStartResponder { tx_id } }
812    }
813
814    pub fn new_stop(self) -> Self {
815        Self::Stop {}
816    }
817
818    pub fn r#start_as_message(
819        arena: fdf::Arena,
820        mut start_args: DriverStartArgs,
821        tx_id: u32,
822    ) -> Result<fdf::Message<[u8]>, fidl::Error> {
823        let ordinal = 0x27be00ae42aa60c2;
824        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
825        let body = (&mut start_args,);
826        let msg = fidl::encoding::TransactionMessage {
827            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
828            body,
829        };
830        fidl::encoding::with_tls_encoded::<
831            fidl::encoding::TransactionMessageType<DriverStartRequest>,
832            fidl::encoding::DefaultFuchsiaResourceDialect,
833            fdf::Message<[u8]>,
834        >(msg, |bytes, mut handles| {
835            let handles = arena.insert_from_iter(
836                std::mem::take(handles)
837                    .into_iter()
838                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
839            );
840            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
841        })
842    }
843
844    pub fn r#stop_as_message(arena: fdf::Arena) -> Result<fdf::Message<[u8]>, fidl::Error> {
845        let tx_id = 0;
846        let ordinal = 0x4b96c67e29b3843d;
847        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
848        let body = ();
849        let msg = fidl::encoding::TransactionMessage {
850            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
851            body,
852        };
853        fidl::encoding::with_tls_encoded::<
854            fidl::encoding::TransactionMessageType<fidl::encoding::EmptyPayload>,
855            fidl::encoding::DefaultFuchsiaResourceDialect,
856            fdf::Message<[u8]>,
857        >(msg, |bytes, mut handles| {
858            let handles = arena.insert_from_iter(
859                std::mem::take(handles)
860                    .into_iter()
861                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
862            );
863            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
864        })
865    }
866
867    #[allow(irrefutable_let_patterns)]
868    pub fn read_from(bytes: &[u8], _handles: &mut [zx::HandleInfo]) -> Result<Self, fidl::Error> {
869        let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
870
871        match header.ordinal {
872            0x27be00ae42aa60c2 => {
873                header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
874                let mut req = fidl::new_empty!(
875                    DriverStartRequest,
876                    fidl::encoding::DefaultFuchsiaResourceDialect
877                );
878                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverStartRequest>(&header, _body_bytes, _handles, &mut req)?;
879                Ok(DriverRequest::Start {
880                    start_args: req.start_args,
881
882                    responder: DriverStartResponder { tx_id: header.tx_id },
883                })
884            }
885            0x4b96c67e29b3843d => {
886                header.validate_request_tx_id(fidl::MethodType::OneWay)?;
887                let mut req = fidl::new_empty!(
888                    fidl::encoding::EmptyPayload,
889                    fidl::encoding::DefaultFuchsiaResourceDialect
890                );
891                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, _handles, &mut req)?;
892                Ok(DriverRequest::Stop {})
893            }
894            _ if header.tx_id == 0
895                && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
896            {
897                Ok(DriverRequest::_UnknownMethod {
898                    ordinal: header.ordinal,
899                    method_type: fidl::MethodType::OneWay,
900                })
901            }
902            _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
903                Ok(DriverRequest::_UnknownMethod {
904                    ordinal: header.ordinal,
905                    method_type: fidl::MethodType::TwoWay,
906                })
907            }
908            _ => Err(fidl::Error::UnknownOrdinal {
909                ordinal: header.ordinal,
910                protocol_name:
911                    <DriverMarker as fidl_driver::endpoints::DriverProtocolMarker>::DEBUG_NAME,
912            }),
913        }
914    }
915
916    pub fn read_from_message(
917        mut message: fdf::Message<[u8]>,
918    ) -> Result<(fdf::Arena, Self), fidl::Error> {
919        let (arena, Some(body), Some(handles)) = message.take_arena_boxes() else {
920            return Err(fidl::Error::Invalid);
921        };
922        let mut handles = arena.try_insert_from_iter(
923            handles
924                .into_iter()
925                .map(|handle| unsafe { fidl_driver::encoding::mixed_into_handle_info(handle) }),
926        );
927        let res = match handles {
928            Ok(ref mut handles) => Self::read_from(&*body, handles)?,
929            Err(_) => return Err(fidl::Error::Invalid),
930        };
931        std::mem::drop((body, handles));
932        Ok((message.take_arena(), res))
933    }
934
935    /// Name of the method defined in FIDL
936    pub fn method_name(&self) -> &'static str {
937        match *self {
938            DriverRequest::Start { .. } => "start",
939            DriverRequest::Stop { .. } => "stop",
940            DriverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
941                "unknown one-way method"
942            }
943            DriverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
944                "unknown two-way method"
945            }
946        }
947    }
948}
949
950/// Like [`DriverRequest::read_from_message`] except it drops the [`Arena`].
951#[cfg(feature = "driver")]
952impl std::convert::TryFrom<fdf::Message<[u8]>> for DriverRequest {
953    type Error = fidl::Error;
954    fn try_from(msg: fdf::Message<[u8]>) -> Result<DriverRequest, fidl::Error> {
955        Ok(DriverRequest::read_from_message(msg)?.1)
956    }
957}
958
959#[must_use = "FIDL methods require a response to be sent"]
960#[cfg(feature = "driver")]
961#[derive(Debug)]
962pub struct DriverStartResponder {
963    tx_id: u32,
964}
965
966#[cfg(feature = "driver")]
967impl DriverStartResponder {
968    pub fn send_response(
969        &self,
970        server_handle: &fdf::Channel<[u8]>,
971        mut result: Result<(), i32>,
972    ) -> Result<(), fidl::Error> {
973        let msg = fidl::encoding::TransactionMessage {
974            header: fidl::encoding::TransactionHeader::new(
975                self.tx_id,
976                0x27be00ae42aa60c2,
977                fidl::encoding::DynamicFlags::FLEXIBLE,
978            ),
979            body: fidl::encoding::FlexibleResult::new(result),
980        };
981        fidl::encoding::with_tls_encoded::<
982            fidl::encoding::TransactionMessageType<
983                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
984            >,
985            fidl::encoding::DefaultFuchsiaResourceDialect,
986            (),
987        >(msg, |body, _handles| {
988            server_handle
989                .write_with_data(fdf::Arena::new(), |arena| arena.insert_slice(&body))
990                .unwrap();
991            Ok(())
992        })
993    }
994}
995
996#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
997pub struct NodeMarker;
998
999impl fidl::endpoints::ProtocolMarker for NodeMarker {
1000    type Proxy = NodeProxy;
1001    type RequestStream = NodeRequestStream;
1002    #[cfg(target_os = "fuchsia")]
1003    type SynchronousProxy = NodeSynchronousProxy;
1004
1005    const DEBUG_NAME: &'static str = "(anonymous) Node";
1006}
1007pub type NodeAddChildResult = Result<(), NodeError>;
1008
1009pub trait NodeProxyInterface: Send + Sync {
1010    type AddChildResponseFut: std::future::Future<Output = Result<NodeAddChildResult, fidl::Error>>
1011        + Send;
1012    fn r#add_child(
1013        &self,
1014        args: NodeAddArgs,
1015        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1016        node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1017    ) -> Self::AddChildResponseFut;
1018}
1019#[derive(Debug)]
1020#[cfg(target_os = "fuchsia")]
1021pub struct NodeSynchronousProxy {
1022    client: fidl::client::sync::Client,
1023}
1024
1025#[cfg(target_os = "fuchsia")]
1026impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
1027    type Proxy = NodeProxy;
1028    type Protocol = NodeMarker;
1029
1030    fn from_channel(inner: fidl::Channel) -> Self {
1031        Self::new(inner)
1032    }
1033
1034    fn into_channel(self) -> fidl::Channel {
1035        self.client.into_channel()
1036    }
1037
1038    fn as_channel(&self) -> &fidl::Channel {
1039        self.client.as_channel()
1040    }
1041}
1042
1043#[cfg(target_os = "fuchsia")]
1044impl NodeSynchronousProxy {
1045    pub fn new(channel: fidl::Channel) -> Self {
1046        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1047        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1048    }
1049
1050    pub fn into_channel(self) -> fidl::Channel {
1051        self.client.into_channel()
1052    }
1053
1054    /// Waits until an event arrives and returns it. It is safe for other
1055    /// threads to make concurrent requests while waiting for an event.
1056    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
1057        NodeEvent::decode(self.client.wait_for_event(deadline)?)
1058    }
1059
1060    /// Adds a child node to this node.
1061    ///
1062    /// If `node` is present, this driver takes responsibility for binding to
1063    /// the newly created child. Otherwise, the driver framework will locate an
1064    /// appropriate driver to bind the child to.
1065    pub fn r#add_child(
1066        &self,
1067        mut args: NodeAddArgs,
1068        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1069        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1070        ___deadline: zx::MonotonicInstant,
1071    ) -> Result<NodeAddChildResult, fidl::Error> {
1072        let _response = self.client.send_query::<
1073            NodeAddChildRequest,
1074            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1075        >(
1076            (&mut args, controller, node,),
1077            0x77d10dff3c1ea129,
1078            fidl::encoding::DynamicFlags::FLEXIBLE,
1079            ___deadline,
1080        )?
1081        .into_result::<NodeMarker>("add_child")?;
1082        Ok(_response.map(|x| x))
1083    }
1084}
1085
1086#[cfg(target_os = "fuchsia")]
1087impl From<NodeSynchronousProxy> for zx::Handle {
1088    fn from(value: NodeSynchronousProxy) -> Self {
1089        value.into_channel().into()
1090    }
1091}
1092
1093#[cfg(target_os = "fuchsia")]
1094impl From<fidl::Channel> for NodeSynchronousProxy {
1095    fn from(value: fidl::Channel) -> Self {
1096        Self::new(value)
1097    }
1098}
1099
1100#[cfg(target_os = "fuchsia")]
1101impl fidl::endpoints::FromClient for NodeSynchronousProxy {
1102    type Protocol = NodeMarker;
1103
1104    fn from_client(value: fidl::endpoints::ClientEnd<NodeMarker>) -> Self {
1105        Self::new(value.into_channel())
1106    }
1107}
1108
1109#[derive(Debug, Clone)]
1110pub struct NodeProxy {
1111    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1112}
1113
1114impl fidl::endpoints::Proxy for NodeProxy {
1115    type Protocol = NodeMarker;
1116
1117    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1118        Self::new(inner)
1119    }
1120
1121    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1122        self.client.into_channel().map_err(|client| Self { client })
1123    }
1124
1125    fn as_channel(&self) -> &::fidl::AsyncChannel {
1126        self.client.as_channel()
1127    }
1128}
1129
1130impl NodeProxy {
1131    /// Create a new Proxy for fuchsia.driver.framework/Node.
1132    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1133        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1134        Self { client: fidl::client::Client::new(channel, protocol_name) }
1135    }
1136
1137    /// Get a Stream of events from the remote end of the protocol.
1138    ///
1139    /// # Panics
1140    ///
1141    /// Panics if the event stream was already taken.
1142    pub fn take_event_stream(&self) -> NodeEventStream {
1143        NodeEventStream { event_receiver: self.client.take_event_receiver() }
1144    }
1145
1146    /// Adds a child node to this node.
1147    ///
1148    /// If `node` is present, this driver takes responsibility for binding to
1149    /// the newly created child. Otherwise, the driver framework will locate an
1150    /// appropriate driver to bind the child to.
1151    pub fn r#add_child(
1152        &self,
1153        mut args: NodeAddArgs,
1154        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1155        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1156    ) -> fidl::client::QueryResponseFut<
1157        NodeAddChildResult,
1158        fidl::encoding::DefaultFuchsiaResourceDialect,
1159    > {
1160        NodeProxyInterface::r#add_child(self, args, controller, node)
1161    }
1162}
1163
1164impl NodeProxyInterface for NodeProxy {
1165    type AddChildResponseFut = fidl::client::QueryResponseFut<
1166        NodeAddChildResult,
1167        fidl::encoding::DefaultFuchsiaResourceDialect,
1168    >;
1169    fn r#add_child(
1170        &self,
1171        mut args: NodeAddArgs,
1172        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1173        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1174    ) -> Self::AddChildResponseFut {
1175        fn _decode(
1176            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1177        ) -> Result<NodeAddChildResult, fidl::Error> {
1178            let _response = fidl::client::decode_transaction_body::<
1179                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1180                fidl::encoding::DefaultFuchsiaResourceDialect,
1181                0x77d10dff3c1ea129,
1182            >(_buf?)?
1183            .into_result::<NodeMarker>("add_child")?;
1184            Ok(_response.map(|x| x))
1185        }
1186        self.client.send_query_and_decode::<NodeAddChildRequest, NodeAddChildResult>(
1187            (&mut args, controller, node),
1188            0x77d10dff3c1ea129,
1189            fidl::encoding::DynamicFlags::FLEXIBLE,
1190            _decode,
1191        )
1192    }
1193}
1194
1195pub struct NodeEventStream {
1196    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1197}
1198
1199impl std::marker::Unpin for NodeEventStream {}
1200
1201impl futures::stream::FusedStream for NodeEventStream {
1202    fn is_terminated(&self) -> bool {
1203        self.event_receiver.is_terminated()
1204    }
1205}
1206
1207impl futures::Stream for NodeEventStream {
1208    type Item = Result<NodeEvent, fidl::Error>;
1209
1210    fn poll_next(
1211        mut self: std::pin::Pin<&mut Self>,
1212        cx: &mut std::task::Context<'_>,
1213    ) -> std::task::Poll<Option<Self::Item>> {
1214        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1215            &mut self.event_receiver,
1216            cx
1217        )?) {
1218            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
1219            None => std::task::Poll::Ready(None),
1220        }
1221    }
1222}
1223
1224#[derive(Debug)]
1225pub enum NodeEvent {
1226    #[non_exhaustive]
1227    _UnknownEvent {
1228        /// Ordinal of the event that was sent.
1229        ordinal: u64,
1230    },
1231}
1232
1233impl NodeEvent {
1234    /// Decodes a message buffer as a [`NodeEvent`].
1235    fn decode(
1236        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1237    ) -> Result<NodeEvent, fidl::Error> {
1238        let (bytes, _handles) = buf.split_mut();
1239        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1240        debug_assert_eq!(tx_header.tx_id, 0);
1241        match tx_header.ordinal {
1242            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1243                Ok(NodeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1244            }
1245            _ => Err(fidl::Error::UnknownOrdinal {
1246                ordinal: tx_header.ordinal,
1247                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1248            }),
1249        }
1250    }
1251}
1252
1253/// A Stream of incoming requests for fuchsia.driver.framework/Node.
1254pub struct NodeRequestStream {
1255    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1256    is_terminated: bool,
1257}
1258
1259impl std::marker::Unpin for NodeRequestStream {}
1260
1261impl futures::stream::FusedStream for NodeRequestStream {
1262    fn is_terminated(&self) -> bool {
1263        self.is_terminated
1264    }
1265}
1266
1267impl fidl::endpoints::RequestStream for NodeRequestStream {
1268    type Protocol = NodeMarker;
1269    type ControlHandle = NodeControlHandle;
1270
1271    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1272        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1273    }
1274
1275    fn control_handle(&self) -> Self::ControlHandle {
1276        NodeControlHandle { inner: self.inner.clone() }
1277    }
1278
1279    fn into_inner(
1280        self,
1281    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1282    {
1283        (self.inner, self.is_terminated)
1284    }
1285
1286    fn from_inner(
1287        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1288        is_terminated: bool,
1289    ) -> Self {
1290        Self { inner, is_terminated }
1291    }
1292}
1293
1294impl futures::Stream for NodeRequestStream {
1295    type Item = Result<NodeRequest, fidl::Error>;
1296
1297    fn poll_next(
1298        mut self: std::pin::Pin<&mut Self>,
1299        cx: &mut std::task::Context<'_>,
1300    ) -> std::task::Poll<Option<Self::Item>> {
1301        let this = &mut *self;
1302        if this.inner.check_shutdown(cx) {
1303            this.is_terminated = true;
1304            return std::task::Poll::Ready(None);
1305        }
1306        if this.is_terminated {
1307            panic!("polled NodeRequestStream after completion");
1308        }
1309        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1310            |bytes, handles| {
1311                match this.inner.channel().read_etc(cx, bytes, handles) {
1312                    std::task::Poll::Ready(Ok(())) => {}
1313                    std::task::Poll::Pending => return std::task::Poll::Pending,
1314                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1315                        this.is_terminated = true;
1316                        return std::task::Poll::Ready(None);
1317                    }
1318                    std::task::Poll::Ready(Err(e)) => {
1319                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1320                            e.into(),
1321                        ))));
1322                    }
1323                }
1324
1325                // A message has been received from the channel
1326                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1327
1328                std::task::Poll::Ready(Some(match header.ordinal {
1329                    0x77d10dff3c1ea129 => {
1330                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1331                        let mut req = fidl::new_empty!(
1332                            NodeAddChildRequest,
1333                            fidl::encoding::DefaultFuchsiaResourceDialect
1334                        );
1335                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
1336                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
1337                        Ok(NodeRequest::AddChild {
1338                            args: req.args,
1339                            controller: req.controller,
1340                            node: req.node,
1341
1342                            responder: NodeAddChildResponder {
1343                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1344                                tx_id: header.tx_id,
1345                            },
1346                        })
1347                    }
1348                    _ if header.tx_id == 0
1349                        && header
1350                            .dynamic_flags()
1351                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1352                    {
1353                        Ok(NodeRequest::_UnknownMethod {
1354                            ordinal: header.ordinal,
1355                            control_handle: NodeControlHandle { inner: this.inner.clone() },
1356                            method_type: fidl::MethodType::OneWay,
1357                        })
1358                    }
1359                    _ if header
1360                        .dynamic_flags()
1361                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1362                    {
1363                        this.inner.send_framework_err(
1364                            fidl::encoding::FrameworkErr::UnknownMethod,
1365                            header.tx_id,
1366                            header.ordinal,
1367                            header.dynamic_flags(),
1368                            (bytes, handles),
1369                        )?;
1370                        Ok(NodeRequest::_UnknownMethod {
1371                            ordinal: header.ordinal,
1372                            control_handle: NodeControlHandle { inner: this.inner.clone() },
1373                            method_type: fidl::MethodType::TwoWay,
1374                        })
1375                    }
1376                    _ => Err(fidl::Error::UnknownOrdinal {
1377                        ordinal: header.ordinal,
1378                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1379                    }),
1380                }))
1381            },
1382        )
1383    }
1384}
1385
1386/// Protocol through which a driver manages a node that it is bound to.
1387/// Drivers should maintain their client connection to the node. Dropping
1388/// the client connection while the driver is running will cause the
1389/// driver framework to remove the driver and node from the topology.
1390/// If the driver has set `host_restart_on_crash` to "true" in their
1391/// component manifest, dropping the connection will initiate a restart of
1392/// the driver host and driver.
1393#[derive(Debug)]
1394pub enum NodeRequest {
1395    /// Adds a child node to this node.
1396    ///
1397    /// If `node` is present, this driver takes responsibility for binding to
1398    /// the newly created child. Otherwise, the driver framework will locate an
1399    /// appropriate driver to bind the child to.
1400    AddChild {
1401        args: NodeAddArgs,
1402        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1403        node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1404        responder: NodeAddChildResponder,
1405    },
1406    /// An interaction was received which does not match any known method.
1407    #[non_exhaustive]
1408    _UnknownMethod {
1409        /// Ordinal of the method that was called.
1410        ordinal: u64,
1411        control_handle: NodeControlHandle,
1412        method_type: fidl::MethodType,
1413    },
1414}
1415
1416impl NodeRequest {
1417    #[allow(irrefutable_let_patterns)]
1418    pub fn into_add_child(
1419        self,
1420    ) -> Option<(
1421        NodeAddArgs,
1422        fidl::endpoints::ServerEnd<NodeControllerMarker>,
1423        Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1424        NodeAddChildResponder,
1425    )> {
1426        if let NodeRequest::AddChild { args, controller, node, responder } = self {
1427            Some((args, controller, node, responder))
1428        } else {
1429            None
1430        }
1431    }
1432
1433    /// Name of the method defined in FIDL
1434    pub fn method_name(&self) -> &'static str {
1435        match *self {
1436            NodeRequest::AddChild { .. } => "add_child",
1437            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1438                "unknown one-way method"
1439            }
1440            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1441                "unknown two-way method"
1442            }
1443        }
1444    }
1445}
1446
1447#[derive(Debug, Clone)]
1448pub struct NodeControlHandle {
1449    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1450}
1451
1452impl fidl::endpoints::ControlHandle for NodeControlHandle {
1453    fn shutdown(&self) {
1454        self.inner.shutdown()
1455    }
1456    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1457        self.inner.shutdown_with_epitaph(status)
1458    }
1459
1460    fn is_closed(&self) -> bool {
1461        self.inner.channel().is_closed()
1462    }
1463    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1464        self.inner.channel().on_closed()
1465    }
1466
1467    #[cfg(target_os = "fuchsia")]
1468    fn signal_peer(
1469        &self,
1470        clear_mask: zx::Signals,
1471        set_mask: zx::Signals,
1472    ) -> Result<(), zx_status::Status> {
1473        use fidl::Peered;
1474        self.inner.channel().signal_peer(clear_mask, set_mask)
1475    }
1476}
1477
1478impl NodeControlHandle {}
1479
1480#[must_use = "FIDL methods require a response to be sent"]
1481#[derive(Debug)]
1482pub struct NodeAddChildResponder {
1483    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
1484    tx_id: u32,
1485}
1486
1487/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
1488/// if the responder is dropped without sending a response, so that the client
1489/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1490impl std::ops::Drop for NodeAddChildResponder {
1491    fn drop(&mut self) {
1492        self.control_handle.shutdown();
1493        // Safety: drops once, never accessed again
1494        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1495    }
1496}
1497
1498impl fidl::endpoints::Responder for NodeAddChildResponder {
1499    type ControlHandle = NodeControlHandle;
1500
1501    fn control_handle(&self) -> &NodeControlHandle {
1502        &self.control_handle
1503    }
1504
1505    fn drop_without_shutdown(mut self) {
1506        // Safety: drops once, never accessed again due to mem::forget
1507        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1508        // Prevent Drop from running (which would shut down the channel)
1509        std::mem::forget(self);
1510    }
1511}
1512
1513impl NodeAddChildResponder {
1514    /// Sends a response to the FIDL transaction.
1515    ///
1516    /// Sets the channel to shutdown if an error occurs.
1517    pub fn send(self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
1518        let _result = self.send_raw(result);
1519        if _result.is_err() {
1520            self.control_handle.shutdown();
1521        }
1522        self.drop_without_shutdown();
1523        _result
1524    }
1525
1526    /// Similar to "send" but does not shutdown the channel if an error occurs.
1527    pub fn send_no_shutdown_on_err(
1528        self,
1529        mut result: Result<(), NodeError>,
1530    ) -> Result<(), fidl::Error> {
1531        let _result = self.send_raw(result);
1532        self.drop_without_shutdown();
1533        _result
1534    }
1535
1536    fn send_raw(&self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
1537        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1538            fidl::encoding::EmptyStruct,
1539            NodeError,
1540        >>(
1541            fidl::encoding::FlexibleResult::new(result),
1542            self.tx_id,
1543            0x77d10dff3c1ea129,
1544            fidl::encoding::DynamicFlags::FLEXIBLE,
1545        )
1546    }
1547}
1548
1549#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1550pub struct NodeControllerMarker;
1551
1552impl fidl::endpoints::ProtocolMarker for NodeControllerMarker {
1553    type Proxy = NodeControllerProxy;
1554    type RequestStream = NodeControllerRequestStream;
1555    #[cfg(target_os = "fuchsia")]
1556    type SynchronousProxy = NodeControllerSynchronousProxy;
1557
1558    const DEBUG_NAME: &'static str = "(anonymous) NodeController";
1559}
1560pub type NodeControllerRequestBindResult = Result<(), i32>;
1561pub type NodeControllerWaitForDriverResult = Result<DriverResult, i32>;
1562
1563pub trait NodeControllerProxyInterface: Send + Sync {
1564    fn r#remove(&self) -> Result<(), fidl::Error>;
1565    type RequestBindResponseFut: std::future::Future<Output = Result<NodeControllerRequestBindResult, fidl::Error>>
1566        + Send;
1567    fn r#request_bind(
1568        &self,
1569        payload: &NodeControllerRequestBindRequest,
1570    ) -> Self::RequestBindResponseFut;
1571    type WaitForDriverResponseFut: std::future::Future<Output = Result<NodeControllerWaitForDriverResult, fidl::Error>>
1572        + Send;
1573    fn r#wait_for_driver(&self) -> Self::WaitForDriverResponseFut;
1574}
1575#[derive(Debug)]
1576#[cfg(target_os = "fuchsia")]
1577pub struct NodeControllerSynchronousProxy {
1578    client: fidl::client::sync::Client,
1579}
1580
1581#[cfg(target_os = "fuchsia")]
1582impl fidl::endpoints::SynchronousProxy for NodeControllerSynchronousProxy {
1583    type Proxy = NodeControllerProxy;
1584    type Protocol = NodeControllerMarker;
1585
1586    fn from_channel(inner: fidl::Channel) -> Self {
1587        Self::new(inner)
1588    }
1589
1590    fn into_channel(self) -> fidl::Channel {
1591        self.client.into_channel()
1592    }
1593
1594    fn as_channel(&self) -> &fidl::Channel {
1595        self.client.as_channel()
1596    }
1597}
1598
1599#[cfg(target_os = "fuchsia")]
1600impl NodeControllerSynchronousProxy {
1601    pub fn new(channel: fidl::Channel) -> Self {
1602        let protocol_name = <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1603        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1604    }
1605
1606    pub fn into_channel(self) -> fidl::Channel {
1607        self.client.into_channel()
1608    }
1609
1610    /// Waits until an event arrives and returns it. It is safe for other
1611    /// threads to make concurrent requests while waiting for an event.
1612    pub fn wait_for_event(
1613        &self,
1614        deadline: zx::MonotonicInstant,
1615    ) -> Result<NodeControllerEvent, fidl::Error> {
1616        NodeControllerEvent::decode(self.client.wait_for_event(deadline)?)
1617    }
1618
1619    /// Removes the node and all of its children.
1620    pub fn r#remove(&self) -> Result<(), fidl::Error> {
1621        self.client.send::<fidl::encoding::EmptyPayload>(
1622            (),
1623            0x54fa8b3dfe7bb341,
1624            fidl::encoding::DynamicFlags::FLEXIBLE,
1625        )
1626    }
1627
1628    /// Request that the framework attempts to bind a driver to this node.
1629    /// This is an *additional* request for binding as the framework attempts to bind a node once
1630    /// when the node is created.
1631    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
1632    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
1633    /// not completed.
1634    pub fn r#request_bind(
1635        &self,
1636        mut payload: &NodeControllerRequestBindRequest,
1637        ___deadline: zx::MonotonicInstant,
1638    ) -> Result<NodeControllerRequestBindResult, fidl::Error> {
1639        let _response = self.client.send_query::<
1640            NodeControllerRequestBindRequest,
1641            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1642        >(
1643            payload,
1644            0x41b954726b13508f,
1645            fidl::encoding::DynamicFlags::FLEXIBLE,
1646            ___deadline,
1647        )?
1648        .into_result::<NodeControllerMarker>("request_bind")?;
1649        Ok(_response.map(|x| x))
1650    }
1651
1652    /// Hanging get style call that returns a terminal state for the associated `Node`,
1653    /// or the composite node that is parented by this node.
1654    /// For a successfully started driver this returns immediately with the token of the
1655    /// node that the driver started on.
1656    /// If an error happens we wait until bootup is complete, which is when all drivers that
1657    /// can bind and start have done so, before returning the error.
1658    pub fn r#wait_for_driver(
1659        &self,
1660        ___deadline: zx::MonotonicInstant,
1661    ) -> Result<NodeControllerWaitForDriverResult, fidl::Error> {
1662        let _response = self.client.send_query::<
1663            fidl::encoding::EmptyPayload,
1664            fidl::encoding::FlexibleResultType<DriverResult, i32>,
1665        >(
1666            (),
1667            0x69f7106e47d81387,
1668            fidl::encoding::DynamicFlags::FLEXIBLE,
1669            ___deadline,
1670        )?
1671        .into_result::<NodeControllerMarker>("wait_for_driver")?;
1672        Ok(_response.map(|x| x))
1673    }
1674}
1675
1676#[cfg(target_os = "fuchsia")]
1677impl From<NodeControllerSynchronousProxy> for zx::Handle {
1678    fn from(value: NodeControllerSynchronousProxy) -> Self {
1679        value.into_channel().into()
1680    }
1681}
1682
1683#[cfg(target_os = "fuchsia")]
1684impl From<fidl::Channel> for NodeControllerSynchronousProxy {
1685    fn from(value: fidl::Channel) -> Self {
1686        Self::new(value)
1687    }
1688}
1689
1690#[cfg(target_os = "fuchsia")]
1691impl fidl::endpoints::FromClient for NodeControllerSynchronousProxy {
1692    type Protocol = NodeControllerMarker;
1693
1694    fn from_client(value: fidl::endpoints::ClientEnd<NodeControllerMarker>) -> Self {
1695        Self::new(value.into_channel())
1696    }
1697}
1698
1699#[derive(Debug, Clone)]
1700pub struct NodeControllerProxy {
1701    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1702}
1703
1704impl fidl::endpoints::Proxy for NodeControllerProxy {
1705    type Protocol = NodeControllerMarker;
1706
1707    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1708        Self::new(inner)
1709    }
1710
1711    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1712        self.client.into_channel().map_err(|client| Self { client })
1713    }
1714
1715    fn as_channel(&self) -> &::fidl::AsyncChannel {
1716        self.client.as_channel()
1717    }
1718}
1719
1720impl NodeControllerProxy {
1721    /// Create a new Proxy for fuchsia.driver.framework/NodeController.
1722    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1723        let protocol_name = <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1724        Self { client: fidl::client::Client::new(channel, protocol_name) }
1725    }
1726
1727    /// Get a Stream of events from the remote end of the protocol.
1728    ///
1729    /// # Panics
1730    ///
1731    /// Panics if the event stream was already taken.
1732    pub fn take_event_stream(&self) -> NodeControllerEventStream {
1733        NodeControllerEventStream { event_receiver: self.client.take_event_receiver() }
1734    }
1735
1736    /// Removes the node and all of its children.
1737    pub fn r#remove(&self) -> Result<(), fidl::Error> {
1738        NodeControllerProxyInterface::r#remove(self)
1739    }
1740
1741    /// Request that the framework attempts to bind a driver to this node.
1742    /// This is an *additional* request for binding as the framework attempts to bind a node once
1743    /// when the node is created.
1744    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
1745    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
1746    /// not completed.
1747    pub fn r#request_bind(
1748        &self,
1749        mut payload: &NodeControllerRequestBindRequest,
1750    ) -> fidl::client::QueryResponseFut<
1751        NodeControllerRequestBindResult,
1752        fidl::encoding::DefaultFuchsiaResourceDialect,
1753    > {
1754        NodeControllerProxyInterface::r#request_bind(self, payload)
1755    }
1756
1757    /// Hanging get style call that returns a terminal state for the associated `Node`,
1758    /// or the composite node that is parented by this node.
1759    /// For a successfully started driver this returns immediately with the token of the
1760    /// node that the driver started on.
1761    /// If an error happens we wait until bootup is complete, which is when all drivers that
1762    /// can bind and start have done so, before returning the error.
1763    pub fn r#wait_for_driver(
1764        &self,
1765    ) -> fidl::client::QueryResponseFut<
1766        NodeControllerWaitForDriverResult,
1767        fidl::encoding::DefaultFuchsiaResourceDialect,
1768    > {
1769        NodeControllerProxyInterface::r#wait_for_driver(self)
1770    }
1771}
1772
1773impl NodeControllerProxyInterface for NodeControllerProxy {
1774    fn r#remove(&self) -> Result<(), fidl::Error> {
1775        self.client.send::<fidl::encoding::EmptyPayload>(
1776            (),
1777            0x54fa8b3dfe7bb341,
1778            fidl::encoding::DynamicFlags::FLEXIBLE,
1779        )
1780    }
1781
1782    type RequestBindResponseFut = fidl::client::QueryResponseFut<
1783        NodeControllerRequestBindResult,
1784        fidl::encoding::DefaultFuchsiaResourceDialect,
1785    >;
1786    fn r#request_bind(
1787        &self,
1788        mut payload: &NodeControllerRequestBindRequest,
1789    ) -> Self::RequestBindResponseFut {
1790        fn _decode(
1791            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1792        ) -> Result<NodeControllerRequestBindResult, fidl::Error> {
1793            let _response = fidl::client::decode_transaction_body::<
1794                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1795                fidl::encoding::DefaultFuchsiaResourceDialect,
1796                0x41b954726b13508f,
1797            >(_buf?)?
1798            .into_result::<NodeControllerMarker>("request_bind")?;
1799            Ok(_response.map(|x| x))
1800        }
1801        self.client.send_query_and_decode::<
1802            NodeControllerRequestBindRequest,
1803            NodeControllerRequestBindResult,
1804        >(
1805            payload,
1806            0x41b954726b13508f,
1807            fidl::encoding::DynamicFlags::FLEXIBLE,
1808            _decode,
1809        )
1810    }
1811
1812    type WaitForDriverResponseFut = fidl::client::QueryResponseFut<
1813        NodeControllerWaitForDriverResult,
1814        fidl::encoding::DefaultFuchsiaResourceDialect,
1815    >;
1816    fn r#wait_for_driver(&self) -> Self::WaitForDriverResponseFut {
1817        fn _decode(
1818            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1819        ) -> Result<NodeControllerWaitForDriverResult, fidl::Error> {
1820            let _response = fidl::client::decode_transaction_body::<
1821                fidl::encoding::FlexibleResultType<DriverResult, i32>,
1822                fidl::encoding::DefaultFuchsiaResourceDialect,
1823                0x69f7106e47d81387,
1824            >(_buf?)?
1825            .into_result::<NodeControllerMarker>("wait_for_driver")?;
1826            Ok(_response.map(|x| x))
1827        }
1828        self.client.send_query_and_decode::<
1829            fidl::encoding::EmptyPayload,
1830            NodeControllerWaitForDriverResult,
1831        >(
1832            (),
1833            0x69f7106e47d81387,
1834            fidl::encoding::DynamicFlags::FLEXIBLE,
1835            _decode,
1836        )
1837    }
1838}
1839
1840pub struct NodeControllerEventStream {
1841    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1842}
1843
1844impl std::marker::Unpin for NodeControllerEventStream {}
1845
1846impl futures::stream::FusedStream for NodeControllerEventStream {
1847    fn is_terminated(&self) -> bool {
1848        self.event_receiver.is_terminated()
1849    }
1850}
1851
1852impl futures::Stream for NodeControllerEventStream {
1853    type Item = Result<NodeControllerEvent, fidl::Error>;
1854
1855    fn poll_next(
1856        mut self: std::pin::Pin<&mut Self>,
1857        cx: &mut std::task::Context<'_>,
1858    ) -> std::task::Poll<Option<Self::Item>> {
1859        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1860            &mut self.event_receiver,
1861            cx
1862        )?) {
1863            Some(buf) => std::task::Poll::Ready(Some(NodeControllerEvent::decode(buf))),
1864            None => std::task::Poll::Ready(None),
1865        }
1866    }
1867}
1868
1869#[derive(Debug)]
1870pub enum NodeControllerEvent {
1871    OnBind {
1872        payload: NodeControllerOnBindRequest,
1873    },
1874    #[non_exhaustive]
1875    _UnknownEvent {
1876        /// Ordinal of the event that was sent.
1877        ordinal: u64,
1878    },
1879}
1880
1881impl NodeControllerEvent {
1882    #[allow(irrefutable_let_patterns)]
1883    pub fn into_on_bind(self) -> Option<NodeControllerOnBindRequest> {
1884        if let NodeControllerEvent::OnBind { payload } = self { Some((payload)) } else { None }
1885    }
1886
1887    /// Decodes a message buffer as a [`NodeControllerEvent`].
1888    fn decode(
1889        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1890    ) -> Result<NodeControllerEvent, fidl::Error> {
1891        let (bytes, _handles) = buf.split_mut();
1892        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1893        debug_assert_eq!(tx_header.tx_id, 0);
1894        match tx_header.ordinal {
1895            0x51f4165bc5ea202a => {
1896                let mut out = fidl::new_empty!(
1897                    NodeControllerOnBindRequest,
1898                    fidl::encoding::DefaultFuchsiaResourceDialect
1899                );
1900                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeControllerOnBindRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1901                Ok((NodeControllerEvent::OnBind { payload: out }))
1902            }
1903            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1904                Ok(NodeControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1905            }
1906            _ => Err(fidl::Error::UnknownOrdinal {
1907                ordinal: tx_header.ordinal,
1908                protocol_name:
1909                    <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1910            }),
1911        }
1912    }
1913}
1914
1915/// A Stream of incoming requests for fuchsia.driver.framework/NodeController.
1916pub struct NodeControllerRequestStream {
1917    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1918    is_terminated: bool,
1919}
1920
1921impl std::marker::Unpin for NodeControllerRequestStream {}
1922
1923impl futures::stream::FusedStream for NodeControllerRequestStream {
1924    fn is_terminated(&self) -> bool {
1925        self.is_terminated
1926    }
1927}
1928
1929impl fidl::endpoints::RequestStream for NodeControllerRequestStream {
1930    type Protocol = NodeControllerMarker;
1931    type ControlHandle = NodeControllerControlHandle;
1932
1933    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1934        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1935    }
1936
1937    fn control_handle(&self) -> Self::ControlHandle {
1938        NodeControllerControlHandle { inner: self.inner.clone() }
1939    }
1940
1941    fn into_inner(
1942        self,
1943    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1944    {
1945        (self.inner, self.is_terminated)
1946    }
1947
1948    fn from_inner(
1949        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1950        is_terminated: bool,
1951    ) -> Self {
1952        Self { inner, is_terminated }
1953    }
1954}
1955
1956impl futures::Stream for NodeControllerRequestStream {
1957    type Item = Result<NodeControllerRequest, fidl::Error>;
1958
1959    fn poll_next(
1960        mut self: std::pin::Pin<&mut Self>,
1961        cx: &mut std::task::Context<'_>,
1962    ) -> std::task::Poll<Option<Self::Item>> {
1963        let this = &mut *self;
1964        if this.inner.check_shutdown(cx) {
1965            this.is_terminated = true;
1966            return std::task::Poll::Ready(None);
1967        }
1968        if this.is_terminated {
1969            panic!("polled NodeControllerRequestStream after completion");
1970        }
1971        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1972            |bytes, handles| {
1973                match this.inner.channel().read_etc(cx, bytes, handles) {
1974                    std::task::Poll::Ready(Ok(())) => {}
1975                    std::task::Poll::Pending => return std::task::Poll::Pending,
1976                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1977                        this.is_terminated = true;
1978                        return std::task::Poll::Ready(None);
1979                    }
1980                    std::task::Poll::Ready(Err(e)) => {
1981                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1982                            e.into(),
1983                        ))));
1984                    }
1985                }
1986
1987                // A message has been received from the channel
1988                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1989
1990                std::task::Poll::Ready(Some(match header.ordinal {
1991                    0x54fa8b3dfe7bb341 => {
1992                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1993                        let mut req = fidl::new_empty!(
1994                            fidl::encoding::EmptyPayload,
1995                            fidl::encoding::DefaultFuchsiaResourceDialect
1996                        );
1997                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1998                        let control_handle =
1999                            NodeControllerControlHandle { inner: this.inner.clone() };
2000                        Ok(NodeControllerRequest::Remove { control_handle })
2001                    }
2002                    0x41b954726b13508f => {
2003                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2004                        let mut req = fidl::new_empty!(
2005                            NodeControllerRequestBindRequest,
2006                            fidl::encoding::DefaultFuchsiaResourceDialect
2007                        );
2008                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeControllerRequestBindRequest>(&header, _body_bytes, handles, &mut req)?;
2009                        let control_handle =
2010                            NodeControllerControlHandle { inner: this.inner.clone() };
2011                        Ok(NodeControllerRequest::RequestBind {
2012                            payload: req,
2013                            responder: NodeControllerRequestBindResponder {
2014                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2015                                tx_id: header.tx_id,
2016                            },
2017                        })
2018                    }
2019                    0x69f7106e47d81387 => {
2020                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2021                        let mut req = fidl::new_empty!(
2022                            fidl::encoding::EmptyPayload,
2023                            fidl::encoding::DefaultFuchsiaResourceDialect
2024                        );
2025                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2026                        let control_handle =
2027                            NodeControllerControlHandle { inner: this.inner.clone() };
2028                        Ok(NodeControllerRequest::WaitForDriver {
2029                            responder: NodeControllerWaitForDriverResponder {
2030                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2031                                tx_id: header.tx_id,
2032                            },
2033                        })
2034                    }
2035                    _ if header.tx_id == 0
2036                        && header
2037                            .dynamic_flags()
2038                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2039                    {
2040                        Ok(NodeControllerRequest::_UnknownMethod {
2041                            ordinal: header.ordinal,
2042                            control_handle: NodeControllerControlHandle {
2043                                inner: this.inner.clone(),
2044                            },
2045                            method_type: fidl::MethodType::OneWay,
2046                        })
2047                    }
2048                    _ if header
2049                        .dynamic_flags()
2050                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2051                    {
2052                        this.inner.send_framework_err(
2053                            fidl::encoding::FrameworkErr::UnknownMethod,
2054                            header.tx_id,
2055                            header.ordinal,
2056                            header.dynamic_flags(),
2057                            (bytes, handles),
2058                        )?;
2059                        Ok(NodeControllerRequest::_UnknownMethod {
2060                            ordinal: header.ordinal,
2061                            control_handle: NodeControllerControlHandle {
2062                                inner: this.inner.clone(),
2063                            },
2064                            method_type: fidl::MethodType::TwoWay,
2065                        })
2066                    }
2067                    _ => Err(fidl::Error::UnknownOrdinal {
2068                        ordinal: header.ordinal,
2069                        protocol_name:
2070                            <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2071                    }),
2072                }))
2073            },
2074        )
2075    }
2076}
2077
2078/// Protocol through which a parent node controls one of its children.
2079#[derive(Debug)]
2080pub enum NodeControllerRequest {
2081    /// Removes the node and all of its children.
2082    Remove { control_handle: NodeControllerControlHandle },
2083    /// Request that the framework attempts to bind a driver to this node.
2084    /// This is an *additional* request for binding as the framework attempts to bind a node once
2085    /// when the node is created.
2086    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
2087    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
2088    /// not completed.
2089    RequestBind {
2090        payload: NodeControllerRequestBindRequest,
2091        responder: NodeControllerRequestBindResponder,
2092    },
2093    /// Hanging get style call that returns a terminal state for the associated `Node`,
2094    /// or the composite node that is parented by this node.
2095    /// For a successfully started driver this returns immediately with the token of the
2096    /// node that the driver started on.
2097    /// If an error happens we wait until bootup is complete, which is when all drivers that
2098    /// can bind and start have done so, before returning the error.
2099    WaitForDriver { responder: NodeControllerWaitForDriverResponder },
2100    /// An interaction was received which does not match any known method.
2101    #[non_exhaustive]
2102    _UnknownMethod {
2103        /// Ordinal of the method that was called.
2104        ordinal: u64,
2105        control_handle: NodeControllerControlHandle,
2106        method_type: fidl::MethodType,
2107    },
2108}
2109
2110impl NodeControllerRequest {
2111    #[allow(irrefutable_let_patterns)]
2112    pub fn into_remove(self) -> Option<(NodeControllerControlHandle)> {
2113        if let NodeControllerRequest::Remove { control_handle } = self {
2114            Some((control_handle))
2115        } else {
2116            None
2117        }
2118    }
2119
2120    #[allow(irrefutable_let_patterns)]
2121    pub fn into_request_bind(
2122        self,
2123    ) -> Option<(NodeControllerRequestBindRequest, NodeControllerRequestBindResponder)> {
2124        if let NodeControllerRequest::RequestBind { payload, responder } = self {
2125            Some((payload, responder))
2126        } else {
2127            None
2128        }
2129    }
2130
2131    #[allow(irrefutable_let_patterns)]
2132    pub fn into_wait_for_driver(self) -> Option<(NodeControllerWaitForDriverResponder)> {
2133        if let NodeControllerRequest::WaitForDriver { responder } = self {
2134            Some((responder))
2135        } else {
2136            None
2137        }
2138    }
2139
2140    /// Name of the method defined in FIDL
2141    pub fn method_name(&self) -> &'static str {
2142        match *self {
2143            NodeControllerRequest::Remove { .. } => "remove",
2144            NodeControllerRequest::RequestBind { .. } => "request_bind",
2145            NodeControllerRequest::WaitForDriver { .. } => "wait_for_driver",
2146            NodeControllerRequest::_UnknownMethod {
2147                method_type: fidl::MethodType::OneWay, ..
2148            } => "unknown one-way method",
2149            NodeControllerRequest::_UnknownMethod {
2150                method_type: fidl::MethodType::TwoWay, ..
2151            } => "unknown two-way method",
2152        }
2153    }
2154}
2155
2156#[derive(Debug, Clone)]
2157pub struct NodeControllerControlHandle {
2158    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2159}
2160
2161impl fidl::endpoints::ControlHandle for NodeControllerControlHandle {
2162    fn shutdown(&self) {
2163        self.inner.shutdown()
2164    }
2165    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2166        self.inner.shutdown_with_epitaph(status)
2167    }
2168
2169    fn is_closed(&self) -> bool {
2170        self.inner.channel().is_closed()
2171    }
2172    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2173        self.inner.channel().on_closed()
2174    }
2175
2176    #[cfg(target_os = "fuchsia")]
2177    fn signal_peer(
2178        &self,
2179        clear_mask: zx::Signals,
2180        set_mask: zx::Signals,
2181    ) -> Result<(), zx_status::Status> {
2182        use fidl::Peered;
2183        self.inner.channel().signal_peer(clear_mask, set_mask)
2184    }
2185}
2186
2187impl NodeControllerControlHandle {
2188    pub fn send_on_bind(
2189        &self,
2190        mut payload: NodeControllerOnBindRequest,
2191    ) -> Result<(), fidl::Error> {
2192        self.inner.send::<NodeControllerOnBindRequest>(
2193            &mut payload,
2194            0,
2195            0x51f4165bc5ea202a,
2196            fidl::encoding::DynamicFlags::FLEXIBLE,
2197        )
2198    }
2199}
2200
2201#[must_use = "FIDL methods require a response to be sent"]
2202#[derive(Debug)]
2203pub struct NodeControllerRequestBindResponder {
2204    control_handle: std::mem::ManuallyDrop<NodeControllerControlHandle>,
2205    tx_id: u32,
2206}
2207
2208/// Set the the channel to be shutdown (see [`NodeControllerControlHandle::shutdown`])
2209/// if the responder is dropped without sending a response, so that the client
2210/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2211impl std::ops::Drop for NodeControllerRequestBindResponder {
2212    fn drop(&mut self) {
2213        self.control_handle.shutdown();
2214        // Safety: drops once, never accessed again
2215        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2216    }
2217}
2218
2219impl fidl::endpoints::Responder for NodeControllerRequestBindResponder {
2220    type ControlHandle = NodeControllerControlHandle;
2221
2222    fn control_handle(&self) -> &NodeControllerControlHandle {
2223        &self.control_handle
2224    }
2225
2226    fn drop_without_shutdown(mut self) {
2227        // Safety: drops once, never accessed again due to mem::forget
2228        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2229        // Prevent Drop from running (which would shut down the channel)
2230        std::mem::forget(self);
2231    }
2232}
2233
2234impl NodeControllerRequestBindResponder {
2235    /// Sends a response to the FIDL transaction.
2236    ///
2237    /// Sets the channel to shutdown if an error occurs.
2238    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2239        let _result = self.send_raw(result);
2240        if _result.is_err() {
2241            self.control_handle.shutdown();
2242        }
2243        self.drop_without_shutdown();
2244        _result
2245    }
2246
2247    /// Similar to "send" but does not shutdown the channel if an error occurs.
2248    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2249        let _result = self.send_raw(result);
2250        self.drop_without_shutdown();
2251        _result
2252    }
2253
2254    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2255        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2256            fidl::encoding::EmptyStruct,
2257            i32,
2258        >>(
2259            fidl::encoding::FlexibleResult::new(result),
2260            self.tx_id,
2261            0x41b954726b13508f,
2262            fidl::encoding::DynamicFlags::FLEXIBLE,
2263        )
2264    }
2265}
2266
2267#[must_use = "FIDL methods require a response to be sent"]
2268#[derive(Debug)]
2269pub struct NodeControllerWaitForDriverResponder {
2270    control_handle: std::mem::ManuallyDrop<NodeControllerControlHandle>,
2271    tx_id: u32,
2272}
2273
2274/// Set the the channel to be shutdown (see [`NodeControllerControlHandle::shutdown`])
2275/// if the responder is dropped without sending a response, so that the client
2276/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2277impl std::ops::Drop for NodeControllerWaitForDriverResponder {
2278    fn drop(&mut self) {
2279        self.control_handle.shutdown();
2280        // Safety: drops once, never accessed again
2281        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2282    }
2283}
2284
2285impl fidl::endpoints::Responder for NodeControllerWaitForDriverResponder {
2286    type ControlHandle = NodeControllerControlHandle;
2287
2288    fn control_handle(&self) -> &NodeControllerControlHandle {
2289        &self.control_handle
2290    }
2291
2292    fn drop_without_shutdown(mut self) {
2293        // Safety: drops once, never accessed again due to mem::forget
2294        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2295        // Prevent Drop from running (which would shut down the channel)
2296        std::mem::forget(self);
2297    }
2298}
2299
2300impl NodeControllerWaitForDriverResponder {
2301    /// Sends a response to the FIDL transaction.
2302    ///
2303    /// Sets the channel to shutdown if an error occurs.
2304    pub fn send(self, mut result: Result<DriverResult, i32>) -> Result<(), fidl::Error> {
2305        let _result = self.send_raw(result);
2306        if _result.is_err() {
2307            self.control_handle.shutdown();
2308        }
2309        self.drop_without_shutdown();
2310        _result
2311    }
2312
2313    /// Similar to "send" but does not shutdown the channel if an error occurs.
2314    pub fn send_no_shutdown_on_err(
2315        self,
2316        mut result: Result<DriverResult, i32>,
2317    ) -> Result<(), fidl::Error> {
2318        let _result = self.send_raw(result);
2319        self.drop_without_shutdown();
2320        _result
2321    }
2322
2323    fn send_raw(&self, mut result: Result<DriverResult, i32>) -> Result<(), fidl::Error> {
2324        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<DriverResult, i32>>(
2325            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2326            self.tx_id,
2327            0x69f7106e47d81387,
2328            fidl::encoding::DynamicFlags::FLEXIBLE,
2329        )
2330    }
2331}
2332
2333mod internal {
2334    use super::*;
2335
2336    impl fidl::encoding::ResourceTypeMarker for DriverStartRequest {
2337        type Borrowed<'a> = &'a mut Self;
2338        fn take_or_borrow<'a>(
2339            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2340        ) -> Self::Borrowed<'a> {
2341            value
2342        }
2343    }
2344
2345    unsafe impl fidl::encoding::TypeMarker for DriverStartRequest {
2346        type Owned = Self;
2347
2348        #[inline(always)]
2349        fn inline_align(_context: fidl::encoding::Context) -> usize {
2350            8
2351        }
2352
2353        #[inline(always)]
2354        fn inline_size(_context: fidl::encoding::Context) -> usize {
2355            16
2356        }
2357    }
2358
2359    unsafe impl
2360        fidl::encoding::Encode<DriverStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2361        for &mut DriverStartRequest
2362    {
2363        #[inline]
2364        unsafe fn encode(
2365            self,
2366            encoder: &mut fidl::encoding::Encoder<
2367                '_,
2368                fidl::encoding::DefaultFuchsiaResourceDialect,
2369            >,
2370            offset: usize,
2371            _depth: fidl::encoding::Depth,
2372        ) -> fidl::Result<()> {
2373            encoder.debug_check_bounds::<DriverStartRequest>(offset);
2374            // Delegate to tuple encoding.
2375            fidl::encoding::Encode::<
2376                DriverStartRequest,
2377                fidl::encoding::DefaultFuchsiaResourceDialect,
2378            >::encode(
2379                (<DriverStartArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2380                    &mut self.start_args,
2381                ),),
2382                encoder,
2383                offset,
2384                _depth,
2385            )
2386        }
2387    }
2388    unsafe impl<
2389        T0: fidl::encoding::Encode<DriverStartArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
2390    > fidl::encoding::Encode<DriverStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2391        for (T0,)
2392    {
2393        #[inline]
2394        unsafe fn encode(
2395            self,
2396            encoder: &mut fidl::encoding::Encoder<
2397                '_,
2398                fidl::encoding::DefaultFuchsiaResourceDialect,
2399            >,
2400            offset: usize,
2401            depth: fidl::encoding::Depth,
2402        ) -> fidl::Result<()> {
2403            encoder.debug_check_bounds::<DriverStartRequest>(offset);
2404            // Zero out padding regions. There's no need to apply masks
2405            // because the unmasked parts will be overwritten by fields.
2406            // Write the fields.
2407            self.0.encode(encoder, offset + 0, depth)?;
2408            Ok(())
2409        }
2410    }
2411
2412    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2413        for DriverStartRequest
2414    {
2415        #[inline(always)]
2416        fn new_empty() -> Self {
2417            Self {
2418                start_args: fidl::new_empty!(
2419                    DriverStartArgs,
2420                    fidl::encoding::DefaultFuchsiaResourceDialect
2421                ),
2422            }
2423        }
2424
2425        #[inline]
2426        unsafe fn decode(
2427            &mut self,
2428            decoder: &mut fidl::encoding::Decoder<
2429                '_,
2430                fidl::encoding::DefaultFuchsiaResourceDialect,
2431            >,
2432            offset: usize,
2433            _depth: fidl::encoding::Depth,
2434        ) -> fidl::Result<()> {
2435            decoder.debug_check_bounds::<Self>(offset);
2436            // Verify that padding bytes are zero.
2437            fidl::decode!(
2438                DriverStartArgs,
2439                fidl::encoding::DefaultFuchsiaResourceDialect,
2440                &mut self.start_args,
2441                decoder,
2442                offset + 0,
2443                _depth
2444            )?;
2445            Ok(())
2446        }
2447    }
2448
2449    impl fidl::encoding::ResourceTypeMarker for NodeAddChildRequest {
2450        type Borrowed<'a> = &'a mut Self;
2451        fn take_or_borrow<'a>(
2452            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2453        ) -> Self::Borrowed<'a> {
2454            value
2455        }
2456    }
2457
2458    unsafe impl fidl::encoding::TypeMarker for NodeAddChildRequest {
2459        type Owned = Self;
2460
2461        #[inline(always)]
2462        fn inline_align(_context: fidl::encoding::Context) -> usize {
2463            8
2464        }
2465
2466        #[inline(always)]
2467        fn inline_size(_context: fidl::encoding::Context) -> usize {
2468            24
2469        }
2470    }
2471
2472    unsafe impl
2473        fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2474        for &mut NodeAddChildRequest
2475    {
2476        #[inline]
2477        unsafe fn encode(
2478            self,
2479            encoder: &mut fidl::encoding::Encoder<
2480                '_,
2481                fidl::encoding::DefaultFuchsiaResourceDialect,
2482            >,
2483            offset: usize,
2484            _depth: fidl::encoding::Depth,
2485        ) -> fidl::Result<()> {
2486            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
2487            // Delegate to tuple encoding.
2488            fidl::encoding::Encode::<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2489                (
2490                    <NodeAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
2491                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
2492                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.node),
2493                ),
2494                encoder, offset, _depth
2495            )
2496        }
2497    }
2498    unsafe impl<
2499        T0: fidl::encoding::Encode<NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
2500        T1: fidl::encoding::Encode<
2501                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
2502                fidl::encoding::DefaultFuchsiaResourceDialect,
2503            >,
2504        T2: fidl::encoding::Encode<
2505                fidl::encoding::Optional<
2506                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
2507                >,
2508                fidl::encoding::DefaultFuchsiaResourceDialect,
2509            >,
2510    > fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2511        for (T0, T1, T2)
2512    {
2513        #[inline]
2514        unsafe fn encode(
2515            self,
2516            encoder: &mut fidl::encoding::Encoder<
2517                '_,
2518                fidl::encoding::DefaultFuchsiaResourceDialect,
2519            >,
2520            offset: usize,
2521            depth: fidl::encoding::Depth,
2522        ) -> fidl::Result<()> {
2523            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
2524            // Zero out padding regions. There's no need to apply masks
2525            // because the unmasked parts will be overwritten by fields.
2526            // Write the fields.
2527            self.0.encode(encoder, offset + 0, depth)?;
2528            self.1.encode(encoder, offset + 16, depth)?;
2529            self.2.encode(encoder, offset + 20, depth)?;
2530            Ok(())
2531        }
2532    }
2533
2534    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2535        for NodeAddChildRequest
2536    {
2537        #[inline(always)]
2538        fn new_empty() -> Self {
2539            Self {
2540                args: fidl::new_empty!(NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect),
2541                controller: fidl::new_empty!(
2542                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
2543                    fidl::encoding::DefaultFuchsiaResourceDialect
2544                ),
2545                node: fidl::new_empty!(
2546                    fidl::encoding::Optional<
2547                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
2548                    >,
2549                    fidl::encoding::DefaultFuchsiaResourceDialect
2550                ),
2551            }
2552        }
2553
2554        #[inline]
2555        unsafe fn decode(
2556            &mut self,
2557            decoder: &mut fidl::encoding::Decoder<
2558                '_,
2559                fidl::encoding::DefaultFuchsiaResourceDialect,
2560            >,
2561            offset: usize,
2562            _depth: fidl::encoding::Depth,
2563        ) -> fidl::Result<()> {
2564            decoder.debug_check_bounds::<Self>(offset);
2565            // Verify that padding bytes are zero.
2566            fidl::decode!(
2567                NodeAddArgs,
2568                fidl::encoding::DefaultFuchsiaResourceDialect,
2569                &mut self.args,
2570                decoder,
2571                offset + 0,
2572                _depth
2573            )?;
2574            fidl::decode!(
2575                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
2576                fidl::encoding::DefaultFuchsiaResourceDialect,
2577                &mut self.controller,
2578                decoder,
2579                offset + 16,
2580                _depth
2581            )?;
2582            fidl::decode!(
2583                fidl::encoding::Optional<
2584                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
2585                >,
2586                fidl::encoding::DefaultFuchsiaResourceDialect,
2587                &mut self.node,
2588                decoder,
2589                offset + 20,
2590                _depth
2591            )?;
2592            Ok(())
2593        }
2594    }
2595
2596    impl DevfsAddArgs {
2597        #[inline(always)]
2598        fn max_ordinal_present(&self) -> u64 {
2599            if let Some(_) = self.controller_connector {
2600                return 5;
2601            }
2602            if let Some(_) = self.connector_supports {
2603                return 4;
2604            }
2605            if let Some(_) = self.inspect {
2606                return 3;
2607            }
2608            if let Some(_) = self.class_name {
2609                return 2;
2610            }
2611            if let Some(_) = self.connector {
2612                return 1;
2613            }
2614            0
2615        }
2616    }
2617
2618    impl fidl::encoding::ResourceTypeMarker for DevfsAddArgs {
2619        type Borrowed<'a> = &'a mut Self;
2620        fn take_or_borrow<'a>(
2621            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2622        ) -> Self::Borrowed<'a> {
2623            value
2624        }
2625    }
2626
2627    unsafe impl fidl::encoding::TypeMarker for DevfsAddArgs {
2628        type Owned = Self;
2629
2630        #[inline(always)]
2631        fn inline_align(_context: fidl::encoding::Context) -> usize {
2632            8
2633        }
2634
2635        #[inline(always)]
2636        fn inline_size(_context: fidl::encoding::Context) -> usize {
2637            16
2638        }
2639    }
2640
2641    unsafe impl fidl::encoding::Encode<DevfsAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
2642        for &mut DevfsAddArgs
2643    {
2644        unsafe fn encode(
2645            self,
2646            encoder: &mut fidl::encoding::Encoder<
2647                '_,
2648                fidl::encoding::DefaultFuchsiaResourceDialect,
2649            >,
2650            offset: usize,
2651            mut depth: fidl::encoding::Depth,
2652        ) -> fidl::Result<()> {
2653            encoder.debug_check_bounds::<DevfsAddArgs>(offset);
2654            // Vector header
2655            let max_ordinal: u64 = self.max_ordinal_present();
2656            encoder.write_num(max_ordinal, offset);
2657            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2658            // Calling encoder.out_of_line_offset(0) is not allowed.
2659            if max_ordinal == 0 {
2660                return Ok(());
2661            }
2662            depth.increment()?;
2663            let envelope_size = 8;
2664            let bytes_len = max_ordinal as usize * envelope_size;
2665            #[allow(unused_variables)]
2666            let offset = encoder.out_of_line_offset(bytes_len);
2667            let mut _prev_end_offset: usize = 0;
2668            if 1 > max_ordinal {
2669                return Ok(());
2670            }
2671
2672            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2673            // are envelope_size bytes.
2674            let cur_offset: usize = (1 - 1) * envelope_size;
2675
2676            // Zero reserved fields.
2677            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2678
2679            // Safety:
2680            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2681            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2682            //   envelope_size bytes, there is always sufficient room.
2683            fidl::encoding::encode_in_envelope_optional::<
2684                fidl::encoding::Endpoint<
2685                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2686                >,
2687                fidl::encoding::DefaultFuchsiaResourceDialect,
2688            >(
2689                self.connector.as_mut().map(
2690                    <fidl::encoding::Endpoint<
2691                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2692                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2693                ),
2694                encoder,
2695                offset + cur_offset,
2696                depth,
2697            )?;
2698
2699            _prev_end_offset = cur_offset + envelope_size;
2700            if 2 > max_ordinal {
2701                return Ok(());
2702            }
2703
2704            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2705            // are envelope_size bytes.
2706            let cur_offset: usize = (2 - 1) * envelope_size;
2707
2708            // Zero reserved fields.
2709            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2710
2711            // Safety:
2712            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2713            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2714            //   envelope_size bytes, there is always sufficient room.
2715            fidl::encoding::encode_in_envelope_optional::<
2716                fidl::encoding::BoundedString<255>,
2717                fidl::encoding::DefaultFuchsiaResourceDialect,
2718            >(
2719                self.class_name.as_ref().map(
2720                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
2721                ),
2722                encoder,
2723                offset + cur_offset,
2724                depth,
2725            )?;
2726
2727            _prev_end_offset = cur_offset + envelope_size;
2728            if 3 > max_ordinal {
2729                return Ok(());
2730            }
2731
2732            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2733            // are envelope_size bytes.
2734            let cur_offset: usize = (3 - 1) * envelope_size;
2735
2736            // Zero reserved fields.
2737            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2738
2739            // Safety:
2740            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2741            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2742            //   envelope_size bytes, there is always sufficient room.
2743            fidl::encoding::encode_in_envelope_optional::<
2744                fidl::encoding::HandleType<
2745                    fidl::Vmo,
2746                    { fidl::ObjectType::VMO.into_raw() },
2747                    2147483648,
2748                >,
2749                fidl::encoding::DefaultFuchsiaResourceDialect,
2750            >(
2751                self.inspect.as_mut().map(
2752                    <fidl::encoding::HandleType<
2753                        fidl::Vmo,
2754                        { fidl::ObjectType::VMO.into_raw() },
2755                        2147483648,
2756                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2757                ),
2758                encoder,
2759                offset + cur_offset,
2760                depth,
2761            )?;
2762
2763            _prev_end_offset = cur_offset + envelope_size;
2764            if 4 > max_ordinal {
2765                return Ok(());
2766            }
2767
2768            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2769            // are envelope_size bytes.
2770            let cur_offset: usize = (4 - 1) * envelope_size;
2771
2772            // Zero reserved fields.
2773            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2774
2775            // Safety:
2776            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2777            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2778            //   envelope_size bytes, there is always sufficient room.
2779            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_device_fs::ConnectionType, fidl::encoding::DefaultFuchsiaResourceDialect>(
2780            self.connector_supports.as_ref().map(<fidl_fuchsia_device_fs::ConnectionType as fidl::encoding::ValueTypeMarker>::borrow),
2781            encoder, offset + cur_offset, depth
2782        )?;
2783
2784            _prev_end_offset = cur_offset + envelope_size;
2785            if 5 > max_ordinal {
2786                return Ok(());
2787            }
2788
2789            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2790            // are envelope_size bytes.
2791            let cur_offset: usize = (5 - 1) * envelope_size;
2792
2793            // Zero reserved fields.
2794            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2795
2796            // Safety:
2797            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2798            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2799            //   envelope_size bytes, there is always sufficient room.
2800            fidl::encoding::encode_in_envelope_optional::<
2801                fidl::encoding::Endpoint<
2802                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2803                >,
2804                fidl::encoding::DefaultFuchsiaResourceDialect,
2805            >(
2806                self.controller_connector.as_mut().map(
2807                    <fidl::encoding::Endpoint<
2808                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2809                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2810                ),
2811                encoder,
2812                offset + cur_offset,
2813                depth,
2814            )?;
2815
2816            _prev_end_offset = cur_offset + envelope_size;
2817
2818            Ok(())
2819        }
2820    }
2821
2822    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DevfsAddArgs {
2823        #[inline(always)]
2824        fn new_empty() -> Self {
2825            Self::default()
2826        }
2827
2828        unsafe fn decode(
2829            &mut self,
2830            decoder: &mut fidl::encoding::Decoder<
2831                '_,
2832                fidl::encoding::DefaultFuchsiaResourceDialect,
2833            >,
2834            offset: usize,
2835            mut depth: fidl::encoding::Depth,
2836        ) -> fidl::Result<()> {
2837            decoder.debug_check_bounds::<Self>(offset);
2838            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2839                None => return Err(fidl::Error::NotNullable),
2840                Some(len) => len,
2841            };
2842            // Calling decoder.out_of_line_offset(0) is not allowed.
2843            if len == 0 {
2844                return Ok(());
2845            };
2846            depth.increment()?;
2847            let envelope_size = 8;
2848            let bytes_len = len * envelope_size;
2849            let offset = decoder.out_of_line_offset(bytes_len)?;
2850            // Decode the envelope for each type.
2851            let mut _next_ordinal_to_read = 0;
2852            let mut next_offset = offset;
2853            let end_offset = offset + bytes_len;
2854            _next_ordinal_to_read += 1;
2855            if next_offset >= end_offset {
2856                return Ok(());
2857            }
2858
2859            // Decode unknown envelopes for gaps in ordinals.
2860            while _next_ordinal_to_read < 1 {
2861                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2862                _next_ordinal_to_read += 1;
2863                next_offset += envelope_size;
2864            }
2865
2866            let next_out_of_line = decoder.next_out_of_line();
2867            let handles_before = decoder.remaining_handles();
2868            if let Some((inlined, num_bytes, num_handles)) =
2869                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2870            {
2871                let member_inline_size = <fidl::encoding::Endpoint<
2872                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2873                > as fidl::encoding::TypeMarker>::inline_size(
2874                    decoder.context
2875                );
2876                if inlined != (member_inline_size <= 4) {
2877                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2878                }
2879                let inner_offset;
2880                let mut inner_depth = depth.clone();
2881                if inlined {
2882                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2883                    inner_offset = next_offset;
2884                } else {
2885                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2886                    inner_depth.increment()?;
2887                }
2888                let val_ref = self.connector.get_or_insert_with(|| {
2889                    fidl::new_empty!(
2890                        fidl::encoding::Endpoint<
2891                            fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2892                        >,
2893                        fidl::encoding::DefaultFuchsiaResourceDialect
2894                    )
2895                });
2896                fidl::decode!(
2897                    fidl::encoding::Endpoint<
2898                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
2899                    >,
2900                    fidl::encoding::DefaultFuchsiaResourceDialect,
2901                    val_ref,
2902                    decoder,
2903                    inner_offset,
2904                    inner_depth
2905                )?;
2906                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2907                {
2908                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2909                }
2910                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2911                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2912                }
2913            }
2914
2915            next_offset += envelope_size;
2916            _next_ordinal_to_read += 1;
2917            if next_offset >= end_offset {
2918                return Ok(());
2919            }
2920
2921            // Decode unknown envelopes for gaps in ordinals.
2922            while _next_ordinal_to_read < 2 {
2923                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2924                _next_ordinal_to_read += 1;
2925                next_offset += envelope_size;
2926            }
2927
2928            let next_out_of_line = decoder.next_out_of_line();
2929            let handles_before = decoder.remaining_handles();
2930            if let Some((inlined, num_bytes, num_handles)) =
2931                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2932            {
2933                let member_inline_size =
2934                    <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
2935                        decoder.context,
2936                    );
2937                if inlined != (member_inline_size <= 4) {
2938                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2939                }
2940                let inner_offset;
2941                let mut inner_depth = depth.clone();
2942                if inlined {
2943                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2944                    inner_offset = next_offset;
2945                } else {
2946                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2947                    inner_depth.increment()?;
2948                }
2949                let val_ref = self.class_name.get_or_insert_with(|| {
2950                    fidl::new_empty!(
2951                        fidl::encoding::BoundedString<255>,
2952                        fidl::encoding::DefaultFuchsiaResourceDialect
2953                    )
2954                });
2955                fidl::decode!(
2956                    fidl::encoding::BoundedString<255>,
2957                    fidl::encoding::DefaultFuchsiaResourceDialect,
2958                    val_ref,
2959                    decoder,
2960                    inner_offset,
2961                    inner_depth
2962                )?;
2963                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2964                {
2965                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2966                }
2967                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2968                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2969                }
2970            }
2971
2972            next_offset += envelope_size;
2973            _next_ordinal_to_read += 1;
2974            if next_offset >= end_offset {
2975                return Ok(());
2976            }
2977
2978            // Decode unknown envelopes for gaps in ordinals.
2979            while _next_ordinal_to_read < 3 {
2980                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2981                _next_ordinal_to_read += 1;
2982                next_offset += envelope_size;
2983            }
2984
2985            let next_out_of_line = decoder.next_out_of_line();
2986            let handles_before = decoder.remaining_handles();
2987            if let Some((inlined, num_bytes, num_handles)) =
2988                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2989            {
2990                let member_inline_size = <fidl::encoding::HandleType<
2991                    fidl::Vmo,
2992                    { fidl::ObjectType::VMO.into_raw() },
2993                    2147483648,
2994                > as fidl::encoding::TypeMarker>::inline_size(
2995                    decoder.context
2996                );
2997                if inlined != (member_inline_size <= 4) {
2998                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2999                }
3000                let inner_offset;
3001                let mut inner_depth = depth.clone();
3002                if inlined {
3003                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3004                    inner_offset = next_offset;
3005                } else {
3006                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3007                    inner_depth.increment()?;
3008                }
3009                let val_ref =
3010                self.inspect.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
3011                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3012                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3013                {
3014                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3015                }
3016                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3017                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3018                }
3019            }
3020
3021            next_offset += envelope_size;
3022            _next_ordinal_to_read += 1;
3023            if next_offset >= end_offset {
3024                return Ok(());
3025            }
3026
3027            // Decode unknown envelopes for gaps in ordinals.
3028            while _next_ordinal_to_read < 4 {
3029                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3030                _next_ordinal_to_read += 1;
3031                next_offset += envelope_size;
3032            }
3033
3034            let next_out_of_line = decoder.next_out_of_line();
3035            let handles_before = decoder.remaining_handles();
3036            if let Some((inlined, num_bytes, num_handles)) =
3037                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3038            {
3039                let member_inline_size = <fidl_fuchsia_device_fs::ConnectionType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3040                if inlined != (member_inline_size <= 4) {
3041                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3042                }
3043                let inner_offset;
3044                let mut inner_depth = depth.clone();
3045                if inlined {
3046                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3047                    inner_offset = next_offset;
3048                } else {
3049                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3050                    inner_depth.increment()?;
3051                }
3052                let val_ref = self.connector_supports.get_or_insert_with(|| {
3053                    fidl::new_empty!(
3054                        fidl_fuchsia_device_fs::ConnectionType,
3055                        fidl::encoding::DefaultFuchsiaResourceDialect
3056                    )
3057                });
3058                fidl::decode!(
3059                    fidl_fuchsia_device_fs::ConnectionType,
3060                    fidl::encoding::DefaultFuchsiaResourceDialect,
3061                    val_ref,
3062                    decoder,
3063                    inner_offset,
3064                    inner_depth
3065                )?;
3066                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3067                {
3068                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3069                }
3070                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3071                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3072                }
3073            }
3074
3075            next_offset += envelope_size;
3076            _next_ordinal_to_read += 1;
3077            if next_offset >= end_offset {
3078                return Ok(());
3079            }
3080
3081            // Decode unknown envelopes for gaps in ordinals.
3082            while _next_ordinal_to_read < 5 {
3083                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3084                _next_ordinal_to_read += 1;
3085                next_offset += envelope_size;
3086            }
3087
3088            let next_out_of_line = decoder.next_out_of_line();
3089            let handles_before = decoder.remaining_handles();
3090            if let Some((inlined, num_bytes, num_handles)) =
3091                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3092            {
3093                let member_inline_size = <fidl::encoding::Endpoint<
3094                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
3095                > as fidl::encoding::TypeMarker>::inline_size(
3096                    decoder.context
3097                );
3098                if inlined != (member_inline_size <= 4) {
3099                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3100                }
3101                let inner_offset;
3102                let mut inner_depth = depth.clone();
3103                if inlined {
3104                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3105                    inner_offset = next_offset;
3106                } else {
3107                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3108                    inner_depth.increment()?;
3109                }
3110                let val_ref = self.controller_connector.get_or_insert_with(|| {
3111                    fidl::new_empty!(
3112                        fidl::encoding::Endpoint<
3113                            fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
3114                        >,
3115                        fidl::encoding::DefaultFuchsiaResourceDialect
3116                    )
3117                });
3118                fidl::decode!(
3119                    fidl::encoding::Endpoint<
3120                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
3121                    >,
3122                    fidl::encoding::DefaultFuchsiaResourceDialect,
3123                    val_ref,
3124                    decoder,
3125                    inner_offset,
3126                    inner_depth
3127                )?;
3128                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3129                {
3130                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3131                }
3132                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3133                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3134                }
3135            }
3136
3137            next_offset += envelope_size;
3138
3139            // Decode the remaining unknown envelopes.
3140            while next_offset < end_offset {
3141                _next_ordinal_to_read += 1;
3142                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3143                next_offset += envelope_size;
3144            }
3145
3146            Ok(())
3147        }
3148    }
3149
3150    impl DriverStartArgs {
3151        #[inline(always)]
3152        fn max_ordinal_present(&self) -> u64 {
3153            if let Some(_) = self.vmar {
3154                return 13;
3155            }
3156            if let Some(_) = self.node_properties_2 {
3157                return 12;
3158            }
3159            if let Some(_) = self.node_token {
3160                return 11;
3161            }
3162            if let Some(_) = self.node_offers {
3163                return 10;
3164            }
3165            if let Some(_) = self.node_properties {
3166                return 9;
3167            }
3168            if let Some(_) = self.node_name {
3169                return 8;
3170            }
3171            if let Some(_) = self.config {
3172                return 7;
3173            }
3174            if let Some(_) = self.outgoing_dir {
3175                return 6;
3176            }
3177            if let Some(_) = self.incoming {
3178                return 5;
3179            }
3180            if let Some(_) = self.program {
3181                return 4;
3182            }
3183            if let Some(_) = self.url {
3184                return 3;
3185            }
3186            if let Some(_) = self.symbols {
3187                return 2;
3188            }
3189            if let Some(_) = self.node {
3190                return 1;
3191            }
3192            0
3193        }
3194    }
3195
3196    impl fidl::encoding::ResourceTypeMarker for DriverStartArgs {
3197        type Borrowed<'a> = &'a mut Self;
3198        fn take_or_borrow<'a>(
3199            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3200        ) -> Self::Borrowed<'a> {
3201            value
3202        }
3203    }
3204
3205    unsafe impl fidl::encoding::TypeMarker for DriverStartArgs {
3206        type Owned = Self;
3207
3208        #[inline(always)]
3209        fn inline_align(_context: fidl::encoding::Context) -> usize {
3210            8
3211        }
3212
3213        #[inline(always)]
3214        fn inline_size(_context: fidl::encoding::Context) -> usize {
3215            16
3216        }
3217    }
3218
3219    unsafe impl
3220        fidl::encoding::Encode<DriverStartArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
3221        for &mut DriverStartArgs
3222    {
3223        unsafe fn encode(
3224            self,
3225            encoder: &mut fidl::encoding::Encoder<
3226                '_,
3227                fidl::encoding::DefaultFuchsiaResourceDialect,
3228            >,
3229            offset: usize,
3230            mut depth: fidl::encoding::Depth,
3231        ) -> fidl::Result<()> {
3232            encoder.debug_check_bounds::<DriverStartArgs>(offset);
3233            // Vector header
3234            let max_ordinal: u64 = self.max_ordinal_present();
3235            encoder.write_num(max_ordinal, offset);
3236            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3237            // Calling encoder.out_of_line_offset(0) is not allowed.
3238            if max_ordinal == 0 {
3239                return Ok(());
3240            }
3241            depth.increment()?;
3242            let envelope_size = 8;
3243            let bytes_len = max_ordinal as usize * envelope_size;
3244            #[allow(unused_variables)]
3245            let offset = encoder.out_of_line_offset(bytes_len);
3246            let mut _prev_end_offset: usize = 0;
3247            if 1 > max_ordinal {
3248                return Ok(());
3249            }
3250
3251            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3252            // are envelope_size bytes.
3253            let cur_offset: usize = (1 - 1) * envelope_size;
3254
3255            // Zero reserved fields.
3256            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3257
3258            // Safety:
3259            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3260            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3261            //   envelope_size bytes, there is always sufficient room.
3262            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3263            self.node.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3264            encoder, offset + cur_offset, depth
3265        )?;
3266
3267            _prev_end_offset = cur_offset + envelope_size;
3268            if 2 > max_ordinal {
3269                return Ok(());
3270            }
3271
3272            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3273            // are envelope_size bytes.
3274            let cur_offset: usize = (2 - 1) * envelope_size;
3275
3276            // Zero reserved fields.
3277            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3278
3279            // Safety:
3280            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3281            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3282            //   envelope_size bytes, there is always sufficient room.
3283            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3284            self.symbols.as_ref().map(<fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::ValueTypeMarker>::borrow),
3285            encoder, offset + cur_offset, depth
3286        )?;
3287
3288            _prev_end_offset = cur_offset + envelope_size;
3289            if 3 > max_ordinal {
3290                return Ok(());
3291            }
3292
3293            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3294            // are envelope_size bytes.
3295            let cur_offset: usize = (3 - 1) * envelope_size;
3296
3297            // Zero reserved fields.
3298            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3299
3300            // Safety:
3301            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3302            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3303            //   envelope_size bytes, there is always sufficient room.
3304            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3305            self.url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
3306            encoder, offset + cur_offset, depth
3307        )?;
3308
3309            _prev_end_offset = cur_offset + envelope_size;
3310            if 4 > max_ordinal {
3311                return Ok(());
3312            }
3313
3314            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3315            // are envelope_size bytes.
3316            let cur_offset: usize = (4 - 1) * envelope_size;
3317
3318            // Zero reserved fields.
3319            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3320
3321            // Safety:
3322            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3323            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3324            //   envelope_size bytes, there is always sufficient room.
3325            fidl::encoding::encode_in_envelope_optional::<
3326                fidl_fuchsia_data::Dictionary,
3327                fidl::encoding::DefaultFuchsiaResourceDialect,
3328            >(
3329                self.program.as_ref().map(
3330                    <fidl_fuchsia_data::Dictionary as fidl::encoding::ValueTypeMarker>::borrow,
3331                ),
3332                encoder,
3333                offset + cur_offset,
3334                depth,
3335            )?;
3336
3337            _prev_end_offset = cur_offset + envelope_size;
3338            if 5 > max_ordinal {
3339                return Ok(());
3340            }
3341
3342            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3343            // are envelope_size bytes.
3344            let cur_offset: usize = (5 - 1) * envelope_size;
3345
3346            // Zero reserved fields.
3347            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3348
3349            // Safety:
3350            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3351            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3352            //   envelope_size bytes, there is always sufficient room.
3353            fidl::encoding::encode_in_envelope_optional::<
3354                fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>,
3355                fidl::encoding::DefaultFuchsiaResourceDialect,
3356            >(
3357                self.incoming.as_mut().map(
3358                    <fidl::encoding::Vector<
3359                        fidl_fuchsia_component_runner::ComponentNamespaceEntry,
3360                        32,
3361                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3362                ),
3363                encoder,
3364                offset + cur_offset,
3365                depth,
3366            )?;
3367
3368            _prev_end_offset = cur_offset + envelope_size;
3369            if 6 > max_ordinal {
3370                return Ok(());
3371            }
3372
3373            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3374            // are envelope_size bytes.
3375            let cur_offset: usize = (6 - 1) * envelope_size;
3376
3377            // Zero reserved fields.
3378            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3379
3380            // Safety:
3381            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3382            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3383            //   envelope_size bytes, there is always sufficient room.
3384            fidl::encoding::encode_in_envelope_optional::<
3385                fidl::encoding::Endpoint<
3386                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3387                >,
3388                fidl::encoding::DefaultFuchsiaResourceDialect,
3389            >(
3390                self.outgoing_dir.as_mut().map(
3391                    <fidl::encoding::Endpoint<
3392                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3393                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3394                ),
3395                encoder,
3396                offset + cur_offset,
3397                depth,
3398            )?;
3399
3400            _prev_end_offset = cur_offset + envelope_size;
3401            if 7 > max_ordinal {
3402                return Ok(());
3403            }
3404
3405            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3406            // are envelope_size bytes.
3407            let cur_offset: usize = (7 - 1) * envelope_size;
3408
3409            // Zero reserved fields.
3410            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3411
3412            // Safety:
3413            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3414            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3415            //   envelope_size bytes, there is always sufficient room.
3416            fidl::encoding::encode_in_envelope_optional::<
3417                fidl::encoding::HandleType<
3418                    fidl::Vmo,
3419                    { fidl::ObjectType::VMO.into_raw() },
3420                    2147483648,
3421                >,
3422                fidl::encoding::DefaultFuchsiaResourceDialect,
3423            >(
3424                self.config.as_mut().map(
3425                    <fidl::encoding::HandleType<
3426                        fidl::Vmo,
3427                        { fidl::ObjectType::VMO.into_raw() },
3428                        2147483648,
3429                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3430                ),
3431                encoder,
3432                offset + cur_offset,
3433                depth,
3434            )?;
3435
3436            _prev_end_offset = cur_offset + envelope_size;
3437            if 8 > max_ordinal {
3438                return Ok(());
3439            }
3440
3441            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3442            // are envelope_size bytes.
3443            let cur_offset: usize = (8 - 1) * envelope_size;
3444
3445            // Zero reserved fields.
3446            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3447
3448            // Safety:
3449            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3450            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3451            //   envelope_size bytes, there is always sufficient room.
3452            fidl::encoding::encode_in_envelope_optional::<
3453                fidl::encoding::UnboundedString,
3454                fidl::encoding::DefaultFuchsiaResourceDialect,
3455            >(
3456                self.node_name.as_ref().map(
3457                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
3458                ),
3459                encoder,
3460                offset + cur_offset,
3461                depth,
3462            )?;
3463
3464            _prev_end_offset = cur_offset + envelope_size;
3465            if 9 > max_ordinal {
3466                return Ok(());
3467            }
3468
3469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3470            // are envelope_size bytes.
3471            let cur_offset: usize = (9 - 1) * envelope_size;
3472
3473            // Zero reserved fields.
3474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3475
3476            // Safety:
3477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3479            //   envelope_size bytes, there is always sufficient room.
3480            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<NodePropertyEntry>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3481            self.node_properties.as_ref().map(<fidl::encoding::UnboundedVector<NodePropertyEntry> as fidl::encoding::ValueTypeMarker>::borrow),
3482            encoder, offset + cur_offset, depth
3483        )?;
3484
3485            _prev_end_offset = cur_offset + envelope_size;
3486            if 10 > max_ordinal {
3487                return Ok(());
3488            }
3489
3490            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3491            // are envelope_size bytes.
3492            let cur_offset: usize = (10 - 1) * envelope_size;
3493
3494            // Zero reserved fields.
3495            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3496
3497            // Safety:
3498            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3499            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3500            //   envelope_size bytes, there is always sufficient room.
3501            fidl::encoding::encode_in_envelope_optional::<
3502                fidl::encoding::Vector<Offer, 128>,
3503                fidl::encoding::DefaultFuchsiaResourceDialect,
3504            >(
3505                self.node_offers.as_ref().map(
3506                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::ValueTypeMarker>::borrow,
3507                ),
3508                encoder,
3509                offset + cur_offset,
3510                depth,
3511            )?;
3512
3513            _prev_end_offset = cur_offset + envelope_size;
3514            if 11 > max_ordinal {
3515                return Ok(());
3516            }
3517
3518            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3519            // are envelope_size bytes.
3520            let cur_offset: usize = (11 - 1) * envelope_size;
3521
3522            // Zero reserved fields.
3523            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3524
3525            // Safety:
3526            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3527            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3528            //   envelope_size bytes, there is always sufficient room.
3529            fidl::encoding::encode_in_envelope_optional::<
3530                fidl::encoding::HandleType<
3531                    fidl::Event,
3532                    { fidl::ObjectType::EVENT.into_raw() },
3533                    2147483648,
3534                >,
3535                fidl::encoding::DefaultFuchsiaResourceDialect,
3536            >(
3537                self.node_token.as_mut().map(
3538                    <fidl::encoding::HandleType<
3539                        fidl::Event,
3540                        { fidl::ObjectType::EVENT.into_raw() },
3541                        2147483648,
3542                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3543                ),
3544                encoder,
3545                offset + cur_offset,
3546                depth,
3547            )?;
3548
3549            _prev_end_offset = cur_offset + envelope_size;
3550            if 12 > max_ordinal {
3551                return Ok(());
3552            }
3553
3554            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3555            // are envelope_size bytes.
3556            let cur_offset: usize = (12 - 1) * envelope_size;
3557
3558            // Zero reserved fields.
3559            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3560
3561            // Safety:
3562            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3563            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3564            //   envelope_size bytes, there is always sufficient room.
3565            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<NodePropertyEntry2>, fidl::encoding::DefaultFuchsiaResourceDialect>(
3566            self.node_properties_2.as_ref().map(<fidl::encoding::UnboundedVector<NodePropertyEntry2> as fidl::encoding::ValueTypeMarker>::borrow),
3567            encoder, offset + cur_offset, depth
3568        )?;
3569
3570            _prev_end_offset = cur_offset + envelope_size;
3571            if 13 > max_ordinal {
3572                return Ok(());
3573            }
3574
3575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3576            // are envelope_size bytes.
3577            let cur_offset: usize = (13 - 1) * envelope_size;
3578
3579            // Zero reserved fields.
3580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3581
3582            // Safety:
3583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3585            //   envelope_size bytes, there is always sufficient room.
3586            fidl::encoding::encode_in_envelope_optional::<
3587                fidl::encoding::HandleType<
3588                    fidl::Vmar,
3589                    { fidl::ObjectType::VMAR.into_raw() },
3590                    2147483648,
3591                >,
3592                fidl::encoding::DefaultFuchsiaResourceDialect,
3593            >(
3594                self.vmar.as_mut().map(
3595                    <fidl::encoding::HandleType<
3596                        fidl::Vmar,
3597                        { fidl::ObjectType::VMAR.into_raw() },
3598                        2147483648,
3599                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
3600                ),
3601                encoder,
3602                offset + cur_offset,
3603                depth,
3604            )?;
3605
3606            _prev_end_offset = cur_offset + envelope_size;
3607
3608            Ok(())
3609        }
3610    }
3611
3612    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3613        for DriverStartArgs
3614    {
3615        #[inline(always)]
3616        fn new_empty() -> Self {
3617            Self::default()
3618        }
3619
3620        unsafe fn decode(
3621            &mut self,
3622            decoder: &mut fidl::encoding::Decoder<
3623                '_,
3624                fidl::encoding::DefaultFuchsiaResourceDialect,
3625            >,
3626            offset: usize,
3627            mut depth: fidl::encoding::Depth,
3628        ) -> fidl::Result<()> {
3629            decoder.debug_check_bounds::<Self>(offset);
3630            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3631                None => return Err(fidl::Error::NotNullable),
3632                Some(len) => len,
3633            };
3634            // Calling decoder.out_of_line_offset(0) is not allowed.
3635            if len == 0 {
3636                return Ok(());
3637            };
3638            depth.increment()?;
3639            let envelope_size = 8;
3640            let bytes_len = len * envelope_size;
3641            let offset = decoder.out_of_line_offset(bytes_len)?;
3642            // Decode the envelope for each type.
3643            let mut _next_ordinal_to_read = 0;
3644            let mut next_offset = offset;
3645            let end_offset = offset + bytes_len;
3646            _next_ordinal_to_read += 1;
3647            if next_offset >= end_offset {
3648                return Ok(());
3649            }
3650
3651            // Decode unknown envelopes for gaps in ordinals.
3652            while _next_ordinal_to_read < 1 {
3653                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3654                _next_ordinal_to_read += 1;
3655                next_offset += envelope_size;
3656            }
3657
3658            let next_out_of_line = decoder.next_out_of_line();
3659            let handles_before = decoder.remaining_handles();
3660            if let Some((inlined, num_bytes, num_handles)) =
3661                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3662            {
3663                let member_inline_size = <fidl::encoding::Endpoint<
3664                    fidl::endpoints::ClientEnd<NodeMarker>,
3665                > as fidl::encoding::TypeMarker>::inline_size(
3666                    decoder.context
3667                );
3668                if inlined != (member_inline_size <= 4) {
3669                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3670                }
3671                let inner_offset;
3672                let mut inner_depth = depth.clone();
3673                if inlined {
3674                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3675                    inner_offset = next_offset;
3676                } else {
3677                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3678                    inner_depth.increment()?;
3679                }
3680                let val_ref = self.node.get_or_insert_with(|| {
3681                    fidl::new_empty!(
3682                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>,
3683                        fidl::encoding::DefaultFuchsiaResourceDialect
3684                    )
3685                });
3686                fidl::decode!(
3687                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>,
3688                    fidl::encoding::DefaultFuchsiaResourceDialect,
3689                    val_ref,
3690                    decoder,
3691                    inner_offset,
3692                    inner_depth
3693                )?;
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 < 2 {
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 = <fidl::encoding::Vector<NodeSymbol, 64> 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 =
3735                self.symbols.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
3736                fidl::decode!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3737                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3738                {
3739                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3740                }
3741                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3742                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3743                }
3744            }
3745
3746            next_offset += envelope_size;
3747            _next_ordinal_to_read += 1;
3748            if next_offset >= end_offset {
3749                return Ok(());
3750            }
3751
3752            // Decode unknown envelopes for gaps in ordinals.
3753            while _next_ordinal_to_read < 3 {
3754                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3755                _next_ordinal_to_read += 1;
3756                next_offset += envelope_size;
3757            }
3758
3759            let next_out_of_line = decoder.next_out_of_line();
3760            let handles_before = decoder.remaining_handles();
3761            if let Some((inlined, num_bytes, num_handles)) =
3762                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3763            {
3764                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3765                if inlined != (member_inline_size <= 4) {
3766                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3767                }
3768                let inner_offset;
3769                let mut inner_depth = depth.clone();
3770                if inlined {
3771                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3772                    inner_offset = next_offset;
3773                } else {
3774                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3775                    inner_depth.increment()?;
3776                }
3777                let val_ref = self.url.get_or_insert_with(|| {
3778                    fidl::new_empty!(
3779                        fidl::encoding::BoundedString<4096>,
3780                        fidl::encoding::DefaultFuchsiaResourceDialect
3781                    )
3782                });
3783                fidl::decode!(
3784                    fidl::encoding::BoundedString<4096>,
3785                    fidl::encoding::DefaultFuchsiaResourceDialect,
3786                    val_ref,
3787                    decoder,
3788                    inner_offset,
3789                    inner_depth
3790                )?;
3791                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3792                {
3793                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3794                }
3795                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3796                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3797                }
3798            }
3799
3800            next_offset += envelope_size;
3801            _next_ordinal_to_read += 1;
3802            if next_offset >= end_offset {
3803                return Ok(());
3804            }
3805
3806            // Decode unknown envelopes for gaps in ordinals.
3807            while _next_ordinal_to_read < 4 {
3808                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3809                _next_ordinal_to_read += 1;
3810                next_offset += envelope_size;
3811            }
3812
3813            let next_out_of_line = decoder.next_out_of_line();
3814            let handles_before = decoder.remaining_handles();
3815            if let Some((inlined, num_bytes, num_handles)) =
3816                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3817            {
3818                let member_inline_size =
3819                    <fidl_fuchsia_data::Dictionary as fidl::encoding::TypeMarker>::inline_size(
3820                        decoder.context,
3821                    );
3822                if inlined != (member_inline_size <= 4) {
3823                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3824                }
3825                let inner_offset;
3826                let mut inner_depth = depth.clone();
3827                if inlined {
3828                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3829                    inner_offset = next_offset;
3830                } else {
3831                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3832                    inner_depth.increment()?;
3833                }
3834                let val_ref = self.program.get_or_insert_with(|| {
3835                    fidl::new_empty!(
3836                        fidl_fuchsia_data::Dictionary,
3837                        fidl::encoding::DefaultFuchsiaResourceDialect
3838                    )
3839                });
3840                fidl::decode!(
3841                    fidl_fuchsia_data::Dictionary,
3842                    fidl::encoding::DefaultFuchsiaResourceDialect,
3843                    val_ref,
3844                    decoder,
3845                    inner_offset,
3846                    inner_depth
3847                )?;
3848                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3849                {
3850                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3851                }
3852                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3853                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3854                }
3855            }
3856
3857            next_offset += envelope_size;
3858            _next_ordinal_to_read += 1;
3859            if next_offset >= end_offset {
3860                return Ok(());
3861            }
3862
3863            // Decode unknown envelopes for gaps in ordinals.
3864            while _next_ordinal_to_read < 5 {
3865                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3866                _next_ordinal_to_read += 1;
3867                next_offset += envelope_size;
3868            }
3869
3870            let next_out_of_line = decoder.next_out_of_line();
3871            let handles_before = decoder.remaining_handles();
3872            if let Some((inlined, num_bytes, num_handles)) =
3873                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3874            {
3875                let member_inline_size = <fidl::encoding::Vector<
3876                    fidl_fuchsia_component_runner::ComponentNamespaceEntry,
3877                    32,
3878                > as fidl::encoding::TypeMarker>::inline_size(
3879                    decoder.context
3880                );
3881                if inlined != (member_inline_size <= 4) {
3882                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3883                }
3884                let inner_offset;
3885                let mut inner_depth = depth.clone();
3886                if inlined {
3887                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3888                    inner_offset = next_offset;
3889                } else {
3890                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3891                    inner_depth.increment()?;
3892                }
3893                let val_ref =
3894                self.incoming.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
3895                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
3896                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3897                {
3898                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3899                }
3900                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3901                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3902                }
3903            }
3904
3905            next_offset += envelope_size;
3906            _next_ordinal_to_read += 1;
3907            if next_offset >= end_offset {
3908                return Ok(());
3909            }
3910
3911            // Decode unknown envelopes for gaps in ordinals.
3912            while _next_ordinal_to_read < 6 {
3913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3914                _next_ordinal_to_read += 1;
3915                next_offset += envelope_size;
3916            }
3917
3918            let next_out_of_line = decoder.next_out_of_line();
3919            let handles_before = decoder.remaining_handles();
3920            if let Some((inlined, num_bytes, num_handles)) =
3921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3922            {
3923                let member_inline_size = <fidl::encoding::Endpoint<
3924                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3925                > as fidl::encoding::TypeMarker>::inline_size(
3926                    decoder.context
3927                );
3928                if inlined != (member_inline_size <= 4) {
3929                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3930                }
3931                let inner_offset;
3932                let mut inner_depth = depth.clone();
3933                if inlined {
3934                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3935                    inner_offset = next_offset;
3936                } else {
3937                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3938                    inner_depth.increment()?;
3939                }
3940                let val_ref = self.outgoing_dir.get_or_insert_with(|| {
3941                    fidl::new_empty!(
3942                        fidl::encoding::Endpoint<
3943                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3944                        >,
3945                        fidl::encoding::DefaultFuchsiaResourceDialect
3946                    )
3947                });
3948                fidl::decode!(
3949                    fidl::encoding::Endpoint<
3950                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
3951                    >,
3952                    fidl::encoding::DefaultFuchsiaResourceDialect,
3953                    val_ref,
3954                    decoder,
3955                    inner_offset,
3956                    inner_depth
3957                )?;
3958                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3959                {
3960                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3961                }
3962                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3963                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3964                }
3965            }
3966
3967            next_offset += envelope_size;
3968            _next_ordinal_to_read += 1;
3969            if next_offset >= end_offset {
3970                return Ok(());
3971            }
3972
3973            // Decode unknown envelopes for gaps in ordinals.
3974            while _next_ordinal_to_read < 7 {
3975                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3976                _next_ordinal_to_read += 1;
3977                next_offset += envelope_size;
3978            }
3979
3980            let next_out_of_line = decoder.next_out_of_line();
3981            let handles_before = decoder.remaining_handles();
3982            if let Some((inlined, num_bytes, num_handles)) =
3983                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3984            {
3985                let member_inline_size = <fidl::encoding::HandleType<
3986                    fidl::Vmo,
3987                    { fidl::ObjectType::VMO.into_raw() },
3988                    2147483648,
3989                > as fidl::encoding::TypeMarker>::inline_size(
3990                    decoder.context
3991                );
3992                if inlined != (member_inline_size <= 4) {
3993                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3994                }
3995                let inner_offset;
3996                let mut inner_depth = depth.clone();
3997                if inlined {
3998                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3999                    inner_offset = next_offset;
4000                } else {
4001                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4002                    inner_depth.increment()?;
4003                }
4004                let val_ref =
4005                self.config.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4006                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4007                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4008                {
4009                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4010                }
4011                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4012                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4013                }
4014            }
4015
4016            next_offset += envelope_size;
4017            _next_ordinal_to_read += 1;
4018            if next_offset >= end_offset {
4019                return Ok(());
4020            }
4021
4022            // Decode unknown envelopes for gaps in ordinals.
4023            while _next_ordinal_to_read < 8 {
4024                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4025                _next_ordinal_to_read += 1;
4026                next_offset += envelope_size;
4027            }
4028
4029            let next_out_of_line = decoder.next_out_of_line();
4030            let handles_before = decoder.remaining_handles();
4031            if let Some((inlined, num_bytes, num_handles)) =
4032                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4033            {
4034                let member_inline_size =
4035                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
4036                        decoder.context,
4037                    );
4038                if inlined != (member_inline_size <= 4) {
4039                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4040                }
4041                let inner_offset;
4042                let mut inner_depth = depth.clone();
4043                if inlined {
4044                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4045                    inner_offset = next_offset;
4046                } else {
4047                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4048                    inner_depth.increment()?;
4049                }
4050                let val_ref = self.node_name.get_or_insert_with(|| {
4051                    fidl::new_empty!(
4052                        fidl::encoding::UnboundedString,
4053                        fidl::encoding::DefaultFuchsiaResourceDialect
4054                    )
4055                });
4056                fidl::decode!(
4057                    fidl::encoding::UnboundedString,
4058                    fidl::encoding::DefaultFuchsiaResourceDialect,
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            _next_ordinal_to_read += 1;
4075            if next_offset >= end_offset {
4076                return Ok(());
4077            }
4078
4079            // Decode unknown envelopes for gaps in ordinals.
4080            while _next_ordinal_to_read < 9 {
4081                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4082                _next_ordinal_to_read += 1;
4083                next_offset += envelope_size;
4084            }
4085
4086            let next_out_of_line = decoder.next_out_of_line();
4087            let handles_before = decoder.remaining_handles();
4088            if let Some((inlined, num_bytes, num_handles)) =
4089                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4090            {
4091                let member_inline_size = <fidl::encoding::UnboundedVector<NodePropertyEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4092                if inlined != (member_inline_size <= 4) {
4093                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4094                }
4095                let inner_offset;
4096                let mut inner_depth = depth.clone();
4097                if inlined {
4098                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4099                    inner_offset = next_offset;
4100                } else {
4101                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4102                    inner_depth.increment()?;
4103                }
4104                let val_ref = self.node_properties.get_or_insert_with(|| {
4105                    fidl::new_empty!(
4106                        fidl::encoding::UnboundedVector<NodePropertyEntry>,
4107                        fidl::encoding::DefaultFuchsiaResourceDialect
4108                    )
4109                });
4110                fidl::decode!(
4111                    fidl::encoding::UnboundedVector<NodePropertyEntry>,
4112                    fidl::encoding::DefaultFuchsiaResourceDialect,
4113                    val_ref,
4114                    decoder,
4115                    inner_offset,
4116                    inner_depth
4117                )?;
4118                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4119                {
4120                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4121                }
4122                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4123                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4124                }
4125            }
4126
4127            next_offset += envelope_size;
4128            _next_ordinal_to_read += 1;
4129            if next_offset >= end_offset {
4130                return Ok(());
4131            }
4132
4133            // Decode unknown envelopes for gaps in ordinals.
4134            while _next_ordinal_to_read < 10 {
4135                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4136                _next_ordinal_to_read += 1;
4137                next_offset += envelope_size;
4138            }
4139
4140            let next_out_of_line = decoder.next_out_of_line();
4141            let handles_before = decoder.remaining_handles();
4142            if let Some((inlined, num_bytes, num_handles)) =
4143                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4144            {
4145                let member_inline_size =
4146                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::TypeMarker>::inline_size(
4147                        decoder.context,
4148                    );
4149                if inlined != (member_inline_size <= 4) {
4150                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4151                }
4152                let inner_offset;
4153                let mut inner_depth = depth.clone();
4154                if inlined {
4155                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4156                    inner_offset = next_offset;
4157                } else {
4158                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4159                    inner_depth.increment()?;
4160                }
4161                let val_ref =
4162                self.node_offers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect));
4163                fidl::decode!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4164                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4165                {
4166                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4167                }
4168                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4169                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4170                }
4171            }
4172
4173            next_offset += envelope_size;
4174            _next_ordinal_to_read += 1;
4175            if next_offset >= end_offset {
4176                return Ok(());
4177            }
4178
4179            // Decode unknown envelopes for gaps in ordinals.
4180            while _next_ordinal_to_read < 11 {
4181                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4182                _next_ordinal_to_read += 1;
4183                next_offset += envelope_size;
4184            }
4185
4186            let next_out_of_line = decoder.next_out_of_line();
4187            let handles_before = decoder.remaining_handles();
4188            if let Some((inlined, num_bytes, num_handles)) =
4189                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4190            {
4191                let member_inline_size = <fidl::encoding::HandleType<
4192                    fidl::Event,
4193                    { fidl::ObjectType::EVENT.into_raw() },
4194                    2147483648,
4195                > as fidl::encoding::TypeMarker>::inline_size(
4196                    decoder.context
4197                );
4198                if inlined != (member_inline_size <= 4) {
4199                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4200                }
4201                let inner_offset;
4202                let mut inner_depth = depth.clone();
4203                if inlined {
4204                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4205                    inner_offset = next_offset;
4206                } else {
4207                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4208                    inner_depth.increment()?;
4209                }
4210                let val_ref =
4211                self.node_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4212                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4213                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4214                {
4215                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4216                }
4217                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4218                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4219                }
4220            }
4221
4222            next_offset += envelope_size;
4223            _next_ordinal_to_read += 1;
4224            if next_offset >= end_offset {
4225                return Ok(());
4226            }
4227
4228            // Decode unknown envelopes for gaps in ordinals.
4229            while _next_ordinal_to_read < 12 {
4230                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4231                _next_ordinal_to_read += 1;
4232                next_offset += envelope_size;
4233            }
4234
4235            let next_out_of_line = decoder.next_out_of_line();
4236            let handles_before = decoder.remaining_handles();
4237            if let Some((inlined, num_bytes, num_handles)) =
4238                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4239            {
4240                let member_inline_size = <fidl::encoding::UnboundedVector<NodePropertyEntry2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4241                if inlined != (member_inline_size <= 4) {
4242                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4243                }
4244                let inner_offset;
4245                let mut inner_depth = depth.clone();
4246                if inlined {
4247                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4248                    inner_offset = next_offset;
4249                } else {
4250                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4251                    inner_depth.increment()?;
4252                }
4253                let val_ref = self.node_properties_2.get_or_insert_with(|| {
4254                    fidl::new_empty!(
4255                        fidl::encoding::UnboundedVector<NodePropertyEntry2>,
4256                        fidl::encoding::DefaultFuchsiaResourceDialect
4257                    )
4258                });
4259                fidl::decode!(
4260                    fidl::encoding::UnboundedVector<NodePropertyEntry2>,
4261                    fidl::encoding::DefaultFuchsiaResourceDialect,
4262                    val_ref,
4263                    decoder,
4264                    inner_offset,
4265                    inner_depth
4266                )?;
4267                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4268                {
4269                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4270                }
4271                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4272                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4273                }
4274            }
4275
4276            next_offset += envelope_size;
4277            _next_ordinal_to_read += 1;
4278            if next_offset >= end_offset {
4279                return Ok(());
4280            }
4281
4282            // Decode unknown envelopes for gaps in ordinals.
4283            while _next_ordinal_to_read < 13 {
4284                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4285                _next_ordinal_to_read += 1;
4286                next_offset += envelope_size;
4287            }
4288
4289            let next_out_of_line = decoder.next_out_of_line();
4290            let handles_before = decoder.remaining_handles();
4291            if let Some((inlined, num_bytes, num_handles)) =
4292                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4293            {
4294                let member_inline_size = <fidl::encoding::HandleType<
4295                    fidl::Vmar,
4296                    { fidl::ObjectType::VMAR.into_raw() },
4297                    2147483648,
4298                > as fidl::encoding::TypeMarker>::inline_size(
4299                    decoder.context
4300                );
4301                if inlined != (member_inline_size <= 4) {
4302                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4303                }
4304                let inner_offset;
4305                let mut inner_depth = depth.clone();
4306                if inlined {
4307                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4308                    inner_offset = next_offset;
4309                } else {
4310                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4311                    inner_depth.increment()?;
4312                }
4313                let val_ref =
4314                self.vmar.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4315                fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4316                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4317                {
4318                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4319                }
4320                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4321                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4322                }
4323            }
4324
4325            next_offset += envelope_size;
4326
4327            // Decode the remaining unknown envelopes.
4328            while next_offset < end_offset {
4329                _next_ordinal_to_read += 1;
4330                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4331                next_offset += envelope_size;
4332            }
4333
4334            Ok(())
4335        }
4336    }
4337
4338    impl NodeAddArgs {
4339        #[inline(always)]
4340        fn max_ordinal_present(&self) -> u64 {
4341            if let Some(_) = self.offers_dictionary {
4342                return 9;
4343            }
4344            if let Some(_) = self.properties2 {
4345                return 8;
4346            }
4347            if let Some(_) = self.bus_info {
4348                return 7;
4349            }
4350            if let Some(_) = self.offers2 {
4351                return 6;
4352            }
4353            if let Some(_) = self.devfs_args {
4354                return 5;
4355            }
4356            if let Some(_) = self.properties {
4357                return 4;
4358            }
4359            if let Some(_) = self.symbols {
4360                return 3;
4361            }
4362            if let Some(_) = self.name {
4363                return 1;
4364            }
4365            0
4366        }
4367    }
4368
4369    impl fidl::encoding::ResourceTypeMarker for NodeAddArgs {
4370        type Borrowed<'a> = &'a mut Self;
4371        fn take_or_borrow<'a>(
4372            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4373        ) -> Self::Borrowed<'a> {
4374            value
4375        }
4376    }
4377
4378    unsafe impl fidl::encoding::TypeMarker for NodeAddArgs {
4379        type Owned = Self;
4380
4381        #[inline(always)]
4382        fn inline_align(_context: fidl::encoding::Context) -> usize {
4383            8
4384        }
4385
4386        #[inline(always)]
4387        fn inline_size(_context: fidl::encoding::Context) -> usize {
4388            16
4389        }
4390    }
4391
4392    unsafe impl fidl::encoding::Encode<NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
4393        for &mut NodeAddArgs
4394    {
4395        unsafe fn encode(
4396            self,
4397            encoder: &mut fidl::encoding::Encoder<
4398                '_,
4399                fidl::encoding::DefaultFuchsiaResourceDialect,
4400            >,
4401            offset: usize,
4402            mut depth: fidl::encoding::Depth,
4403        ) -> fidl::Result<()> {
4404            encoder.debug_check_bounds::<NodeAddArgs>(offset);
4405            // Vector header
4406            let max_ordinal: u64 = self.max_ordinal_present();
4407            encoder.write_num(max_ordinal, offset);
4408            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4409            // Calling encoder.out_of_line_offset(0) is not allowed.
4410            if max_ordinal == 0 {
4411                return Ok(());
4412            }
4413            depth.increment()?;
4414            let envelope_size = 8;
4415            let bytes_len = max_ordinal as usize * envelope_size;
4416            #[allow(unused_variables)]
4417            let offset = encoder.out_of_line_offset(bytes_len);
4418            let mut _prev_end_offset: usize = 0;
4419            if 1 > max_ordinal {
4420                return Ok(());
4421            }
4422
4423            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4424            // are envelope_size bytes.
4425            let cur_offset: usize = (1 - 1) * envelope_size;
4426
4427            // Zero reserved fields.
4428            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4429
4430            // Safety:
4431            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4432            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4433            //   envelope_size bytes, there is always sufficient room.
4434            fidl::encoding::encode_in_envelope_optional::<
4435                fidl::encoding::BoundedString<128>,
4436                fidl::encoding::DefaultFuchsiaResourceDialect,
4437            >(
4438                self.name.as_ref().map(
4439                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
4440                ),
4441                encoder,
4442                offset + cur_offset,
4443                depth,
4444            )?;
4445
4446            _prev_end_offset = cur_offset + envelope_size;
4447            if 3 > max_ordinal {
4448                return Ok(());
4449            }
4450
4451            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4452            // are envelope_size bytes.
4453            let cur_offset: usize = (3 - 1) * envelope_size;
4454
4455            // Zero reserved fields.
4456            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4457
4458            // Safety:
4459            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4460            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4461            //   envelope_size bytes, there is always sufficient room.
4462            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4463            self.symbols.as_ref().map(<fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::ValueTypeMarker>::borrow),
4464            encoder, offset + cur_offset, depth
4465        )?;
4466
4467            _prev_end_offset = cur_offset + envelope_size;
4468            if 4 > max_ordinal {
4469                return Ok(());
4470            }
4471
4472            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4473            // are envelope_size bytes.
4474            let cur_offset: usize = (4 - 1) * envelope_size;
4475
4476            // Zero reserved fields.
4477            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4478
4479            // Safety:
4480            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4481            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4482            //   envelope_size bytes, there is always sufficient room.
4483            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4484            self.properties.as_ref().map(<fidl::encoding::Vector<NodeProperty, 64> as fidl::encoding::ValueTypeMarker>::borrow),
4485            encoder, offset + cur_offset, depth
4486        )?;
4487
4488            _prev_end_offset = cur_offset + envelope_size;
4489            if 5 > max_ordinal {
4490                return Ok(());
4491            }
4492
4493            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4494            // are envelope_size bytes.
4495            let cur_offset: usize = (5 - 1) * envelope_size;
4496
4497            // Zero reserved fields.
4498            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4499
4500            // Safety:
4501            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4502            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4503            //   envelope_size bytes, there is always sufficient room.
4504            fidl::encoding::encode_in_envelope_optional::<
4505                DevfsAddArgs,
4506                fidl::encoding::DefaultFuchsiaResourceDialect,
4507            >(
4508                self.devfs_args
4509                    .as_mut()
4510                    .map(<DevfsAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4511                encoder,
4512                offset + cur_offset,
4513                depth,
4514            )?;
4515
4516            _prev_end_offset = cur_offset + envelope_size;
4517            if 6 > max_ordinal {
4518                return Ok(());
4519            }
4520
4521            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4522            // are envelope_size bytes.
4523            let cur_offset: usize = (6 - 1) * envelope_size;
4524
4525            // Zero reserved fields.
4526            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4527
4528            // Safety:
4529            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4530            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4531            //   envelope_size bytes, there is always sufficient room.
4532            fidl::encoding::encode_in_envelope_optional::<
4533                fidl::encoding::Vector<Offer, 128>,
4534                fidl::encoding::DefaultFuchsiaResourceDialect,
4535            >(
4536                self.offers2.as_ref().map(
4537                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::ValueTypeMarker>::borrow,
4538                ),
4539                encoder,
4540                offset + cur_offset,
4541                depth,
4542            )?;
4543
4544            _prev_end_offset = cur_offset + envelope_size;
4545            if 7 > max_ordinal {
4546                return Ok(());
4547            }
4548
4549            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4550            // are envelope_size bytes.
4551            let cur_offset: usize = (7 - 1) * envelope_size;
4552
4553            // Zero reserved fields.
4554            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4555
4556            // Safety:
4557            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4558            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4559            //   envelope_size bytes, there is always sufficient room.
4560            fidl::encoding::encode_in_envelope_optional::<
4561                BusInfo,
4562                fidl::encoding::DefaultFuchsiaResourceDialect,
4563            >(
4564                self.bus_info.as_ref().map(<BusInfo as fidl::encoding::ValueTypeMarker>::borrow),
4565                encoder,
4566                offset + cur_offset,
4567                depth,
4568            )?;
4569
4570            _prev_end_offset = cur_offset + envelope_size;
4571            if 8 > max_ordinal {
4572                return Ok(());
4573            }
4574
4575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4576            // are envelope_size bytes.
4577            let cur_offset: usize = (8 - 1) * envelope_size;
4578
4579            // Zero reserved fields.
4580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4581
4582            // Safety:
4583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4585            //   envelope_size bytes, there is always sufficient room.
4586            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4587            self.properties2.as_ref().map(<fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::ValueTypeMarker>::borrow),
4588            encoder, offset + cur_offset, depth
4589        )?;
4590
4591            _prev_end_offset = cur_offset + envelope_size;
4592            if 9 > max_ordinal {
4593                return Ok(());
4594            }
4595
4596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4597            // are envelope_size bytes.
4598            let cur_offset: usize = (9 - 1) * envelope_size;
4599
4600            // Zero reserved fields.
4601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4602
4603            // Safety:
4604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4606            //   envelope_size bytes, there is always sufficient room.
4607            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_component_sandbox::DictionaryRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
4608            self.offers_dictionary.as_mut().map(<fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4609            encoder, offset + cur_offset, depth
4610        )?;
4611
4612            _prev_end_offset = cur_offset + envelope_size;
4613
4614            Ok(())
4615        }
4616    }
4617
4618    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddArgs {
4619        #[inline(always)]
4620        fn new_empty() -> Self {
4621            Self::default()
4622        }
4623
4624        unsafe fn decode(
4625            &mut self,
4626            decoder: &mut fidl::encoding::Decoder<
4627                '_,
4628                fidl::encoding::DefaultFuchsiaResourceDialect,
4629            >,
4630            offset: usize,
4631            mut depth: fidl::encoding::Depth,
4632        ) -> fidl::Result<()> {
4633            decoder.debug_check_bounds::<Self>(offset);
4634            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4635                None => return Err(fidl::Error::NotNullable),
4636                Some(len) => len,
4637            };
4638            // Calling decoder.out_of_line_offset(0) is not allowed.
4639            if len == 0 {
4640                return Ok(());
4641            };
4642            depth.increment()?;
4643            let envelope_size = 8;
4644            let bytes_len = len * envelope_size;
4645            let offset = decoder.out_of_line_offset(bytes_len)?;
4646            // Decode the envelope for each type.
4647            let mut _next_ordinal_to_read = 0;
4648            let mut next_offset = offset;
4649            let end_offset = offset + bytes_len;
4650            _next_ordinal_to_read += 1;
4651            if next_offset >= end_offset {
4652                return Ok(());
4653            }
4654
4655            // Decode unknown envelopes for gaps in ordinals.
4656            while _next_ordinal_to_read < 1 {
4657                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4658                _next_ordinal_to_read += 1;
4659                next_offset += envelope_size;
4660            }
4661
4662            let next_out_of_line = decoder.next_out_of_line();
4663            let handles_before = decoder.remaining_handles();
4664            if let Some((inlined, num_bytes, num_handles)) =
4665                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4666            {
4667                let member_inline_size =
4668                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
4669                        decoder.context,
4670                    );
4671                if inlined != (member_inline_size <= 4) {
4672                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4673                }
4674                let inner_offset;
4675                let mut inner_depth = depth.clone();
4676                if inlined {
4677                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4678                    inner_offset = next_offset;
4679                } else {
4680                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4681                    inner_depth.increment()?;
4682                }
4683                let val_ref = self.name.get_or_insert_with(|| {
4684                    fidl::new_empty!(
4685                        fidl::encoding::BoundedString<128>,
4686                        fidl::encoding::DefaultFuchsiaResourceDialect
4687                    )
4688                });
4689                fidl::decode!(
4690                    fidl::encoding::BoundedString<128>,
4691                    fidl::encoding::DefaultFuchsiaResourceDialect,
4692                    val_ref,
4693                    decoder,
4694                    inner_offset,
4695                    inner_depth
4696                )?;
4697                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4698                {
4699                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4700                }
4701                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4702                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4703                }
4704            }
4705
4706            next_offset += envelope_size;
4707            _next_ordinal_to_read += 1;
4708            if next_offset >= end_offset {
4709                return Ok(());
4710            }
4711
4712            // Decode unknown envelopes for gaps in ordinals.
4713            while _next_ordinal_to_read < 3 {
4714                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4715                _next_ordinal_to_read += 1;
4716                next_offset += envelope_size;
4717            }
4718
4719            let next_out_of_line = decoder.next_out_of_line();
4720            let handles_before = decoder.remaining_handles();
4721            if let Some((inlined, num_bytes, num_handles)) =
4722                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4723            {
4724                let member_inline_size = <fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4725                if inlined != (member_inline_size <= 4) {
4726                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4727                }
4728                let inner_offset;
4729                let mut inner_depth = depth.clone();
4730                if inlined {
4731                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4732                    inner_offset = next_offset;
4733                } else {
4734                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4735                    inner_depth.increment()?;
4736                }
4737                let val_ref =
4738                self.symbols.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
4739                fidl::decode!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4740                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4741                {
4742                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4743                }
4744                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4745                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4746                }
4747            }
4748
4749            next_offset += envelope_size;
4750            _next_ordinal_to_read += 1;
4751            if next_offset >= end_offset {
4752                return Ok(());
4753            }
4754
4755            // Decode unknown envelopes for gaps in ordinals.
4756            while _next_ordinal_to_read < 4 {
4757                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4758                _next_ordinal_to_read += 1;
4759                next_offset += envelope_size;
4760            }
4761
4762            let next_out_of_line = decoder.next_out_of_line();
4763            let handles_before = decoder.remaining_handles();
4764            if let Some((inlined, num_bytes, num_handles)) =
4765                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4766            {
4767                let member_inline_size = <fidl::encoding::Vector<NodeProperty, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4768                if inlined != (member_inline_size <= 4) {
4769                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4770                }
4771                let inner_offset;
4772                let mut inner_depth = depth.clone();
4773                if inlined {
4774                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4775                    inner_offset = next_offset;
4776                } else {
4777                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4778                    inner_depth.increment()?;
4779                }
4780                let val_ref =
4781                self.properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
4782                fidl::decode!(fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4783                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4784                {
4785                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4786                }
4787                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4788                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4789                }
4790            }
4791
4792            next_offset += envelope_size;
4793            _next_ordinal_to_read += 1;
4794            if next_offset >= end_offset {
4795                return Ok(());
4796            }
4797
4798            // Decode unknown envelopes for gaps in ordinals.
4799            while _next_ordinal_to_read < 5 {
4800                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4801                _next_ordinal_to_read += 1;
4802                next_offset += envelope_size;
4803            }
4804
4805            let next_out_of_line = decoder.next_out_of_line();
4806            let handles_before = decoder.remaining_handles();
4807            if let Some((inlined, num_bytes, num_handles)) =
4808                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4809            {
4810                let member_inline_size =
4811                    <DevfsAddArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4812                if inlined != (member_inline_size <= 4) {
4813                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4814                }
4815                let inner_offset;
4816                let mut inner_depth = depth.clone();
4817                if inlined {
4818                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4819                    inner_offset = next_offset;
4820                } else {
4821                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4822                    inner_depth.increment()?;
4823                }
4824                let val_ref = self.devfs_args.get_or_insert_with(|| {
4825                    fidl::new_empty!(DevfsAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect)
4826                });
4827                fidl::decode!(
4828                    DevfsAddArgs,
4829                    fidl::encoding::DefaultFuchsiaResourceDialect,
4830                    val_ref,
4831                    decoder,
4832                    inner_offset,
4833                    inner_depth
4834                )?;
4835                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4836                {
4837                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4838                }
4839                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4840                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4841                }
4842            }
4843
4844            next_offset += envelope_size;
4845            _next_ordinal_to_read += 1;
4846            if next_offset >= end_offset {
4847                return Ok(());
4848            }
4849
4850            // Decode unknown envelopes for gaps in ordinals.
4851            while _next_ordinal_to_read < 6 {
4852                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4853                _next_ordinal_to_read += 1;
4854                next_offset += envelope_size;
4855            }
4856
4857            let next_out_of_line = decoder.next_out_of_line();
4858            let handles_before = decoder.remaining_handles();
4859            if let Some((inlined, num_bytes, num_handles)) =
4860                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4861            {
4862                let member_inline_size =
4863                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::TypeMarker>::inline_size(
4864                        decoder.context,
4865                    );
4866                if inlined != (member_inline_size <= 4) {
4867                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4868                }
4869                let inner_offset;
4870                let mut inner_depth = depth.clone();
4871                if inlined {
4872                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4873                    inner_offset = next_offset;
4874                } else {
4875                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4876                    inner_depth.increment()?;
4877                }
4878                let val_ref =
4879                self.offers2.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect));
4880                fidl::decode!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4881                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4882                {
4883                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4884                }
4885                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4886                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4887                }
4888            }
4889
4890            next_offset += envelope_size;
4891            _next_ordinal_to_read += 1;
4892            if next_offset >= end_offset {
4893                return Ok(());
4894            }
4895
4896            // Decode unknown envelopes for gaps in ordinals.
4897            while _next_ordinal_to_read < 7 {
4898                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4899                _next_ordinal_to_read += 1;
4900                next_offset += envelope_size;
4901            }
4902
4903            let next_out_of_line = decoder.next_out_of_line();
4904            let handles_before = decoder.remaining_handles();
4905            if let Some((inlined, num_bytes, num_handles)) =
4906                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4907            {
4908                let member_inline_size =
4909                    <BusInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4910                if inlined != (member_inline_size <= 4) {
4911                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4912                }
4913                let inner_offset;
4914                let mut inner_depth = depth.clone();
4915                if inlined {
4916                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4917                    inner_offset = next_offset;
4918                } else {
4919                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4920                    inner_depth.increment()?;
4921                }
4922                let val_ref = self.bus_info.get_or_insert_with(|| {
4923                    fidl::new_empty!(BusInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
4924                });
4925                fidl::decode!(
4926                    BusInfo,
4927                    fidl::encoding::DefaultFuchsiaResourceDialect,
4928                    val_ref,
4929                    decoder,
4930                    inner_offset,
4931                    inner_depth
4932                )?;
4933                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4934                {
4935                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4936                }
4937                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4938                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4939                }
4940            }
4941
4942            next_offset += envelope_size;
4943            _next_ordinal_to_read += 1;
4944            if next_offset >= end_offset {
4945                return Ok(());
4946            }
4947
4948            // Decode unknown envelopes for gaps in ordinals.
4949            while _next_ordinal_to_read < 8 {
4950                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4951                _next_ordinal_to_read += 1;
4952                next_offset += envelope_size;
4953            }
4954
4955            let next_out_of_line = decoder.next_out_of_line();
4956            let handles_before = decoder.remaining_handles();
4957            if let Some((inlined, num_bytes, num_handles)) =
4958                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4959            {
4960                let member_inline_size = <fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4961                if inlined != (member_inline_size <= 4) {
4962                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4963                }
4964                let inner_offset;
4965                let mut inner_depth = depth.clone();
4966                if inlined {
4967                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4968                    inner_offset = next_offset;
4969                } else {
4970                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4971                    inner_depth.increment()?;
4972                }
4973                let val_ref =
4974                self.properties2.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
4975                fidl::decode!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4976                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4977                {
4978                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4979                }
4980                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4981                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4982                }
4983            }
4984
4985            next_offset += envelope_size;
4986            _next_ordinal_to_read += 1;
4987            if next_offset >= end_offset {
4988                return Ok(());
4989            }
4990
4991            // Decode unknown envelopes for gaps in ordinals.
4992            while _next_ordinal_to_read < 9 {
4993                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4994                _next_ordinal_to_read += 1;
4995                next_offset += envelope_size;
4996            }
4997
4998            let next_out_of_line = decoder.next_out_of_line();
4999            let handles_before = decoder.remaining_handles();
5000            if let Some((inlined, num_bytes, num_handles)) =
5001                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5002            {
5003                let member_inline_size = <fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5004                if inlined != (member_inline_size <= 4) {
5005                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5006                }
5007                let inner_offset;
5008                let mut inner_depth = depth.clone();
5009                if inlined {
5010                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5011                    inner_offset = next_offset;
5012                } else {
5013                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5014                    inner_depth.increment()?;
5015                }
5016                let val_ref = self.offers_dictionary.get_or_insert_with(|| {
5017                    fidl::new_empty!(
5018                        fidl_fuchsia_component_sandbox::DictionaryRef,
5019                        fidl::encoding::DefaultFuchsiaResourceDialect
5020                    )
5021                });
5022                fidl::decode!(
5023                    fidl_fuchsia_component_sandbox::DictionaryRef,
5024                    fidl::encoding::DefaultFuchsiaResourceDialect,
5025                    val_ref,
5026                    decoder,
5027                    inner_offset,
5028                    inner_depth
5029                )?;
5030                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5031                {
5032                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5033                }
5034                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5035                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5036                }
5037            }
5038
5039            next_offset += envelope_size;
5040
5041            // Decode the remaining unknown envelopes.
5042            while next_offset < end_offset {
5043                _next_ordinal_to_read += 1;
5044                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5045                next_offset += envelope_size;
5046            }
5047
5048            Ok(())
5049        }
5050    }
5051
5052    impl NodeControllerOnBindRequest {
5053        #[inline(always)]
5054        fn max_ordinal_present(&self) -> u64 {
5055            if let Some(_) = self.node_token {
5056                return 1;
5057            }
5058            0
5059        }
5060    }
5061
5062    impl fidl::encoding::ResourceTypeMarker for NodeControllerOnBindRequest {
5063        type Borrowed<'a> = &'a mut Self;
5064        fn take_or_borrow<'a>(
5065            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5066        ) -> Self::Borrowed<'a> {
5067            value
5068        }
5069    }
5070
5071    unsafe impl fidl::encoding::TypeMarker for NodeControllerOnBindRequest {
5072        type Owned = Self;
5073
5074        #[inline(always)]
5075        fn inline_align(_context: fidl::encoding::Context) -> usize {
5076            8
5077        }
5078
5079        #[inline(always)]
5080        fn inline_size(_context: fidl::encoding::Context) -> usize {
5081            16
5082        }
5083    }
5084
5085    unsafe impl
5086        fidl::encoding::Encode<
5087            NodeControllerOnBindRequest,
5088            fidl::encoding::DefaultFuchsiaResourceDialect,
5089        > for &mut NodeControllerOnBindRequest
5090    {
5091        unsafe fn encode(
5092            self,
5093            encoder: &mut fidl::encoding::Encoder<
5094                '_,
5095                fidl::encoding::DefaultFuchsiaResourceDialect,
5096            >,
5097            offset: usize,
5098            mut depth: fidl::encoding::Depth,
5099        ) -> fidl::Result<()> {
5100            encoder.debug_check_bounds::<NodeControllerOnBindRequest>(offset);
5101            // Vector header
5102            let max_ordinal: u64 = self.max_ordinal_present();
5103            encoder.write_num(max_ordinal, offset);
5104            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5105            // Calling encoder.out_of_line_offset(0) is not allowed.
5106            if max_ordinal == 0 {
5107                return Ok(());
5108            }
5109            depth.increment()?;
5110            let envelope_size = 8;
5111            let bytes_len = max_ordinal as usize * envelope_size;
5112            #[allow(unused_variables)]
5113            let offset = encoder.out_of_line_offset(bytes_len);
5114            let mut _prev_end_offset: usize = 0;
5115            if 1 > max_ordinal {
5116                return Ok(());
5117            }
5118
5119            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5120            // are envelope_size bytes.
5121            let cur_offset: usize = (1 - 1) * envelope_size;
5122
5123            // Zero reserved fields.
5124            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5125
5126            // Safety:
5127            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5128            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5129            //   envelope_size bytes, there is always sufficient room.
5130            fidl::encoding::encode_in_envelope_optional::<
5131                fidl::encoding::HandleType<
5132                    fidl::Event,
5133                    { fidl::ObjectType::EVENT.into_raw() },
5134                    2147483648,
5135                >,
5136                fidl::encoding::DefaultFuchsiaResourceDialect,
5137            >(
5138                self.node_token.as_mut().map(
5139                    <fidl::encoding::HandleType<
5140                        fidl::Event,
5141                        { fidl::ObjectType::EVENT.into_raw() },
5142                        2147483648,
5143                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5144                ),
5145                encoder,
5146                offset + cur_offset,
5147                depth,
5148            )?;
5149
5150            _prev_end_offset = cur_offset + envelope_size;
5151
5152            Ok(())
5153        }
5154    }
5155
5156    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5157        for NodeControllerOnBindRequest
5158    {
5159        #[inline(always)]
5160        fn new_empty() -> Self {
5161            Self::default()
5162        }
5163
5164        unsafe fn decode(
5165            &mut self,
5166            decoder: &mut fidl::encoding::Decoder<
5167                '_,
5168                fidl::encoding::DefaultFuchsiaResourceDialect,
5169            >,
5170            offset: usize,
5171            mut depth: fidl::encoding::Depth,
5172        ) -> fidl::Result<()> {
5173            decoder.debug_check_bounds::<Self>(offset);
5174            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5175                None => return Err(fidl::Error::NotNullable),
5176                Some(len) => len,
5177            };
5178            // Calling decoder.out_of_line_offset(0) is not allowed.
5179            if len == 0 {
5180                return Ok(());
5181            };
5182            depth.increment()?;
5183            let envelope_size = 8;
5184            let bytes_len = len * envelope_size;
5185            let offset = decoder.out_of_line_offset(bytes_len)?;
5186            // Decode the envelope for each type.
5187            let mut _next_ordinal_to_read = 0;
5188            let mut next_offset = offset;
5189            let end_offset = offset + bytes_len;
5190            _next_ordinal_to_read += 1;
5191            if next_offset >= end_offset {
5192                return Ok(());
5193            }
5194
5195            // Decode unknown envelopes for gaps in ordinals.
5196            while _next_ordinal_to_read < 1 {
5197                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5198                _next_ordinal_to_read += 1;
5199                next_offset += envelope_size;
5200            }
5201
5202            let next_out_of_line = decoder.next_out_of_line();
5203            let handles_before = decoder.remaining_handles();
5204            if let Some((inlined, num_bytes, num_handles)) =
5205                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5206            {
5207                let member_inline_size = <fidl::encoding::HandleType<
5208                    fidl::Event,
5209                    { fidl::ObjectType::EVENT.into_raw() },
5210                    2147483648,
5211                > as fidl::encoding::TypeMarker>::inline_size(
5212                    decoder.context
5213                );
5214                if inlined != (member_inline_size <= 4) {
5215                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5216                }
5217                let inner_offset;
5218                let mut inner_depth = depth.clone();
5219                if inlined {
5220                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5221                    inner_offset = next_offset;
5222                } else {
5223                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5224                    inner_depth.increment()?;
5225                }
5226                let val_ref =
5227                self.node_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5228                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5229                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5230                {
5231                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5232                }
5233                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5234                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5235                }
5236            }
5237
5238            next_offset += envelope_size;
5239
5240            // Decode the remaining unknown envelopes.
5241            while next_offset < end_offset {
5242                _next_ordinal_to_read += 1;
5243                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5244                next_offset += envelope_size;
5245            }
5246
5247            Ok(())
5248        }
5249    }
5250
5251    impl fidl::encoding::ResourceTypeMarker for DriverResult {
5252        type Borrowed<'a> = &'a mut Self;
5253        fn take_or_borrow<'a>(
5254            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5255        ) -> Self::Borrowed<'a> {
5256            value
5257        }
5258    }
5259
5260    unsafe impl fidl::encoding::TypeMarker for DriverResult {
5261        type Owned = Self;
5262
5263        #[inline(always)]
5264        fn inline_align(_context: fidl::encoding::Context) -> usize {
5265            8
5266        }
5267
5268        #[inline(always)]
5269        fn inline_size(_context: fidl::encoding::Context) -> usize {
5270            16
5271        }
5272    }
5273
5274    unsafe impl fidl::encoding::Encode<DriverResult, fidl::encoding::DefaultFuchsiaResourceDialect>
5275        for &mut DriverResult
5276    {
5277        #[inline]
5278        unsafe fn encode(
5279            self,
5280            encoder: &mut fidl::encoding::Encoder<
5281                '_,
5282                fidl::encoding::DefaultFuchsiaResourceDialect,
5283            >,
5284            offset: usize,
5285            _depth: fidl::encoding::Depth,
5286        ) -> fidl::Result<()> {
5287            encoder.debug_check_bounds::<DriverResult>(offset);
5288            encoder.write_num::<u64>(self.ordinal(), offset);
5289            match self {
5290                DriverResult::DriverStartedNodeToken(ref mut val) => {
5291                    fidl::encoding::encode_in_envelope::<
5292                        fidl::encoding::HandleType<
5293                            fidl::Event,
5294                            { fidl::ObjectType::EVENT.into_raw() },
5295                            2147483648,
5296                        >,
5297                        fidl::encoding::DefaultFuchsiaResourceDialect,
5298                    >(
5299                        <fidl::encoding::HandleType<
5300                            fidl::Event,
5301                            { fidl::ObjectType::EVENT.into_raw() },
5302                            2147483648,
5303                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
5304                            val
5305                        ),
5306                        encoder,
5307                        offset + 8,
5308                        _depth,
5309                    )
5310                }
5311                DriverResult::MatchError(ref val) => fidl::encoding::encode_in_envelope::<
5312                    i32,
5313                    fidl::encoding::DefaultFuchsiaResourceDialect,
5314                >(
5315                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
5316                    encoder,
5317                    offset + 8,
5318                    _depth,
5319                ),
5320                DriverResult::StartError(ref val) => fidl::encoding::encode_in_envelope::<
5321                    i32,
5322                    fidl::encoding::DefaultFuchsiaResourceDialect,
5323                >(
5324                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
5325                    encoder,
5326                    offset + 8,
5327                    _depth,
5328                ),
5329                DriverResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
5330            }
5331        }
5332    }
5333
5334    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverResult {
5335        #[inline(always)]
5336        fn new_empty() -> Self {
5337            Self::__SourceBreaking { unknown_ordinal: 0 }
5338        }
5339
5340        #[inline]
5341        unsafe fn decode(
5342            &mut self,
5343            decoder: &mut fidl::encoding::Decoder<
5344                '_,
5345                fidl::encoding::DefaultFuchsiaResourceDialect,
5346            >,
5347            offset: usize,
5348            mut depth: fidl::encoding::Depth,
5349        ) -> fidl::Result<()> {
5350            decoder.debug_check_bounds::<Self>(offset);
5351            #[allow(unused_variables)]
5352            let next_out_of_line = decoder.next_out_of_line();
5353            let handles_before = decoder.remaining_handles();
5354            let (ordinal, inlined, num_bytes, num_handles) =
5355                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
5356
5357            let member_inline_size = match ordinal {
5358                1 => <fidl::encoding::HandleType<
5359                    fidl::Event,
5360                    { fidl::ObjectType::EVENT.into_raw() },
5361                    2147483648,
5362                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5363                2 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5364                3 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5365                0 => return Err(fidl::Error::UnknownUnionTag),
5366                _ => num_bytes as usize,
5367            };
5368
5369            if inlined != (member_inline_size <= 4) {
5370                return Err(fidl::Error::InvalidInlineBitInEnvelope);
5371            }
5372            let _inner_offset;
5373            if inlined {
5374                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
5375                _inner_offset = offset + 8;
5376            } else {
5377                depth.increment()?;
5378                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5379            }
5380            match ordinal {
5381                1 => {
5382                    #[allow(irrefutable_let_patterns)]
5383                    if let DriverResult::DriverStartedNodeToken(_) = self {
5384                        // Do nothing, read the value into the object
5385                    } else {
5386                        // Initialize `self` to the right variant
5387                        *self = DriverResult::DriverStartedNodeToken(
5388                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
5389                        );
5390                    }
5391                    #[allow(irrefutable_let_patterns)]
5392                    if let DriverResult::DriverStartedNodeToken(ref mut val) = self {
5393                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
5394                    } else {
5395                        unreachable!()
5396                    }
5397                }
5398                2 => {
5399                    #[allow(irrefutable_let_patterns)]
5400                    if let DriverResult::MatchError(_) = self {
5401                        // Do nothing, read the value into the object
5402                    } else {
5403                        // Initialize `self` to the right variant
5404                        *self = DriverResult::MatchError(fidl::new_empty!(
5405                            i32,
5406                            fidl::encoding::DefaultFuchsiaResourceDialect
5407                        ));
5408                    }
5409                    #[allow(irrefutable_let_patterns)]
5410                    if let DriverResult::MatchError(ref mut val) = self {
5411                        fidl::decode!(
5412                            i32,
5413                            fidl::encoding::DefaultFuchsiaResourceDialect,
5414                            val,
5415                            decoder,
5416                            _inner_offset,
5417                            depth
5418                        )?;
5419                    } else {
5420                        unreachable!()
5421                    }
5422                }
5423                3 => {
5424                    #[allow(irrefutable_let_patterns)]
5425                    if let DriverResult::StartError(_) = self {
5426                        // Do nothing, read the value into the object
5427                    } else {
5428                        // Initialize `self` to the right variant
5429                        *self = DriverResult::StartError(fidl::new_empty!(
5430                            i32,
5431                            fidl::encoding::DefaultFuchsiaResourceDialect
5432                        ));
5433                    }
5434                    #[allow(irrefutable_let_patterns)]
5435                    if let DriverResult::StartError(ref mut val) = self {
5436                        fidl::decode!(
5437                            i32,
5438                            fidl::encoding::DefaultFuchsiaResourceDialect,
5439                            val,
5440                            decoder,
5441                            _inner_offset,
5442                            depth
5443                        )?;
5444                    } else {
5445                        unreachable!()
5446                    }
5447                }
5448                #[allow(deprecated)]
5449                ordinal => {
5450                    for _ in 0..num_handles {
5451                        decoder.drop_next_handle()?;
5452                    }
5453                    *self = DriverResult::__SourceBreaking { unknown_ordinal: ordinal };
5454                }
5455            }
5456            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
5457                return Err(fidl::Error::InvalidNumBytesInEnvelope);
5458            }
5459            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5460                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5461            }
5462            Ok(())
5463        }
5464    }
5465}