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