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