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