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