Skip to main content

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, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DriverResumeRequest {
16    pub power_element_lease: Option<fidl::EventPair>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverResumeRequest {}
20
21#[derive(Debug, PartialEq)]
22pub struct DriverStartRequest {
23    pub start_args: DriverStartArgs,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverStartRequest {}
27
28#[derive(Debug, PartialEq)]
29pub struct NodeAddChildRequest {
30    pub args: NodeAddArgs,
31    pub controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
32    pub node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddChildRequest {}
36
37#[derive(Debug, PartialEq)]
38pub struct NodeManagerAddNodeRequest {
39    pub node: Node2,
40    pub controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
41    pub node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeManagerAddNodeRequest {}
45
46#[derive(Debug, PartialEq)]
47pub struct NodeProvideResourceRequest {
48    pub resource: ResourceArgs,
49    pub controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for NodeProvideResourceRequest
54{
55}
56
57#[derive(Debug, Default, PartialEq)]
58pub struct DevfsAddArgs {
59    /// This is the connector to be installed in devfs.
60    /// `Connect()` will be called when a client connects to this node in the filesystem.
61    /// Optional: If this is not provided then an empty node will appear in devfs.
62    pub connector: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>>,
63    /// This is the class name for installing this node in devfs.
64    /// The node will be placed within /dev/class/{class_name}.
65    /// If `class_name` does not exist under /dev/class/ it will be created.
66    /// Optional: If this is not provided then the node will only be added via topological path.
67    pub class_name: Option<String>,
68    /// This is a vmo of inspect data that will be installed in devfs.
69    /// Optional: If this is not provided then the devfs's inspect data will be empty.
70    pub inspect: Option<fidl::Vmo>,
71    /// The connection types that are supported by the |connector| given.
72    /// The driver framework should handle connection types that are not supported by the
73    /// connector.
74    /// If not provided, only the device type is assumed as supported by the connector.
75    pub connector_supports: Option<fidl_fuchsia_device_fs::ConnectionType>,
76    /// This is the controller connector to be installed in devfs.
77    /// `Connect()` will be called when a client connects to the device_controller connection
78    /// for this node in the filesystem.
79    /// Optional: If this is not provided then the Node will handle the connection natively.
80    /// This option should only be used by the compat shim or in tests
81    pub controller_connector:
82        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>>,
83    #[doc(hidden)]
84    pub __source_breaking: fidl::marker::SourceBreaking,
85}
86
87impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevfsAddArgs {}
88
89/// Arguments for starting a driver.
90#[derive(Debug, Default, PartialEq)]
91pub struct DriverStartArgs {
92    /// Node that the driver is bound to.
93    pub node: Option<fidl::endpoints::ClientEnd<NodeMarker>>,
94    /// Symbols provided to the driver, for |node|. These come from the driver
95    /// that added |node|, and are filtered to the symbols requested in the bind
96    /// program.
97    pub symbols: Option<Vec<NodeSymbol>>,
98    /// URL of the package containing the driver. This is purely informational,
99    /// used only to provide data for inspect.
100    pub url: Option<String>,
101    /// Information about the driver to start. Currently, we support the
102    /// following entries:
103    ///   1. "binary": a string containing the package-relative path to the
104    ///      driver binary.
105    ///   2. "colocate" (optional): a string containing "true" or "false"
106    ///      specifying whether the driver should be colocated in the same
107    ///      driver host as the driver that added |node|. If not specified, the
108    ///      driver will be launched in a new driver host.
109    ///   3. "default_dispatcher_opts" (optional): an array of strings specifying
110    ///      the options for creating the default dispatcher. A string can be one
111    ///      of the following:
112    ///      * `allow_sync_calls`: allows synchronous calls to be done on the
113    ///      default dispatcher's thread.
114    ///   4. "default_dispatcher_scheduler_role" (optional): the scheduler role to
115    ///      set for the default dispatcher created for the driver.
116    pub program: Option<fidl_fuchsia_data::Dictionary>,
117    /// Incoming namespace provided to the driver.
118    pub incoming: Option<Vec<fidl_fuchsia_component_runner::ComponentNamespaceEntry>>,
119    /// Outgoing directory served by the driver.
120    pub outgoing_dir: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
121    /// Configuration passed to the driver.
122    pub config: Option<fidl::Vmo>,
123    /// The name of the node the driver is bound to.
124    pub node_name: Option<String>,
125    /// Node properties of the node the driver is bound to.
126    /// If the node is non-composite then the "default" entry will contain the
127    /// node's own properties.
128    /// If the node is a composite then there is an entry for each of its parents
129    /// and the "default" entry will reference the primary composite parent
130    /// node's properties. The composite parent node's properties are those that
131    /// were provided in the composite node specification and not the original
132    /// properties of the parent.
133    pub node_properties: Option<Vec<NodePropertyEntry>>,
134    /// Node offers of the node the driver is bound to.
135    pub node_offers: Option<Vec<Offer>>,
136    /// Provides a token representing this node which can be exchanged with the
137    /// driver framework to discern additional information about this node.
138    pub node_token: Option<fidl::Event>,
139    pub node_properties_2: Option<Vec<NodePropertyEntry2>>,
140    /// Root VMAR the driver is mapped into. All child mappings should be placed into this VMAR
141    /// if they want to have the same scheduler profile applied to them.
142    pub vmar: Option<fidl::Vmar>,
143    /// Handles related to the driver's power elements on products where suspend is enabled by the
144    /// `fuchsia.power.SuspendEnabled` config capability.
145    /// If the driver's manifest contains `suspend_enabled = "true"` in the program section of its
146    /// manifest, the `element_server`, `lessor_client`, and `token` are passed to the driver,
147    /// otherwise the handles are retained by the driver host. `control_client` is always retained
148    /// by the driver host and never passed to the driver.
149    pub power_element_args: Option<PowerElementArgs>,
150    /// Log sink channel.
151    pub log_sink: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>>,
152    #[doc(hidden)]
153    pub __source_breaking: fidl::marker::SourceBreaking,
154}
155
156impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverStartArgs {}
157
158/// Arguments for adding a node.
159#[derive(Debug, Default, PartialEq)]
160pub struct NodeAddArgs {
161    /// Name of the node.
162    pub name: Option<String>,
163    /// Functions to provide to the driver that is bound to this node.
164    pub symbols: Option<Vec<NodeSymbol>>,
165    /// Properties of the node. Deprecated: all new usages should set properties2 and leave
166    /// this field blank.
167    pub properties: Option<Vec<NodeProperty>>,
168    /// The arguments for how this node should be added to devfs.
169    pub devfs_args: Option<DevfsAddArgs>,
170    /// Capabilities to offer to the driver that is bound to this node.
171    /// The driver must ensure these capabilities are added to its outgoing directory or in the
172    /// |offers_dictionary| (if any of these are |dictionary_offer| type)
173    /// before adding the child node.
174    pub offers2: Option<Vec<Offer>>,
175    /// Information that feeds into a structured bus topology for the device. It should
176    /// only be specified by bus drivers, ideally those which are included by default.
177    pub bus_info: Option<BusInfo>,
178    /// Properties of the node. If set, the `properties` field must be blank. Otherwise,
179    /// adding the node will return an error.
180    pub properties2: Option<Vec<NodeProperty2>>,
181    /// This can be used to provide additional offers, through a dictionary, to the driver that is
182    /// bound to this node. The user MUST use the |offers2| field to specify |dictionary_offer|
183    /// type offers for offers that exist in this dictionary.
184    pub offers_dictionary: Option<fidl_fuchsia_component_sandbox::DictionaryRef>,
185    /// An identifier for the driver host which a driver that binds to this node should live in.
186    /// All drivers which specify the same identifier will be colocated into the same driver host.
187    /// If the driver host hasn't been started, it will be started upon the time the node is bound
188    /// to. Only respected if the driver binds directly to this node. If a composite binds to this
189    /// node, then this field will be ignored as it should be expressed in the composite node spec
190    /// instead.
191    pub driver_host: Option<String>,
192    #[doc(hidden)]
193    pub __source_breaking: fidl::marker::SourceBreaking,
194}
195
196impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddArgs {}
197
198#[derive(Debug, Default, PartialEq)]
199pub struct NodeControllerOnBindRequest {
200    /// Provides a token representing this node which can be exchanged with the
201    /// driver framework to discern additional information about this node.
202    pub node_token: Option<fidl::Event>,
203    #[doc(hidden)]
204    pub __source_breaking: fidl::marker::SourceBreaking,
205}
206
207impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
208    for NodeControllerOnBindRequest
209{
210}
211
212#[derive(Debug, Default, PartialEq)]
213pub struct PowerElementArgs {
214    pub control_client:
215        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::ElementControlMarker>>,
216    pub runner_server:
217        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::ElementRunnerMarker>>,
218    pub lessor_client: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>>,
219    pub token: Option<fidl::Event>,
220    #[doc(hidden)]
221    pub __source_breaking: fidl::marker::SourceBreaking,
222}
223
224impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElementArgs {}
225
226/// Arguments for providing a resource.
227#[derive(Debug, Default, PartialEq)]
228pub struct ResourceArgs {
229    /// Name of the resource. Required.
230    pub name: Option<String>,
231    /// Properties of the resource. Required.
232    pub properties: Option<Vec<NodeProperty2>>,
233    /// Capabilities the resource offers to the node that depends on it. Required.
234    pub offers: Option<Vec<Offer>>,
235    /// Information that feeds into a structured bus topology for the device. It should
236    /// only be specified by bus drivers, ideally those which are included by default. Optional.
237    pub bus_info: Option<BusInfo>,
238    #[doc(hidden)]
239    pub __source_breaking: fidl::marker::SourceBreaking,
240}
241
242impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ResourceArgs {}
243
244#[derive(Debug)]
245pub enum DriverResult {
246    /// The token that belongs to the node that a driver has started successfully on.
247    DriverStartedNodeToken(fidl::Event),
248    /// The node failed to find a matching driver or composite spec.
249    MatchError(i32),
250    /// The driver that bound to the node failed to start successfully.
251    StartError(i32),
252    #[doc(hidden)]
253    __SourceBreaking { unknown_ordinal: u64 },
254}
255
256/// Pattern that matches an unknown `DriverResult` member.
257#[macro_export]
258macro_rules! DriverResultUnknown {
259    () => {
260        _
261    };
262}
263
264// Custom PartialEq so that unknown variants are not equal to themselves.
265impl PartialEq for DriverResult {
266    fn eq(&self, other: &Self) -> bool {
267        match (self, other) {
268            (Self::DriverStartedNodeToken(x), Self::DriverStartedNodeToken(y)) => *x == *y,
269            (Self::MatchError(x), Self::MatchError(y)) => *x == *y,
270            (Self::StartError(x), Self::StartError(y)) => *x == *y,
271            _ => false,
272        }
273    }
274}
275
276impl DriverResult {
277    #[inline]
278    pub fn ordinal(&self) -> u64 {
279        match *self {
280            Self::DriverStartedNodeToken(_) => 1,
281            Self::MatchError(_) => 2,
282            Self::StartError(_) => 3,
283            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
284        }
285    }
286
287    #[inline]
288    pub fn unknown_variant_for_testing() -> Self {
289        Self::__SourceBreaking { unknown_ordinal: 0 }
290    }
291
292    #[inline]
293    pub fn is_unknown(&self) -> bool {
294        match self {
295            Self::__SourceBreaking { .. } => true,
296            _ => false,
297        }
298    }
299}
300
301impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverResult {}
302
303#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
304pub struct CompositeNodeManagerMarker;
305
306impl fidl::endpoints::ProtocolMarker for CompositeNodeManagerMarker {
307    type Proxy = CompositeNodeManagerProxy;
308    type RequestStream = CompositeNodeManagerRequestStream;
309    #[cfg(target_os = "fuchsia")]
310    type SynchronousProxy = CompositeNodeManagerSynchronousProxy;
311
312    const DEBUG_NAME: &'static str = "fuchsia.driver.framework.CompositeNodeManager";
313}
314impl fidl::endpoints::DiscoverableProtocolMarker for CompositeNodeManagerMarker {}
315pub type CompositeNodeManagerAddSpecResult = Result<(), CompositeNodeSpecError>;
316
317pub trait CompositeNodeManagerProxyInterface: Send + Sync {
318    type AddSpecResponseFut: std::future::Future<Output = Result<CompositeNodeManagerAddSpecResult, fidl::Error>>
319        + Send;
320    fn r#add_spec(&self, payload: &CompositeNodeSpec) -> Self::AddSpecResponseFut;
321}
322#[derive(Debug)]
323#[cfg(target_os = "fuchsia")]
324pub struct CompositeNodeManagerSynchronousProxy {
325    client: fidl::client::sync::Client,
326}
327
328#[cfg(target_os = "fuchsia")]
329impl fidl::endpoints::SynchronousProxy for CompositeNodeManagerSynchronousProxy {
330    type Proxy = CompositeNodeManagerProxy;
331    type Protocol = CompositeNodeManagerMarker;
332
333    fn from_channel(inner: fidl::Channel) -> Self {
334        Self::new(inner)
335    }
336
337    fn into_channel(self) -> fidl::Channel {
338        self.client.into_channel()
339    }
340
341    fn as_channel(&self) -> &fidl::Channel {
342        self.client.as_channel()
343    }
344}
345
346#[cfg(target_os = "fuchsia")]
347impl CompositeNodeManagerSynchronousProxy {
348    pub fn new(channel: fidl::Channel) -> Self {
349        Self { client: fidl::client::sync::Client::new(channel) }
350    }
351
352    pub fn into_channel(self) -> fidl::Channel {
353        self.client.into_channel()
354    }
355
356    /// Waits until an event arrives and returns it. It is safe for other
357    /// threads to make concurrent requests while waiting for an event.
358    pub fn wait_for_event(
359        &self,
360        deadline: zx::MonotonicInstant,
361    ) -> Result<CompositeNodeManagerEvent, fidl::Error> {
362        CompositeNodeManagerEvent::decode(
363            self.client.wait_for_event::<CompositeNodeManagerMarker>(deadline)?,
364        )
365    }
366
367    /// Adds the given composite node specification to the driver framework.
368    pub fn r#add_spec(
369        &self,
370        mut payload: &CompositeNodeSpec,
371        ___deadline: zx::MonotonicInstant,
372    ) -> Result<CompositeNodeManagerAddSpecResult, fidl::Error> {
373        let _response =
374            self.client
375                .send_query::<CompositeNodeSpec, fidl::encoding::FlexibleResultType<
376                    fidl::encoding::EmptyStruct,
377                    CompositeNodeSpecError,
378                >, CompositeNodeManagerMarker>(
379                    payload,
380                    0x524e353c8130cc74,
381                    fidl::encoding::DynamicFlags::FLEXIBLE,
382                    ___deadline,
383                )?
384                .into_result::<CompositeNodeManagerMarker>("add_spec")?;
385        Ok(_response.map(|x| x))
386    }
387}
388
389#[cfg(target_os = "fuchsia")]
390impl From<CompositeNodeManagerSynchronousProxy> for zx::NullableHandle {
391    fn from(value: CompositeNodeManagerSynchronousProxy) -> Self {
392        value.into_channel().into()
393    }
394}
395
396#[cfg(target_os = "fuchsia")]
397impl From<fidl::Channel> for CompositeNodeManagerSynchronousProxy {
398    fn from(value: fidl::Channel) -> Self {
399        Self::new(value)
400    }
401}
402
403#[cfg(target_os = "fuchsia")]
404impl fidl::endpoints::FromClient for CompositeNodeManagerSynchronousProxy {
405    type Protocol = CompositeNodeManagerMarker;
406
407    fn from_client(value: fidl::endpoints::ClientEnd<CompositeNodeManagerMarker>) -> Self {
408        Self::new(value.into_channel())
409    }
410}
411
412#[derive(Debug, Clone)]
413pub struct CompositeNodeManagerProxy {
414    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
415}
416
417impl fidl::endpoints::Proxy for CompositeNodeManagerProxy {
418    type Protocol = CompositeNodeManagerMarker;
419
420    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
421        Self::new(inner)
422    }
423
424    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
425        self.client.into_channel().map_err(|client| Self { client })
426    }
427
428    fn as_channel(&self) -> &::fidl::AsyncChannel {
429        self.client.as_channel()
430    }
431}
432
433impl CompositeNodeManagerProxy {
434    /// Create a new Proxy for fuchsia.driver.framework/CompositeNodeManager.
435    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
436        let protocol_name =
437            <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
438        Self { client: fidl::client::Client::new(channel, protocol_name) }
439    }
440
441    /// Get a Stream of events from the remote end of the protocol.
442    ///
443    /// # Panics
444    ///
445    /// Panics if the event stream was already taken.
446    pub fn take_event_stream(&self) -> CompositeNodeManagerEventStream {
447        CompositeNodeManagerEventStream { event_receiver: self.client.take_event_receiver() }
448    }
449
450    /// Adds the given composite node specification to the driver framework.
451    pub fn r#add_spec(
452        &self,
453        mut payload: &CompositeNodeSpec,
454    ) -> fidl::client::QueryResponseFut<
455        CompositeNodeManagerAddSpecResult,
456        fidl::encoding::DefaultFuchsiaResourceDialect,
457    > {
458        CompositeNodeManagerProxyInterface::r#add_spec(self, payload)
459    }
460}
461
462impl CompositeNodeManagerProxyInterface for CompositeNodeManagerProxy {
463    type AddSpecResponseFut = fidl::client::QueryResponseFut<
464        CompositeNodeManagerAddSpecResult,
465        fidl::encoding::DefaultFuchsiaResourceDialect,
466    >;
467    fn r#add_spec(&self, mut payload: &CompositeNodeSpec) -> Self::AddSpecResponseFut {
468        fn _decode(
469            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
470        ) -> Result<CompositeNodeManagerAddSpecResult, fidl::Error> {
471            let _response = fidl::client::decode_transaction_body::<
472                fidl::encoding::FlexibleResultType<
473                    fidl::encoding::EmptyStruct,
474                    CompositeNodeSpecError,
475                >,
476                fidl::encoding::DefaultFuchsiaResourceDialect,
477                0x524e353c8130cc74,
478            >(_buf?)?
479            .into_result::<CompositeNodeManagerMarker>("add_spec")?;
480            Ok(_response.map(|x| x))
481        }
482        self.client.send_query_and_decode::<CompositeNodeSpec, CompositeNodeManagerAddSpecResult>(
483            payload,
484            0x524e353c8130cc74,
485            fidl::encoding::DynamicFlags::FLEXIBLE,
486            _decode,
487        )
488    }
489}
490
491pub struct CompositeNodeManagerEventStream {
492    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
493}
494
495impl std::marker::Unpin for CompositeNodeManagerEventStream {}
496
497impl futures::stream::FusedStream for CompositeNodeManagerEventStream {
498    fn is_terminated(&self) -> bool {
499        self.event_receiver.is_terminated()
500    }
501}
502
503impl futures::Stream for CompositeNodeManagerEventStream {
504    type Item = Result<CompositeNodeManagerEvent, fidl::Error>;
505
506    fn poll_next(
507        mut self: std::pin::Pin<&mut Self>,
508        cx: &mut std::task::Context<'_>,
509    ) -> std::task::Poll<Option<Self::Item>> {
510        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
511            &mut self.event_receiver,
512            cx
513        )?) {
514            Some(buf) => std::task::Poll::Ready(Some(CompositeNodeManagerEvent::decode(buf))),
515            None => std::task::Poll::Ready(None),
516        }
517    }
518}
519
520#[derive(Debug)]
521pub enum CompositeNodeManagerEvent {
522    #[non_exhaustive]
523    _UnknownEvent {
524        /// Ordinal of the event that was sent.
525        ordinal: u64,
526    },
527}
528
529impl CompositeNodeManagerEvent {
530    /// Decodes a message buffer as a [`CompositeNodeManagerEvent`].
531    fn decode(
532        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
533    ) -> Result<CompositeNodeManagerEvent, fidl::Error> {
534        let (bytes, _handles) = buf.split_mut();
535        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
536        debug_assert_eq!(tx_header.tx_id, 0);
537        match tx_header.ordinal {
538            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
539                Ok(CompositeNodeManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
540            }
541            _ => Err(fidl::Error::UnknownOrdinal {
542                ordinal: tx_header.ordinal,
543                protocol_name:
544                    <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
545            }),
546        }
547    }
548}
549
550/// A Stream of incoming requests for fuchsia.driver.framework/CompositeNodeManager.
551pub struct CompositeNodeManagerRequestStream {
552    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
553    is_terminated: bool,
554}
555
556impl std::marker::Unpin for CompositeNodeManagerRequestStream {}
557
558impl futures::stream::FusedStream for CompositeNodeManagerRequestStream {
559    fn is_terminated(&self) -> bool {
560        self.is_terminated
561    }
562}
563
564impl fidl::endpoints::RequestStream for CompositeNodeManagerRequestStream {
565    type Protocol = CompositeNodeManagerMarker;
566    type ControlHandle = CompositeNodeManagerControlHandle;
567
568    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
569        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
570    }
571
572    fn control_handle(&self) -> Self::ControlHandle {
573        CompositeNodeManagerControlHandle { inner: self.inner.clone() }
574    }
575
576    fn into_inner(
577        self,
578    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
579    {
580        (self.inner, self.is_terminated)
581    }
582
583    fn from_inner(
584        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
585        is_terminated: bool,
586    ) -> Self {
587        Self { inner, is_terminated }
588    }
589}
590
591impl futures::Stream for CompositeNodeManagerRequestStream {
592    type Item = Result<CompositeNodeManagerRequest, fidl::Error>;
593
594    fn poll_next(
595        mut self: std::pin::Pin<&mut Self>,
596        cx: &mut std::task::Context<'_>,
597    ) -> std::task::Poll<Option<Self::Item>> {
598        let this = &mut *self;
599        if this.inner.check_shutdown(cx) {
600            this.is_terminated = true;
601            return std::task::Poll::Ready(None);
602        }
603        if this.is_terminated {
604            panic!("polled CompositeNodeManagerRequestStream after completion");
605        }
606        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
607            |bytes, handles| {
608                match this.inner.channel().read_etc(cx, bytes, handles) {
609                    std::task::Poll::Ready(Ok(())) => {}
610                    std::task::Poll::Pending => return std::task::Poll::Pending,
611                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
612                        this.is_terminated = true;
613                        return std::task::Poll::Ready(None);
614                    }
615                    std::task::Poll::Ready(Err(e)) => {
616                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
617                            e.into(),
618                        ))));
619                    }
620                }
621
622                // A message has been received from the channel
623                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
624
625                std::task::Poll::Ready(Some(match header.ordinal {
626                0x524e353c8130cc74 => {
627                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
628                    let mut req = fidl::new_empty!(CompositeNodeSpec, fidl::encoding::DefaultFuchsiaResourceDialect);
629                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CompositeNodeSpec>(&header, _body_bytes, handles, &mut req)?;
630                    let control_handle = CompositeNodeManagerControlHandle {
631                        inner: this.inner.clone(),
632                    };
633                    Ok(CompositeNodeManagerRequest::AddSpec {payload: req,
634                        responder: CompositeNodeManagerAddSpecResponder {
635                            control_handle: std::mem::ManuallyDrop::new(control_handle),
636                            tx_id: header.tx_id,
637                        },
638                    })
639                }
640                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
641                    Ok(CompositeNodeManagerRequest::_UnknownMethod {
642                        ordinal: header.ordinal,
643                        control_handle: CompositeNodeManagerControlHandle { inner: this.inner.clone() },
644                        method_type: fidl::MethodType::OneWay,
645                    })
646                }
647                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
648                    this.inner.send_framework_err(
649                        fidl::encoding::FrameworkErr::UnknownMethod,
650                        header.tx_id,
651                        header.ordinal,
652                        header.dynamic_flags(),
653                        (bytes, handles),
654                    )?;
655                    Ok(CompositeNodeManagerRequest::_UnknownMethod {
656                        ordinal: header.ordinal,
657                        control_handle: CompositeNodeManagerControlHandle { inner: this.inner.clone() },
658                        method_type: fidl::MethodType::TwoWay,
659                    })
660                }
661                _ => Err(fidl::Error::UnknownOrdinal {
662                    ordinal: header.ordinal,
663                    protocol_name: <CompositeNodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
664                }),
665            }))
666            },
667        )
668    }
669}
670
671/// Protocol through which board drivers can create composite node specs.
672///
673/// Composite node specs are created at runtime to dynamically bridge the
674/// static bind rules of a composite driver with the dynamic bind properties
675/// of nodes in the system so that the driver bind rules are more generic and reusable.
676#[derive(Debug)]
677pub enum CompositeNodeManagerRequest {
678    /// Adds the given composite node specification to the driver framework.
679    AddSpec { payload: CompositeNodeSpec, responder: CompositeNodeManagerAddSpecResponder },
680    /// An interaction was received which does not match any known method.
681    #[non_exhaustive]
682    _UnknownMethod {
683        /// Ordinal of the method that was called.
684        ordinal: u64,
685        control_handle: CompositeNodeManagerControlHandle,
686        method_type: fidl::MethodType,
687    },
688}
689
690impl CompositeNodeManagerRequest {
691    #[allow(irrefutable_let_patterns)]
692    pub fn into_add_spec(
693        self,
694    ) -> Option<(CompositeNodeSpec, CompositeNodeManagerAddSpecResponder)> {
695        if let CompositeNodeManagerRequest::AddSpec { payload, responder } = self {
696            Some((payload, responder))
697        } else {
698            None
699        }
700    }
701
702    /// Name of the method defined in FIDL
703    pub fn method_name(&self) -> &'static str {
704        match *self {
705            CompositeNodeManagerRequest::AddSpec { .. } => "add_spec",
706            CompositeNodeManagerRequest::_UnknownMethod {
707                method_type: fidl::MethodType::OneWay,
708                ..
709            } => "unknown one-way method",
710            CompositeNodeManagerRequest::_UnknownMethod {
711                method_type: fidl::MethodType::TwoWay,
712                ..
713            } => "unknown two-way method",
714        }
715    }
716}
717
718#[derive(Debug, Clone)]
719pub struct CompositeNodeManagerControlHandle {
720    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
721}
722
723impl fidl::endpoints::ControlHandle for CompositeNodeManagerControlHandle {
724    fn shutdown(&self) {
725        self.inner.shutdown()
726    }
727
728    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
729        self.inner.shutdown_with_epitaph(status)
730    }
731
732    fn is_closed(&self) -> bool {
733        self.inner.channel().is_closed()
734    }
735    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
736        self.inner.channel().on_closed()
737    }
738
739    #[cfg(target_os = "fuchsia")]
740    fn signal_peer(
741        &self,
742        clear_mask: zx::Signals,
743        set_mask: zx::Signals,
744    ) -> Result<(), zx_status::Status> {
745        use fidl::Peered;
746        self.inner.channel().signal_peer(clear_mask, set_mask)
747    }
748}
749
750impl CompositeNodeManagerControlHandle {}
751
752#[must_use = "FIDL methods require a response to be sent"]
753#[derive(Debug)]
754pub struct CompositeNodeManagerAddSpecResponder {
755    control_handle: std::mem::ManuallyDrop<CompositeNodeManagerControlHandle>,
756    tx_id: u32,
757}
758
759/// Set the the channel to be shutdown (see [`CompositeNodeManagerControlHandle::shutdown`])
760/// if the responder is dropped without sending a response, so that the client
761/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
762impl std::ops::Drop for CompositeNodeManagerAddSpecResponder {
763    fn drop(&mut self) {
764        self.control_handle.shutdown();
765        // Safety: drops once, never accessed again
766        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
767    }
768}
769
770impl fidl::endpoints::Responder for CompositeNodeManagerAddSpecResponder {
771    type ControlHandle = CompositeNodeManagerControlHandle;
772
773    fn control_handle(&self) -> &CompositeNodeManagerControlHandle {
774        &self.control_handle
775    }
776
777    fn drop_without_shutdown(mut self) {
778        // Safety: drops once, never accessed again due to mem::forget
779        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
780        // Prevent Drop from running (which would shut down the channel)
781        std::mem::forget(self);
782    }
783}
784
785impl CompositeNodeManagerAddSpecResponder {
786    /// Sends a response to the FIDL transaction.
787    ///
788    /// Sets the channel to shutdown if an error occurs.
789    pub fn send(self, mut result: Result<(), CompositeNodeSpecError>) -> Result<(), fidl::Error> {
790        let _result = self.send_raw(result);
791        if _result.is_err() {
792            self.control_handle.shutdown();
793        }
794        self.drop_without_shutdown();
795        _result
796    }
797
798    /// Similar to "send" but does not shutdown the channel if an error occurs.
799    pub fn send_no_shutdown_on_err(
800        self,
801        mut result: Result<(), CompositeNodeSpecError>,
802    ) -> Result<(), fidl::Error> {
803        let _result = self.send_raw(result);
804        self.drop_without_shutdown();
805        _result
806    }
807
808    fn send_raw(&self, mut result: Result<(), CompositeNodeSpecError>) -> Result<(), fidl::Error> {
809        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
810            fidl::encoding::EmptyStruct,
811            CompositeNodeSpecError,
812        >>(
813            fidl::encoding::FlexibleResult::new(result),
814            self.tx_id,
815            0x524e353c8130cc74,
816            fidl::encoding::DynamicFlags::FLEXIBLE,
817        )
818    }
819}
820
821#[cfg(feature = "driver")]
822#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
823pub struct DriverMarker;
824
825#[cfg(feature = "driver")]
826impl fidl_driver::endpoints::DriverProtocolMarker for DriverMarker {
827    const DEBUG_NAME: &'static str = "(anonymous) Driver";
828}
829pub type DriverStartResult = Result<(), i32>;
830pub type DriverSuspendResult = Result<(), i32>;
831pub type DriverResumeResult = Result<(), i32>;
832
833/// This protocol is used by the Driver Framework's Driver Host to communicate various messages and
834/// lifecycle hooks to the driver. The connection for this protocol is established through the
835/// |DriverRegistration| defined in the `driver_symbols` library.
836///
837/// Once the driver has closed its server end, the Driver Framework will initiate the shutdown
838/// of all dispatchers belonging to this driver.
839
840#[cfg(feature = "driver")]
841#[derive(Debug)]
842pub enum DriverRequest {
843    /// Starts the driver with the given |start_args|.
844    ///
845    /// Drivers should finish their initial setup and enumeration before returning from |Start|.
846    /// In particular they should enumerate all currently available nodes by utilizing
847    /// `fuchsia.driver.framework/Node.AddChild` and waiting for all calls to be completed.
848    ///
849    /// The Framework will not consider the driver to be started until this call has returned
850    /// successfully. Therefore a driver will not have |Stop| called on it until after it has
851    /// replied to |Start| successfully.
852    ///
853    /// If a driver returns an error, it will not have |Stop| called on it before the
854    /// Driver Framework initiates shutdown of the driver's dispatchers. Therefore it should have
855    /// performed all necessary cleanup before returning an error.
856    Start { start_args: DriverStartArgs, responder: DriverStartResponder },
857    /// Stops the driver. To stop, the driver should teardown any resources it set up in or after
858    /// |Start|. This is a one-way FIDL method. When the driver has completed stopping, it should
859    /// close its server end. Asynchronous operations should fully complete before closing
860    /// the server end.
861    Stop {},
862    /// Returns when the driver has suspended the hardware.
863    /// This is called when the power element requests the off power state.
864    /// The driver should turn off the hardware as a response to this call.
865    ///
866    /// Note on execution order after a suspend is requested by the power element:
867    ///  - dispatchers stop accepting new work in the work queue
868    ///  - dispatcher drains previously queued work
869    ///  - Once all work is drained, this method is called
870    ///
871    /// The driver will not immediately |Stop| after it has been suspended.
872    /// It will first go through |Resume| before it is told to |Stop|.
873    Suspend { responder: DriverSuspendResponder },
874    /// Returns when the driver has resumed the hardware.
875    /// This is called when the power framework requests the power element move to the on power state.
876    /// The driver should turn the hardware back on as a response to this call.
877    ///
878    /// |power_element_lease| is the lease associated with the current wake if the
879    /// wake was from a wake vector. Otherwise it is None.
880    ///
881    /// Note on execution order after a resume is requested by the power element:
882    ///  - This method is called (the dispatcher does not accept any other work at this point)
883    ///  - Once this method completes, dispatchers start accepting new work in the work queue
884    Resume { power_element_lease: Option<fidl::EventPair>, responder: DriverResumeResponder },
885    /// An interaction was received which does not match any known method.
886    #[non_exhaustive]
887    _UnknownMethod {
888        /// Ordinal of the method that was called.
889        ordinal: u64,
890        method_type: fidl::MethodType,
891    },
892}
893
894#[cfg(feature = "driver")]
895impl DriverRequest {
896    #[allow(irrefutable_let_patterns)]
897    pub fn into_start(self) -> Option<(DriverStartArgs, DriverStartResponder)> {
898        if let DriverRequest::Start { start_args, responder } = self {
899            Some((start_args, responder))
900        } else {
901            None
902        }
903    }
904
905    #[allow(irrefutable_let_patterns)]
906    pub fn into_stop(self) -> Option<()> {
907        if let DriverRequest::Stop {} = self { Some(()) } else { None }
908    }
909
910    #[allow(irrefutable_let_patterns)]
911    pub fn into_suspend(self) -> Option<(DriverSuspendResponder)> {
912        if let DriverRequest::Suspend { responder } = self { Some((responder)) } else { None }
913    }
914
915    #[allow(irrefutable_let_patterns)]
916    pub fn into_resume(self) -> Option<(Option<fidl::EventPair>, DriverResumeResponder)> {
917        if let DriverRequest::Resume { power_element_lease, responder } = self {
918            Some((power_element_lease, responder))
919        } else {
920            None
921        }
922    }
923
924    pub fn new_start(self, start_args: DriverStartArgs, tx_id: u32) -> Self {
925        Self::Start { start_args, responder: DriverStartResponder { tx_id } }
926    }
927
928    pub fn new_stop(self) -> Self {
929        Self::Stop {}
930    }
931
932    pub fn new_suspend(self, tx_id: u32) -> Self {
933        Self::Suspend { responder: DriverSuspendResponder { tx_id } }
934    }
935
936    pub fn new_resume(self, power_element_lease: Option<fidl::EventPair>, tx_id: u32) -> Self {
937        Self::Resume { power_element_lease, responder: DriverResumeResponder { tx_id } }
938    }
939
940    pub fn r#start_as_message(
941        arena: fdf::Arena,
942        mut start_args: DriverStartArgs,
943        tx_id: u32,
944    ) -> Result<fdf::Message<[u8]>, fidl::Error> {
945        let ordinal = 0x27be00ae42aa60c2;
946        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
947        let body = (&mut start_args,);
948        let msg = fidl::encoding::TransactionMessage {
949            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
950            body,
951        };
952        fidl::encoding::with_tls_encoded::<
953            fidl::encoding::TransactionMessageType<DriverStartRequest>,
954            fidl::encoding::DefaultFuchsiaResourceDialect,
955            fdf::Message<[u8]>,
956        >(msg, |bytes, mut handles| {
957            let handles = arena.insert_from_iter(
958                std::mem::take(handles)
959                    .into_iter()
960                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
961            );
962            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
963        })
964    }
965
966    pub fn r#stop_as_message(arena: fdf::Arena) -> Result<fdf::Message<[u8]>, fidl::Error> {
967        let tx_id = 0;
968        let ordinal = 0x4b96c67e29b3843d;
969        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
970        let body = ();
971        let msg = fidl::encoding::TransactionMessage {
972            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
973            body,
974        };
975        fidl::encoding::with_tls_encoded::<
976            fidl::encoding::TransactionMessageType<fidl::encoding::EmptyPayload>,
977            fidl::encoding::DefaultFuchsiaResourceDialect,
978            fdf::Message<[u8]>,
979        >(msg, |bytes, mut handles| {
980            let handles = arena.insert_from_iter(
981                std::mem::take(handles)
982                    .into_iter()
983                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
984            );
985            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
986        })
987    }
988
989    pub fn r#suspend_as_message(
990        arena: fdf::Arena,
991        tx_id: u32,
992    ) -> Result<fdf::Message<[u8]>, fidl::Error> {
993        let ordinal = 0x4cebadedf5da22b8;
994        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
995        let body = ();
996        let msg = fidl::encoding::TransactionMessage {
997            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
998            body,
999        };
1000        fidl::encoding::with_tls_encoded::<
1001            fidl::encoding::TransactionMessageType<fidl::encoding::EmptyPayload>,
1002            fidl::encoding::DefaultFuchsiaResourceDialect,
1003            fdf::Message<[u8]>,
1004        >(msg, |bytes, mut handles| {
1005            let handles = arena.insert_from_iter(
1006                std::mem::take(handles)
1007                    .into_iter()
1008                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
1009            );
1010            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
1011        })
1012    }
1013
1014    pub fn r#resume_as_message(
1015        arena: fdf::Arena,
1016        mut power_element_lease: Option<fidl::EventPair>,
1017        tx_id: u32,
1018    ) -> Result<fdf::Message<[u8]>, fidl::Error> {
1019        let ordinal = 0x2535384cc6595148;
1020        let dynamic_flags = fidl::encoding::DynamicFlags::FLEXIBLE;
1021        let body = (power_element_lease,);
1022        let msg = fidl::encoding::TransactionMessage {
1023            header: fidl::encoding::TransactionHeader::new(tx_id, ordinal, dynamic_flags),
1024            body,
1025        };
1026        fidl::encoding::with_tls_encoded::<
1027            fidl::encoding::TransactionMessageType<DriverResumeRequest>,
1028            fidl::encoding::DefaultFuchsiaResourceDialect,
1029            fdf::Message<[u8]>,
1030        >(msg, |bytes, mut handles| {
1031            let handles = arena.insert_from_iter(
1032                std::mem::take(handles)
1033                    .into_iter()
1034                    .map(fidl_driver::encoding::mixed_from_handle_disposition),
1035            );
1036            Ok(fdf::Message::new(&arena, Some(arena.insert_slice(bytes)), Some(handles)))
1037        })
1038    }
1039
1040    #[allow(irrefutable_let_patterns)]
1041    pub fn read_from(bytes: &[u8], _handles: &mut [zx::HandleInfo]) -> Result<Self, fidl::Error> {
1042        let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1043
1044        match header.ordinal {
1045            0x27be00ae42aa60c2 => {
1046                header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1047                let mut req = fidl::new_empty!(
1048                    DriverStartRequest,
1049                    fidl::encoding::DefaultFuchsiaResourceDialect
1050                );
1051                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverStartRequest>(&header, _body_bytes, _handles, &mut req)?;
1052                Ok(DriverRequest::Start {
1053                    start_args: req.start_args,
1054
1055                    responder: DriverStartResponder { tx_id: header.tx_id },
1056                })
1057            }
1058            0x4b96c67e29b3843d => {
1059                header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1060                let mut req = fidl::new_empty!(
1061                    fidl::encoding::EmptyPayload,
1062                    fidl::encoding::DefaultFuchsiaResourceDialect
1063                );
1064                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, _handles, &mut req)?;
1065                Ok(DriverRequest::Stop {})
1066            }
1067            0x4cebadedf5da22b8 => {
1068                header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1069                let mut req = fidl::new_empty!(
1070                    fidl::encoding::EmptyPayload,
1071                    fidl::encoding::DefaultFuchsiaResourceDialect
1072                );
1073                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, _handles, &mut req)?;
1074                Ok(DriverRequest::Suspend {
1075                    responder: DriverSuspendResponder { tx_id: header.tx_id },
1076                })
1077            }
1078            0x2535384cc6595148 => {
1079                header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1080                let mut req = fidl::new_empty!(
1081                    DriverResumeRequest,
1082                    fidl::encoding::DefaultFuchsiaResourceDialect
1083                );
1084                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverResumeRequest>(&header, _body_bytes, _handles, &mut req)?;
1085                Ok(DriverRequest::Resume {
1086                    power_element_lease: req.power_element_lease,
1087
1088                    responder: DriverResumeResponder { tx_id: header.tx_id },
1089                })
1090            }
1091            _ if header.tx_id == 0
1092                && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1093            {
1094                Ok(DriverRequest::_UnknownMethod {
1095                    ordinal: header.ordinal,
1096                    method_type: fidl::MethodType::OneWay,
1097                })
1098            }
1099            _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1100                Ok(DriverRequest::_UnknownMethod {
1101                    ordinal: header.ordinal,
1102                    method_type: fidl::MethodType::TwoWay,
1103                })
1104            }
1105            _ => Err(fidl::Error::UnknownOrdinal {
1106                ordinal: header.ordinal,
1107                protocol_name:
1108                    <DriverMarker as fidl_driver::endpoints::DriverProtocolMarker>::DEBUG_NAME,
1109            }),
1110        }
1111    }
1112
1113    pub fn read_from_message(
1114        mut message: fdf::Message<[u8]>,
1115    ) -> Result<(fdf::Arena, Self), fidl::Error> {
1116        let (arena, Some(body), handles) = message.take_arena_boxes() else {
1117            return Err(fidl::Error::Invalid);
1118        };
1119        let mut handles =
1120            handles
1121                .map(|handles| {
1122                    arena.try_insert_from_iter(handles.into_iter().map(|handle| unsafe {
1123                        fidl_driver::encoding::mixed_into_handle_info(handle)
1124                    }))
1125                })
1126                .transpose();
1127        let res = match handles {
1128            Ok(ref mut handles) => {
1129                Self::read_from(&*body, handles.as_deref_mut().unwrap_or(&mut []))?
1130            }
1131            Err(_) => return Err(fidl::Error::Invalid),
1132        };
1133        std::mem::drop((body, handles));
1134        Ok((message.take_arena(), res))
1135    }
1136
1137    /// Name of the method defined in FIDL
1138    pub fn method_name(&self) -> &'static str {
1139        match *self {
1140            DriverRequest::Start { .. } => "start",
1141            DriverRequest::Stop { .. } => "stop",
1142            DriverRequest::Suspend { .. } => "suspend",
1143            DriverRequest::Resume { .. } => "resume",
1144            DriverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1145                "unknown one-way method"
1146            }
1147            DriverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1148                "unknown two-way method"
1149            }
1150        }
1151    }
1152}
1153
1154/// Like [`DriverRequest::read_from_message`] except it drops the [`Arena`].
1155#[cfg(feature = "driver")]
1156impl std::convert::TryFrom<fdf::Message<[u8]>> for DriverRequest {
1157    type Error = fidl::Error;
1158    fn try_from(msg: fdf::Message<[u8]>) -> Result<DriverRequest, fidl::Error> {
1159        Ok(DriverRequest::read_from_message(msg)?.1)
1160    }
1161}
1162
1163#[must_use = "FIDL methods require a response to be sent"]
1164#[cfg(feature = "driver")]
1165#[derive(Debug)]
1166pub struct DriverStartResponder {
1167    tx_id: u32,
1168}
1169
1170#[cfg(feature = "driver")]
1171impl DriverStartResponder {
1172    pub fn send_response(
1173        &self,
1174        server_handle: &fdf::Channel<[u8]>,
1175        mut result: Result<(), i32>,
1176    ) -> Result<(), fidl::Error> {
1177        let msg = fidl::encoding::TransactionMessage {
1178            header: fidl::encoding::TransactionHeader::new(
1179                self.tx_id,
1180                0x27be00ae42aa60c2,
1181                fidl::encoding::DynamicFlags::FLEXIBLE,
1182            ),
1183            body: fidl::encoding::FlexibleResult::new(result),
1184        };
1185        fidl::encoding::with_tls_encoded::<
1186            fidl::encoding::TransactionMessageType<
1187                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1188            >,
1189            fidl::encoding::DefaultFuchsiaResourceDialect,
1190            (),
1191        >(msg, |body, _handles| {
1192            server_handle
1193                .write_with_data(fdf::Arena::new(), |arena| arena.insert_slice(&body))
1194                .unwrap();
1195            Ok(())
1196        })
1197    }
1198}
1199
1200#[must_use = "FIDL methods require a response to be sent"]
1201#[cfg(feature = "driver")]
1202#[derive(Debug)]
1203pub struct DriverSuspendResponder {
1204    tx_id: u32,
1205}
1206
1207#[cfg(feature = "driver")]
1208impl DriverSuspendResponder {
1209    pub fn send_response(
1210        &self,
1211        server_handle: &fdf::Channel<[u8]>,
1212        mut result: Result<(), i32>,
1213    ) -> Result<(), fidl::Error> {
1214        let msg = fidl::encoding::TransactionMessage {
1215            header: fidl::encoding::TransactionHeader::new(
1216                self.tx_id,
1217                0x4cebadedf5da22b8,
1218                fidl::encoding::DynamicFlags::FLEXIBLE,
1219            ),
1220            body: fidl::encoding::FlexibleResult::new(result),
1221        };
1222        fidl::encoding::with_tls_encoded::<
1223            fidl::encoding::TransactionMessageType<
1224                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1225            >,
1226            fidl::encoding::DefaultFuchsiaResourceDialect,
1227            (),
1228        >(msg, |body, _handles| {
1229            server_handle
1230                .write_with_data(fdf::Arena::new(), |arena| arena.insert_slice(&body))
1231                .unwrap();
1232            Ok(())
1233        })
1234    }
1235}
1236
1237#[must_use = "FIDL methods require a response to be sent"]
1238#[cfg(feature = "driver")]
1239#[derive(Debug)]
1240pub struct DriverResumeResponder {
1241    tx_id: u32,
1242}
1243
1244#[cfg(feature = "driver")]
1245impl DriverResumeResponder {
1246    pub fn send_response(
1247        &self,
1248        server_handle: &fdf::Channel<[u8]>,
1249        mut result: Result<(), i32>,
1250    ) -> Result<(), fidl::Error> {
1251        let msg = fidl::encoding::TransactionMessage {
1252            header: fidl::encoding::TransactionHeader::new(
1253                self.tx_id,
1254                0x2535384cc6595148,
1255                fidl::encoding::DynamicFlags::FLEXIBLE,
1256            ),
1257            body: fidl::encoding::FlexibleResult::new(result),
1258        };
1259        fidl::encoding::with_tls_encoded::<
1260            fidl::encoding::TransactionMessageType<
1261                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
1262            >,
1263            fidl::encoding::DefaultFuchsiaResourceDialect,
1264            (),
1265        >(msg, |body, _handles| {
1266            server_handle
1267                .write_with_data(fdf::Arena::new(), |arena| arena.insert_slice(&body))
1268                .unwrap();
1269            Ok(())
1270        })
1271    }
1272}
1273
1274#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1275pub struct NodeMarker;
1276
1277impl fidl::endpoints::ProtocolMarker for NodeMarker {
1278    type Proxy = NodeProxy;
1279    type RequestStream = NodeRequestStream;
1280    #[cfg(target_os = "fuchsia")]
1281    type SynchronousProxy = NodeSynchronousProxy;
1282
1283    const DEBUG_NAME: &'static str = "(anonymous) Node";
1284}
1285pub type NodeAddChildResult = Result<(), NodeError>;
1286pub type NodeProvideResourceResult = Result<(), NodeError>;
1287
1288pub trait NodeProxyInterface: Send + Sync {
1289    type AddChildResponseFut: std::future::Future<Output = Result<NodeAddChildResult, fidl::Error>>
1290        + Send;
1291    fn r#add_child(
1292        &self,
1293        args: NodeAddArgs,
1294        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1295        node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1296    ) -> Self::AddChildResponseFut;
1297    type ProvideResourceResponseFut: std::future::Future<Output = Result<NodeProvideResourceResult, fidl::Error>>
1298        + Send;
1299    fn r#provide_resource(
1300        &self,
1301        resource: ResourceArgs,
1302        controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1303    ) -> Self::ProvideResourceResponseFut;
1304}
1305#[derive(Debug)]
1306#[cfg(target_os = "fuchsia")]
1307pub struct NodeSynchronousProxy {
1308    client: fidl::client::sync::Client,
1309}
1310
1311#[cfg(target_os = "fuchsia")]
1312impl fidl::endpoints::SynchronousProxy for NodeSynchronousProxy {
1313    type Proxy = NodeProxy;
1314    type Protocol = NodeMarker;
1315
1316    fn from_channel(inner: fidl::Channel) -> Self {
1317        Self::new(inner)
1318    }
1319
1320    fn into_channel(self) -> fidl::Channel {
1321        self.client.into_channel()
1322    }
1323
1324    fn as_channel(&self) -> &fidl::Channel {
1325        self.client.as_channel()
1326    }
1327}
1328
1329#[cfg(target_os = "fuchsia")]
1330impl NodeSynchronousProxy {
1331    pub fn new(channel: fidl::Channel) -> Self {
1332        Self { client: fidl::client::sync::Client::new(channel) }
1333    }
1334
1335    pub fn into_channel(self) -> fidl::Channel {
1336        self.client.into_channel()
1337    }
1338
1339    /// Waits until an event arrives and returns it. It is safe for other
1340    /// threads to make concurrent requests while waiting for an event.
1341    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<NodeEvent, fidl::Error> {
1342        NodeEvent::decode(self.client.wait_for_event::<NodeMarker>(deadline)?)
1343    }
1344
1345    /// Adds a child node to this node.
1346    ///
1347    /// If `node` is present, this driver takes responsibility for binding to
1348    /// the newly created child. Otherwise, the driver framework will locate an
1349    /// appropriate driver to bind the child to.
1350    pub fn r#add_child(
1351        &self,
1352        mut args: NodeAddArgs,
1353        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1354        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1355        ___deadline: zx::MonotonicInstant,
1356    ) -> Result<NodeAddChildResult, fidl::Error> {
1357        let _response = self.client.send_query::<
1358            NodeAddChildRequest,
1359            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1360            NodeMarker,
1361        >(
1362            (&mut args, controller, node,),
1363            0x77d10dff3c1ea129,
1364            fidl::encoding::DynamicFlags::FLEXIBLE,
1365            ___deadline,
1366        )?
1367        .into_result::<NodeMarker>("add_child")?;
1368        Ok(_response.map(|x| x))
1369    }
1370
1371    /// Provides a resource that other nodes can depend on. The lifetime of the
1372    /// provided resource is tied to the `controller` client connection. Dropping
1373    /// the client connection will cause the resource to be removed.
1374    pub fn r#provide_resource(
1375        &self,
1376        mut resource: ResourceArgs,
1377        mut controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1378        ___deadline: zx::MonotonicInstant,
1379    ) -> Result<NodeProvideResourceResult, fidl::Error> {
1380        let _response = self.client.send_query::<
1381            NodeProvideResourceRequest,
1382            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1383            NodeMarker,
1384        >(
1385            (&mut resource, controller,),
1386            0x2ba4a8e5f3409ace,
1387            fidl::encoding::DynamicFlags::FLEXIBLE,
1388            ___deadline,
1389        )?
1390        .into_result::<NodeMarker>("provide_resource")?;
1391        Ok(_response.map(|x| x))
1392    }
1393}
1394
1395#[cfg(target_os = "fuchsia")]
1396impl From<NodeSynchronousProxy> for zx::NullableHandle {
1397    fn from(value: NodeSynchronousProxy) -> Self {
1398        value.into_channel().into()
1399    }
1400}
1401
1402#[cfg(target_os = "fuchsia")]
1403impl From<fidl::Channel> for NodeSynchronousProxy {
1404    fn from(value: fidl::Channel) -> Self {
1405        Self::new(value)
1406    }
1407}
1408
1409#[cfg(target_os = "fuchsia")]
1410impl fidl::endpoints::FromClient for NodeSynchronousProxy {
1411    type Protocol = NodeMarker;
1412
1413    fn from_client(value: fidl::endpoints::ClientEnd<NodeMarker>) -> Self {
1414        Self::new(value.into_channel())
1415    }
1416}
1417
1418#[derive(Debug, Clone)]
1419pub struct NodeProxy {
1420    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1421}
1422
1423impl fidl::endpoints::Proxy for NodeProxy {
1424    type Protocol = NodeMarker;
1425
1426    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1427        Self::new(inner)
1428    }
1429
1430    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1431        self.client.into_channel().map_err(|client| Self { client })
1432    }
1433
1434    fn as_channel(&self) -> &::fidl::AsyncChannel {
1435        self.client.as_channel()
1436    }
1437}
1438
1439impl NodeProxy {
1440    /// Create a new Proxy for fuchsia.driver.framework/Node.
1441    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1442        let protocol_name = <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1443        Self { client: fidl::client::Client::new(channel, protocol_name) }
1444    }
1445
1446    /// Get a Stream of events from the remote end of the protocol.
1447    ///
1448    /// # Panics
1449    ///
1450    /// Panics if the event stream was already taken.
1451    pub fn take_event_stream(&self) -> NodeEventStream {
1452        NodeEventStream { event_receiver: self.client.take_event_receiver() }
1453    }
1454
1455    /// Adds a child node to this node.
1456    ///
1457    /// If `node` is present, this driver takes responsibility for binding to
1458    /// the newly created child. Otherwise, the driver framework will locate an
1459    /// appropriate driver to bind the child to.
1460    pub fn r#add_child(
1461        &self,
1462        mut args: NodeAddArgs,
1463        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1464        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1465    ) -> fidl::client::QueryResponseFut<
1466        NodeAddChildResult,
1467        fidl::encoding::DefaultFuchsiaResourceDialect,
1468    > {
1469        NodeProxyInterface::r#add_child(self, args, controller, node)
1470    }
1471
1472    /// Provides a resource that other nodes can depend on. The lifetime of the
1473    /// provided resource is tied to the `controller` client connection. Dropping
1474    /// the client connection will cause the resource to be removed.
1475    pub fn r#provide_resource(
1476        &self,
1477        mut resource: ResourceArgs,
1478        mut controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1479    ) -> fidl::client::QueryResponseFut<
1480        NodeProvideResourceResult,
1481        fidl::encoding::DefaultFuchsiaResourceDialect,
1482    > {
1483        NodeProxyInterface::r#provide_resource(self, resource, controller)
1484    }
1485}
1486
1487impl NodeProxyInterface for NodeProxy {
1488    type AddChildResponseFut = fidl::client::QueryResponseFut<
1489        NodeAddChildResult,
1490        fidl::encoding::DefaultFuchsiaResourceDialect,
1491    >;
1492    fn r#add_child(
1493        &self,
1494        mut args: NodeAddArgs,
1495        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1496        mut node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1497    ) -> Self::AddChildResponseFut {
1498        fn _decode(
1499            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1500        ) -> Result<NodeAddChildResult, fidl::Error> {
1501            let _response = fidl::client::decode_transaction_body::<
1502                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1503                fidl::encoding::DefaultFuchsiaResourceDialect,
1504                0x77d10dff3c1ea129,
1505            >(_buf?)?
1506            .into_result::<NodeMarker>("add_child")?;
1507            Ok(_response.map(|x| x))
1508        }
1509        self.client.send_query_and_decode::<NodeAddChildRequest, NodeAddChildResult>(
1510            (&mut args, controller, node),
1511            0x77d10dff3c1ea129,
1512            fidl::encoding::DynamicFlags::FLEXIBLE,
1513            _decode,
1514        )
1515    }
1516
1517    type ProvideResourceResponseFut = fidl::client::QueryResponseFut<
1518        NodeProvideResourceResult,
1519        fidl::encoding::DefaultFuchsiaResourceDialect,
1520    >;
1521    fn r#provide_resource(
1522        &self,
1523        mut resource: ResourceArgs,
1524        mut controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1525    ) -> Self::ProvideResourceResponseFut {
1526        fn _decode(
1527            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1528        ) -> Result<NodeProvideResourceResult, fidl::Error> {
1529            let _response = fidl::client::decode_transaction_body::<
1530                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
1531                fidl::encoding::DefaultFuchsiaResourceDialect,
1532                0x2ba4a8e5f3409ace,
1533            >(_buf?)?
1534            .into_result::<NodeMarker>("provide_resource")?;
1535            Ok(_response.map(|x| x))
1536        }
1537        self.client.send_query_and_decode::<NodeProvideResourceRequest, NodeProvideResourceResult>(
1538            (&mut resource, controller),
1539            0x2ba4a8e5f3409ace,
1540            fidl::encoding::DynamicFlags::FLEXIBLE,
1541            _decode,
1542        )
1543    }
1544}
1545
1546pub struct NodeEventStream {
1547    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1548}
1549
1550impl std::marker::Unpin for NodeEventStream {}
1551
1552impl futures::stream::FusedStream for NodeEventStream {
1553    fn is_terminated(&self) -> bool {
1554        self.event_receiver.is_terminated()
1555    }
1556}
1557
1558impl futures::Stream for NodeEventStream {
1559    type Item = Result<NodeEvent, fidl::Error>;
1560
1561    fn poll_next(
1562        mut self: std::pin::Pin<&mut Self>,
1563        cx: &mut std::task::Context<'_>,
1564    ) -> std::task::Poll<Option<Self::Item>> {
1565        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1566            &mut self.event_receiver,
1567            cx
1568        )?) {
1569            Some(buf) => std::task::Poll::Ready(Some(NodeEvent::decode(buf))),
1570            None => std::task::Poll::Ready(None),
1571        }
1572    }
1573}
1574
1575#[derive(Debug)]
1576pub enum NodeEvent {
1577    #[non_exhaustive]
1578    _UnknownEvent {
1579        /// Ordinal of the event that was sent.
1580        ordinal: u64,
1581    },
1582}
1583
1584impl NodeEvent {
1585    /// Decodes a message buffer as a [`NodeEvent`].
1586    fn decode(
1587        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1588    ) -> Result<NodeEvent, fidl::Error> {
1589        let (bytes, _handles) = buf.split_mut();
1590        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1591        debug_assert_eq!(tx_header.tx_id, 0);
1592        match tx_header.ordinal {
1593            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1594                Ok(NodeEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1595            }
1596            _ => Err(fidl::Error::UnknownOrdinal {
1597                ordinal: tx_header.ordinal,
1598                protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1599            }),
1600        }
1601    }
1602}
1603
1604/// A Stream of incoming requests for fuchsia.driver.framework/Node.
1605pub struct NodeRequestStream {
1606    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1607    is_terminated: bool,
1608}
1609
1610impl std::marker::Unpin for NodeRequestStream {}
1611
1612impl futures::stream::FusedStream for NodeRequestStream {
1613    fn is_terminated(&self) -> bool {
1614        self.is_terminated
1615    }
1616}
1617
1618impl fidl::endpoints::RequestStream for NodeRequestStream {
1619    type Protocol = NodeMarker;
1620    type ControlHandle = NodeControlHandle;
1621
1622    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1623        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1624    }
1625
1626    fn control_handle(&self) -> Self::ControlHandle {
1627        NodeControlHandle { inner: self.inner.clone() }
1628    }
1629
1630    fn into_inner(
1631        self,
1632    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1633    {
1634        (self.inner, self.is_terminated)
1635    }
1636
1637    fn from_inner(
1638        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1639        is_terminated: bool,
1640    ) -> Self {
1641        Self { inner, is_terminated }
1642    }
1643}
1644
1645impl futures::Stream for NodeRequestStream {
1646    type Item = Result<NodeRequest, fidl::Error>;
1647
1648    fn poll_next(
1649        mut self: std::pin::Pin<&mut Self>,
1650        cx: &mut std::task::Context<'_>,
1651    ) -> std::task::Poll<Option<Self::Item>> {
1652        let this = &mut *self;
1653        if this.inner.check_shutdown(cx) {
1654            this.is_terminated = true;
1655            return std::task::Poll::Ready(None);
1656        }
1657        if this.is_terminated {
1658            panic!("polled NodeRequestStream after completion");
1659        }
1660        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1661            |bytes, handles| {
1662                match this.inner.channel().read_etc(cx, bytes, handles) {
1663                    std::task::Poll::Ready(Ok(())) => {}
1664                    std::task::Poll::Pending => return std::task::Poll::Pending,
1665                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1666                        this.is_terminated = true;
1667                        return std::task::Poll::Ready(None);
1668                    }
1669                    std::task::Poll::Ready(Err(e)) => {
1670                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1671                            e.into(),
1672                        ))));
1673                    }
1674                }
1675
1676                // A message has been received from the channel
1677                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1678
1679                std::task::Poll::Ready(Some(match header.ordinal {
1680                    0x77d10dff3c1ea129 => {
1681                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1682                        let mut req = fidl::new_empty!(
1683                            NodeAddChildRequest,
1684                            fidl::encoding::DefaultFuchsiaResourceDialect
1685                        );
1686                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
1687                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
1688                        Ok(NodeRequest::AddChild {
1689                            args: req.args,
1690                            controller: req.controller,
1691                            node: req.node,
1692
1693                            responder: NodeAddChildResponder {
1694                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1695                                tx_id: header.tx_id,
1696                            },
1697                        })
1698                    }
1699                    0x2ba4a8e5f3409ace => {
1700                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1701                        let mut req = fidl::new_empty!(
1702                            NodeProvideResourceRequest,
1703                            fidl::encoding::DefaultFuchsiaResourceDialect
1704                        );
1705                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeProvideResourceRequest>(&header, _body_bytes, handles, &mut req)?;
1706                        let control_handle = NodeControlHandle { inner: this.inner.clone() };
1707                        Ok(NodeRequest::ProvideResource {
1708                            resource: req.resource,
1709                            controller: req.controller,
1710
1711                            responder: NodeProvideResourceResponder {
1712                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1713                                tx_id: header.tx_id,
1714                            },
1715                        })
1716                    }
1717                    _ if header.tx_id == 0
1718                        && header
1719                            .dynamic_flags()
1720                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1721                    {
1722                        Ok(NodeRequest::_UnknownMethod {
1723                            ordinal: header.ordinal,
1724                            control_handle: NodeControlHandle { inner: this.inner.clone() },
1725                            method_type: fidl::MethodType::OneWay,
1726                        })
1727                    }
1728                    _ if header
1729                        .dynamic_flags()
1730                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1731                    {
1732                        this.inner.send_framework_err(
1733                            fidl::encoding::FrameworkErr::UnknownMethod,
1734                            header.tx_id,
1735                            header.ordinal,
1736                            header.dynamic_flags(),
1737                            (bytes, handles),
1738                        )?;
1739                        Ok(NodeRequest::_UnknownMethod {
1740                            ordinal: header.ordinal,
1741                            control_handle: NodeControlHandle { inner: this.inner.clone() },
1742                            method_type: fidl::MethodType::TwoWay,
1743                        })
1744                    }
1745                    _ => Err(fidl::Error::UnknownOrdinal {
1746                        ordinal: header.ordinal,
1747                        protocol_name: <NodeMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1748                    }),
1749                }))
1750            },
1751        )
1752    }
1753}
1754
1755/// Protocol through which a driver manages a node that it is bound to.
1756/// Drivers should maintain their client connection to the node. Dropping
1757/// the client connection while the driver is running will cause the
1758/// driver framework to remove the driver and node from the topology.
1759/// If the driver has set `host_restart_on_crash` to "true" in their
1760/// component manifest, dropping the connection will initiate a restart of
1761/// the driver host and driver.
1762#[derive(Debug)]
1763pub enum NodeRequest {
1764    /// Adds a child node to this node.
1765    ///
1766    /// If `node` is present, this driver takes responsibility for binding to
1767    /// the newly created child. Otherwise, the driver framework will locate an
1768    /// appropriate driver to bind the child to.
1769    AddChild {
1770        args: NodeAddArgs,
1771        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
1772        node: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1773        responder: NodeAddChildResponder,
1774    },
1775    /// Provides a resource that other nodes can depend on. The lifetime of the
1776    /// provided resource is tied to the `controller` client connection. Dropping
1777    /// the client connection will cause the resource to be removed.
1778    ProvideResource {
1779        resource: ResourceArgs,
1780        controller: fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1781        responder: NodeProvideResourceResponder,
1782    },
1783    /// An interaction was received which does not match any known method.
1784    #[non_exhaustive]
1785    _UnknownMethod {
1786        /// Ordinal of the method that was called.
1787        ordinal: u64,
1788        control_handle: NodeControlHandle,
1789        method_type: fidl::MethodType,
1790    },
1791}
1792
1793impl NodeRequest {
1794    #[allow(irrefutable_let_patterns)]
1795    pub fn into_add_child(
1796        self,
1797    ) -> Option<(
1798        NodeAddArgs,
1799        fidl::endpoints::ServerEnd<NodeControllerMarker>,
1800        Option<fidl::endpoints::ServerEnd<NodeMarker>>,
1801        NodeAddChildResponder,
1802    )> {
1803        if let NodeRequest::AddChild { args, controller, node, responder } = self {
1804            Some((args, controller, node, responder))
1805        } else {
1806            None
1807        }
1808    }
1809
1810    #[allow(irrefutable_let_patterns)]
1811    pub fn into_provide_resource(
1812        self,
1813    ) -> Option<(
1814        ResourceArgs,
1815        fidl::endpoints::ServerEnd<ResourceControllerMarker>,
1816        NodeProvideResourceResponder,
1817    )> {
1818        if let NodeRequest::ProvideResource { resource, controller, responder } = self {
1819            Some((resource, controller, responder))
1820        } else {
1821            None
1822        }
1823    }
1824
1825    /// Name of the method defined in FIDL
1826    pub fn method_name(&self) -> &'static str {
1827        match *self {
1828            NodeRequest::AddChild { .. } => "add_child",
1829            NodeRequest::ProvideResource { .. } => "provide_resource",
1830            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1831                "unknown one-way method"
1832            }
1833            NodeRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1834                "unknown two-way method"
1835            }
1836        }
1837    }
1838}
1839
1840#[derive(Debug, Clone)]
1841pub struct NodeControlHandle {
1842    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1843}
1844
1845impl fidl::endpoints::ControlHandle for NodeControlHandle {
1846    fn shutdown(&self) {
1847        self.inner.shutdown()
1848    }
1849
1850    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1851        self.inner.shutdown_with_epitaph(status)
1852    }
1853
1854    fn is_closed(&self) -> bool {
1855        self.inner.channel().is_closed()
1856    }
1857    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1858        self.inner.channel().on_closed()
1859    }
1860
1861    #[cfg(target_os = "fuchsia")]
1862    fn signal_peer(
1863        &self,
1864        clear_mask: zx::Signals,
1865        set_mask: zx::Signals,
1866    ) -> Result<(), zx_status::Status> {
1867        use fidl::Peered;
1868        self.inner.channel().signal_peer(clear_mask, set_mask)
1869    }
1870}
1871
1872impl NodeControlHandle {}
1873
1874#[must_use = "FIDL methods require a response to be sent"]
1875#[derive(Debug)]
1876pub struct NodeAddChildResponder {
1877    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
1878    tx_id: u32,
1879}
1880
1881/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
1882/// if the responder is dropped without sending a response, so that the client
1883/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1884impl std::ops::Drop for NodeAddChildResponder {
1885    fn drop(&mut self) {
1886        self.control_handle.shutdown();
1887        // Safety: drops once, never accessed again
1888        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1889    }
1890}
1891
1892impl fidl::endpoints::Responder for NodeAddChildResponder {
1893    type ControlHandle = NodeControlHandle;
1894
1895    fn control_handle(&self) -> &NodeControlHandle {
1896        &self.control_handle
1897    }
1898
1899    fn drop_without_shutdown(mut self) {
1900        // Safety: drops once, never accessed again due to mem::forget
1901        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1902        // Prevent Drop from running (which would shut down the channel)
1903        std::mem::forget(self);
1904    }
1905}
1906
1907impl NodeAddChildResponder {
1908    /// Sends a response to the FIDL transaction.
1909    ///
1910    /// Sets the channel to shutdown if an error occurs.
1911    pub fn send(self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
1912        let _result = self.send_raw(result);
1913        if _result.is_err() {
1914            self.control_handle.shutdown();
1915        }
1916        self.drop_without_shutdown();
1917        _result
1918    }
1919
1920    /// Similar to "send" but does not shutdown the channel if an error occurs.
1921    pub fn send_no_shutdown_on_err(
1922        self,
1923        mut result: Result<(), NodeError>,
1924    ) -> Result<(), fidl::Error> {
1925        let _result = self.send_raw(result);
1926        self.drop_without_shutdown();
1927        _result
1928    }
1929
1930    fn send_raw(&self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
1931        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1932            fidl::encoding::EmptyStruct,
1933            NodeError,
1934        >>(
1935            fidl::encoding::FlexibleResult::new(result),
1936            self.tx_id,
1937            0x77d10dff3c1ea129,
1938            fidl::encoding::DynamicFlags::FLEXIBLE,
1939        )
1940    }
1941}
1942
1943#[must_use = "FIDL methods require a response to be sent"]
1944#[derive(Debug)]
1945pub struct NodeProvideResourceResponder {
1946    control_handle: std::mem::ManuallyDrop<NodeControlHandle>,
1947    tx_id: u32,
1948}
1949
1950/// Set the the channel to be shutdown (see [`NodeControlHandle::shutdown`])
1951/// if the responder is dropped without sending a response, so that the client
1952/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1953impl std::ops::Drop for NodeProvideResourceResponder {
1954    fn drop(&mut self) {
1955        self.control_handle.shutdown();
1956        // Safety: drops once, never accessed again
1957        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1958    }
1959}
1960
1961impl fidl::endpoints::Responder for NodeProvideResourceResponder {
1962    type ControlHandle = NodeControlHandle;
1963
1964    fn control_handle(&self) -> &NodeControlHandle {
1965        &self.control_handle
1966    }
1967
1968    fn drop_without_shutdown(mut self) {
1969        // Safety: drops once, never accessed again due to mem::forget
1970        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1971        // Prevent Drop from running (which would shut down the channel)
1972        std::mem::forget(self);
1973    }
1974}
1975
1976impl NodeProvideResourceResponder {
1977    /// Sends a response to the FIDL transaction.
1978    ///
1979    /// Sets the channel to shutdown if an error occurs.
1980    pub fn send(self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
1981        let _result = self.send_raw(result);
1982        if _result.is_err() {
1983            self.control_handle.shutdown();
1984        }
1985        self.drop_without_shutdown();
1986        _result
1987    }
1988
1989    /// Similar to "send" but does not shutdown the channel if an error occurs.
1990    pub fn send_no_shutdown_on_err(
1991        self,
1992        mut result: Result<(), NodeError>,
1993    ) -> Result<(), fidl::Error> {
1994        let _result = self.send_raw(result);
1995        self.drop_without_shutdown();
1996        _result
1997    }
1998
1999    fn send_raw(&self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
2000        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2001            fidl::encoding::EmptyStruct,
2002            NodeError,
2003        >>(
2004            fidl::encoding::FlexibleResult::new(result),
2005            self.tx_id,
2006            0x2ba4a8e5f3409ace,
2007            fidl::encoding::DynamicFlags::FLEXIBLE,
2008        )
2009    }
2010}
2011
2012#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2013pub struct NodeControllerMarker;
2014
2015impl fidl::endpoints::ProtocolMarker for NodeControllerMarker {
2016    type Proxy = NodeControllerProxy;
2017    type RequestStream = NodeControllerRequestStream;
2018    #[cfg(target_os = "fuchsia")]
2019    type SynchronousProxy = NodeControllerSynchronousProxy;
2020
2021    const DEBUG_NAME: &'static str = "(anonymous) NodeController";
2022}
2023pub type NodeControllerRequestBindResult = Result<(), i32>;
2024pub type NodeControllerWaitForDriverResult = Result<DriverResult, i32>;
2025
2026pub trait NodeControllerProxyInterface: Send + Sync {
2027    fn r#remove(&self) -> Result<(), fidl::Error>;
2028    type RequestBindResponseFut: std::future::Future<Output = Result<NodeControllerRequestBindResult, fidl::Error>>
2029        + Send;
2030    fn r#request_bind(
2031        &self,
2032        payload: &NodeControllerRequestBindRequest,
2033    ) -> Self::RequestBindResponseFut;
2034    type WaitForDriverResponseFut: std::future::Future<Output = Result<NodeControllerWaitForDriverResult, fidl::Error>>
2035        + Send;
2036    fn r#wait_for_driver(&self) -> Self::WaitForDriverResponseFut;
2037}
2038#[derive(Debug)]
2039#[cfg(target_os = "fuchsia")]
2040pub struct NodeControllerSynchronousProxy {
2041    client: fidl::client::sync::Client,
2042}
2043
2044#[cfg(target_os = "fuchsia")]
2045impl fidl::endpoints::SynchronousProxy for NodeControllerSynchronousProxy {
2046    type Proxy = NodeControllerProxy;
2047    type Protocol = NodeControllerMarker;
2048
2049    fn from_channel(inner: fidl::Channel) -> Self {
2050        Self::new(inner)
2051    }
2052
2053    fn into_channel(self) -> fidl::Channel {
2054        self.client.into_channel()
2055    }
2056
2057    fn as_channel(&self) -> &fidl::Channel {
2058        self.client.as_channel()
2059    }
2060}
2061
2062#[cfg(target_os = "fuchsia")]
2063impl NodeControllerSynchronousProxy {
2064    pub fn new(channel: fidl::Channel) -> Self {
2065        Self { client: fidl::client::sync::Client::new(channel) }
2066    }
2067
2068    pub fn into_channel(self) -> fidl::Channel {
2069        self.client.into_channel()
2070    }
2071
2072    /// Waits until an event arrives and returns it. It is safe for other
2073    /// threads to make concurrent requests while waiting for an event.
2074    pub fn wait_for_event(
2075        &self,
2076        deadline: zx::MonotonicInstant,
2077    ) -> Result<NodeControllerEvent, fidl::Error> {
2078        NodeControllerEvent::decode(self.client.wait_for_event::<NodeControllerMarker>(deadline)?)
2079    }
2080
2081    /// Removes the node and all of its children.
2082    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2083        self.client.send::<fidl::encoding::EmptyPayload>(
2084            (),
2085            0x54fa8b3dfe7bb341,
2086            fidl::encoding::DynamicFlags::FLEXIBLE,
2087        )
2088    }
2089
2090    /// Request that the framework attempts to bind a driver to this node.
2091    /// This is an *additional* request for binding as the framework attempts to bind a node once
2092    /// when the node is created.
2093    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
2094    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
2095    /// not completed.
2096    pub fn r#request_bind(
2097        &self,
2098        mut payload: &NodeControllerRequestBindRequest,
2099        ___deadline: zx::MonotonicInstant,
2100    ) -> Result<NodeControllerRequestBindResult, fidl::Error> {
2101        let _response = self.client.send_query::<
2102            NodeControllerRequestBindRequest,
2103            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2104            NodeControllerMarker,
2105        >(
2106            payload,
2107            0x41b954726b13508f,
2108            fidl::encoding::DynamicFlags::FLEXIBLE,
2109            ___deadline,
2110        )?
2111        .into_result::<NodeControllerMarker>("request_bind")?;
2112        Ok(_response.map(|x| x))
2113    }
2114
2115    /// Hanging get style call that returns a terminal state for the associated `Node`,
2116    /// or the composite node that is parented by this node.
2117    /// For a successfully started driver this returns immediately with the token of the
2118    /// node that the driver started on.
2119    /// If an error happens we wait until bootup is complete, which is when all drivers that
2120    /// can bind and start have done so, before returning the error.
2121    pub fn r#wait_for_driver(
2122        &self,
2123        ___deadline: zx::MonotonicInstant,
2124    ) -> Result<NodeControllerWaitForDriverResult, fidl::Error> {
2125        let _response = self.client.send_query::<
2126            fidl::encoding::EmptyPayload,
2127            fidl::encoding::FlexibleResultType<DriverResult, i32>,
2128            NodeControllerMarker,
2129        >(
2130            (),
2131            0x69f7106e47d81387,
2132            fidl::encoding::DynamicFlags::FLEXIBLE,
2133            ___deadline,
2134        )?
2135        .into_result::<NodeControllerMarker>("wait_for_driver")?;
2136        Ok(_response.map(|x| x))
2137    }
2138}
2139
2140#[cfg(target_os = "fuchsia")]
2141impl From<NodeControllerSynchronousProxy> for zx::NullableHandle {
2142    fn from(value: NodeControllerSynchronousProxy) -> Self {
2143        value.into_channel().into()
2144    }
2145}
2146
2147#[cfg(target_os = "fuchsia")]
2148impl From<fidl::Channel> for NodeControllerSynchronousProxy {
2149    fn from(value: fidl::Channel) -> Self {
2150        Self::new(value)
2151    }
2152}
2153
2154#[cfg(target_os = "fuchsia")]
2155impl fidl::endpoints::FromClient for NodeControllerSynchronousProxy {
2156    type Protocol = NodeControllerMarker;
2157
2158    fn from_client(value: fidl::endpoints::ClientEnd<NodeControllerMarker>) -> Self {
2159        Self::new(value.into_channel())
2160    }
2161}
2162
2163#[derive(Debug, Clone)]
2164pub struct NodeControllerProxy {
2165    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2166}
2167
2168impl fidl::endpoints::Proxy for NodeControllerProxy {
2169    type Protocol = NodeControllerMarker;
2170
2171    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2172        Self::new(inner)
2173    }
2174
2175    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2176        self.client.into_channel().map_err(|client| Self { client })
2177    }
2178
2179    fn as_channel(&self) -> &::fidl::AsyncChannel {
2180        self.client.as_channel()
2181    }
2182}
2183
2184impl NodeControllerProxy {
2185    /// Create a new Proxy for fuchsia.driver.framework/NodeController.
2186    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2187        let protocol_name = <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2188        Self { client: fidl::client::Client::new(channel, protocol_name) }
2189    }
2190
2191    /// Get a Stream of events from the remote end of the protocol.
2192    ///
2193    /// # Panics
2194    ///
2195    /// Panics if the event stream was already taken.
2196    pub fn take_event_stream(&self) -> NodeControllerEventStream {
2197        NodeControllerEventStream { event_receiver: self.client.take_event_receiver() }
2198    }
2199
2200    /// Removes the node and all of its children.
2201    pub fn r#remove(&self) -> Result<(), fidl::Error> {
2202        NodeControllerProxyInterface::r#remove(self)
2203    }
2204
2205    /// Request that the framework attempts to bind a driver to this node.
2206    /// This is an *additional* request for binding as the framework attempts to bind a node once
2207    /// when the node is created.
2208    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
2209    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
2210    /// not completed.
2211    pub fn r#request_bind(
2212        &self,
2213        mut payload: &NodeControllerRequestBindRequest,
2214    ) -> fidl::client::QueryResponseFut<
2215        NodeControllerRequestBindResult,
2216        fidl::encoding::DefaultFuchsiaResourceDialect,
2217    > {
2218        NodeControllerProxyInterface::r#request_bind(self, payload)
2219    }
2220
2221    /// Hanging get style call that returns a terminal state for the associated `Node`,
2222    /// or the composite node that is parented by this node.
2223    /// For a successfully started driver this returns immediately with the token of the
2224    /// node that the driver started on.
2225    /// If an error happens we wait until bootup is complete, which is when all drivers that
2226    /// can bind and start have done so, before returning the error.
2227    pub fn r#wait_for_driver(
2228        &self,
2229    ) -> fidl::client::QueryResponseFut<
2230        NodeControllerWaitForDriverResult,
2231        fidl::encoding::DefaultFuchsiaResourceDialect,
2232    > {
2233        NodeControllerProxyInterface::r#wait_for_driver(self)
2234    }
2235}
2236
2237impl NodeControllerProxyInterface for NodeControllerProxy {
2238    fn r#remove(&self) -> Result<(), fidl::Error> {
2239        self.client.send::<fidl::encoding::EmptyPayload>(
2240            (),
2241            0x54fa8b3dfe7bb341,
2242            fidl::encoding::DynamicFlags::FLEXIBLE,
2243        )
2244    }
2245
2246    type RequestBindResponseFut = fidl::client::QueryResponseFut<
2247        NodeControllerRequestBindResult,
2248        fidl::encoding::DefaultFuchsiaResourceDialect,
2249    >;
2250    fn r#request_bind(
2251        &self,
2252        mut payload: &NodeControllerRequestBindRequest,
2253    ) -> Self::RequestBindResponseFut {
2254        fn _decode(
2255            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2256        ) -> Result<NodeControllerRequestBindResult, fidl::Error> {
2257            let _response = fidl::client::decode_transaction_body::<
2258                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2259                fidl::encoding::DefaultFuchsiaResourceDialect,
2260                0x41b954726b13508f,
2261            >(_buf?)?
2262            .into_result::<NodeControllerMarker>("request_bind")?;
2263            Ok(_response.map(|x| x))
2264        }
2265        self.client.send_query_and_decode::<
2266            NodeControllerRequestBindRequest,
2267            NodeControllerRequestBindResult,
2268        >(
2269            payload,
2270            0x41b954726b13508f,
2271            fidl::encoding::DynamicFlags::FLEXIBLE,
2272            _decode,
2273        )
2274    }
2275
2276    type WaitForDriverResponseFut = fidl::client::QueryResponseFut<
2277        NodeControllerWaitForDriverResult,
2278        fidl::encoding::DefaultFuchsiaResourceDialect,
2279    >;
2280    fn r#wait_for_driver(&self) -> Self::WaitForDriverResponseFut {
2281        fn _decode(
2282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2283        ) -> Result<NodeControllerWaitForDriverResult, fidl::Error> {
2284            let _response = fidl::client::decode_transaction_body::<
2285                fidl::encoding::FlexibleResultType<DriverResult, i32>,
2286                fidl::encoding::DefaultFuchsiaResourceDialect,
2287                0x69f7106e47d81387,
2288            >(_buf?)?
2289            .into_result::<NodeControllerMarker>("wait_for_driver")?;
2290            Ok(_response.map(|x| x))
2291        }
2292        self.client.send_query_and_decode::<
2293            fidl::encoding::EmptyPayload,
2294            NodeControllerWaitForDriverResult,
2295        >(
2296            (),
2297            0x69f7106e47d81387,
2298            fidl::encoding::DynamicFlags::FLEXIBLE,
2299            _decode,
2300        )
2301    }
2302}
2303
2304pub struct NodeControllerEventStream {
2305    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2306}
2307
2308impl std::marker::Unpin for NodeControllerEventStream {}
2309
2310impl futures::stream::FusedStream for NodeControllerEventStream {
2311    fn is_terminated(&self) -> bool {
2312        self.event_receiver.is_terminated()
2313    }
2314}
2315
2316impl futures::Stream for NodeControllerEventStream {
2317    type Item = Result<NodeControllerEvent, fidl::Error>;
2318
2319    fn poll_next(
2320        mut self: std::pin::Pin<&mut Self>,
2321        cx: &mut std::task::Context<'_>,
2322    ) -> std::task::Poll<Option<Self::Item>> {
2323        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2324            &mut self.event_receiver,
2325            cx
2326        )?) {
2327            Some(buf) => std::task::Poll::Ready(Some(NodeControllerEvent::decode(buf))),
2328            None => std::task::Poll::Ready(None),
2329        }
2330    }
2331}
2332
2333#[derive(Debug)]
2334pub enum NodeControllerEvent {
2335    OnBind {
2336        payload: NodeControllerOnBindRequest,
2337    },
2338    #[non_exhaustive]
2339    _UnknownEvent {
2340        /// Ordinal of the event that was sent.
2341        ordinal: u64,
2342    },
2343}
2344
2345impl NodeControllerEvent {
2346    #[allow(irrefutable_let_patterns)]
2347    pub fn into_on_bind(self) -> Option<NodeControllerOnBindRequest> {
2348        if let NodeControllerEvent::OnBind { payload } = self { Some((payload)) } else { None }
2349    }
2350
2351    /// Decodes a message buffer as a [`NodeControllerEvent`].
2352    fn decode(
2353        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2354    ) -> Result<NodeControllerEvent, fidl::Error> {
2355        let (bytes, _handles) = buf.split_mut();
2356        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2357        debug_assert_eq!(tx_header.tx_id, 0);
2358        match tx_header.ordinal {
2359            0x51f4165bc5ea202a => {
2360                let mut out = fidl::new_empty!(
2361                    NodeControllerOnBindRequest,
2362                    fidl::encoding::DefaultFuchsiaResourceDialect
2363                );
2364                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeControllerOnBindRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2365                Ok((NodeControllerEvent::OnBind { payload: out }))
2366            }
2367            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2368                Ok(NodeControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2369            }
2370            _ => Err(fidl::Error::UnknownOrdinal {
2371                ordinal: tx_header.ordinal,
2372                protocol_name:
2373                    <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2374            }),
2375        }
2376    }
2377}
2378
2379/// A Stream of incoming requests for fuchsia.driver.framework/NodeController.
2380pub struct NodeControllerRequestStream {
2381    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2382    is_terminated: bool,
2383}
2384
2385impl std::marker::Unpin for NodeControllerRequestStream {}
2386
2387impl futures::stream::FusedStream for NodeControllerRequestStream {
2388    fn is_terminated(&self) -> bool {
2389        self.is_terminated
2390    }
2391}
2392
2393impl fidl::endpoints::RequestStream for NodeControllerRequestStream {
2394    type Protocol = NodeControllerMarker;
2395    type ControlHandle = NodeControllerControlHandle;
2396
2397    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2398        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2399    }
2400
2401    fn control_handle(&self) -> Self::ControlHandle {
2402        NodeControllerControlHandle { inner: self.inner.clone() }
2403    }
2404
2405    fn into_inner(
2406        self,
2407    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2408    {
2409        (self.inner, self.is_terminated)
2410    }
2411
2412    fn from_inner(
2413        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2414        is_terminated: bool,
2415    ) -> Self {
2416        Self { inner, is_terminated }
2417    }
2418}
2419
2420impl futures::Stream for NodeControllerRequestStream {
2421    type Item = Result<NodeControllerRequest, fidl::Error>;
2422
2423    fn poll_next(
2424        mut self: std::pin::Pin<&mut Self>,
2425        cx: &mut std::task::Context<'_>,
2426    ) -> std::task::Poll<Option<Self::Item>> {
2427        let this = &mut *self;
2428        if this.inner.check_shutdown(cx) {
2429            this.is_terminated = true;
2430            return std::task::Poll::Ready(None);
2431        }
2432        if this.is_terminated {
2433            panic!("polled NodeControllerRequestStream after completion");
2434        }
2435        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2436            |bytes, handles| {
2437                match this.inner.channel().read_etc(cx, bytes, handles) {
2438                    std::task::Poll::Ready(Ok(())) => {}
2439                    std::task::Poll::Pending => return std::task::Poll::Pending,
2440                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2441                        this.is_terminated = true;
2442                        return std::task::Poll::Ready(None);
2443                    }
2444                    std::task::Poll::Ready(Err(e)) => {
2445                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2446                            e.into(),
2447                        ))));
2448                    }
2449                }
2450
2451                // A message has been received from the channel
2452                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2453
2454                std::task::Poll::Ready(Some(match header.ordinal {
2455                    0x54fa8b3dfe7bb341 => {
2456                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2457                        let mut req = fidl::new_empty!(
2458                            fidl::encoding::EmptyPayload,
2459                            fidl::encoding::DefaultFuchsiaResourceDialect
2460                        );
2461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2462                        let control_handle =
2463                            NodeControllerControlHandle { inner: this.inner.clone() };
2464                        Ok(NodeControllerRequest::Remove { control_handle })
2465                    }
2466                    0x41b954726b13508f => {
2467                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2468                        let mut req = fidl::new_empty!(
2469                            NodeControllerRequestBindRequest,
2470                            fidl::encoding::DefaultFuchsiaResourceDialect
2471                        );
2472                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeControllerRequestBindRequest>(&header, _body_bytes, handles, &mut req)?;
2473                        let control_handle =
2474                            NodeControllerControlHandle { inner: this.inner.clone() };
2475                        Ok(NodeControllerRequest::RequestBind {
2476                            payload: req,
2477                            responder: NodeControllerRequestBindResponder {
2478                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2479                                tx_id: header.tx_id,
2480                            },
2481                        })
2482                    }
2483                    0x69f7106e47d81387 => {
2484                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2485                        let mut req = fidl::new_empty!(
2486                            fidl::encoding::EmptyPayload,
2487                            fidl::encoding::DefaultFuchsiaResourceDialect
2488                        );
2489                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2490                        let control_handle =
2491                            NodeControllerControlHandle { inner: this.inner.clone() };
2492                        Ok(NodeControllerRequest::WaitForDriver {
2493                            responder: NodeControllerWaitForDriverResponder {
2494                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2495                                tx_id: header.tx_id,
2496                            },
2497                        })
2498                    }
2499                    _ if header.tx_id == 0
2500                        && header
2501                            .dynamic_flags()
2502                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2503                    {
2504                        Ok(NodeControllerRequest::_UnknownMethod {
2505                            ordinal: header.ordinal,
2506                            control_handle: NodeControllerControlHandle {
2507                                inner: this.inner.clone(),
2508                            },
2509                            method_type: fidl::MethodType::OneWay,
2510                        })
2511                    }
2512                    _ if header
2513                        .dynamic_flags()
2514                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2515                    {
2516                        this.inner.send_framework_err(
2517                            fidl::encoding::FrameworkErr::UnknownMethod,
2518                            header.tx_id,
2519                            header.ordinal,
2520                            header.dynamic_flags(),
2521                            (bytes, handles),
2522                        )?;
2523                        Ok(NodeControllerRequest::_UnknownMethod {
2524                            ordinal: header.ordinal,
2525                            control_handle: NodeControllerControlHandle {
2526                                inner: this.inner.clone(),
2527                            },
2528                            method_type: fidl::MethodType::TwoWay,
2529                        })
2530                    }
2531                    _ => Err(fidl::Error::UnknownOrdinal {
2532                        ordinal: header.ordinal,
2533                        protocol_name:
2534                            <NodeControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2535                    }),
2536                }))
2537            },
2538        )
2539    }
2540}
2541
2542/// Protocol through which a parent node controls one of its children.
2543#[derive(Debug)]
2544pub enum NodeControllerRequest {
2545    /// Removes the node and all of its children.
2546    Remove { control_handle: NodeControllerControlHandle },
2547    /// Request that the framework attempts to bind a driver to this node.
2548    /// This is an *additional* request for binding as the framework attempts to bind a node once
2549    /// when the node is created.
2550    /// * error `ZX_ERR_ALREADY_BOUND` if the node is already bound and `force_rebind` is false.
2551    /// * error `ZX_ERR_ALREADY_EXISTS` if the node has an outstanding |RequestBind| call which has
2552    /// not completed.
2553    RequestBind {
2554        payload: NodeControllerRequestBindRequest,
2555        responder: NodeControllerRequestBindResponder,
2556    },
2557    /// Hanging get style call that returns a terminal state for the associated `Node`,
2558    /// or the composite node that is parented by this node.
2559    /// For a successfully started driver this returns immediately with the token of the
2560    /// node that the driver started on.
2561    /// If an error happens we wait until bootup is complete, which is when all drivers that
2562    /// can bind and start have done so, before returning the error.
2563    WaitForDriver { responder: NodeControllerWaitForDriverResponder },
2564    /// An interaction was received which does not match any known method.
2565    #[non_exhaustive]
2566    _UnknownMethod {
2567        /// Ordinal of the method that was called.
2568        ordinal: u64,
2569        control_handle: NodeControllerControlHandle,
2570        method_type: fidl::MethodType,
2571    },
2572}
2573
2574impl NodeControllerRequest {
2575    #[allow(irrefutable_let_patterns)]
2576    pub fn into_remove(self) -> Option<(NodeControllerControlHandle)> {
2577        if let NodeControllerRequest::Remove { control_handle } = self {
2578            Some((control_handle))
2579        } else {
2580            None
2581        }
2582    }
2583
2584    #[allow(irrefutable_let_patterns)]
2585    pub fn into_request_bind(
2586        self,
2587    ) -> Option<(NodeControllerRequestBindRequest, NodeControllerRequestBindResponder)> {
2588        if let NodeControllerRequest::RequestBind { payload, responder } = self {
2589            Some((payload, responder))
2590        } else {
2591            None
2592        }
2593    }
2594
2595    #[allow(irrefutable_let_patterns)]
2596    pub fn into_wait_for_driver(self) -> Option<(NodeControllerWaitForDriverResponder)> {
2597        if let NodeControllerRequest::WaitForDriver { responder } = self {
2598            Some((responder))
2599        } else {
2600            None
2601        }
2602    }
2603
2604    /// Name of the method defined in FIDL
2605    pub fn method_name(&self) -> &'static str {
2606        match *self {
2607            NodeControllerRequest::Remove { .. } => "remove",
2608            NodeControllerRequest::RequestBind { .. } => "request_bind",
2609            NodeControllerRequest::WaitForDriver { .. } => "wait_for_driver",
2610            NodeControllerRequest::_UnknownMethod {
2611                method_type: fidl::MethodType::OneWay, ..
2612            } => "unknown one-way method",
2613            NodeControllerRequest::_UnknownMethod {
2614                method_type: fidl::MethodType::TwoWay, ..
2615            } => "unknown two-way method",
2616        }
2617    }
2618}
2619
2620#[derive(Debug, Clone)]
2621pub struct NodeControllerControlHandle {
2622    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2623}
2624
2625impl fidl::endpoints::ControlHandle for NodeControllerControlHandle {
2626    fn shutdown(&self) {
2627        self.inner.shutdown()
2628    }
2629
2630    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2631        self.inner.shutdown_with_epitaph(status)
2632    }
2633
2634    fn is_closed(&self) -> bool {
2635        self.inner.channel().is_closed()
2636    }
2637    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2638        self.inner.channel().on_closed()
2639    }
2640
2641    #[cfg(target_os = "fuchsia")]
2642    fn signal_peer(
2643        &self,
2644        clear_mask: zx::Signals,
2645        set_mask: zx::Signals,
2646    ) -> Result<(), zx_status::Status> {
2647        use fidl::Peered;
2648        self.inner.channel().signal_peer(clear_mask, set_mask)
2649    }
2650}
2651
2652impl NodeControllerControlHandle {
2653    pub fn send_on_bind(
2654        &self,
2655        mut payload: NodeControllerOnBindRequest,
2656    ) -> Result<(), fidl::Error> {
2657        self.inner.send::<NodeControllerOnBindRequest>(
2658            &mut payload,
2659            0,
2660            0x51f4165bc5ea202a,
2661            fidl::encoding::DynamicFlags::FLEXIBLE,
2662        )
2663    }
2664}
2665
2666#[must_use = "FIDL methods require a response to be sent"]
2667#[derive(Debug)]
2668pub struct NodeControllerRequestBindResponder {
2669    control_handle: std::mem::ManuallyDrop<NodeControllerControlHandle>,
2670    tx_id: u32,
2671}
2672
2673/// Set the the channel to be shutdown (see [`NodeControllerControlHandle::shutdown`])
2674/// if the responder is dropped without sending a response, so that the client
2675/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2676impl std::ops::Drop for NodeControllerRequestBindResponder {
2677    fn drop(&mut self) {
2678        self.control_handle.shutdown();
2679        // Safety: drops once, never accessed again
2680        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2681    }
2682}
2683
2684impl fidl::endpoints::Responder for NodeControllerRequestBindResponder {
2685    type ControlHandle = NodeControllerControlHandle;
2686
2687    fn control_handle(&self) -> &NodeControllerControlHandle {
2688        &self.control_handle
2689    }
2690
2691    fn drop_without_shutdown(mut self) {
2692        // Safety: drops once, never accessed again due to mem::forget
2693        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2694        // Prevent Drop from running (which would shut down the channel)
2695        std::mem::forget(self);
2696    }
2697}
2698
2699impl NodeControllerRequestBindResponder {
2700    /// Sends a response to the FIDL transaction.
2701    ///
2702    /// Sets the channel to shutdown if an error occurs.
2703    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2704        let _result = self.send_raw(result);
2705        if _result.is_err() {
2706            self.control_handle.shutdown();
2707        }
2708        self.drop_without_shutdown();
2709        _result
2710    }
2711
2712    /// Similar to "send" but does not shutdown the channel if an error occurs.
2713    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2714        let _result = self.send_raw(result);
2715        self.drop_without_shutdown();
2716        _result
2717    }
2718
2719    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2720        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2721            fidl::encoding::EmptyStruct,
2722            i32,
2723        >>(
2724            fidl::encoding::FlexibleResult::new(result),
2725            self.tx_id,
2726            0x41b954726b13508f,
2727            fidl::encoding::DynamicFlags::FLEXIBLE,
2728        )
2729    }
2730}
2731
2732#[must_use = "FIDL methods require a response to be sent"]
2733#[derive(Debug)]
2734pub struct NodeControllerWaitForDriverResponder {
2735    control_handle: std::mem::ManuallyDrop<NodeControllerControlHandle>,
2736    tx_id: u32,
2737}
2738
2739/// Set the the channel to be shutdown (see [`NodeControllerControlHandle::shutdown`])
2740/// if the responder is dropped without sending a response, so that the client
2741/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2742impl std::ops::Drop for NodeControllerWaitForDriverResponder {
2743    fn drop(&mut self) {
2744        self.control_handle.shutdown();
2745        // Safety: drops once, never accessed again
2746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2747    }
2748}
2749
2750impl fidl::endpoints::Responder for NodeControllerWaitForDriverResponder {
2751    type ControlHandle = NodeControllerControlHandle;
2752
2753    fn control_handle(&self) -> &NodeControllerControlHandle {
2754        &self.control_handle
2755    }
2756
2757    fn drop_without_shutdown(mut self) {
2758        // Safety: drops once, never accessed again due to mem::forget
2759        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2760        // Prevent Drop from running (which would shut down the channel)
2761        std::mem::forget(self);
2762    }
2763}
2764
2765impl NodeControllerWaitForDriverResponder {
2766    /// Sends a response to the FIDL transaction.
2767    ///
2768    /// Sets the channel to shutdown if an error occurs.
2769    pub fn send(self, mut result: Result<DriverResult, i32>) -> Result<(), fidl::Error> {
2770        let _result = self.send_raw(result);
2771        if _result.is_err() {
2772            self.control_handle.shutdown();
2773        }
2774        self.drop_without_shutdown();
2775        _result
2776    }
2777
2778    /// Similar to "send" but does not shutdown the channel if an error occurs.
2779    pub fn send_no_shutdown_on_err(
2780        self,
2781        mut result: Result<DriverResult, i32>,
2782    ) -> Result<(), fidl::Error> {
2783        let _result = self.send_raw(result);
2784        self.drop_without_shutdown();
2785        _result
2786    }
2787
2788    fn send_raw(&self, mut result: Result<DriverResult, i32>) -> Result<(), fidl::Error> {
2789        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<DriverResult, i32>>(
2790            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
2791            self.tx_id,
2792            0x69f7106e47d81387,
2793            fidl::encoding::DynamicFlags::FLEXIBLE,
2794        )
2795    }
2796}
2797
2798#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2799pub struct NodeManagerMarker;
2800
2801impl fidl::endpoints::ProtocolMarker for NodeManagerMarker {
2802    type Proxy = NodeManagerProxy;
2803    type RequestStream = NodeManagerRequestStream;
2804    #[cfg(target_os = "fuchsia")]
2805    type SynchronousProxy = NodeManagerSynchronousProxy;
2806
2807    const DEBUG_NAME: &'static str = "fuchsia.driver.framework.NodeManager";
2808}
2809impl fidl::endpoints::DiscoverableProtocolMarker for NodeManagerMarker {}
2810pub type NodeManagerAddNodeResult = Result<(), NodeError>;
2811
2812pub trait NodeManagerProxyInterface: Send + Sync {
2813    type AddNodeResponseFut: std::future::Future<Output = Result<NodeManagerAddNodeResult, fidl::Error>>
2814        + Send;
2815    fn r#add_node(
2816        &self,
2817        node: &Node2,
2818        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
2819        node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
2820    ) -> Self::AddNodeResponseFut;
2821}
2822#[derive(Debug)]
2823#[cfg(target_os = "fuchsia")]
2824pub struct NodeManagerSynchronousProxy {
2825    client: fidl::client::sync::Client,
2826}
2827
2828#[cfg(target_os = "fuchsia")]
2829impl fidl::endpoints::SynchronousProxy for NodeManagerSynchronousProxy {
2830    type Proxy = NodeManagerProxy;
2831    type Protocol = NodeManagerMarker;
2832
2833    fn from_channel(inner: fidl::Channel) -> Self {
2834        Self::new(inner)
2835    }
2836
2837    fn into_channel(self) -> fidl::Channel {
2838        self.client.into_channel()
2839    }
2840
2841    fn as_channel(&self) -> &fidl::Channel {
2842        self.client.as_channel()
2843    }
2844}
2845
2846#[cfg(target_os = "fuchsia")]
2847impl NodeManagerSynchronousProxy {
2848    pub fn new(channel: fidl::Channel) -> Self {
2849        Self { client: fidl::client::sync::Client::new(channel) }
2850    }
2851
2852    pub fn into_channel(self) -> fidl::Channel {
2853        self.client.into_channel()
2854    }
2855
2856    /// Waits until an event arrives and returns it. It is safe for other
2857    /// threads to make concurrent requests while waiting for an event.
2858    pub fn wait_for_event(
2859        &self,
2860        deadline: zx::MonotonicInstant,
2861    ) -> Result<NodeManagerEvent, fidl::Error> {
2862        NodeManagerEvent::decode(self.client.wait_for_event::<NodeManagerMarker>(deadline)?)
2863    }
2864
2865    /// Adds a Node2 to the driver framework.
2866    pub fn r#add_node(
2867        &self,
2868        mut node: &Node2,
2869        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
2870        mut node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
2871        ___deadline: zx::MonotonicInstant,
2872    ) -> Result<NodeManagerAddNodeResult, fidl::Error> {
2873        let _response = self.client.send_query::<
2874            NodeManagerAddNodeRequest,
2875            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
2876            NodeManagerMarker,
2877        >(
2878            (node, controller, node_ref,),
2879            0x71873eed0baf16fd,
2880            fidl::encoding::DynamicFlags::FLEXIBLE,
2881            ___deadline,
2882        )?
2883        .into_result::<NodeManagerMarker>("add_node")?;
2884        Ok(_response.map(|x| x))
2885    }
2886}
2887
2888#[cfg(target_os = "fuchsia")]
2889impl From<NodeManagerSynchronousProxy> for zx::NullableHandle {
2890    fn from(value: NodeManagerSynchronousProxy) -> Self {
2891        value.into_channel().into()
2892    }
2893}
2894
2895#[cfg(target_os = "fuchsia")]
2896impl From<fidl::Channel> for NodeManagerSynchronousProxy {
2897    fn from(value: fidl::Channel) -> Self {
2898        Self::new(value)
2899    }
2900}
2901
2902#[cfg(target_os = "fuchsia")]
2903impl fidl::endpoints::FromClient for NodeManagerSynchronousProxy {
2904    type Protocol = NodeManagerMarker;
2905
2906    fn from_client(value: fidl::endpoints::ClientEnd<NodeManagerMarker>) -> Self {
2907        Self::new(value.into_channel())
2908    }
2909}
2910
2911#[derive(Debug, Clone)]
2912pub struct NodeManagerProxy {
2913    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2914}
2915
2916impl fidl::endpoints::Proxy for NodeManagerProxy {
2917    type Protocol = NodeManagerMarker;
2918
2919    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2920        Self::new(inner)
2921    }
2922
2923    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2924        self.client.into_channel().map_err(|client| Self { client })
2925    }
2926
2927    fn as_channel(&self) -> &::fidl::AsyncChannel {
2928        self.client.as_channel()
2929    }
2930}
2931
2932impl NodeManagerProxy {
2933    /// Create a new Proxy for fuchsia.driver.framework/NodeManager.
2934    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2935        let protocol_name = <NodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2936        Self { client: fidl::client::Client::new(channel, protocol_name) }
2937    }
2938
2939    /// Get a Stream of events from the remote end of the protocol.
2940    ///
2941    /// # Panics
2942    ///
2943    /// Panics if the event stream was already taken.
2944    pub fn take_event_stream(&self) -> NodeManagerEventStream {
2945        NodeManagerEventStream { event_receiver: self.client.take_event_receiver() }
2946    }
2947
2948    /// Adds a Node2 to the driver framework.
2949    pub fn r#add_node(
2950        &self,
2951        mut node: &Node2,
2952        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
2953        mut node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
2954    ) -> fidl::client::QueryResponseFut<
2955        NodeManagerAddNodeResult,
2956        fidl::encoding::DefaultFuchsiaResourceDialect,
2957    > {
2958        NodeManagerProxyInterface::r#add_node(self, node, controller, node_ref)
2959    }
2960}
2961
2962impl NodeManagerProxyInterface for NodeManagerProxy {
2963    type AddNodeResponseFut = fidl::client::QueryResponseFut<
2964        NodeManagerAddNodeResult,
2965        fidl::encoding::DefaultFuchsiaResourceDialect,
2966    >;
2967    fn r#add_node(
2968        &self,
2969        mut node: &Node2,
2970        mut controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
2971        mut node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
2972    ) -> Self::AddNodeResponseFut {
2973        fn _decode(
2974            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2975        ) -> Result<NodeManagerAddNodeResult, fidl::Error> {
2976            let _response = fidl::client::decode_transaction_body::<
2977                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, NodeError>,
2978                fidl::encoding::DefaultFuchsiaResourceDialect,
2979                0x71873eed0baf16fd,
2980            >(_buf?)?
2981            .into_result::<NodeManagerMarker>("add_node")?;
2982            Ok(_response.map(|x| x))
2983        }
2984        self.client.send_query_and_decode::<NodeManagerAddNodeRequest, NodeManagerAddNodeResult>(
2985            (node, controller, node_ref),
2986            0x71873eed0baf16fd,
2987            fidl::encoding::DynamicFlags::FLEXIBLE,
2988            _decode,
2989        )
2990    }
2991}
2992
2993pub struct NodeManagerEventStream {
2994    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2995}
2996
2997impl std::marker::Unpin for NodeManagerEventStream {}
2998
2999impl futures::stream::FusedStream for NodeManagerEventStream {
3000    fn is_terminated(&self) -> bool {
3001        self.event_receiver.is_terminated()
3002    }
3003}
3004
3005impl futures::Stream for NodeManagerEventStream {
3006    type Item = Result<NodeManagerEvent, fidl::Error>;
3007
3008    fn poll_next(
3009        mut self: std::pin::Pin<&mut Self>,
3010        cx: &mut std::task::Context<'_>,
3011    ) -> std::task::Poll<Option<Self::Item>> {
3012        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3013            &mut self.event_receiver,
3014            cx
3015        )?) {
3016            Some(buf) => std::task::Poll::Ready(Some(NodeManagerEvent::decode(buf))),
3017            None => std::task::Poll::Ready(None),
3018        }
3019    }
3020}
3021
3022#[derive(Debug)]
3023pub enum NodeManagerEvent {
3024    #[non_exhaustive]
3025    _UnknownEvent {
3026        /// Ordinal of the event that was sent.
3027        ordinal: u64,
3028    },
3029}
3030
3031impl NodeManagerEvent {
3032    /// Decodes a message buffer as a [`NodeManagerEvent`].
3033    fn decode(
3034        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3035    ) -> Result<NodeManagerEvent, fidl::Error> {
3036        let (bytes, _handles) = buf.split_mut();
3037        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3038        debug_assert_eq!(tx_header.tx_id, 0);
3039        match tx_header.ordinal {
3040            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3041                Ok(NodeManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3042            }
3043            _ => Err(fidl::Error::UnknownOrdinal {
3044                ordinal: tx_header.ordinal,
3045                protocol_name: <NodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3046            }),
3047        }
3048    }
3049}
3050
3051/// A Stream of incoming requests for fuchsia.driver.framework/NodeManager.
3052pub struct NodeManagerRequestStream {
3053    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3054    is_terminated: bool,
3055}
3056
3057impl std::marker::Unpin for NodeManagerRequestStream {}
3058
3059impl futures::stream::FusedStream for NodeManagerRequestStream {
3060    fn is_terminated(&self) -> bool {
3061        self.is_terminated
3062    }
3063}
3064
3065impl fidl::endpoints::RequestStream for NodeManagerRequestStream {
3066    type Protocol = NodeManagerMarker;
3067    type ControlHandle = NodeManagerControlHandle;
3068
3069    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3070        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3071    }
3072
3073    fn control_handle(&self) -> Self::ControlHandle {
3074        NodeManagerControlHandle { inner: self.inner.clone() }
3075    }
3076
3077    fn into_inner(
3078        self,
3079    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3080    {
3081        (self.inner, self.is_terminated)
3082    }
3083
3084    fn from_inner(
3085        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3086        is_terminated: bool,
3087    ) -> Self {
3088        Self { inner, is_terminated }
3089    }
3090}
3091
3092impl futures::Stream for NodeManagerRequestStream {
3093    type Item = Result<NodeManagerRequest, fidl::Error>;
3094
3095    fn poll_next(
3096        mut self: std::pin::Pin<&mut Self>,
3097        cx: &mut std::task::Context<'_>,
3098    ) -> std::task::Poll<Option<Self::Item>> {
3099        let this = &mut *self;
3100        if this.inner.check_shutdown(cx) {
3101            this.is_terminated = true;
3102            return std::task::Poll::Ready(None);
3103        }
3104        if this.is_terminated {
3105            panic!("polled NodeManagerRequestStream after completion");
3106        }
3107        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3108            |bytes, handles| {
3109                match this.inner.channel().read_etc(cx, bytes, handles) {
3110                    std::task::Poll::Ready(Ok(())) => {}
3111                    std::task::Poll::Pending => return std::task::Poll::Pending,
3112                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3113                        this.is_terminated = true;
3114                        return std::task::Poll::Ready(None);
3115                    }
3116                    std::task::Poll::Ready(Err(e)) => {
3117                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3118                            e.into(),
3119                        ))));
3120                    }
3121                }
3122
3123                // A message has been received from the channel
3124                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3125
3126                std::task::Poll::Ready(Some(match header.ordinal {
3127                    0x71873eed0baf16fd => {
3128                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3129                        let mut req = fidl::new_empty!(
3130                            NodeManagerAddNodeRequest,
3131                            fidl::encoding::DefaultFuchsiaResourceDialect
3132                        );
3133                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NodeManagerAddNodeRequest>(&header, _body_bytes, handles, &mut req)?;
3134                        let control_handle = NodeManagerControlHandle { inner: this.inner.clone() };
3135                        Ok(NodeManagerRequest::AddNode {
3136                            node: req.node,
3137                            controller: req.controller,
3138                            node_ref: req.node_ref,
3139
3140                            responder: NodeManagerAddNodeResponder {
3141                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3142                                tx_id: header.tx_id,
3143                            },
3144                        })
3145                    }
3146                    _ if header.tx_id == 0
3147                        && header
3148                            .dynamic_flags()
3149                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3150                    {
3151                        Ok(NodeManagerRequest::_UnknownMethod {
3152                            ordinal: header.ordinal,
3153                            control_handle: NodeManagerControlHandle { inner: this.inner.clone() },
3154                            method_type: fidl::MethodType::OneWay,
3155                        })
3156                    }
3157                    _ if header
3158                        .dynamic_flags()
3159                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3160                    {
3161                        this.inner.send_framework_err(
3162                            fidl::encoding::FrameworkErr::UnknownMethod,
3163                            header.tx_id,
3164                            header.ordinal,
3165                            header.dynamic_flags(),
3166                            (bytes, handles),
3167                        )?;
3168                        Ok(NodeManagerRequest::_UnknownMethod {
3169                            ordinal: header.ordinal,
3170                            control_handle: NodeManagerControlHandle { inner: this.inner.clone() },
3171                            method_type: fidl::MethodType::TwoWay,
3172                        })
3173                    }
3174                    _ => Err(fidl::Error::UnknownOrdinal {
3175                        ordinal: header.ordinal,
3176                        protocol_name:
3177                            <NodeManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3178                    }),
3179                }))
3180            },
3181        )
3182    }
3183}
3184
3185/// Protocol through which a client can add a Node2 to the driver topology.
3186#[derive(Debug)]
3187pub enum NodeManagerRequest {
3188    /// Adds a Node2 to the driver framework.
3189    AddNode {
3190        node: Node2,
3191        controller: fidl::endpoints::ServerEnd<NodeControllerMarker>,
3192        node_ref: Option<fidl::endpoints::ServerEnd<NodeMarker>>,
3193        responder: NodeManagerAddNodeResponder,
3194    },
3195    /// An interaction was received which does not match any known method.
3196    #[non_exhaustive]
3197    _UnknownMethod {
3198        /// Ordinal of the method that was called.
3199        ordinal: u64,
3200        control_handle: NodeManagerControlHandle,
3201        method_type: fidl::MethodType,
3202    },
3203}
3204
3205impl NodeManagerRequest {
3206    #[allow(irrefutable_let_patterns)]
3207    pub fn into_add_node(
3208        self,
3209    ) -> Option<(
3210        Node2,
3211        fidl::endpoints::ServerEnd<NodeControllerMarker>,
3212        Option<fidl::endpoints::ServerEnd<NodeMarker>>,
3213        NodeManagerAddNodeResponder,
3214    )> {
3215        if let NodeManagerRequest::AddNode { node, controller, node_ref, responder } = self {
3216            Some((node, controller, node_ref, responder))
3217        } else {
3218            None
3219        }
3220    }
3221
3222    /// Name of the method defined in FIDL
3223    pub fn method_name(&self) -> &'static str {
3224        match *self {
3225            NodeManagerRequest::AddNode { .. } => "add_node",
3226            NodeManagerRequest::_UnknownMethod {
3227                method_type: fidl::MethodType::OneWay, ..
3228            } => "unknown one-way method",
3229            NodeManagerRequest::_UnknownMethod {
3230                method_type: fidl::MethodType::TwoWay, ..
3231            } => "unknown two-way method",
3232        }
3233    }
3234}
3235
3236#[derive(Debug, Clone)]
3237pub struct NodeManagerControlHandle {
3238    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3239}
3240
3241impl fidl::endpoints::ControlHandle for NodeManagerControlHandle {
3242    fn shutdown(&self) {
3243        self.inner.shutdown()
3244    }
3245
3246    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3247        self.inner.shutdown_with_epitaph(status)
3248    }
3249
3250    fn is_closed(&self) -> bool {
3251        self.inner.channel().is_closed()
3252    }
3253    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3254        self.inner.channel().on_closed()
3255    }
3256
3257    #[cfg(target_os = "fuchsia")]
3258    fn signal_peer(
3259        &self,
3260        clear_mask: zx::Signals,
3261        set_mask: zx::Signals,
3262    ) -> Result<(), zx_status::Status> {
3263        use fidl::Peered;
3264        self.inner.channel().signal_peer(clear_mask, set_mask)
3265    }
3266}
3267
3268impl NodeManagerControlHandle {}
3269
3270#[must_use = "FIDL methods require a response to be sent"]
3271#[derive(Debug)]
3272pub struct NodeManagerAddNodeResponder {
3273    control_handle: std::mem::ManuallyDrop<NodeManagerControlHandle>,
3274    tx_id: u32,
3275}
3276
3277/// Set the the channel to be shutdown (see [`NodeManagerControlHandle::shutdown`])
3278/// if the responder is dropped without sending a response, so that the client
3279/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3280impl std::ops::Drop for NodeManagerAddNodeResponder {
3281    fn drop(&mut self) {
3282        self.control_handle.shutdown();
3283        // Safety: drops once, never accessed again
3284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3285    }
3286}
3287
3288impl fidl::endpoints::Responder for NodeManagerAddNodeResponder {
3289    type ControlHandle = NodeManagerControlHandle;
3290
3291    fn control_handle(&self) -> &NodeManagerControlHandle {
3292        &self.control_handle
3293    }
3294
3295    fn drop_without_shutdown(mut self) {
3296        // Safety: drops once, never accessed again due to mem::forget
3297        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3298        // Prevent Drop from running (which would shut down the channel)
3299        std::mem::forget(self);
3300    }
3301}
3302
3303impl NodeManagerAddNodeResponder {
3304    /// Sends a response to the FIDL transaction.
3305    ///
3306    /// Sets the channel to shutdown if an error occurs.
3307    pub fn send(self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
3308        let _result = self.send_raw(result);
3309        if _result.is_err() {
3310            self.control_handle.shutdown();
3311        }
3312        self.drop_without_shutdown();
3313        _result
3314    }
3315
3316    /// Similar to "send" but does not shutdown the channel if an error occurs.
3317    pub fn send_no_shutdown_on_err(
3318        self,
3319        mut result: Result<(), NodeError>,
3320    ) -> Result<(), fidl::Error> {
3321        let _result = self.send_raw(result);
3322        self.drop_without_shutdown();
3323        _result
3324    }
3325
3326    fn send_raw(&self, mut result: Result<(), NodeError>) -> Result<(), fidl::Error> {
3327        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3328            fidl::encoding::EmptyStruct,
3329            NodeError,
3330        >>(
3331            fidl::encoding::FlexibleResult::new(result),
3332            self.tx_id,
3333            0x71873eed0baf16fd,
3334            fidl::encoding::DynamicFlags::FLEXIBLE,
3335        )
3336    }
3337}
3338
3339#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3340pub struct ResourceControllerMarker;
3341
3342impl fidl::endpoints::ProtocolMarker for ResourceControllerMarker {
3343    type Proxy = ResourceControllerProxy;
3344    type RequestStream = ResourceControllerRequestStream;
3345    #[cfg(target_os = "fuchsia")]
3346    type SynchronousProxy = ResourceControllerSynchronousProxy;
3347
3348    const DEBUG_NAME: &'static str = "(anonymous) ResourceController";
3349}
3350
3351pub trait ResourceControllerProxyInterface: Send + Sync {
3352    fn r#remove(&self) -> Result<(), fidl::Error>;
3353}
3354#[derive(Debug)]
3355#[cfg(target_os = "fuchsia")]
3356pub struct ResourceControllerSynchronousProxy {
3357    client: fidl::client::sync::Client,
3358}
3359
3360#[cfg(target_os = "fuchsia")]
3361impl fidl::endpoints::SynchronousProxy for ResourceControllerSynchronousProxy {
3362    type Proxy = ResourceControllerProxy;
3363    type Protocol = ResourceControllerMarker;
3364
3365    fn from_channel(inner: fidl::Channel) -> Self {
3366        Self::new(inner)
3367    }
3368
3369    fn into_channel(self) -> fidl::Channel {
3370        self.client.into_channel()
3371    }
3372
3373    fn as_channel(&self) -> &fidl::Channel {
3374        self.client.as_channel()
3375    }
3376}
3377
3378#[cfg(target_os = "fuchsia")]
3379impl ResourceControllerSynchronousProxy {
3380    pub fn new(channel: fidl::Channel) -> Self {
3381        Self { client: fidl::client::sync::Client::new(channel) }
3382    }
3383
3384    pub fn into_channel(self) -> fidl::Channel {
3385        self.client.into_channel()
3386    }
3387
3388    /// Waits until an event arrives and returns it. It is safe for other
3389    /// threads to make concurrent requests while waiting for an event.
3390    pub fn wait_for_event(
3391        &self,
3392        deadline: zx::MonotonicInstant,
3393    ) -> Result<ResourceControllerEvent, fidl::Error> {
3394        ResourceControllerEvent::decode(
3395            self.client.wait_for_event::<ResourceControllerMarker>(deadline)?,
3396        )
3397    }
3398
3399    /// Removes the resource.
3400    pub fn r#remove(&self) -> Result<(), fidl::Error> {
3401        self.client.send::<fidl::encoding::EmptyPayload>(
3402            (),
3403            0x1257bec06bde4f98,
3404            fidl::encoding::DynamicFlags::FLEXIBLE,
3405        )
3406    }
3407}
3408
3409#[cfg(target_os = "fuchsia")]
3410impl From<ResourceControllerSynchronousProxy> for zx::NullableHandle {
3411    fn from(value: ResourceControllerSynchronousProxy) -> Self {
3412        value.into_channel().into()
3413    }
3414}
3415
3416#[cfg(target_os = "fuchsia")]
3417impl From<fidl::Channel> for ResourceControllerSynchronousProxy {
3418    fn from(value: fidl::Channel) -> Self {
3419        Self::new(value)
3420    }
3421}
3422
3423#[cfg(target_os = "fuchsia")]
3424impl fidl::endpoints::FromClient for ResourceControllerSynchronousProxy {
3425    type Protocol = ResourceControllerMarker;
3426
3427    fn from_client(value: fidl::endpoints::ClientEnd<ResourceControllerMarker>) -> Self {
3428        Self::new(value.into_channel())
3429    }
3430}
3431
3432#[derive(Debug, Clone)]
3433pub struct ResourceControllerProxy {
3434    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3435}
3436
3437impl fidl::endpoints::Proxy for ResourceControllerProxy {
3438    type Protocol = ResourceControllerMarker;
3439
3440    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3441        Self::new(inner)
3442    }
3443
3444    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3445        self.client.into_channel().map_err(|client| Self { client })
3446    }
3447
3448    fn as_channel(&self) -> &::fidl::AsyncChannel {
3449        self.client.as_channel()
3450    }
3451}
3452
3453impl ResourceControllerProxy {
3454    /// Create a new Proxy for fuchsia.driver.framework/ResourceController.
3455    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3456        let protocol_name =
3457            <ResourceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3458        Self { client: fidl::client::Client::new(channel, protocol_name) }
3459    }
3460
3461    /// Get a Stream of events from the remote end of the protocol.
3462    ///
3463    /// # Panics
3464    ///
3465    /// Panics if the event stream was already taken.
3466    pub fn take_event_stream(&self) -> ResourceControllerEventStream {
3467        ResourceControllerEventStream { event_receiver: self.client.take_event_receiver() }
3468    }
3469
3470    /// Removes the resource.
3471    pub fn r#remove(&self) -> Result<(), fidl::Error> {
3472        ResourceControllerProxyInterface::r#remove(self)
3473    }
3474}
3475
3476impl ResourceControllerProxyInterface for ResourceControllerProxy {
3477    fn r#remove(&self) -> Result<(), fidl::Error> {
3478        self.client.send::<fidl::encoding::EmptyPayload>(
3479            (),
3480            0x1257bec06bde4f98,
3481            fidl::encoding::DynamicFlags::FLEXIBLE,
3482        )
3483    }
3484}
3485
3486pub struct ResourceControllerEventStream {
3487    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3488}
3489
3490impl std::marker::Unpin for ResourceControllerEventStream {}
3491
3492impl futures::stream::FusedStream for ResourceControllerEventStream {
3493    fn is_terminated(&self) -> bool {
3494        self.event_receiver.is_terminated()
3495    }
3496}
3497
3498impl futures::Stream for ResourceControllerEventStream {
3499    type Item = Result<ResourceControllerEvent, fidl::Error>;
3500
3501    fn poll_next(
3502        mut self: std::pin::Pin<&mut Self>,
3503        cx: &mut std::task::Context<'_>,
3504    ) -> std::task::Poll<Option<Self::Item>> {
3505        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3506            &mut self.event_receiver,
3507            cx
3508        )?) {
3509            Some(buf) => std::task::Poll::Ready(Some(ResourceControllerEvent::decode(buf))),
3510            None => std::task::Poll::Ready(None),
3511        }
3512    }
3513}
3514
3515#[derive(Debug)]
3516pub enum ResourceControllerEvent {
3517    #[non_exhaustive]
3518    _UnknownEvent {
3519        /// Ordinal of the event that was sent.
3520        ordinal: u64,
3521    },
3522}
3523
3524impl ResourceControllerEvent {
3525    /// Decodes a message buffer as a [`ResourceControllerEvent`].
3526    fn decode(
3527        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3528    ) -> Result<ResourceControllerEvent, fidl::Error> {
3529        let (bytes, _handles) = buf.split_mut();
3530        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3531        debug_assert_eq!(tx_header.tx_id, 0);
3532        match tx_header.ordinal {
3533            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3534                Ok(ResourceControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3535            }
3536            _ => Err(fidl::Error::UnknownOrdinal {
3537                ordinal: tx_header.ordinal,
3538                protocol_name:
3539                    <ResourceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3540            }),
3541        }
3542    }
3543}
3544
3545/// A Stream of incoming requests for fuchsia.driver.framework/ResourceController.
3546pub struct ResourceControllerRequestStream {
3547    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3548    is_terminated: bool,
3549}
3550
3551impl std::marker::Unpin for ResourceControllerRequestStream {}
3552
3553impl futures::stream::FusedStream for ResourceControllerRequestStream {
3554    fn is_terminated(&self) -> bool {
3555        self.is_terminated
3556    }
3557}
3558
3559impl fidl::endpoints::RequestStream for ResourceControllerRequestStream {
3560    type Protocol = ResourceControllerMarker;
3561    type ControlHandle = ResourceControllerControlHandle;
3562
3563    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3564        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3565    }
3566
3567    fn control_handle(&self) -> Self::ControlHandle {
3568        ResourceControllerControlHandle { inner: self.inner.clone() }
3569    }
3570
3571    fn into_inner(
3572        self,
3573    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3574    {
3575        (self.inner, self.is_terminated)
3576    }
3577
3578    fn from_inner(
3579        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3580        is_terminated: bool,
3581    ) -> Self {
3582        Self { inner, is_terminated }
3583    }
3584}
3585
3586impl futures::Stream for ResourceControllerRequestStream {
3587    type Item = Result<ResourceControllerRequest, fidl::Error>;
3588
3589    fn poll_next(
3590        mut self: std::pin::Pin<&mut Self>,
3591        cx: &mut std::task::Context<'_>,
3592    ) -> std::task::Poll<Option<Self::Item>> {
3593        let this = &mut *self;
3594        if this.inner.check_shutdown(cx) {
3595            this.is_terminated = true;
3596            return std::task::Poll::Ready(None);
3597        }
3598        if this.is_terminated {
3599            panic!("polled ResourceControllerRequestStream after completion");
3600        }
3601        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3602            |bytes, handles| {
3603                match this.inner.channel().read_etc(cx, bytes, handles) {
3604                    std::task::Poll::Ready(Ok(())) => {}
3605                    std::task::Poll::Pending => return std::task::Poll::Pending,
3606                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3607                        this.is_terminated = true;
3608                        return std::task::Poll::Ready(None);
3609                    }
3610                    std::task::Poll::Ready(Err(e)) => {
3611                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3612                            e.into(),
3613                        ))));
3614                    }
3615                }
3616
3617                // A message has been received from the channel
3618                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3619
3620                std::task::Poll::Ready(Some(match header.ordinal {
3621                0x1257bec06bde4f98 => {
3622                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3623                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
3624                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3625                    let control_handle = ResourceControllerControlHandle {
3626                        inner: this.inner.clone(),
3627                    };
3628                    Ok(ResourceControllerRequest::Remove {
3629                        control_handle,
3630                    })
3631                }
3632                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3633                    Ok(ResourceControllerRequest::_UnknownMethod {
3634                        ordinal: header.ordinal,
3635                        control_handle: ResourceControllerControlHandle { inner: this.inner.clone() },
3636                        method_type: fidl::MethodType::OneWay,
3637                    })
3638                }
3639                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3640                    this.inner.send_framework_err(
3641                        fidl::encoding::FrameworkErr::UnknownMethod,
3642                        header.tx_id,
3643                        header.ordinal,
3644                        header.dynamic_flags(),
3645                        (bytes, handles),
3646                    )?;
3647                    Ok(ResourceControllerRequest::_UnknownMethod {
3648                        ordinal: header.ordinal,
3649                        control_handle: ResourceControllerControlHandle { inner: this.inner.clone() },
3650                        method_type: fidl::MethodType::TwoWay,
3651                    })
3652                }
3653                _ => Err(fidl::Error::UnknownOrdinal {
3654                    ordinal: header.ordinal,
3655                    protocol_name: <ResourceControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3656                }),
3657            }))
3658            },
3659        )
3660    }
3661}
3662
3663/// Protocol through which the resource's provider can use to control it.
3664#[derive(Debug)]
3665pub enum ResourceControllerRequest {
3666    /// Removes the resource.
3667    Remove { control_handle: ResourceControllerControlHandle },
3668    /// An interaction was received which does not match any known method.
3669    #[non_exhaustive]
3670    _UnknownMethod {
3671        /// Ordinal of the method that was called.
3672        ordinal: u64,
3673        control_handle: ResourceControllerControlHandle,
3674        method_type: fidl::MethodType,
3675    },
3676}
3677
3678impl ResourceControllerRequest {
3679    #[allow(irrefutable_let_patterns)]
3680    pub fn into_remove(self) -> Option<(ResourceControllerControlHandle)> {
3681        if let ResourceControllerRequest::Remove { control_handle } = self {
3682            Some((control_handle))
3683        } else {
3684            None
3685        }
3686    }
3687
3688    /// Name of the method defined in FIDL
3689    pub fn method_name(&self) -> &'static str {
3690        match *self {
3691            ResourceControllerRequest::Remove { .. } => "remove",
3692            ResourceControllerRequest::_UnknownMethod {
3693                method_type: fidl::MethodType::OneWay,
3694                ..
3695            } => "unknown one-way method",
3696            ResourceControllerRequest::_UnknownMethod {
3697                method_type: fidl::MethodType::TwoWay,
3698                ..
3699            } => "unknown two-way method",
3700        }
3701    }
3702}
3703
3704#[derive(Debug, Clone)]
3705pub struct ResourceControllerControlHandle {
3706    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3707}
3708
3709impl fidl::endpoints::ControlHandle for ResourceControllerControlHandle {
3710    fn shutdown(&self) {
3711        self.inner.shutdown()
3712    }
3713
3714    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3715        self.inner.shutdown_with_epitaph(status)
3716    }
3717
3718    fn is_closed(&self) -> bool {
3719        self.inner.channel().is_closed()
3720    }
3721    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3722        self.inner.channel().on_closed()
3723    }
3724
3725    #[cfg(target_os = "fuchsia")]
3726    fn signal_peer(
3727        &self,
3728        clear_mask: zx::Signals,
3729        set_mask: zx::Signals,
3730    ) -> Result<(), zx_status::Status> {
3731        use fidl::Peered;
3732        self.inner.channel().signal_peer(clear_mask, set_mask)
3733    }
3734}
3735
3736impl ResourceControllerControlHandle {}
3737
3738mod internal {
3739    use super::*;
3740
3741    impl fidl::encoding::ResourceTypeMarker for DriverResumeRequest {
3742        type Borrowed<'a> = &'a mut Self;
3743        fn take_or_borrow<'a>(
3744            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3745        ) -> Self::Borrowed<'a> {
3746            value
3747        }
3748    }
3749
3750    unsafe impl fidl::encoding::TypeMarker for DriverResumeRequest {
3751        type Owned = Self;
3752
3753        #[inline(always)]
3754        fn inline_align(_context: fidl::encoding::Context) -> usize {
3755            4
3756        }
3757
3758        #[inline(always)]
3759        fn inline_size(_context: fidl::encoding::Context) -> usize {
3760            4
3761        }
3762    }
3763
3764    unsafe impl
3765        fidl::encoding::Encode<DriverResumeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3766        for &mut DriverResumeRequest
3767    {
3768        #[inline]
3769        unsafe fn encode(
3770            self,
3771            encoder: &mut fidl::encoding::Encoder<
3772                '_,
3773                fidl::encoding::DefaultFuchsiaResourceDialect,
3774            >,
3775            offset: usize,
3776            _depth: fidl::encoding::Depth,
3777        ) -> fidl::Result<()> {
3778            encoder.debug_check_bounds::<DriverResumeRequest>(offset);
3779            // Delegate to tuple encoding.
3780            fidl::encoding::Encode::<
3781                DriverResumeRequest,
3782                fidl::encoding::DefaultFuchsiaResourceDialect,
3783            >::encode(
3784                (<fidl::encoding::Optional<
3785                    fidl::encoding::HandleType<
3786                        fidl::EventPair,
3787                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3788                        24579,
3789                    >,
3790                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3791                    &mut self.power_element_lease,
3792                ),),
3793                encoder,
3794                offset,
3795                _depth,
3796            )
3797        }
3798    }
3799    unsafe impl<
3800        T0: fidl::encoding::Encode<
3801                fidl::encoding::Optional<
3802                    fidl::encoding::HandleType<
3803                        fidl::EventPair,
3804                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3805                        24579,
3806                    >,
3807                >,
3808                fidl::encoding::DefaultFuchsiaResourceDialect,
3809            >,
3810    > fidl::encoding::Encode<DriverResumeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3811        for (T0,)
3812    {
3813        #[inline]
3814        unsafe fn encode(
3815            self,
3816            encoder: &mut fidl::encoding::Encoder<
3817                '_,
3818                fidl::encoding::DefaultFuchsiaResourceDialect,
3819            >,
3820            offset: usize,
3821            depth: fidl::encoding::Depth,
3822        ) -> fidl::Result<()> {
3823            encoder.debug_check_bounds::<DriverResumeRequest>(offset);
3824            // Zero out padding regions. There's no need to apply masks
3825            // because the unmasked parts will be overwritten by fields.
3826            // Write the fields.
3827            self.0.encode(encoder, offset + 0, depth)?;
3828            Ok(())
3829        }
3830    }
3831
3832    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3833        for DriverResumeRequest
3834    {
3835        #[inline(always)]
3836        fn new_empty() -> Self {
3837            Self {
3838                power_element_lease: fidl::new_empty!(
3839                    fidl::encoding::Optional<
3840                        fidl::encoding::HandleType<
3841                            fidl::EventPair,
3842                            { fidl::ObjectType::EVENTPAIR.into_raw() },
3843                            24579,
3844                        >,
3845                    >,
3846                    fidl::encoding::DefaultFuchsiaResourceDialect
3847                ),
3848            }
3849        }
3850
3851        #[inline]
3852        unsafe fn decode(
3853            &mut self,
3854            decoder: &mut fidl::encoding::Decoder<
3855                '_,
3856                fidl::encoding::DefaultFuchsiaResourceDialect,
3857            >,
3858            offset: usize,
3859            _depth: fidl::encoding::Depth,
3860        ) -> fidl::Result<()> {
3861            decoder.debug_check_bounds::<Self>(offset);
3862            // Verify that padding bytes are zero.
3863            fidl::decode!(
3864                fidl::encoding::Optional<
3865                    fidl::encoding::HandleType<
3866                        fidl::EventPair,
3867                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3868                        24579,
3869                    >,
3870                >,
3871                fidl::encoding::DefaultFuchsiaResourceDialect,
3872                &mut self.power_element_lease,
3873                decoder,
3874                offset + 0,
3875                _depth
3876            )?;
3877            Ok(())
3878        }
3879    }
3880
3881    impl fidl::encoding::ResourceTypeMarker for DriverStartRequest {
3882        type Borrowed<'a> = &'a mut Self;
3883        fn take_or_borrow<'a>(
3884            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3885        ) -> Self::Borrowed<'a> {
3886            value
3887        }
3888    }
3889
3890    unsafe impl fidl::encoding::TypeMarker for DriverStartRequest {
3891        type Owned = Self;
3892
3893        #[inline(always)]
3894        fn inline_align(_context: fidl::encoding::Context) -> usize {
3895            8
3896        }
3897
3898        #[inline(always)]
3899        fn inline_size(_context: fidl::encoding::Context) -> usize {
3900            16
3901        }
3902    }
3903
3904    unsafe impl
3905        fidl::encoding::Encode<DriverStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3906        for &mut DriverStartRequest
3907    {
3908        #[inline]
3909        unsafe fn encode(
3910            self,
3911            encoder: &mut fidl::encoding::Encoder<
3912                '_,
3913                fidl::encoding::DefaultFuchsiaResourceDialect,
3914            >,
3915            offset: usize,
3916            _depth: fidl::encoding::Depth,
3917        ) -> fidl::Result<()> {
3918            encoder.debug_check_bounds::<DriverStartRequest>(offset);
3919            // Delegate to tuple encoding.
3920            fidl::encoding::Encode::<
3921                DriverStartRequest,
3922                fidl::encoding::DefaultFuchsiaResourceDialect,
3923            >::encode(
3924                (<DriverStartArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3925                    &mut self.start_args,
3926                ),),
3927                encoder,
3928                offset,
3929                _depth,
3930            )
3931        }
3932    }
3933    unsafe impl<
3934        T0: fidl::encoding::Encode<DriverStartArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
3935    > fidl::encoding::Encode<DriverStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
3936        for (T0,)
3937    {
3938        #[inline]
3939        unsafe fn encode(
3940            self,
3941            encoder: &mut fidl::encoding::Encoder<
3942                '_,
3943                fidl::encoding::DefaultFuchsiaResourceDialect,
3944            >,
3945            offset: usize,
3946            depth: fidl::encoding::Depth,
3947        ) -> fidl::Result<()> {
3948            encoder.debug_check_bounds::<DriverStartRequest>(offset);
3949            // Zero out padding regions. There's no need to apply masks
3950            // because the unmasked parts will be overwritten by fields.
3951            // Write the fields.
3952            self.0.encode(encoder, offset + 0, depth)?;
3953            Ok(())
3954        }
3955    }
3956
3957    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3958        for DriverStartRequest
3959    {
3960        #[inline(always)]
3961        fn new_empty() -> Self {
3962            Self {
3963                start_args: fidl::new_empty!(
3964                    DriverStartArgs,
3965                    fidl::encoding::DefaultFuchsiaResourceDialect
3966                ),
3967            }
3968        }
3969
3970        #[inline]
3971        unsafe fn decode(
3972            &mut self,
3973            decoder: &mut fidl::encoding::Decoder<
3974                '_,
3975                fidl::encoding::DefaultFuchsiaResourceDialect,
3976            >,
3977            offset: usize,
3978            _depth: fidl::encoding::Depth,
3979        ) -> fidl::Result<()> {
3980            decoder.debug_check_bounds::<Self>(offset);
3981            // Verify that padding bytes are zero.
3982            fidl::decode!(
3983                DriverStartArgs,
3984                fidl::encoding::DefaultFuchsiaResourceDialect,
3985                &mut self.start_args,
3986                decoder,
3987                offset + 0,
3988                _depth
3989            )?;
3990            Ok(())
3991        }
3992    }
3993
3994    impl fidl::encoding::ResourceTypeMarker for NodeAddChildRequest {
3995        type Borrowed<'a> = &'a mut Self;
3996        fn take_or_borrow<'a>(
3997            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3998        ) -> Self::Borrowed<'a> {
3999            value
4000        }
4001    }
4002
4003    unsafe impl fidl::encoding::TypeMarker for NodeAddChildRequest {
4004        type Owned = Self;
4005
4006        #[inline(always)]
4007        fn inline_align(_context: fidl::encoding::Context) -> usize {
4008            8
4009        }
4010
4011        #[inline(always)]
4012        fn inline_size(_context: fidl::encoding::Context) -> usize {
4013            24
4014        }
4015    }
4016
4017    unsafe impl
4018        fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4019        for &mut NodeAddChildRequest
4020    {
4021        #[inline]
4022        unsafe fn encode(
4023            self,
4024            encoder: &mut fidl::encoding::Encoder<
4025                '_,
4026                fidl::encoding::DefaultFuchsiaResourceDialect,
4027            >,
4028            offset: usize,
4029            _depth: fidl::encoding::Depth,
4030        ) -> fidl::Result<()> {
4031            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
4032            // Delegate to tuple encoding.
4033            fidl::encoding::Encode::<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4034                (
4035                    <NodeAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
4036                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
4037                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.node),
4038                ),
4039                encoder, offset, _depth
4040            )
4041        }
4042    }
4043    unsafe impl<
4044        T0: fidl::encoding::Encode<NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
4045        T1: fidl::encoding::Encode<
4046                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4047                fidl::encoding::DefaultFuchsiaResourceDialect,
4048            >,
4049        T2: fidl::encoding::Encode<
4050                fidl::encoding::Optional<
4051                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4052                >,
4053                fidl::encoding::DefaultFuchsiaResourceDialect,
4054            >,
4055    > fidl::encoding::Encode<NodeAddChildRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4056        for (T0, T1, T2)
4057    {
4058        #[inline]
4059        unsafe fn encode(
4060            self,
4061            encoder: &mut fidl::encoding::Encoder<
4062                '_,
4063                fidl::encoding::DefaultFuchsiaResourceDialect,
4064            >,
4065            offset: usize,
4066            depth: fidl::encoding::Depth,
4067        ) -> fidl::Result<()> {
4068            encoder.debug_check_bounds::<NodeAddChildRequest>(offset);
4069            // Zero out padding regions. There's no need to apply masks
4070            // because the unmasked parts will be overwritten by fields.
4071            // Write the fields.
4072            self.0.encode(encoder, offset + 0, depth)?;
4073            self.1.encode(encoder, offset + 16, depth)?;
4074            self.2.encode(encoder, offset + 20, depth)?;
4075            Ok(())
4076        }
4077    }
4078
4079    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4080        for NodeAddChildRequest
4081    {
4082        #[inline(always)]
4083        fn new_empty() -> Self {
4084            Self {
4085                args: fidl::new_empty!(NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect),
4086                controller: fidl::new_empty!(
4087                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4088                    fidl::encoding::DefaultFuchsiaResourceDialect
4089                ),
4090                node: fidl::new_empty!(
4091                    fidl::encoding::Optional<
4092                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4093                    >,
4094                    fidl::encoding::DefaultFuchsiaResourceDialect
4095                ),
4096            }
4097        }
4098
4099        #[inline]
4100        unsafe fn decode(
4101            &mut self,
4102            decoder: &mut fidl::encoding::Decoder<
4103                '_,
4104                fidl::encoding::DefaultFuchsiaResourceDialect,
4105            >,
4106            offset: usize,
4107            _depth: fidl::encoding::Depth,
4108        ) -> fidl::Result<()> {
4109            decoder.debug_check_bounds::<Self>(offset);
4110            // Verify that padding bytes are zero.
4111            fidl::decode!(
4112                NodeAddArgs,
4113                fidl::encoding::DefaultFuchsiaResourceDialect,
4114                &mut self.args,
4115                decoder,
4116                offset + 0,
4117                _depth
4118            )?;
4119            fidl::decode!(
4120                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4121                fidl::encoding::DefaultFuchsiaResourceDialect,
4122                &mut self.controller,
4123                decoder,
4124                offset + 16,
4125                _depth
4126            )?;
4127            fidl::decode!(
4128                fidl::encoding::Optional<
4129                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4130                >,
4131                fidl::encoding::DefaultFuchsiaResourceDialect,
4132                &mut self.node,
4133                decoder,
4134                offset + 20,
4135                _depth
4136            )?;
4137            Ok(())
4138        }
4139    }
4140
4141    impl fidl::encoding::ResourceTypeMarker for NodeManagerAddNodeRequest {
4142        type Borrowed<'a> = &'a mut Self;
4143        fn take_or_borrow<'a>(
4144            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4145        ) -> Self::Borrowed<'a> {
4146            value
4147        }
4148    }
4149
4150    unsafe impl fidl::encoding::TypeMarker for NodeManagerAddNodeRequest {
4151        type Owned = Self;
4152
4153        #[inline(always)]
4154        fn inline_align(_context: fidl::encoding::Context) -> usize {
4155            8
4156        }
4157
4158        #[inline(always)]
4159        fn inline_size(_context: fidl::encoding::Context) -> usize {
4160            24
4161        }
4162    }
4163
4164    unsafe impl
4165        fidl::encoding::Encode<
4166            NodeManagerAddNodeRequest,
4167            fidl::encoding::DefaultFuchsiaResourceDialect,
4168        > for &mut NodeManagerAddNodeRequest
4169    {
4170        #[inline]
4171        unsafe fn encode(
4172            self,
4173            encoder: &mut fidl::encoding::Encoder<
4174                '_,
4175                fidl::encoding::DefaultFuchsiaResourceDialect,
4176            >,
4177            offset: usize,
4178            _depth: fidl::encoding::Depth,
4179        ) -> fidl::Result<()> {
4180            encoder.debug_check_bounds::<NodeManagerAddNodeRequest>(offset);
4181            // Delegate to tuple encoding.
4182            fidl::encoding::Encode::<NodeManagerAddNodeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4183                (
4184                    <Node2 as fidl::encoding::ValueTypeMarker>::borrow(&self.node),
4185                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
4186                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.node_ref),
4187                ),
4188                encoder, offset, _depth
4189            )
4190        }
4191    }
4192    unsafe impl<
4193        T0: fidl::encoding::Encode<Node2, fidl::encoding::DefaultFuchsiaResourceDialect>,
4194        T1: fidl::encoding::Encode<
4195                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4196                fidl::encoding::DefaultFuchsiaResourceDialect,
4197            >,
4198        T2: fidl::encoding::Encode<
4199                fidl::encoding::Optional<
4200                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4201                >,
4202                fidl::encoding::DefaultFuchsiaResourceDialect,
4203            >,
4204    >
4205        fidl::encoding::Encode<
4206            NodeManagerAddNodeRequest,
4207            fidl::encoding::DefaultFuchsiaResourceDialect,
4208        > for (T0, T1, T2)
4209    {
4210        #[inline]
4211        unsafe fn encode(
4212            self,
4213            encoder: &mut fidl::encoding::Encoder<
4214                '_,
4215                fidl::encoding::DefaultFuchsiaResourceDialect,
4216            >,
4217            offset: usize,
4218            depth: fidl::encoding::Depth,
4219        ) -> fidl::Result<()> {
4220            encoder.debug_check_bounds::<NodeManagerAddNodeRequest>(offset);
4221            // Zero out padding regions. There's no need to apply masks
4222            // because the unmasked parts will be overwritten by fields.
4223            // Write the fields.
4224            self.0.encode(encoder, offset + 0, depth)?;
4225            self.1.encode(encoder, offset + 16, depth)?;
4226            self.2.encode(encoder, offset + 20, depth)?;
4227            Ok(())
4228        }
4229    }
4230
4231    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4232        for NodeManagerAddNodeRequest
4233    {
4234        #[inline(always)]
4235        fn new_empty() -> Self {
4236            Self {
4237                node: fidl::new_empty!(Node2, fidl::encoding::DefaultFuchsiaResourceDialect),
4238                controller: fidl::new_empty!(
4239                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4240                    fidl::encoding::DefaultFuchsiaResourceDialect
4241                ),
4242                node_ref: fidl::new_empty!(
4243                    fidl::encoding::Optional<
4244                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4245                    >,
4246                    fidl::encoding::DefaultFuchsiaResourceDialect
4247                ),
4248            }
4249        }
4250
4251        #[inline]
4252        unsafe fn decode(
4253            &mut self,
4254            decoder: &mut fidl::encoding::Decoder<
4255                '_,
4256                fidl::encoding::DefaultFuchsiaResourceDialect,
4257            >,
4258            offset: usize,
4259            _depth: fidl::encoding::Depth,
4260        ) -> fidl::Result<()> {
4261            decoder.debug_check_bounds::<Self>(offset);
4262            // Verify that padding bytes are zero.
4263            fidl::decode!(
4264                Node2,
4265                fidl::encoding::DefaultFuchsiaResourceDialect,
4266                &mut self.node,
4267                decoder,
4268                offset + 0,
4269                _depth
4270            )?;
4271            fidl::decode!(
4272                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeControllerMarker>>,
4273                fidl::encoding::DefaultFuchsiaResourceDialect,
4274                &mut self.controller,
4275                decoder,
4276                offset + 16,
4277                _depth
4278            )?;
4279            fidl::decode!(
4280                fidl::encoding::Optional<
4281                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<NodeMarker>>,
4282                >,
4283                fidl::encoding::DefaultFuchsiaResourceDialect,
4284                &mut self.node_ref,
4285                decoder,
4286                offset + 20,
4287                _depth
4288            )?;
4289            Ok(())
4290        }
4291    }
4292
4293    impl fidl::encoding::ResourceTypeMarker for NodeProvideResourceRequest {
4294        type Borrowed<'a> = &'a mut Self;
4295        fn take_or_borrow<'a>(
4296            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4297        ) -> Self::Borrowed<'a> {
4298            value
4299        }
4300    }
4301
4302    unsafe impl fidl::encoding::TypeMarker for NodeProvideResourceRequest {
4303        type Owned = Self;
4304
4305        #[inline(always)]
4306        fn inline_align(_context: fidl::encoding::Context) -> usize {
4307            8
4308        }
4309
4310        #[inline(always)]
4311        fn inline_size(_context: fidl::encoding::Context) -> usize {
4312            24
4313        }
4314    }
4315
4316    unsafe impl
4317        fidl::encoding::Encode<
4318            NodeProvideResourceRequest,
4319            fidl::encoding::DefaultFuchsiaResourceDialect,
4320        > for &mut NodeProvideResourceRequest
4321    {
4322        #[inline]
4323        unsafe fn encode(
4324            self,
4325            encoder: &mut fidl::encoding::Encoder<
4326                '_,
4327                fidl::encoding::DefaultFuchsiaResourceDialect,
4328            >,
4329            offset: usize,
4330            _depth: fidl::encoding::Depth,
4331        ) -> fidl::Result<()> {
4332            encoder.debug_check_bounds::<NodeProvideResourceRequest>(offset);
4333            // Delegate to tuple encoding.
4334            fidl::encoding::Encode::<NodeProvideResourceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4335                (
4336                    <ResourceArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.resource),
4337                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ResourceControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.controller),
4338                ),
4339                encoder, offset, _depth
4340            )
4341        }
4342    }
4343    unsafe impl<
4344        T0: fidl::encoding::Encode<ResourceArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
4345        T1: fidl::encoding::Encode<
4346                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ResourceControllerMarker>>,
4347                fidl::encoding::DefaultFuchsiaResourceDialect,
4348            >,
4349    >
4350        fidl::encoding::Encode<
4351            NodeProvideResourceRequest,
4352            fidl::encoding::DefaultFuchsiaResourceDialect,
4353        > for (T0, T1)
4354    {
4355        #[inline]
4356        unsafe fn encode(
4357            self,
4358            encoder: &mut fidl::encoding::Encoder<
4359                '_,
4360                fidl::encoding::DefaultFuchsiaResourceDialect,
4361            >,
4362            offset: usize,
4363            depth: fidl::encoding::Depth,
4364        ) -> fidl::Result<()> {
4365            encoder.debug_check_bounds::<NodeProvideResourceRequest>(offset);
4366            // Zero out padding regions. There's no need to apply masks
4367            // because the unmasked parts will be overwritten by fields.
4368            unsafe {
4369                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
4370                (ptr as *mut u64).write_unaligned(0);
4371            }
4372            // Write the fields.
4373            self.0.encode(encoder, offset + 0, depth)?;
4374            self.1.encode(encoder, offset + 16, depth)?;
4375            Ok(())
4376        }
4377    }
4378
4379    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4380        for NodeProvideResourceRequest
4381    {
4382        #[inline(always)]
4383        fn new_empty() -> Self {
4384            Self {
4385                resource: fidl::new_empty!(
4386                    ResourceArgs,
4387                    fidl::encoding::DefaultFuchsiaResourceDialect
4388                ),
4389                controller: fidl::new_empty!(
4390                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ResourceControllerMarker>>,
4391                    fidl::encoding::DefaultFuchsiaResourceDialect
4392                ),
4393            }
4394        }
4395
4396        #[inline]
4397        unsafe fn decode(
4398            &mut self,
4399            decoder: &mut fidl::encoding::Decoder<
4400                '_,
4401                fidl::encoding::DefaultFuchsiaResourceDialect,
4402            >,
4403            offset: usize,
4404            _depth: fidl::encoding::Depth,
4405        ) -> fidl::Result<()> {
4406            decoder.debug_check_bounds::<Self>(offset);
4407            // Verify that padding bytes are zero.
4408            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
4409            let padval = unsafe { (ptr as *const u64).read_unaligned() };
4410            let mask = 0xffffffff00000000u64;
4411            let maskedval = padval & mask;
4412            if maskedval != 0 {
4413                return Err(fidl::Error::NonZeroPadding {
4414                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
4415                });
4416            }
4417            fidl::decode!(
4418                ResourceArgs,
4419                fidl::encoding::DefaultFuchsiaResourceDialect,
4420                &mut self.resource,
4421                decoder,
4422                offset + 0,
4423                _depth
4424            )?;
4425            fidl::decode!(
4426                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ResourceControllerMarker>>,
4427                fidl::encoding::DefaultFuchsiaResourceDialect,
4428                &mut self.controller,
4429                decoder,
4430                offset + 16,
4431                _depth
4432            )?;
4433            Ok(())
4434        }
4435    }
4436
4437    impl DevfsAddArgs {
4438        #[inline(always)]
4439        fn max_ordinal_present(&self) -> u64 {
4440            if let Some(_) = self.controller_connector {
4441                return 5;
4442            }
4443            if let Some(_) = self.connector_supports {
4444                return 4;
4445            }
4446            if let Some(_) = self.inspect {
4447                return 3;
4448            }
4449            if let Some(_) = self.class_name {
4450                return 2;
4451            }
4452            if let Some(_) = self.connector {
4453                return 1;
4454            }
4455            0
4456        }
4457    }
4458
4459    impl fidl::encoding::ResourceTypeMarker for DevfsAddArgs {
4460        type Borrowed<'a> = &'a mut Self;
4461        fn take_or_borrow<'a>(
4462            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4463        ) -> Self::Borrowed<'a> {
4464            value
4465        }
4466    }
4467
4468    unsafe impl fidl::encoding::TypeMarker for DevfsAddArgs {
4469        type Owned = Self;
4470
4471        #[inline(always)]
4472        fn inline_align(_context: fidl::encoding::Context) -> usize {
4473            8
4474        }
4475
4476        #[inline(always)]
4477        fn inline_size(_context: fidl::encoding::Context) -> usize {
4478            16
4479        }
4480    }
4481
4482    unsafe impl fidl::encoding::Encode<DevfsAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
4483        for &mut DevfsAddArgs
4484    {
4485        unsafe fn encode(
4486            self,
4487            encoder: &mut fidl::encoding::Encoder<
4488                '_,
4489                fidl::encoding::DefaultFuchsiaResourceDialect,
4490            >,
4491            offset: usize,
4492            mut depth: fidl::encoding::Depth,
4493        ) -> fidl::Result<()> {
4494            encoder.debug_check_bounds::<DevfsAddArgs>(offset);
4495            // Vector header
4496            let max_ordinal: u64 = self.max_ordinal_present();
4497            encoder.write_num(max_ordinal, offset);
4498            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4499            // Calling encoder.out_of_line_offset(0) is not allowed.
4500            if max_ordinal == 0 {
4501                return Ok(());
4502            }
4503            depth.increment()?;
4504            let envelope_size = 8;
4505            let bytes_len = max_ordinal as usize * envelope_size;
4506            #[allow(unused_variables)]
4507            let offset = encoder.out_of_line_offset(bytes_len);
4508            let mut _prev_end_offset: usize = 0;
4509            if 1 > max_ordinal {
4510                return Ok(());
4511            }
4512
4513            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4514            // are envelope_size bytes.
4515            let cur_offset: usize = (1 - 1) * envelope_size;
4516
4517            // Zero reserved fields.
4518            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4519
4520            // Safety:
4521            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4522            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4523            //   envelope_size bytes, there is always sufficient room.
4524            fidl::encoding::encode_in_envelope_optional::<
4525                fidl::encoding::Endpoint<
4526                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4527                >,
4528                fidl::encoding::DefaultFuchsiaResourceDialect,
4529            >(
4530                self.connector.as_mut().map(
4531                    <fidl::encoding::Endpoint<
4532                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4533                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4534                ),
4535                encoder,
4536                offset + cur_offset,
4537                depth,
4538            )?;
4539
4540            _prev_end_offset = cur_offset + envelope_size;
4541            if 2 > max_ordinal {
4542                return Ok(());
4543            }
4544
4545            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4546            // are envelope_size bytes.
4547            let cur_offset: usize = (2 - 1) * envelope_size;
4548
4549            // Zero reserved fields.
4550            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4551
4552            // Safety:
4553            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4554            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4555            //   envelope_size bytes, there is always sufficient room.
4556            fidl::encoding::encode_in_envelope_optional::<
4557                fidl::encoding::BoundedString<255>,
4558                fidl::encoding::DefaultFuchsiaResourceDialect,
4559            >(
4560                self.class_name.as_ref().map(
4561                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
4562                ),
4563                encoder,
4564                offset + cur_offset,
4565                depth,
4566            )?;
4567
4568            _prev_end_offset = cur_offset + envelope_size;
4569            if 3 > max_ordinal {
4570                return Ok(());
4571            }
4572
4573            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4574            // are envelope_size bytes.
4575            let cur_offset: usize = (3 - 1) * envelope_size;
4576
4577            // Zero reserved fields.
4578            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4579
4580            // Safety:
4581            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4582            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4583            //   envelope_size bytes, there is always sufficient room.
4584            fidl::encoding::encode_in_envelope_optional::<
4585                fidl::encoding::HandleType<
4586                    fidl::Vmo,
4587                    { fidl::ObjectType::VMO.into_raw() },
4588                    2147483648,
4589                >,
4590                fidl::encoding::DefaultFuchsiaResourceDialect,
4591            >(
4592                self.inspect.as_mut().map(
4593                    <fidl::encoding::HandleType<
4594                        fidl::Vmo,
4595                        { fidl::ObjectType::VMO.into_raw() },
4596                        2147483648,
4597                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4598                ),
4599                encoder,
4600                offset + cur_offset,
4601                depth,
4602            )?;
4603
4604            _prev_end_offset = cur_offset + envelope_size;
4605            if 4 > max_ordinal {
4606                return Ok(());
4607            }
4608
4609            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4610            // are envelope_size bytes.
4611            let cur_offset: usize = (4 - 1) * envelope_size;
4612
4613            // Zero reserved fields.
4614            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4615
4616            // Safety:
4617            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4618            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4619            //   envelope_size bytes, there is always sufficient room.
4620            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_device_fs::ConnectionType, fidl::encoding::DefaultFuchsiaResourceDialect>(
4621            self.connector_supports.as_ref().map(<fidl_fuchsia_device_fs::ConnectionType as fidl::encoding::ValueTypeMarker>::borrow),
4622            encoder, offset + cur_offset, depth
4623        )?;
4624
4625            _prev_end_offset = cur_offset + envelope_size;
4626            if 5 > max_ordinal {
4627                return Ok(());
4628            }
4629
4630            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4631            // are envelope_size bytes.
4632            let cur_offset: usize = (5 - 1) * envelope_size;
4633
4634            // Zero reserved fields.
4635            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4636
4637            // Safety:
4638            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4639            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4640            //   envelope_size bytes, there is always sufficient room.
4641            fidl::encoding::encode_in_envelope_optional::<
4642                fidl::encoding::Endpoint<
4643                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4644                >,
4645                fidl::encoding::DefaultFuchsiaResourceDialect,
4646            >(
4647                self.controller_connector.as_mut().map(
4648                    <fidl::encoding::Endpoint<
4649                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4650                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4651                ),
4652                encoder,
4653                offset + cur_offset,
4654                depth,
4655            )?;
4656
4657            _prev_end_offset = cur_offset + envelope_size;
4658
4659            Ok(())
4660        }
4661    }
4662
4663    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DevfsAddArgs {
4664        #[inline(always)]
4665        fn new_empty() -> Self {
4666            Self::default()
4667        }
4668
4669        unsafe fn decode(
4670            &mut self,
4671            decoder: &mut fidl::encoding::Decoder<
4672                '_,
4673                fidl::encoding::DefaultFuchsiaResourceDialect,
4674            >,
4675            offset: usize,
4676            mut depth: fidl::encoding::Depth,
4677        ) -> fidl::Result<()> {
4678            decoder.debug_check_bounds::<Self>(offset);
4679            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4680                None => return Err(fidl::Error::NotNullable),
4681                Some(len) => len,
4682            };
4683            // Calling decoder.out_of_line_offset(0) is not allowed.
4684            if len == 0 {
4685                return Ok(());
4686            };
4687            depth.increment()?;
4688            let envelope_size = 8;
4689            let bytes_len = len * envelope_size;
4690            let offset = decoder.out_of_line_offset(bytes_len)?;
4691            // Decode the envelope for each type.
4692            let mut _next_ordinal_to_read = 0;
4693            let mut next_offset = offset;
4694            let end_offset = offset + bytes_len;
4695            _next_ordinal_to_read += 1;
4696            if next_offset >= end_offset {
4697                return Ok(());
4698            }
4699
4700            // Decode unknown envelopes for gaps in ordinals.
4701            while _next_ordinal_to_read < 1 {
4702                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4703                _next_ordinal_to_read += 1;
4704                next_offset += envelope_size;
4705            }
4706
4707            let next_out_of_line = decoder.next_out_of_line();
4708            let handles_before = decoder.remaining_handles();
4709            if let Some((inlined, num_bytes, num_handles)) =
4710                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4711            {
4712                let member_inline_size = <fidl::encoding::Endpoint<
4713                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4714                > as fidl::encoding::TypeMarker>::inline_size(
4715                    decoder.context
4716                );
4717                if inlined != (member_inline_size <= 4) {
4718                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4719                }
4720                let inner_offset;
4721                let mut inner_depth = depth.clone();
4722                if inlined {
4723                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4724                    inner_offset = next_offset;
4725                } else {
4726                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4727                    inner_depth.increment()?;
4728                }
4729                let val_ref = self.connector.get_or_insert_with(|| {
4730                    fidl::new_empty!(
4731                        fidl::encoding::Endpoint<
4732                            fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4733                        >,
4734                        fidl::encoding::DefaultFuchsiaResourceDialect
4735                    )
4736                });
4737                fidl::decode!(
4738                    fidl::encoding::Endpoint<
4739                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4740                    >,
4741                    fidl::encoding::DefaultFuchsiaResourceDialect,
4742                    val_ref,
4743                    decoder,
4744                    inner_offset,
4745                    inner_depth
4746                )?;
4747                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4748                {
4749                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4750                }
4751                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4752                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4753                }
4754            }
4755
4756            next_offset += envelope_size;
4757            _next_ordinal_to_read += 1;
4758            if next_offset >= end_offset {
4759                return Ok(());
4760            }
4761
4762            // Decode unknown envelopes for gaps in ordinals.
4763            while _next_ordinal_to_read < 2 {
4764                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4765                _next_ordinal_to_read += 1;
4766                next_offset += envelope_size;
4767            }
4768
4769            let next_out_of_line = decoder.next_out_of_line();
4770            let handles_before = decoder.remaining_handles();
4771            if let Some((inlined, num_bytes, num_handles)) =
4772                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4773            {
4774                let member_inline_size =
4775                    <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
4776                        decoder.context,
4777                    );
4778                if inlined != (member_inline_size <= 4) {
4779                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4780                }
4781                let inner_offset;
4782                let mut inner_depth = depth.clone();
4783                if inlined {
4784                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4785                    inner_offset = next_offset;
4786                } else {
4787                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4788                    inner_depth.increment()?;
4789                }
4790                let val_ref = self.class_name.get_or_insert_with(|| {
4791                    fidl::new_empty!(
4792                        fidl::encoding::BoundedString<255>,
4793                        fidl::encoding::DefaultFuchsiaResourceDialect
4794                    )
4795                });
4796                fidl::decode!(
4797                    fidl::encoding::BoundedString<255>,
4798                    fidl::encoding::DefaultFuchsiaResourceDialect,
4799                    val_ref,
4800                    decoder,
4801                    inner_offset,
4802                    inner_depth
4803                )?;
4804                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4805                {
4806                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4807                }
4808                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4809                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4810                }
4811            }
4812
4813            next_offset += envelope_size;
4814            _next_ordinal_to_read += 1;
4815            if next_offset >= end_offset {
4816                return Ok(());
4817            }
4818
4819            // Decode unknown envelopes for gaps in ordinals.
4820            while _next_ordinal_to_read < 3 {
4821                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4822                _next_ordinal_to_read += 1;
4823                next_offset += envelope_size;
4824            }
4825
4826            let next_out_of_line = decoder.next_out_of_line();
4827            let handles_before = decoder.remaining_handles();
4828            if let Some((inlined, num_bytes, num_handles)) =
4829                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4830            {
4831                let member_inline_size = <fidl::encoding::HandleType<
4832                    fidl::Vmo,
4833                    { fidl::ObjectType::VMO.into_raw() },
4834                    2147483648,
4835                > as fidl::encoding::TypeMarker>::inline_size(
4836                    decoder.context
4837                );
4838                if inlined != (member_inline_size <= 4) {
4839                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4840                }
4841                let inner_offset;
4842                let mut inner_depth = depth.clone();
4843                if inlined {
4844                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4845                    inner_offset = next_offset;
4846                } else {
4847                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4848                    inner_depth.increment()?;
4849                }
4850                let val_ref =
4851                self.inspect.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
4852                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4853                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4854                {
4855                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4856                }
4857                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4858                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4859                }
4860            }
4861
4862            next_offset += envelope_size;
4863            _next_ordinal_to_read += 1;
4864            if next_offset >= end_offset {
4865                return Ok(());
4866            }
4867
4868            // Decode unknown envelopes for gaps in ordinals.
4869            while _next_ordinal_to_read < 4 {
4870                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4871                _next_ordinal_to_read += 1;
4872                next_offset += envelope_size;
4873            }
4874
4875            let next_out_of_line = decoder.next_out_of_line();
4876            let handles_before = decoder.remaining_handles();
4877            if let Some((inlined, num_bytes, num_handles)) =
4878                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4879            {
4880                let member_inline_size = <fidl_fuchsia_device_fs::ConnectionType as fidl::encoding::TypeMarker>::inline_size(decoder.context);
4881                if inlined != (member_inline_size <= 4) {
4882                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4883                }
4884                let inner_offset;
4885                let mut inner_depth = depth.clone();
4886                if inlined {
4887                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4888                    inner_offset = next_offset;
4889                } else {
4890                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4891                    inner_depth.increment()?;
4892                }
4893                let val_ref = self.connector_supports.get_or_insert_with(|| {
4894                    fidl::new_empty!(
4895                        fidl_fuchsia_device_fs::ConnectionType,
4896                        fidl::encoding::DefaultFuchsiaResourceDialect
4897                    )
4898                });
4899                fidl::decode!(
4900                    fidl_fuchsia_device_fs::ConnectionType,
4901                    fidl::encoding::DefaultFuchsiaResourceDialect,
4902                    val_ref,
4903                    decoder,
4904                    inner_offset,
4905                    inner_depth
4906                )?;
4907                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4908                {
4909                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4910                }
4911                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4912                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4913                }
4914            }
4915
4916            next_offset += envelope_size;
4917            _next_ordinal_to_read += 1;
4918            if next_offset >= end_offset {
4919                return Ok(());
4920            }
4921
4922            // Decode unknown envelopes for gaps in ordinals.
4923            while _next_ordinal_to_read < 5 {
4924                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4925                _next_ordinal_to_read += 1;
4926                next_offset += envelope_size;
4927            }
4928
4929            let next_out_of_line = decoder.next_out_of_line();
4930            let handles_before = decoder.remaining_handles();
4931            if let Some((inlined, num_bytes, num_handles)) =
4932                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4933            {
4934                let member_inline_size = <fidl::encoding::Endpoint<
4935                    fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4936                > as fidl::encoding::TypeMarker>::inline_size(
4937                    decoder.context
4938                );
4939                if inlined != (member_inline_size <= 4) {
4940                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4941                }
4942                let inner_offset;
4943                let mut inner_depth = depth.clone();
4944                if inlined {
4945                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4946                    inner_offset = next_offset;
4947                } else {
4948                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4949                    inner_depth.increment()?;
4950                }
4951                let val_ref = self.controller_connector.get_or_insert_with(|| {
4952                    fidl::new_empty!(
4953                        fidl::encoding::Endpoint<
4954                            fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4955                        >,
4956                        fidl::encoding::DefaultFuchsiaResourceDialect
4957                    )
4958                });
4959                fidl::decode!(
4960                    fidl::encoding::Endpoint<
4961                        fidl::endpoints::ClientEnd<fidl_fuchsia_device_fs::ConnectorMarker>,
4962                    >,
4963                    fidl::encoding::DefaultFuchsiaResourceDialect,
4964                    val_ref,
4965                    decoder,
4966                    inner_offset,
4967                    inner_depth
4968                )?;
4969                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4970                {
4971                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4972                }
4973                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4974                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4975                }
4976            }
4977
4978            next_offset += envelope_size;
4979
4980            // Decode the remaining unknown envelopes.
4981            while next_offset < end_offset {
4982                _next_ordinal_to_read += 1;
4983                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4984                next_offset += envelope_size;
4985            }
4986
4987            Ok(())
4988        }
4989    }
4990
4991    impl DriverStartArgs {
4992        #[inline(always)]
4993        fn max_ordinal_present(&self) -> u64 {
4994            if let Some(_) = self.log_sink {
4995                return 15;
4996            }
4997            if let Some(_) = self.power_element_args {
4998                return 14;
4999            }
5000            if let Some(_) = self.vmar {
5001                return 13;
5002            }
5003            if let Some(_) = self.node_properties_2 {
5004                return 12;
5005            }
5006            if let Some(_) = self.node_token {
5007                return 11;
5008            }
5009            if let Some(_) = self.node_offers {
5010                return 10;
5011            }
5012            if let Some(_) = self.node_properties {
5013                return 9;
5014            }
5015            if let Some(_) = self.node_name {
5016                return 8;
5017            }
5018            if let Some(_) = self.config {
5019                return 7;
5020            }
5021            if let Some(_) = self.outgoing_dir {
5022                return 6;
5023            }
5024            if let Some(_) = self.incoming {
5025                return 5;
5026            }
5027            if let Some(_) = self.program {
5028                return 4;
5029            }
5030            if let Some(_) = self.url {
5031                return 3;
5032            }
5033            if let Some(_) = self.symbols {
5034                return 2;
5035            }
5036            if let Some(_) = self.node {
5037                return 1;
5038            }
5039            0
5040        }
5041    }
5042
5043    impl fidl::encoding::ResourceTypeMarker for DriverStartArgs {
5044        type Borrowed<'a> = &'a mut Self;
5045        fn take_or_borrow<'a>(
5046            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5047        ) -> Self::Borrowed<'a> {
5048            value
5049        }
5050    }
5051
5052    unsafe impl fidl::encoding::TypeMarker for DriverStartArgs {
5053        type Owned = Self;
5054
5055        #[inline(always)]
5056        fn inline_align(_context: fidl::encoding::Context) -> usize {
5057            8
5058        }
5059
5060        #[inline(always)]
5061        fn inline_size(_context: fidl::encoding::Context) -> usize {
5062            16
5063        }
5064    }
5065
5066    unsafe impl
5067        fidl::encoding::Encode<DriverStartArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
5068        for &mut DriverStartArgs
5069    {
5070        unsafe fn encode(
5071            self,
5072            encoder: &mut fidl::encoding::Encoder<
5073                '_,
5074                fidl::encoding::DefaultFuchsiaResourceDialect,
5075            >,
5076            offset: usize,
5077            mut depth: fidl::encoding::Depth,
5078        ) -> fidl::Result<()> {
5079            encoder.debug_check_bounds::<DriverStartArgs>(offset);
5080            // Vector header
5081            let max_ordinal: u64 = self.max_ordinal_present();
5082            encoder.write_num(max_ordinal, offset);
5083            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5084            // Calling encoder.out_of_line_offset(0) is not allowed.
5085            if max_ordinal == 0 {
5086                return Ok(());
5087            }
5088            depth.increment()?;
5089            let envelope_size = 8;
5090            let bytes_len = max_ordinal as usize * envelope_size;
5091            #[allow(unused_variables)]
5092            let offset = encoder.out_of_line_offset(bytes_len);
5093            let mut _prev_end_offset: usize = 0;
5094            if 1 > max_ordinal {
5095                return Ok(());
5096            }
5097
5098            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5099            // are envelope_size bytes.
5100            let cur_offset: usize = (1 - 1) * envelope_size;
5101
5102            // Zero reserved fields.
5103            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5104
5105            // Safety:
5106            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5107            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5108            //   envelope_size bytes, there is always sufficient room.
5109            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5110            self.node.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5111            encoder, offset + cur_offset, depth
5112        )?;
5113
5114            _prev_end_offset = cur_offset + envelope_size;
5115            if 2 > max_ordinal {
5116                return Ok(());
5117            }
5118
5119            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5120            // are envelope_size bytes.
5121            let cur_offset: usize = (2 - 1) * envelope_size;
5122
5123            // Zero reserved fields.
5124            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5125
5126            // Safety:
5127            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5128            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5129            //   envelope_size bytes, there is always sufficient room.
5130            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5131            self.symbols.as_ref().map(<fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::ValueTypeMarker>::borrow),
5132            encoder, offset + cur_offset, depth
5133        )?;
5134
5135            _prev_end_offset = cur_offset + envelope_size;
5136            if 3 > max_ordinal {
5137                return Ok(());
5138            }
5139
5140            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5141            // are envelope_size bytes.
5142            let cur_offset: usize = (3 - 1) * envelope_size;
5143
5144            // Zero reserved fields.
5145            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5146
5147            // Safety:
5148            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5149            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5150            //   envelope_size bytes, there is always sufficient room.
5151            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5152            self.url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
5153            encoder, offset + cur_offset, depth
5154        )?;
5155
5156            _prev_end_offset = cur_offset + envelope_size;
5157            if 4 > max_ordinal {
5158                return Ok(());
5159            }
5160
5161            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5162            // are envelope_size bytes.
5163            let cur_offset: usize = (4 - 1) * envelope_size;
5164
5165            // Zero reserved fields.
5166            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5167
5168            // Safety:
5169            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5170            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5171            //   envelope_size bytes, there is always sufficient room.
5172            fidl::encoding::encode_in_envelope_optional::<
5173                fidl_fuchsia_data::Dictionary,
5174                fidl::encoding::DefaultFuchsiaResourceDialect,
5175            >(
5176                self.program.as_ref().map(
5177                    <fidl_fuchsia_data::Dictionary as fidl::encoding::ValueTypeMarker>::borrow,
5178                ),
5179                encoder,
5180                offset + cur_offset,
5181                depth,
5182            )?;
5183
5184            _prev_end_offset = cur_offset + envelope_size;
5185            if 5 > max_ordinal {
5186                return Ok(());
5187            }
5188
5189            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5190            // are envelope_size bytes.
5191            let cur_offset: usize = (5 - 1) * envelope_size;
5192
5193            // Zero reserved fields.
5194            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5195
5196            // Safety:
5197            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5198            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5199            //   envelope_size bytes, there is always sufficient room.
5200            fidl::encoding::encode_in_envelope_optional::<
5201                fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>,
5202                fidl::encoding::DefaultFuchsiaResourceDialect,
5203            >(
5204                self.incoming.as_mut().map(
5205                    <fidl::encoding::Vector<
5206                        fidl_fuchsia_component_runner::ComponentNamespaceEntry,
5207                        32,
5208                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5209                ),
5210                encoder,
5211                offset + cur_offset,
5212                depth,
5213            )?;
5214
5215            _prev_end_offset = cur_offset + envelope_size;
5216            if 6 > max_ordinal {
5217                return Ok(());
5218            }
5219
5220            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5221            // are envelope_size bytes.
5222            let cur_offset: usize = (6 - 1) * envelope_size;
5223
5224            // Zero reserved fields.
5225            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5226
5227            // Safety:
5228            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5229            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5230            //   envelope_size bytes, there is always sufficient room.
5231            fidl::encoding::encode_in_envelope_optional::<
5232                fidl::encoding::Endpoint<
5233                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5234                >,
5235                fidl::encoding::DefaultFuchsiaResourceDialect,
5236            >(
5237                self.outgoing_dir.as_mut().map(
5238                    <fidl::encoding::Endpoint<
5239                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5240                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5241                ),
5242                encoder,
5243                offset + cur_offset,
5244                depth,
5245            )?;
5246
5247            _prev_end_offset = cur_offset + envelope_size;
5248            if 7 > max_ordinal {
5249                return Ok(());
5250            }
5251
5252            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5253            // are envelope_size bytes.
5254            let cur_offset: usize = (7 - 1) * envelope_size;
5255
5256            // Zero reserved fields.
5257            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5258
5259            // Safety:
5260            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5261            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5262            //   envelope_size bytes, there is always sufficient room.
5263            fidl::encoding::encode_in_envelope_optional::<
5264                fidl::encoding::HandleType<
5265                    fidl::Vmo,
5266                    { fidl::ObjectType::VMO.into_raw() },
5267                    2147483648,
5268                >,
5269                fidl::encoding::DefaultFuchsiaResourceDialect,
5270            >(
5271                self.config.as_mut().map(
5272                    <fidl::encoding::HandleType<
5273                        fidl::Vmo,
5274                        { fidl::ObjectType::VMO.into_raw() },
5275                        2147483648,
5276                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5277                ),
5278                encoder,
5279                offset + cur_offset,
5280                depth,
5281            )?;
5282
5283            _prev_end_offset = cur_offset + envelope_size;
5284            if 8 > max_ordinal {
5285                return Ok(());
5286            }
5287
5288            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5289            // are envelope_size bytes.
5290            let cur_offset: usize = (8 - 1) * envelope_size;
5291
5292            // Zero reserved fields.
5293            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5294
5295            // Safety:
5296            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5297            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5298            //   envelope_size bytes, there is always sufficient room.
5299            fidl::encoding::encode_in_envelope_optional::<
5300                fidl::encoding::UnboundedString,
5301                fidl::encoding::DefaultFuchsiaResourceDialect,
5302            >(
5303                self.node_name.as_ref().map(
5304                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
5305                ),
5306                encoder,
5307                offset + cur_offset,
5308                depth,
5309            )?;
5310
5311            _prev_end_offset = cur_offset + envelope_size;
5312            if 9 > max_ordinal {
5313                return Ok(());
5314            }
5315
5316            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5317            // are envelope_size bytes.
5318            let cur_offset: usize = (9 - 1) * envelope_size;
5319
5320            // Zero reserved fields.
5321            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5322
5323            // Safety:
5324            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5325            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5326            //   envelope_size bytes, there is always sufficient room.
5327            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<NodePropertyEntry>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5328            self.node_properties.as_ref().map(<fidl::encoding::UnboundedVector<NodePropertyEntry> as fidl::encoding::ValueTypeMarker>::borrow),
5329            encoder, offset + cur_offset, depth
5330        )?;
5331
5332            _prev_end_offset = cur_offset + envelope_size;
5333            if 10 > max_ordinal {
5334                return Ok(());
5335            }
5336
5337            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5338            // are envelope_size bytes.
5339            let cur_offset: usize = (10 - 1) * envelope_size;
5340
5341            // Zero reserved fields.
5342            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5343
5344            // Safety:
5345            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5346            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5347            //   envelope_size bytes, there is always sufficient room.
5348            fidl::encoding::encode_in_envelope_optional::<
5349                fidl::encoding::Vector<Offer, 128>,
5350                fidl::encoding::DefaultFuchsiaResourceDialect,
5351            >(
5352                self.node_offers.as_ref().map(
5353                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::ValueTypeMarker>::borrow,
5354                ),
5355                encoder,
5356                offset + cur_offset,
5357                depth,
5358            )?;
5359
5360            _prev_end_offset = cur_offset + envelope_size;
5361            if 11 > max_ordinal {
5362                return Ok(());
5363            }
5364
5365            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5366            // are envelope_size bytes.
5367            let cur_offset: usize = (11 - 1) * envelope_size;
5368
5369            // Zero reserved fields.
5370            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5371
5372            // Safety:
5373            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5374            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5375            //   envelope_size bytes, there is always sufficient room.
5376            fidl::encoding::encode_in_envelope_optional::<
5377                fidl::encoding::HandleType<
5378                    fidl::Event,
5379                    { fidl::ObjectType::EVENT.into_raw() },
5380                    2147483648,
5381                >,
5382                fidl::encoding::DefaultFuchsiaResourceDialect,
5383            >(
5384                self.node_token.as_mut().map(
5385                    <fidl::encoding::HandleType<
5386                        fidl::Event,
5387                        { fidl::ObjectType::EVENT.into_raw() },
5388                        2147483648,
5389                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5390                ),
5391                encoder,
5392                offset + cur_offset,
5393                depth,
5394            )?;
5395
5396            _prev_end_offset = cur_offset + envelope_size;
5397            if 12 > max_ordinal {
5398                return Ok(());
5399            }
5400
5401            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5402            // are envelope_size bytes.
5403            let cur_offset: usize = (12 - 1) * envelope_size;
5404
5405            // Zero reserved fields.
5406            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5407
5408            // Safety:
5409            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5410            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5411            //   envelope_size bytes, there is always sufficient room.
5412            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<NodePropertyEntry2>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5413            self.node_properties_2.as_ref().map(<fidl::encoding::UnboundedVector<NodePropertyEntry2> as fidl::encoding::ValueTypeMarker>::borrow),
5414            encoder, offset + cur_offset, depth
5415        )?;
5416
5417            _prev_end_offset = cur_offset + envelope_size;
5418            if 13 > max_ordinal {
5419                return Ok(());
5420            }
5421
5422            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5423            // are envelope_size bytes.
5424            let cur_offset: usize = (13 - 1) * envelope_size;
5425
5426            // Zero reserved fields.
5427            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5428
5429            // Safety:
5430            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5431            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5432            //   envelope_size bytes, there is always sufficient room.
5433            fidl::encoding::encode_in_envelope_optional::<
5434                fidl::encoding::HandleType<
5435                    fidl::Vmar,
5436                    { fidl::ObjectType::VMAR.into_raw() },
5437                    2147483648,
5438                >,
5439                fidl::encoding::DefaultFuchsiaResourceDialect,
5440            >(
5441                self.vmar.as_mut().map(
5442                    <fidl::encoding::HandleType<
5443                        fidl::Vmar,
5444                        { fidl::ObjectType::VMAR.into_raw() },
5445                        2147483648,
5446                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5447                ),
5448                encoder,
5449                offset + cur_offset,
5450                depth,
5451            )?;
5452
5453            _prev_end_offset = cur_offset + envelope_size;
5454            if 14 > max_ordinal {
5455                return Ok(());
5456            }
5457
5458            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5459            // are envelope_size bytes.
5460            let cur_offset: usize = (14 - 1) * envelope_size;
5461
5462            // Zero reserved fields.
5463            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5464
5465            // Safety:
5466            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5467            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5468            //   envelope_size bytes, there is always sufficient room.
5469            fidl::encoding::encode_in_envelope_optional::<
5470                PowerElementArgs,
5471                fidl::encoding::DefaultFuchsiaResourceDialect,
5472            >(
5473                self.power_element_args
5474                    .as_mut()
5475                    .map(<PowerElementArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5476                encoder,
5477                offset + cur_offset,
5478                depth,
5479            )?;
5480
5481            _prev_end_offset = cur_offset + envelope_size;
5482            if 15 > max_ordinal {
5483                return Ok(());
5484            }
5485
5486            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5487            // are envelope_size bytes.
5488            let cur_offset: usize = (15 - 1) * envelope_size;
5489
5490            // Zero reserved fields.
5491            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5492
5493            // Safety:
5494            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5495            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5496            //   envelope_size bytes, there is always sufficient room.
5497            fidl::encoding::encode_in_envelope_optional::<
5498                fidl::encoding::Endpoint<
5499                    fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>,
5500                >,
5501                fidl::encoding::DefaultFuchsiaResourceDialect,
5502            >(
5503                self.log_sink.as_mut().map(
5504                    <fidl::encoding::Endpoint<
5505                        fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>,
5506                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5507                ),
5508                encoder,
5509                offset + cur_offset,
5510                depth,
5511            )?;
5512
5513            _prev_end_offset = cur_offset + envelope_size;
5514
5515            Ok(())
5516        }
5517    }
5518
5519    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5520        for DriverStartArgs
5521    {
5522        #[inline(always)]
5523        fn new_empty() -> Self {
5524            Self::default()
5525        }
5526
5527        unsafe fn decode(
5528            &mut self,
5529            decoder: &mut fidl::encoding::Decoder<
5530                '_,
5531                fidl::encoding::DefaultFuchsiaResourceDialect,
5532            >,
5533            offset: usize,
5534            mut depth: fidl::encoding::Depth,
5535        ) -> fidl::Result<()> {
5536            decoder.debug_check_bounds::<Self>(offset);
5537            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5538                None => return Err(fidl::Error::NotNullable),
5539                Some(len) => len,
5540            };
5541            // Calling decoder.out_of_line_offset(0) is not allowed.
5542            if len == 0 {
5543                return Ok(());
5544            };
5545            depth.increment()?;
5546            let envelope_size = 8;
5547            let bytes_len = len * envelope_size;
5548            let offset = decoder.out_of_line_offset(bytes_len)?;
5549            // Decode the envelope for each type.
5550            let mut _next_ordinal_to_read = 0;
5551            let mut next_offset = offset;
5552            let end_offset = offset + bytes_len;
5553            _next_ordinal_to_read += 1;
5554            if next_offset >= end_offset {
5555                return Ok(());
5556            }
5557
5558            // Decode unknown envelopes for gaps in ordinals.
5559            while _next_ordinal_to_read < 1 {
5560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5561                _next_ordinal_to_read += 1;
5562                next_offset += envelope_size;
5563            }
5564
5565            let next_out_of_line = decoder.next_out_of_line();
5566            let handles_before = decoder.remaining_handles();
5567            if let Some((inlined, num_bytes, num_handles)) =
5568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5569            {
5570                let member_inline_size = <fidl::encoding::Endpoint<
5571                    fidl::endpoints::ClientEnd<NodeMarker>,
5572                > as fidl::encoding::TypeMarker>::inline_size(
5573                    decoder.context
5574                );
5575                if inlined != (member_inline_size <= 4) {
5576                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5577                }
5578                let inner_offset;
5579                let mut inner_depth = depth.clone();
5580                if inlined {
5581                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5582                    inner_offset = next_offset;
5583                } else {
5584                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5585                    inner_depth.increment()?;
5586                }
5587                let val_ref = self.node.get_or_insert_with(|| {
5588                    fidl::new_empty!(
5589                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>,
5590                        fidl::encoding::DefaultFuchsiaResourceDialect
5591                    )
5592                });
5593                fidl::decode!(
5594                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NodeMarker>>,
5595                    fidl::encoding::DefaultFuchsiaResourceDialect,
5596                    val_ref,
5597                    decoder,
5598                    inner_offset,
5599                    inner_depth
5600                )?;
5601                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5602                {
5603                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5604                }
5605                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5606                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5607                }
5608            }
5609
5610            next_offset += envelope_size;
5611            _next_ordinal_to_read += 1;
5612            if next_offset >= end_offset {
5613                return Ok(());
5614            }
5615
5616            // Decode unknown envelopes for gaps in ordinals.
5617            while _next_ordinal_to_read < 2 {
5618                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5619                _next_ordinal_to_read += 1;
5620                next_offset += envelope_size;
5621            }
5622
5623            let next_out_of_line = decoder.next_out_of_line();
5624            let handles_before = decoder.remaining_handles();
5625            if let Some((inlined, num_bytes, num_handles)) =
5626                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5627            {
5628                let member_inline_size = <fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5629                if inlined != (member_inline_size <= 4) {
5630                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5631                }
5632                let inner_offset;
5633                let mut inner_depth = depth.clone();
5634                if inlined {
5635                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5636                    inner_offset = next_offset;
5637                } else {
5638                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5639                    inner_depth.increment()?;
5640                }
5641                let val_ref =
5642                self.symbols.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
5643                fidl::decode!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5644                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5645                {
5646                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5647                }
5648                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5649                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5650                }
5651            }
5652
5653            next_offset += envelope_size;
5654            _next_ordinal_to_read += 1;
5655            if next_offset >= end_offset {
5656                return Ok(());
5657            }
5658
5659            // Decode unknown envelopes for gaps in ordinals.
5660            while _next_ordinal_to_read < 3 {
5661                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5662                _next_ordinal_to_read += 1;
5663                next_offset += envelope_size;
5664            }
5665
5666            let next_out_of_line = decoder.next_out_of_line();
5667            let handles_before = decoder.remaining_handles();
5668            if let Some((inlined, num_bytes, num_handles)) =
5669                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5670            {
5671                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5672                if inlined != (member_inline_size <= 4) {
5673                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5674                }
5675                let inner_offset;
5676                let mut inner_depth = depth.clone();
5677                if inlined {
5678                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5679                    inner_offset = next_offset;
5680                } else {
5681                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5682                    inner_depth.increment()?;
5683                }
5684                let val_ref = self.url.get_or_insert_with(|| {
5685                    fidl::new_empty!(
5686                        fidl::encoding::BoundedString<4096>,
5687                        fidl::encoding::DefaultFuchsiaResourceDialect
5688                    )
5689                });
5690                fidl::decode!(
5691                    fidl::encoding::BoundedString<4096>,
5692                    fidl::encoding::DefaultFuchsiaResourceDialect,
5693                    val_ref,
5694                    decoder,
5695                    inner_offset,
5696                    inner_depth
5697                )?;
5698                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5699                {
5700                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5701                }
5702                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5703                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5704                }
5705            }
5706
5707            next_offset += envelope_size;
5708            _next_ordinal_to_read += 1;
5709            if next_offset >= end_offset {
5710                return Ok(());
5711            }
5712
5713            // Decode unknown envelopes for gaps in ordinals.
5714            while _next_ordinal_to_read < 4 {
5715                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5716                _next_ordinal_to_read += 1;
5717                next_offset += envelope_size;
5718            }
5719
5720            let next_out_of_line = decoder.next_out_of_line();
5721            let handles_before = decoder.remaining_handles();
5722            if let Some((inlined, num_bytes, num_handles)) =
5723                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5724            {
5725                let member_inline_size =
5726                    <fidl_fuchsia_data::Dictionary as fidl::encoding::TypeMarker>::inline_size(
5727                        decoder.context,
5728                    );
5729                if inlined != (member_inline_size <= 4) {
5730                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5731                }
5732                let inner_offset;
5733                let mut inner_depth = depth.clone();
5734                if inlined {
5735                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5736                    inner_offset = next_offset;
5737                } else {
5738                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5739                    inner_depth.increment()?;
5740                }
5741                let val_ref = self.program.get_or_insert_with(|| {
5742                    fidl::new_empty!(
5743                        fidl_fuchsia_data::Dictionary,
5744                        fidl::encoding::DefaultFuchsiaResourceDialect
5745                    )
5746                });
5747                fidl::decode!(
5748                    fidl_fuchsia_data::Dictionary,
5749                    fidl::encoding::DefaultFuchsiaResourceDialect,
5750                    val_ref,
5751                    decoder,
5752                    inner_offset,
5753                    inner_depth
5754                )?;
5755                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5756                {
5757                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5758                }
5759                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5760                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5761                }
5762            }
5763
5764            next_offset += envelope_size;
5765            _next_ordinal_to_read += 1;
5766            if next_offset >= end_offset {
5767                return Ok(());
5768            }
5769
5770            // Decode unknown envelopes for gaps in ordinals.
5771            while _next_ordinal_to_read < 5 {
5772                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5773                _next_ordinal_to_read += 1;
5774                next_offset += envelope_size;
5775            }
5776
5777            let next_out_of_line = decoder.next_out_of_line();
5778            let handles_before = decoder.remaining_handles();
5779            if let Some((inlined, num_bytes, num_handles)) =
5780                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5781            {
5782                let member_inline_size = <fidl::encoding::Vector<
5783                    fidl_fuchsia_component_runner::ComponentNamespaceEntry,
5784                    32,
5785                > as fidl::encoding::TypeMarker>::inline_size(
5786                    decoder.context
5787                );
5788                if inlined != (member_inline_size <= 4) {
5789                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5790                }
5791                let inner_offset;
5792                let mut inner_depth = depth.clone();
5793                if inlined {
5794                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5795                    inner_offset = next_offset;
5796                } else {
5797                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5798                    inner_depth.increment()?;
5799                }
5800                let val_ref =
5801                self.incoming.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>, fidl::encoding::DefaultFuchsiaResourceDialect));
5802                fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_component_runner::ComponentNamespaceEntry, 32>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5803                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5804                {
5805                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5806                }
5807                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5808                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5809                }
5810            }
5811
5812            next_offset += envelope_size;
5813            _next_ordinal_to_read += 1;
5814            if next_offset >= end_offset {
5815                return Ok(());
5816            }
5817
5818            // Decode unknown envelopes for gaps in ordinals.
5819            while _next_ordinal_to_read < 6 {
5820                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5821                _next_ordinal_to_read += 1;
5822                next_offset += envelope_size;
5823            }
5824
5825            let next_out_of_line = decoder.next_out_of_line();
5826            let handles_before = decoder.remaining_handles();
5827            if let Some((inlined, num_bytes, num_handles)) =
5828                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5829            {
5830                let member_inline_size = <fidl::encoding::Endpoint<
5831                    fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5832                > as fidl::encoding::TypeMarker>::inline_size(
5833                    decoder.context
5834                );
5835                if inlined != (member_inline_size <= 4) {
5836                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5837                }
5838                let inner_offset;
5839                let mut inner_depth = depth.clone();
5840                if inlined {
5841                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5842                    inner_offset = next_offset;
5843                } else {
5844                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5845                    inner_depth.increment()?;
5846                }
5847                let val_ref = self.outgoing_dir.get_or_insert_with(|| {
5848                    fidl::new_empty!(
5849                        fidl::encoding::Endpoint<
5850                            fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5851                        >,
5852                        fidl::encoding::DefaultFuchsiaResourceDialect
5853                    )
5854                });
5855                fidl::decode!(
5856                    fidl::encoding::Endpoint<
5857                        fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>,
5858                    >,
5859                    fidl::encoding::DefaultFuchsiaResourceDialect,
5860                    val_ref,
5861                    decoder,
5862                    inner_offset,
5863                    inner_depth
5864                )?;
5865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5866                {
5867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5868                }
5869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5871                }
5872            }
5873
5874            next_offset += envelope_size;
5875            _next_ordinal_to_read += 1;
5876            if next_offset >= end_offset {
5877                return Ok(());
5878            }
5879
5880            // Decode unknown envelopes for gaps in ordinals.
5881            while _next_ordinal_to_read < 7 {
5882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5883                _next_ordinal_to_read += 1;
5884                next_offset += envelope_size;
5885            }
5886
5887            let next_out_of_line = decoder.next_out_of_line();
5888            let handles_before = decoder.remaining_handles();
5889            if let Some((inlined, num_bytes, num_handles)) =
5890                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5891            {
5892                let member_inline_size = <fidl::encoding::HandleType<
5893                    fidl::Vmo,
5894                    { fidl::ObjectType::VMO.into_raw() },
5895                    2147483648,
5896                > as fidl::encoding::TypeMarker>::inline_size(
5897                    decoder.context
5898                );
5899                if inlined != (member_inline_size <= 4) {
5900                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5901                }
5902                let inner_offset;
5903                let mut inner_depth = depth.clone();
5904                if inlined {
5905                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5906                    inner_offset = next_offset;
5907                } else {
5908                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5909                    inner_depth.increment()?;
5910                }
5911                let val_ref =
5912                self.config.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5913                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5914                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5915                {
5916                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5917                }
5918                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5919                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5920                }
5921            }
5922
5923            next_offset += envelope_size;
5924            _next_ordinal_to_read += 1;
5925            if next_offset >= end_offset {
5926                return Ok(());
5927            }
5928
5929            // Decode unknown envelopes for gaps in ordinals.
5930            while _next_ordinal_to_read < 8 {
5931                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5932                _next_ordinal_to_read += 1;
5933                next_offset += envelope_size;
5934            }
5935
5936            let next_out_of_line = decoder.next_out_of_line();
5937            let handles_before = decoder.remaining_handles();
5938            if let Some((inlined, num_bytes, num_handles)) =
5939                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5940            {
5941                let member_inline_size =
5942                    <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
5943                        decoder.context,
5944                    );
5945                if inlined != (member_inline_size <= 4) {
5946                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5947                }
5948                let inner_offset;
5949                let mut inner_depth = depth.clone();
5950                if inlined {
5951                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5952                    inner_offset = next_offset;
5953                } else {
5954                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5955                    inner_depth.increment()?;
5956                }
5957                let val_ref = self.node_name.get_or_insert_with(|| {
5958                    fidl::new_empty!(
5959                        fidl::encoding::UnboundedString,
5960                        fidl::encoding::DefaultFuchsiaResourceDialect
5961                    )
5962                });
5963                fidl::decode!(
5964                    fidl::encoding::UnboundedString,
5965                    fidl::encoding::DefaultFuchsiaResourceDialect,
5966                    val_ref,
5967                    decoder,
5968                    inner_offset,
5969                    inner_depth
5970                )?;
5971                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5972                {
5973                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5974                }
5975                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5976                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5977                }
5978            }
5979
5980            next_offset += envelope_size;
5981            _next_ordinal_to_read += 1;
5982            if next_offset >= end_offset {
5983                return Ok(());
5984            }
5985
5986            // Decode unknown envelopes for gaps in ordinals.
5987            while _next_ordinal_to_read < 9 {
5988                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5989                _next_ordinal_to_read += 1;
5990                next_offset += envelope_size;
5991            }
5992
5993            let next_out_of_line = decoder.next_out_of_line();
5994            let handles_before = decoder.remaining_handles();
5995            if let Some((inlined, num_bytes, num_handles)) =
5996                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5997            {
5998                let member_inline_size = <fidl::encoding::UnboundedVector<NodePropertyEntry> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5999                if inlined != (member_inline_size <= 4) {
6000                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6001                }
6002                let inner_offset;
6003                let mut inner_depth = depth.clone();
6004                if inlined {
6005                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6006                    inner_offset = next_offset;
6007                } else {
6008                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6009                    inner_depth.increment()?;
6010                }
6011                let val_ref = self.node_properties.get_or_insert_with(|| {
6012                    fidl::new_empty!(
6013                        fidl::encoding::UnboundedVector<NodePropertyEntry>,
6014                        fidl::encoding::DefaultFuchsiaResourceDialect
6015                    )
6016                });
6017                fidl::decode!(
6018                    fidl::encoding::UnboundedVector<NodePropertyEntry>,
6019                    fidl::encoding::DefaultFuchsiaResourceDialect,
6020                    val_ref,
6021                    decoder,
6022                    inner_offset,
6023                    inner_depth
6024                )?;
6025                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6026                {
6027                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6028                }
6029                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6030                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6031                }
6032            }
6033
6034            next_offset += envelope_size;
6035            _next_ordinal_to_read += 1;
6036            if next_offset >= end_offset {
6037                return Ok(());
6038            }
6039
6040            // Decode unknown envelopes for gaps in ordinals.
6041            while _next_ordinal_to_read < 10 {
6042                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6043                _next_ordinal_to_read += 1;
6044                next_offset += envelope_size;
6045            }
6046
6047            let next_out_of_line = decoder.next_out_of_line();
6048            let handles_before = decoder.remaining_handles();
6049            if let Some((inlined, num_bytes, num_handles)) =
6050                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6051            {
6052                let member_inline_size =
6053                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::TypeMarker>::inline_size(
6054                        decoder.context,
6055                    );
6056                if inlined != (member_inline_size <= 4) {
6057                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6058                }
6059                let inner_offset;
6060                let mut inner_depth = depth.clone();
6061                if inlined {
6062                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6063                    inner_offset = next_offset;
6064                } else {
6065                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6066                    inner_depth.increment()?;
6067                }
6068                let val_ref =
6069                self.node_offers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect));
6070                fidl::decode!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6071                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6072                {
6073                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6074                }
6075                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6076                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6077                }
6078            }
6079
6080            next_offset += envelope_size;
6081            _next_ordinal_to_read += 1;
6082            if next_offset >= end_offset {
6083                return Ok(());
6084            }
6085
6086            // Decode unknown envelopes for gaps in ordinals.
6087            while _next_ordinal_to_read < 11 {
6088                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6089                _next_ordinal_to_read += 1;
6090                next_offset += envelope_size;
6091            }
6092
6093            let next_out_of_line = decoder.next_out_of_line();
6094            let handles_before = decoder.remaining_handles();
6095            if let Some((inlined, num_bytes, num_handles)) =
6096                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6097            {
6098                let member_inline_size = <fidl::encoding::HandleType<
6099                    fidl::Event,
6100                    { fidl::ObjectType::EVENT.into_raw() },
6101                    2147483648,
6102                > as fidl::encoding::TypeMarker>::inline_size(
6103                    decoder.context
6104                );
6105                if inlined != (member_inline_size <= 4) {
6106                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6107                }
6108                let inner_offset;
6109                let mut inner_depth = depth.clone();
6110                if inlined {
6111                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6112                    inner_offset = next_offset;
6113                } else {
6114                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6115                    inner_depth.increment()?;
6116                }
6117                let val_ref =
6118                self.node_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6119                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6120                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6121                {
6122                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6123                }
6124                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6125                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6126                }
6127            }
6128
6129            next_offset += envelope_size;
6130            _next_ordinal_to_read += 1;
6131            if next_offset >= end_offset {
6132                return Ok(());
6133            }
6134
6135            // Decode unknown envelopes for gaps in ordinals.
6136            while _next_ordinal_to_read < 12 {
6137                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6138                _next_ordinal_to_read += 1;
6139                next_offset += envelope_size;
6140            }
6141
6142            let next_out_of_line = decoder.next_out_of_line();
6143            let handles_before = decoder.remaining_handles();
6144            if let Some((inlined, num_bytes, num_handles)) =
6145                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6146            {
6147                let member_inline_size = <fidl::encoding::UnboundedVector<NodePropertyEntry2> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6148                if inlined != (member_inline_size <= 4) {
6149                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6150                }
6151                let inner_offset;
6152                let mut inner_depth = depth.clone();
6153                if inlined {
6154                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6155                    inner_offset = next_offset;
6156                } else {
6157                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6158                    inner_depth.increment()?;
6159                }
6160                let val_ref = self.node_properties_2.get_or_insert_with(|| {
6161                    fidl::new_empty!(
6162                        fidl::encoding::UnboundedVector<NodePropertyEntry2>,
6163                        fidl::encoding::DefaultFuchsiaResourceDialect
6164                    )
6165                });
6166                fidl::decode!(
6167                    fidl::encoding::UnboundedVector<NodePropertyEntry2>,
6168                    fidl::encoding::DefaultFuchsiaResourceDialect,
6169                    val_ref,
6170                    decoder,
6171                    inner_offset,
6172                    inner_depth
6173                )?;
6174                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6175                {
6176                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6177                }
6178                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6179                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6180                }
6181            }
6182
6183            next_offset += envelope_size;
6184            _next_ordinal_to_read += 1;
6185            if next_offset >= end_offset {
6186                return Ok(());
6187            }
6188
6189            // Decode unknown envelopes for gaps in ordinals.
6190            while _next_ordinal_to_read < 13 {
6191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6192                _next_ordinal_to_read += 1;
6193                next_offset += envelope_size;
6194            }
6195
6196            let next_out_of_line = decoder.next_out_of_line();
6197            let handles_before = decoder.remaining_handles();
6198            if let Some((inlined, num_bytes, num_handles)) =
6199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6200            {
6201                let member_inline_size = <fidl::encoding::HandleType<
6202                    fidl::Vmar,
6203                    { fidl::ObjectType::VMAR.into_raw() },
6204                    2147483648,
6205                > as fidl::encoding::TypeMarker>::inline_size(
6206                    decoder.context
6207                );
6208                if inlined != (member_inline_size <= 4) {
6209                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6210                }
6211                let inner_offset;
6212                let mut inner_depth = depth.clone();
6213                if inlined {
6214                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6215                    inner_offset = next_offset;
6216                } else {
6217                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6218                    inner_depth.increment()?;
6219                }
6220                let val_ref =
6221                self.vmar.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6222                fidl::decode!(fidl::encoding::HandleType<fidl::Vmar, { fidl::ObjectType::VMAR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6223                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6224                {
6225                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6226                }
6227                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6228                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6229                }
6230            }
6231
6232            next_offset += envelope_size;
6233            _next_ordinal_to_read += 1;
6234            if next_offset >= end_offset {
6235                return Ok(());
6236            }
6237
6238            // Decode unknown envelopes for gaps in ordinals.
6239            while _next_ordinal_to_read < 14 {
6240                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6241                _next_ordinal_to_read += 1;
6242                next_offset += envelope_size;
6243            }
6244
6245            let next_out_of_line = decoder.next_out_of_line();
6246            let handles_before = decoder.remaining_handles();
6247            if let Some((inlined, num_bytes, num_handles)) =
6248                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6249            {
6250                let member_inline_size =
6251                    <PowerElementArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6252                if inlined != (member_inline_size <= 4) {
6253                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6254                }
6255                let inner_offset;
6256                let mut inner_depth = depth.clone();
6257                if inlined {
6258                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6259                    inner_offset = next_offset;
6260                } else {
6261                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6262                    inner_depth.increment()?;
6263                }
6264                let val_ref = self.power_element_args.get_or_insert_with(|| {
6265                    fidl::new_empty!(
6266                        PowerElementArgs,
6267                        fidl::encoding::DefaultFuchsiaResourceDialect
6268                    )
6269                });
6270                fidl::decode!(
6271                    PowerElementArgs,
6272                    fidl::encoding::DefaultFuchsiaResourceDialect,
6273                    val_ref,
6274                    decoder,
6275                    inner_offset,
6276                    inner_depth
6277                )?;
6278                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6279                {
6280                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6281                }
6282                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6283                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6284                }
6285            }
6286
6287            next_offset += envelope_size;
6288            _next_ordinal_to_read += 1;
6289            if next_offset >= end_offset {
6290                return Ok(());
6291            }
6292
6293            // Decode unknown envelopes for gaps in ordinals.
6294            while _next_ordinal_to_read < 15 {
6295                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6296                _next_ordinal_to_read += 1;
6297                next_offset += envelope_size;
6298            }
6299
6300            let next_out_of_line = decoder.next_out_of_line();
6301            let handles_before = decoder.remaining_handles();
6302            if let Some((inlined, num_bytes, num_handles)) =
6303                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6304            {
6305                let member_inline_size = <fidl::encoding::Endpoint<
6306                    fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>,
6307                > as fidl::encoding::TypeMarker>::inline_size(
6308                    decoder.context
6309                );
6310                if inlined != (member_inline_size <= 4) {
6311                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6312                }
6313                let inner_offset;
6314                let mut inner_depth = depth.clone();
6315                if inlined {
6316                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6317                    inner_offset = next_offset;
6318                } else {
6319                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6320                    inner_depth.increment()?;
6321                }
6322                let val_ref = self.log_sink.get_or_insert_with(|| {
6323                    fidl::new_empty!(
6324                        fidl::encoding::Endpoint<
6325                            fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>,
6326                        >,
6327                        fidl::encoding::DefaultFuchsiaResourceDialect
6328                    )
6329                });
6330                fidl::decode!(
6331                    fidl::encoding::Endpoint<
6332                        fidl::endpoints::ClientEnd<fidl_fuchsia_logger::LogSinkMarker>,
6333                    >,
6334                    fidl::encoding::DefaultFuchsiaResourceDialect,
6335                    val_ref,
6336                    decoder,
6337                    inner_offset,
6338                    inner_depth
6339                )?;
6340                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6341                {
6342                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6343                }
6344                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6345                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6346                }
6347            }
6348
6349            next_offset += envelope_size;
6350
6351            // Decode the remaining unknown envelopes.
6352            while next_offset < end_offset {
6353                _next_ordinal_to_read += 1;
6354                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6355                next_offset += envelope_size;
6356            }
6357
6358            Ok(())
6359        }
6360    }
6361
6362    impl NodeAddArgs {
6363        #[inline(always)]
6364        fn max_ordinal_present(&self) -> u64 {
6365            if let Some(_) = self.driver_host {
6366                return 10;
6367            }
6368            if let Some(_) = self.offers_dictionary {
6369                return 9;
6370            }
6371            if let Some(_) = self.properties2 {
6372                return 8;
6373            }
6374            if let Some(_) = self.bus_info {
6375                return 7;
6376            }
6377            if let Some(_) = self.offers2 {
6378                return 6;
6379            }
6380            if let Some(_) = self.devfs_args {
6381                return 5;
6382            }
6383            if let Some(_) = self.properties {
6384                return 4;
6385            }
6386            if let Some(_) = self.symbols {
6387                return 3;
6388            }
6389            if let Some(_) = self.name {
6390                return 1;
6391            }
6392            0
6393        }
6394    }
6395
6396    impl fidl::encoding::ResourceTypeMarker for NodeAddArgs {
6397        type Borrowed<'a> = &'a mut Self;
6398        fn take_or_borrow<'a>(
6399            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6400        ) -> Self::Borrowed<'a> {
6401            value
6402        }
6403    }
6404
6405    unsafe impl fidl::encoding::TypeMarker for NodeAddArgs {
6406        type Owned = Self;
6407
6408        #[inline(always)]
6409        fn inline_align(_context: fidl::encoding::Context) -> usize {
6410            8
6411        }
6412
6413        #[inline(always)]
6414        fn inline_size(_context: fidl::encoding::Context) -> usize {
6415            16
6416        }
6417    }
6418
6419    unsafe impl fidl::encoding::Encode<NodeAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
6420        for &mut NodeAddArgs
6421    {
6422        unsafe fn encode(
6423            self,
6424            encoder: &mut fidl::encoding::Encoder<
6425                '_,
6426                fidl::encoding::DefaultFuchsiaResourceDialect,
6427            >,
6428            offset: usize,
6429            mut depth: fidl::encoding::Depth,
6430        ) -> fidl::Result<()> {
6431            encoder.debug_check_bounds::<NodeAddArgs>(offset);
6432            // Vector header
6433            let max_ordinal: u64 = self.max_ordinal_present();
6434            encoder.write_num(max_ordinal, offset);
6435            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6436            // Calling encoder.out_of_line_offset(0) is not allowed.
6437            if max_ordinal == 0 {
6438                return Ok(());
6439            }
6440            depth.increment()?;
6441            let envelope_size = 8;
6442            let bytes_len = max_ordinal as usize * envelope_size;
6443            #[allow(unused_variables)]
6444            let offset = encoder.out_of_line_offset(bytes_len);
6445            let mut _prev_end_offset: usize = 0;
6446            if 1 > max_ordinal {
6447                return Ok(());
6448            }
6449
6450            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6451            // are envelope_size bytes.
6452            let cur_offset: usize = (1 - 1) * envelope_size;
6453
6454            // Zero reserved fields.
6455            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6456
6457            // Safety:
6458            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6459            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6460            //   envelope_size bytes, there is always sufficient room.
6461            fidl::encoding::encode_in_envelope_optional::<
6462                fidl::encoding::BoundedString<128>,
6463                fidl::encoding::DefaultFuchsiaResourceDialect,
6464            >(
6465                self.name.as_ref().map(
6466                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6467                ),
6468                encoder,
6469                offset + cur_offset,
6470                depth,
6471            )?;
6472
6473            _prev_end_offset = cur_offset + envelope_size;
6474            if 3 > max_ordinal {
6475                return Ok(());
6476            }
6477
6478            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6479            // are envelope_size bytes.
6480            let cur_offset: usize = (3 - 1) * envelope_size;
6481
6482            // Zero reserved fields.
6483            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6484
6485            // Safety:
6486            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6487            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6488            //   envelope_size bytes, there is always sufficient room.
6489            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6490            self.symbols.as_ref().map(<fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::ValueTypeMarker>::borrow),
6491            encoder, offset + cur_offset, depth
6492        )?;
6493
6494            _prev_end_offset = cur_offset + envelope_size;
6495            if 4 > max_ordinal {
6496                return Ok(());
6497            }
6498
6499            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6500            // are envelope_size bytes.
6501            let cur_offset: usize = (4 - 1) * envelope_size;
6502
6503            // Zero reserved fields.
6504            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6505
6506            // Safety:
6507            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6508            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6509            //   envelope_size bytes, there is always sufficient room.
6510            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6511            self.properties.as_ref().map(<fidl::encoding::Vector<NodeProperty, 64> as fidl::encoding::ValueTypeMarker>::borrow),
6512            encoder, offset + cur_offset, depth
6513        )?;
6514
6515            _prev_end_offset = cur_offset + envelope_size;
6516            if 5 > max_ordinal {
6517                return Ok(());
6518            }
6519
6520            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6521            // are envelope_size bytes.
6522            let cur_offset: usize = (5 - 1) * envelope_size;
6523
6524            // Zero reserved fields.
6525            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6526
6527            // Safety:
6528            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6529            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6530            //   envelope_size bytes, there is always sufficient room.
6531            fidl::encoding::encode_in_envelope_optional::<
6532                DevfsAddArgs,
6533                fidl::encoding::DefaultFuchsiaResourceDialect,
6534            >(
6535                self.devfs_args
6536                    .as_mut()
6537                    .map(<DevfsAddArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6538                encoder,
6539                offset + cur_offset,
6540                depth,
6541            )?;
6542
6543            _prev_end_offset = cur_offset + envelope_size;
6544            if 6 > max_ordinal {
6545                return Ok(());
6546            }
6547
6548            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6549            // are envelope_size bytes.
6550            let cur_offset: usize = (6 - 1) * envelope_size;
6551
6552            // Zero reserved fields.
6553            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6554
6555            // Safety:
6556            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6557            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6558            //   envelope_size bytes, there is always sufficient room.
6559            fidl::encoding::encode_in_envelope_optional::<
6560                fidl::encoding::Vector<Offer, 128>,
6561                fidl::encoding::DefaultFuchsiaResourceDialect,
6562            >(
6563                self.offers2.as_ref().map(
6564                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::ValueTypeMarker>::borrow,
6565                ),
6566                encoder,
6567                offset + cur_offset,
6568                depth,
6569            )?;
6570
6571            _prev_end_offset = cur_offset + envelope_size;
6572            if 7 > max_ordinal {
6573                return Ok(());
6574            }
6575
6576            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6577            // are envelope_size bytes.
6578            let cur_offset: usize = (7 - 1) * envelope_size;
6579
6580            // Zero reserved fields.
6581            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6582
6583            // Safety:
6584            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6585            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6586            //   envelope_size bytes, there is always sufficient room.
6587            fidl::encoding::encode_in_envelope_optional::<
6588                BusInfo,
6589                fidl::encoding::DefaultFuchsiaResourceDialect,
6590            >(
6591                self.bus_info.as_ref().map(<BusInfo as fidl::encoding::ValueTypeMarker>::borrow),
6592                encoder,
6593                offset + cur_offset,
6594                depth,
6595            )?;
6596
6597            _prev_end_offset = cur_offset + envelope_size;
6598            if 8 > max_ordinal {
6599                return Ok(());
6600            }
6601
6602            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6603            // are envelope_size bytes.
6604            let cur_offset: usize = (8 - 1) * envelope_size;
6605
6606            // Zero reserved fields.
6607            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6608
6609            // Safety:
6610            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6611            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6612            //   envelope_size bytes, there is always sufficient room.
6613            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
6614            self.properties2.as_ref().map(<fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::ValueTypeMarker>::borrow),
6615            encoder, offset + cur_offset, depth
6616        )?;
6617
6618            _prev_end_offset = cur_offset + envelope_size;
6619            if 9 > max_ordinal {
6620                return Ok(());
6621            }
6622
6623            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6624            // are envelope_size bytes.
6625            let cur_offset: usize = (9 - 1) * envelope_size;
6626
6627            // Zero reserved fields.
6628            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6629
6630            // Safety:
6631            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6632            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6633            //   envelope_size bytes, there is always sufficient room.
6634            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_component_sandbox::DictionaryRef, fidl::encoding::DefaultFuchsiaResourceDialect>(
6635            self.offers_dictionary.as_mut().map(<fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6636            encoder, offset + cur_offset, depth
6637        )?;
6638
6639            _prev_end_offset = cur_offset + envelope_size;
6640            if 10 > max_ordinal {
6641                return Ok(());
6642            }
6643
6644            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6645            // are envelope_size bytes.
6646            let cur_offset: usize = (10 - 1) * envelope_size;
6647
6648            // Zero reserved fields.
6649            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6650
6651            // Safety:
6652            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6653            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6654            //   envelope_size bytes, there is always sufficient room.
6655            fidl::encoding::encode_in_envelope_optional::<
6656                fidl::encoding::BoundedString<128>,
6657                fidl::encoding::DefaultFuchsiaResourceDialect,
6658            >(
6659                self.driver_host.as_ref().map(
6660                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
6661                ),
6662                encoder,
6663                offset + cur_offset,
6664                depth,
6665            )?;
6666
6667            _prev_end_offset = cur_offset + envelope_size;
6668
6669            Ok(())
6670        }
6671    }
6672
6673    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for NodeAddArgs {
6674        #[inline(always)]
6675        fn new_empty() -> Self {
6676            Self::default()
6677        }
6678
6679        unsafe fn decode(
6680            &mut self,
6681            decoder: &mut fidl::encoding::Decoder<
6682                '_,
6683                fidl::encoding::DefaultFuchsiaResourceDialect,
6684            >,
6685            offset: usize,
6686            mut depth: fidl::encoding::Depth,
6687        ) -> fidl::Result<()> {
6688            decoder.debug_check_bounds::<Self>(offset);
6689            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6690                None => return Err(fidl::Error::NotNullable),
6691                Some(len) => len,
6692            };
6693            // Calling decoder.out_of_line_offset(0) is not allowed.
6694            if len == 0 {
6695                return Ok(());
6696            };
6697            depth.increment()?;
6698            let envelope_size = 8;
6699            let bytes_len = len * envelope_size;
6700            let offset = decoder.out_of_line_offset(bytes_len)?;
6701            // Decode the envelope for each type.
6702            let mut _next_ordinal_to_read = 0;
6703            let mut next_offset = offset;
6704            let end_offset = offset + bytes_len;
6705            _next_ordinal_to_read += 1;
6706            if next_offset >= end_offset {
6707                return Ok(());
6708            }
6709
6710            // Decode unknown envelopes for gaps in ordinals.
6711            while _next_ordinal_to_read < 1 {
6712                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6713                _next_ordinal_to_read += 1;
6714                next_offset += envelope_size;
6715            }
6716
6717            let next_out_of_line = decoder.next_out_of_line();
6718            let handles_before = decoder.remaining_handles();
6719            if let Some((inlined, num_bytes, num_handles)) =
6720                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6721            {
6722                let member_inline_size =
6723                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
6724                        decoder.context,
6725                    );
6726                if inlined != (member_inline_size <= 4) {
6727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6728                }
6729                let inner_offset;
6730                let mut inner_depth = depth.clone();
6731                if inlined {
6732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6733                    inner_offset = next_offset;
6734                } else {
6735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6736                    inner_depth.increment()?;
6737                }
6738                let val_ref = self.name.get_or_insert_with(|| {
6739                    fidl::new_empty!(
6740                        fidl::encoding::BoundedString<128>,
6741                        fidl::encoding::DefaultFuchsiaResourceDialect
6742                    )
6743                });
6744                fidl::decode!(
6745                    fidl::encoding::BoundedString<128>,
6746                    fidl::encoding::DefaultFuchsiaResourceDialect,
6747                    val_ref,
6748                    decoder,
6749                    inner_offset,
6750                    inner_depth
6751                )?;
6752                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6753                {
6754                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6755                }
6756                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6757                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6758                }
6759            }
6760
6761            next_offset += envelope_size;
6762            _next_ordinal_to_read += 1;
6763            if next_offset >= end_offset {
6764                return Ok(());
6765            }
6766
6767            // Decode unknown envelopes for gaps in ordinals.
6768            while _next_ordinal_to_read < 3 {
6769                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6770                _next_ordinal_to_read += 1;
6771                next_offset += envelope_size;
6772            }
6773
6774            let next_out_of_line = decoder.next_out_of_line();
6775            let handles_before = decoder.remaining_handles();
6776            if let Some((inlined, num_bytes, num_handles)) =
6777                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6778            {
6779                let member_inline_size = <fidl::encoding::Vector<NodeSymbol, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6780                if inlined != (member_inline_size <= 4) {
6781                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6782                }
6783                let inner_offset;
6784                let mut inner_depth = depth.clone();
6785                if inlined {
6786                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6787                    inner_offset = next_offset;
6788                } else {
6789                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6790                    inner_depth.increment()?;
6791                }
6792                let val_ref =
6793                self.symbols.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
6794                fidl::decode!(fidl::encoding::Vector<NodeSymbol, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6795                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6796                {
6797                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6798                }
6799                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6800                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6801                }
6802            }
6803
6804            next_offset += envelope_size;
6805            _next_ordinal_to_read += 1;
6806            if next_offset >= end_offset {
6807                return Ok(());
6808            }
6809
6810            // Decode unknown envelopes for gaps in ordinals.
6811            while _next_ordinal_to_read < 4 {
6812                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6813                _next_ordinal_to_read += 1;
6814                next_offset += envelope_size;
6815            }
6816
6817            let next_out_of_line = decoder.next_out_of_line();
6818            let handles_before = decoder.remaining_handles();
6819            if let Some((inlined, num_bytes, num_handles)) =
6820                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6821            {
6822                let member_inline_size = <fidl::encoding::Vector<NodeProperty, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6823                if inlined != (member_inline_size <= 4) {
6824                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6825                }
6826                let inner_offset;
6827                let mut inner_depth = depth.clone();
6828                if inlined {
6829                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6830                    inner_offset = next_offset;
6831                } else {
6832                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6833                    inner_depth.increment()?;
6834                }
6835                let val_ref =
6836                self.properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
6837                fidl::decode!(fidl::encoding::Vector<NodeProperty, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6838                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6839                {
6840                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6841                }
6842                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6843                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6844                }
6845            }
6846
6847            next_offset += envelope_size;
6848            _next_ordinal_to_read += 1;
6849            if next_offset >= end_offset {
6850                return Ok(());
6851            }
6852
6853            // Decode unknown envelopes for gaps in ordinals.
6854            while _next_ordinal_to_read < 5 {
6855                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6856                _next_ordinal_to_read += 1;
6857                next_offset += envelope_size;
6858            }
6859
6860            let next_out_of_line = decoder.next_out_of_line();
6861            let handles_before = decoder.remaining_handles();
6862            if let Some((inlined, num_bytes, num_handles)) =
6863                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6864            {
6865                let member_inline_size =
6866                    <DevfsAddArgs as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6867                if inlined != (member_inline_size <= 4) {
6868                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6869                }
6870                let inner_offset;
6871                let mut inner_depth = depth.clone();
6872                if inlined {
6873                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6874                    inner_offset = next_offset;
6875                } else {
6876                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6877                    inner_depth.increment()?;
6878                }
6879                let val_ref = self.devfs_args.get_or_insert_with(|| {
6880                    fidl::new_empty!(DevfsAddArgs, fidl::encoding::DefaultFuchsiaResourceDialect)
6881                });
6882                fidl::decode!(
6883                    DevfsAddArgs,
6884                    fidl::encoding::DefaultFuchsiaResourceDialect,
6885                    val_ref,
6886                    decoder,
6887                    inner_offset,
6888                    inner_depth
6889                )?;
6890                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6891                {
6892                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6893                }
6894                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6895                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6896                }
6897            }
6898
6899            next_offset += envelope_size;
6900            _next_ordinal_to_read += 1;
6901            if next_offset >= end_offset {
6902                return Ok(());
6903            }
6904
6905            // Decode unknown envelopes for gaps in ordinals.
6906            while _next_ordinal_to_read < 6 {
6907                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6908                _next_ordinal_to_read += 1;
6909                next_offset += envelope_size;
6910            }
6911
6912            let next_out_of_line = decoder.next_out_of_line();
6913            let handles_before = decoder.remaining_handles();
6914            if let Some((inlined, num_bytes, num_handles)) =
6915                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6916            {
6917                let member_inline_size =
6918                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::TypeMarker>::inline_size(
6919                        decoder.context,
6920                    );
6921                if inlined != (member_inline_size <= 4) {
6922                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6923                }
6924                let inner_offset;
6925                let mut inner_depth = depth.clone();
6926                if inlined {
6927                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6928                    inner_offset = next_offset;
6929                } else {
6930                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6931                    inner_depth.increment()?;
6932                }
6933                let val_ref =
6934                self.offers2.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect));
6935                fidl::decode!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6936                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6937                {
6938                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6939                }
6940                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6941                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6942                }
6943            }
6944
6945            next_offset += envelope_size;
6946            _next_ordinal_to_read += 1;
6947            if next_offset >= end_offset {
6948                return Ok(());
6949            }
6950
6951            // Decode unknown envelopes for gaps in ordinals.
6952            while _next_ordinal_to_read < 7 {
6953                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6954                _next_ordinal_to_read += 1;
6955                next_offset += envelope_size;
6956            }
6957
6958            let next_out_of_line = decoder.next_out_of_line();
6959            let handles_before = decoder.remaining_handles();
6960            if let Some((inlined, num_bytes, num_handles)) =
6961                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6962            {
6963                let member_inline_size =
6964                    <BusInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6965                if inlined != (member_inline_size <= 4) {
6966                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6967                }
6968                let inner_offset;
6969                let mut inner_depth = depth.clone();
6970                if inlined {
6971                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6972                    inner_offset = next_offset;
6973                } else {
6974                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6975                    inner_depth.increment()?;
6976                }
6977                let val_ref = self.bus_info.get_or_insert_with(|| {
6978                    fidl::new_empty!(BusInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
6979                });
6980                fidl::decode!(
6981                    BusInfo,
6982                    fidl::encoding::DefaultFuchsiaResourceDialect,
6983                    val_ref,
6984                    decoder,
6985                    inner_offset,
6986                    inner_depth
6987                )?;
6988                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6989                {
6990                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6991                }
6992                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6993                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6994                }
6995            }
6996
6997            next_offset += envelope_size;
6998            _next_ordinal_to_read += 1;
6999            if next_offset >= end_offset {
7000                return Ok(());
7001            }
7002
7003            // Decode unknown envelopes for gaps in ordinals.
7004            while _next_ordinal_to_read < 8 {
7005                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7006                _next_ordinal_to_read += 1;
7007                next_offset += envelope_size;
7008            }
7009
7010            let next_out_of_line = decoder.next_out_of_line();
7011            let handles_before = decoder.remaining_handles();
7012            if let Some((inlined, num_bytes, num_handles)) =
7013                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7014            {
7015                let member_inline_size = <fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7016                if inlined != (member_inline_size <= 4) {
7017                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7018                }
7019                let inner_offset;
7020                let mut inner_depth = depth.clone();
7021                if inlined {
7022                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7023                    inner_offset = next_offset;
7024                } else {
7025                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7026                    inner_depth.increment()?;
7027                }
7028                let val_ref =
7029                self.properties2.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
7030                fidl::decode!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7031                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7032                {
7033                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7034                }
7035                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7036                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7037                }
7038            }
7039
7040            next_offset += envelope_size;
7041            _next_ordinal_to_read += 1;
7042            if next_offset >= end_offset {
7043                return Ok(());
7044            }
7045
7046            // Decode unknown envelopes for gaps in ordinals.
7047            while _next_ordinal_to_read < 9 {
7048                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7049                _next_ordinal_to_read += 1;
7050                next_offset += envelope_size;
7051            }
7052
7053            let next_out_of_line = decoder.next_out_of_line();
7054            let handles_before = decoder.remaining_handles();
7055            if let Some((inlined, num_bytes, num_handles)) =
7056                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7057            {
7058                let member_inline_size = <fidl_fuchsia_component_sandbox::DictionaryRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7059                if inlined != (member_inline_size <= 4) {
7060                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7061                }
7062                let inner_offset;
7063                let mut inner_depth = depth.clone();
7064                if inlined {
7065                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7066                    inner_offset = next_offset;
7067                } else {
7068                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7069                    inner_depth.increment()?;
7070                }
7071                let val_ref = self.offers_dictionary.get_or_insert_with(|| {
7072                    fidl::new_empty!(
7073                        fidl_fuchsia_component_sandbox::DictionaryRef,
7074                        fidl::encoding::DefaultFuchsiaResourceDialect
7075                    )
7076                });
7077                fidl::decode!(
7078                    fidl_fuchsia_component_sandbox::DictionaryRef,
7079                    fidl::encoding::DefaultFuchsiaResourceDialect,
7080                    val_ref,
7081                    decoder,
7082                    inner_offset,
7083                    inner_depth
7084                )?;
7085                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7086                {
7087                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7088                }
7089                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7090                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7091                }
7092            }
7093
7094            next_offset += envelope_size;
7095            _next_ordinal_to_read += 1;
7096            if next_offset >= end_offset {
7097                return Ok(());
7098            }
7099
7100            // Decode unknown envelopes for gaps in ordinals.
7101            while _next_ordinal_to_read < 10 {
7102                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7103                _next_ordinal_to_read += 1;
7104                next_offset += envelope_size;
7105            }
7106
7107            let next_out_of_line = decoder.next_out_of_line();
7108            let handles_before = decoder.remaining_handles();
7109            if let Some((inlined, num_bytes, num_handles)) =
7110                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7111            {
7112                let member_inline_size =
7113                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
7114                        decoder.context,
7115                    );
7116                if inlined != (member_inline_size <= 4) {
7117                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7118                }
7119                let inner_offset;
7120                let mut inner_depth = depth.clone();
7121                if inlined {
7122                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7123                    inner_offset = next_offset;
7124                } else {
7125                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7126                    inner_depth.increment()?;
7127                }
7128                let val_ref = self.driver_host.get_or_insert_with(|| {
7129                    fidl::new_empty!(
7130                        fidl::encoding::BoundedString<128>,
7131                        fidl::encoding::DefaultFuchsiaResourceDialect
7132                    )
7133                });
7134                fidl::decode!(
7135                    fidl::encoding::BoundedString<128>,
7136                    fidl::encoding::DefaultFuchsiaResourceDialect,
7137                    val_ref,
7138                    decoder,
7139                    inner_offset,
7140                    inner_depth
7141                )?;
7142                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7143                {
7144                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7145                }
7146                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7147                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7148                }
7149            }
7150
7151            next_offset += envelope_size;
7152
7153            // Decode the remaining unknown envelopes.
7154            while next_offset < end_offset {
7155                _next_ordinal_to_read += 1;
7156                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7157                next_offset += envelope_size;
7158            }
7159
7160            Ok(())
7161        }
7162    }
7163
7164    impl NodeControllerOnBindRequest {
7165        #[inline(always)]
7166        fn max_ordinal_present(&self) -> u64 {
7167            if let Some(_) = self.node_token {
7168                return 1;
7169            }
7170            0
7171        }
7172    }
7173
7174    impl fidl::encoding::ResourceTypeMarker for NodeControllerOnBindRequest {
7175        type Borrowed<'a> = &'a mut Self;
7176        fn take_or_borrow<'a>(
7177            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7178        ) -> Self::Borrowed<'a> {
7179            value
7180        }
7181    }
7182
7183    unsafe impl fidl::encoding::TypeMarker for NodeControllerOnBindRequest {
7184        type Owned = Self;
7185
7186        #[inline(always)]
7187        fn inline_align(_context: fidl::encoding::Context) -> usize {
7188            8
7189        }
7190
7191        #[inline(always)]
7192        fn inline_size(_context: fidl::encoding::Context) -> usize {
7193            16
7194        }
7195    }
7196
7197    unsafe impl
7198        fidl::encoding::Encode<
7199            NodeControllerOnBindRequest,
7200            fidl::encoding::DefaultFuchsiaResourceDialect,
7201        > for &mut NodeControllerOnBindRequest
7202    {
7203        unsafe fn encode(
7204            self,
7205            encoder: &mut fidl::encoding::Encoder<
7206                '_,
7207                fidl::encoding::DefaultFuchsiaResourceDialect,
7208            >,
7209            offset: usize,
7210            mut depth: fidl::encoding::Depth,
7211        ) -> fidl::Result<()> {
7212            encoder.debug_check_bounds::<NodeControllerOnBindRequest>(offset);
7213            // Vector header
7214            let max_ordinal: u64 = self.max_ordinal_present();
7215            encoder.write_num(max_ordinal, offset);
7216            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7217            // Calling encoder.out_of_line_offset(0) is not allowed.
7218            if max_ordinal == 0 {
7219                return Ok(());
7220            }
7221            depth.increment()?;
7222            let envelope_size = 8;
7223            let bytes_len = max_ordinal as usize * envelope_size;
7224            #[allow(unused_variables)]
7225            let offset = encoder.out_of_line_offset(bytes_len);
7226            let mut _prev_end_offset: usize = 0;
7227            if 1 > max_ordinal {
7228                return Ok(());
7229            }
7230
7231            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7232            // are envelope_size bytes.
7233            let cur_offset: usize = (1 - 1) * envelope_size;
7234
7235            // Zero reserved fields.
7236            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7237
7238            // Safety:
7239            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7240            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7241            //   envelope_size bytes, there is always sufficient room.
7242            fidl::encoding::encode_in_envelope_optional::<
7243                fidl::encoding::HandleType<
7244                    fidl::Event,
7245                    { fidl::ObjectType::EVENT.into_raw() },
7246                    2147483648,
7247                >,
7248                fidl::encoding::DefaultFuchsiaResourceDialect,
7249            >(
7250                self.node_token.as_mut().map(
7251                    <fidl::encoding::HandleType<
7252                        fidl::Event,
7253                        { fidl::ObjectType::EVENT.into_raw() },
7254                        2147483648,
7255                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7256                ),
7257                encoder,
7258                offset + cur_offset,
7259                depth,
7260            )?;
7261
7262            _prev_end_offset = cur_offset + envelope_size;
7263
7264            Ok(())
7265        }
7266    }
7267
7268    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7269        for NodeControllerOnBindRequest
7270    {
7271        #[inline(always)]
7272        fn new_empty() -> Self {
7273            Self::default()
7274        }
7275
7276        unsafe fn decode(
7277            &mut self,
7278            decoder: &mut fidl::encoding::Decoder<
7279                '_,
7280                fidl::encoding::DefaultFuchsiaResourceDialect,
7281            >,
7282            offset: usize,
7283            mut depth: fidl::encoding::Depth,
7284        ) -> fidl::Result<()> {
7285            decoder.debug_check_bounds::<Self>(offset);
7286            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7287                None => return Err(fidl::Error::NotNullable),
7288                Some(len) => len,
7289            };
7290            // Calling decoder.out_of_line_offset(0) is not allowed.
7291            if len == 0 {
7292                return Ok(());
7293            };
7294            depth.increment()?;
7295            let envelope_size = 8;
7296            let bytes_len = len * envelope_size;
7297            let offset = decoder.out_of_line_offset(bytes_len)?;
7298            // Decode the envelope for each type.
7299            let mut _next_ordinal_to_read = 0;
7300            let mut next_offset = offset;
7301            let end_offset = offset + bytes_len;
7302            _next_ordinal_to_read += 1;
7303            if next_offset >= end_offset {
7304                return Ok(());
7305            }
7306
7307            // Decode unknown envelopes for gaps in ordinals.
7308            while _next_ordinal_to_read < 1 {
7309                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7310                _next_ordinal_to_read += 1;
7311                next_offset += envelope_size;
7312            }
7313
7314            let next_out_of_line = decoder.next_out_of_line();
7315            let handles_before = decoder.remaining_handles();
7316            if let Some((inlined, num_bytes, num_handles)) =
7317                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7318            {
7319                let member_inline_size = <fidl::encoding::HandleType<
7320                    fidl::Event,
7321                    { fidl::ObjectType::EVENT.into_raw() },
7322                    2147483648,
7323                > as fidl::encoding::TypeMarker>::inline_size(
7324                    decoder.context
7325                );
7326                if inlined != (member_inline_size <= 4) {
7327                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7328                }
7329                let inner_offset;
7330                let mut inner_depth = depth.clone();
7331                if inlined {
7332                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7333                    inner_offset = next_offset;
7334                } else {
7335                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7336                    inner_depth.increment()?;
7337                }
7338                let val_ref =
7339                self.node_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7340                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7341                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7342                {
7343                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7344                }
7345                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7346                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7347                }
7348            }
7349
7350            next_offset += envelope_size;
7351
7352            // Decode the remaining unknown envelopes.
7353            while next_offset < end_offset {
7354                _next_ordinal_to_read += 1;
7355                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7356                next_offset += envelope_size;
7357            }
7358
7359            Ok(())
7360        }
7361    }
7362
7363    impl PowerElementArgs {
7364        #[inline(always)]
7365        fn max_ordinal_present(&self) -> u64 {
7366            if let Some(_) = self.token {
7367                return 4;
7368            }
7369            if let Some(_) = self.lessor_client {
7370                return 3;
7371            }
7372            if let Some(_) = self.runner_server {
7373                return 2;
7374            }
7375            if let Some(_) = self.control_client {
7376                return 1;
7377            }
7378            0
7379        }
7380    }
7381
7382    impl fidl::encoding::ResourceTypeMarker for PowerElementArgs {
7383        type Borrowed<'a> = &'a mut Self;
7384        fn take_or_borrow<'a>(
7385            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7386        ) -> Self::Borrowed<'a> {
7387            value
7388        }
7389    }
7390
7391    unsafe impl fidl::encoding::TypeMarker for PowerElementArgs {
7392        type Owned = Self;
7393
7394        #[inline(always)]
7395        fn inline_align(_context: fidl::encoding::Context) -> usize {
7396            8
7397        }
7398
7399        #[inline(always)]
7400        fn inline_size(_context: fidl::encoding::Context) -> usize {
7401            16
7402        }
7403    }
7404
7405    unsafe impl
7406        fidl::encoding::Encode<PowerElementArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
7407        for &mut PowerElementArgs
7408    {
7409        unsafe fn encode(
7410            self,
7411            encoder: &mut fidl::encoding::Encoder<
7412                '_,
7413                fidl::encoding::DefaultFuchsiaResourceDialect,
7414            >,
7415            offset: usize,
7416            mut depth: fidl::encoding::Depth,
7417        ) -> fidl::Result<()> {
7418            encoder.debug_check_bounds::<PowerElementArgs>(offset);
7419            // Vector header
7420            let max_ordinal: u64 = self.max_ordinal_present();
7421            encoder.write_num(max_ordinal, offset);
7422            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7423            // Calling encoder.out_of_line_offset(0) is not allowed.
7424            if max_ordinal == 0 {
7425                return Ok(());
7426            }
7427            depth.increment()?;
7428            let envelope_size = 8;
7429            let bytes_len = max_ordinal as usize * envelope_size;
7430            #[allow(unused_variables)]
7431            let offset = encoder.out_of_line_offset(bytes_len);
7432            let mut _prev_end_offset: usize = 0;
7433            if 1 > max_ordinal {
7434                return Ok(());
7435            }
7436
7437            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7438            // are envelope_size bytes.
7439            let cur_offset: usize = (1 - 1) * envelope_size;
7440
7441            // Zero reserved fields.
7442            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7443
7444            // Safety:
7445            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7446            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7447            //   envelope_size bytes, there is always sufficient room.
7448            fidl::encoding::encode_in_envelope_optional::<
7449                fidl::encoding::Endpoint<
7450                    fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::ElementControlMarker>,
7451                >,
7452                fidl::encoding::DefaultFuchsiaResourceDialect,
7453            >(
7454                self.control_client.as_mut().map(
7455                    <fidl::encoding::Endpoint<
7456                        fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::ElementControlMarker>,
7457                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7458                ),
7459                encoder,
7460                offset + cur_offset,
7461                depth,
7462            )?;
7463
7464            _prev_end_offset = cur_offset + envelope_size;
7465            if 2 > max_ordinal {
7466                return Ok(());
7467            }
7468
7469            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7470            // are envelope_size bytes.
7471            let cur_offset: usize = (2 - 1) * envelope_size;
7472
7473            // Zero reserved fields.
7474            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7475
7476            // Safety:
7477            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7478            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7479            //   envelope_size bytes, there is always sufficient room.
7480            fidl::encoding::encode_in_envelope_optional::<
7481                fidl::encoding::Endpoint<
7482                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::ElementRunnerMarker>,
7483                >,
7484                fidl::encoding::DefaultFuchsiaResourceDialect,
7485            >(
7486                self.runner_server.as_mut().map(
7487                    <fidl::encoding::Endpoint<
7488                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::ElementRunnerMarker>,
7489                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7490                ),
7491                encoder,
7492                offset + cur_offset,
7493                depth,
7494            )?;
7495
7496            _prev_end_offset = cur_offset + envelope_size;
7497            if 3 > max_ordinal {
7498                return Ok(());
7499            }
7500
7501            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7502            // are envelope_size bytes.
7503            let cur_offset: usize = (3 - 1) * envelope_size;
7504
7505            // Zero reserved fields.
7506            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7507
7508            // Safety:
7509            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7510            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7511            //   envelope_size bytes, there is always sufficient room.
7512            fidl::encoding::encode_in_envelope_optional::<
7513                fidl::encoding::Endpoint<
7514                    fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>,
7515                >,
7516                fidl::encoding::DefaultFuchsiaResourceDialect,
7517            >(
7518                self.lessor_client.as_mut().map(
7519                    <fidl::encoding::Endpoint<
7520                        fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>,
7521                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7522                ),
7523                encoder,
7524                offset + cur_offset,
7525                depth,
7526            )?;
7527
7528            _prev_end_offset = cur_offset + envelope_size;
7529            if 4 > max_ordinal {
7530                return Ok(());
7531            }
7532
7533            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7534            // are envelope_size bytes.
7535            let cur_offset: usize = (4 - 1) * envelope_size;
7536
7537            // Zero reserved fields.
7538            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7539
7540            // Safety:
7541            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7542            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7543            //   envelope_size bytes, there is always sufficient room.
7544            fidl::encoding::encode_in_envelope_optional::<
7545                fidl::encoding::HandleType<
7546                    fidl::Event,
7547                    { fidl::ObjectType::EVENT.into_raw() },
7548                    2147483648,
7549                >,
7550                fidl::encoding::DefaultFuchsiaResourceDialect,
7551            >(
7552                self.token.as_mut().map(
7553                    <fidl::encoding::HandleType<
7554                        fidl::Event,
7555                        { fidl::ObjectType::EVENT.into_raw() },
7556                        2147483648,
7557                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7558                ),
7559                encoder,
7560                offset + cur_offset,
7561                depth,
7562            )?;
7563
7564            _prev_end_offset = cur_offset + envelope_size;
7565
7566            Ok(())
7567        }
7568    }
7569
7570    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7571        for PowerElementArgs
7572    {
7573        #[inline(always)]
7574        fn new_empty() -> Self {
7575            Self::default()
7576        }
7577
7578        unsafe fn decode(
7579            &mut self,
7580            decoder: &mut fidl::encoding::Decoder<
7581                '_,
7582                fidl::encoding::DefaultFuchsiaResourceDialect,
7583            >,
7584            offset: usize,
7585            mut depth: fidl::encoding::Depth,
7586        ) -> fidl::Result<()> {
7587            decoder.debug_check_bounds::<Self>(offset);
7588            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7589                None => return Err(fidl::Error::NotNullable),
7590                Some(len) => len,
7591            };
7592            // Calling decoder.out_of_line_offset(0) is not allowed.
7593            if len == 0 {
7594                return Ok(());
7595            };
7596            depth.increment()?;
7597            let envelope_size = 8;
7598            let bytes_len = len * envelope_size;
7599            let offset = decoder.out_of_line_offset(bytes_len)?;
7600            // Decode the envelope for each type.
7601            let mut _next_ordinal_to_read = 0;
7602            let mut next_offset = offset;
7603            let end_offset = offset + bytes_len;
7604            _next_ordinal_to_read += 1;
7605            if next_offset >= end_offset {
7606                return Ok(());
7607            }
7608
7609            // Decode unknown envelopes for gaps in ordinals.
7610            while _next_ordinal_to_read < 1 {
7611                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7612                _next_ordinal_to_read += 1;
7613                next_offset += envelope_size;
7614            }
7615
7616            let next_out_of_line = decoder.next_out_of_line();
7617            let handles_before = decoder.remaining_handles();
7618            if let Some((inlined, num_bytes, num_handles)) =
7619                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7620            {
7621                let member_inline_size = <fidl::encoding::Endpoint<
7622                    fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::ElementControlMarker>,
7623                > as fidl::encoding::TypeMarker>::inline_size(
7624                    decoder.context
7625                );
7626                if inlined != (member_inline_size <= 4) {
7627                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7628                }
7629                let inner_offset;
7630                let mut inner_depth = depth.clone();
7631                if inlined {
7632                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7633                    inner_offset = next_offset;
7634                } else {
7635                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7636                    inner_depth.increment()?;
7637                }
7638                let val_ref = self.control_client.get_or_insert_with(|| {
7639                    fidl::new_empty!(
7640                        fidl::encoding::Endpoint<
7641                            fidl::endpoints::ClientEnd<
7642                                fidl_fuchsia_power_broker::ElementControlMarker,
7643                            >,
7644                        >,
7645                        fidl::encoding::DefaultFuchsiaResourceDialect
7646                    )
7647                });
7648                fidl::decode!(
7649                    fidl::encoding::Endpoint<
7650                        fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::ElementControlMarker>,
7651                    >,
7652                    fidl::encoding::DefaultFuchsiaResourceDialect,
7653                    val_ref,
7654                    decoder,
7655                    inner_offset,
7656                    inner_depth
7657                )?;
7658                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7659                {
7660                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7661                }
7662                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7663                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7664                }
7665            }
7666
7667            next_offset += envelope_size;
7668            _next_ordinal_to_read += 1;
7669            if next_offset >= end_offset {
7670                return Ok(());
7671            }
7672
7673            // Decode unknown envelopes for gaps in ordinals.
7674            while _next_ordinal_to_read < 2 {
7675                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7676                _next_ordinal_to_read += 1;
7677                next_offset += envelope_size;
7678            }
7679
7680            let next_out_of_line = decoder.next_out_of_line();
7681            let handles_before = decoder.remaining_handles();
7682            if let Some((inlined, num_bytes, num_handles)) =
7683                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7684            {
7685                let member_inline_size = <fidl::encoding::Endpoint<
7686                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::ElementRunnerMarker>,
7687                > as fidl::encoding::TypeMarker>::inline_size(
7688                    decoder.context
7689                );
7690                if inlined != (member_inline_size <= 4) {
7691                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7692                }
7693                let inner_offset;
7694                let mut inner_depth = depth.clone();
7695                if inlined {
7696                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7697                    inner_offset = next_offset;
7698                } else {
7699                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7700                    inner_depth.increment()?;
7701                }
7702                let val_ref = self.runner_server.get_or_insert_with(|| {
7703                    fidl::new_empty!(
7704                        fidl::encoding::Endpoint<
7705                            fidl::endpoints::ServerEnd<
7706                                fidl_fuchsia_power_broker::ElementRunnerMarker,
7707                            >,
7708                        >,
7709                        fidl::encoding::DefaultFuchsiaResourceDialect
7710                    )
7711                });
7712                fidl::decode!(
7713                    fidl::encoding::Endpoint<
7714                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::ElementRunnerMarker>,
7715                    >,
7716                    fidl::encoding::DefaultFuchsiaResourceDialect,
7717                    val_ref,
7718                    decoder,
7719                    inner_offset,
7720                    inner_depth
7721                )?;
7722                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7723                {
7724                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7725                }
7726                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7727                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7728                }
7729            }
7730
7731            next_offset += envelope_size;
7732            _next_ordinal_to_read += 1;
7733            if next_offset >= end_offset {
7734                return Ok(());
7735            }
7736
7737            // Decode unknown envelopes for gaps in ordinals.
7738            while _next_ordinal_to_read < 3 {
7739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7740                _next_ordinal_to_read += 1;
7741                next_offset += envelope_size;
7742            }
7743
7744            let next_out_of_line = decoder.next_out_of_line();
7745            let handles_before = decoder.remaining_handles();
7746            if let Some((inlined, num_bytes, num_handles)) =
7747                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7748            {
7749                let member_inline_size = <fidl::encoding::Endpoint<
7750                    fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>,
7751                > as fidl::encoding::TypeMarker>::inline_size(
7752                    decoder.context
7753                );
7754                if inlined != (member_inline_size <= 4) {
7755                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7756                }
7757                let inner_offset;
7758                let mut inner_depth = depth.clone();
7759                if inlined {
7760                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7761                    inner_offset = next_offset;
7762                } else {
7763                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7764                    inner_depth.increment()?;
7765                }
7766                let val_ref = self.lessor_client.get_or_insert_with(|| {
7767                    fidl::new_empty!(
7768                        fidl::encoding::Endpoint<
7769                            fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>,
7770                        >,
7771                        fidl::encoding::DefaultFuchsiaResourceDialect
7772                    )
7773                });
7774                fidl::decode!(
7775                    fidl::encoding::Endpoint<
7776                        fidl::endpoints::ClientEnd<fidl_fuchsia_power_broker::LessorMarker>,
7777                    >,
7778                    fidl::encoding::DefaultFuchsiaResourceDialect,
7779                    val_ref,
7780                    decoder,
7781                    inner_offset,
7782                    inner_depth
7783                )?;
7784                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7785                {
7786                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7787                }
7788                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7789                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7790                }
7791            }
7792
7793            next_offset += envelope_size;
7794            _next_ordinal_to_read += 1;
7795            if next_offset >= end_offset {
7796                return Ok(());
7797            }
7798
7799            // Decode unknown envelopes for gaps in ordinals.
7800            while _next_ordinal_to_read < 4 {
7801                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7802                _next_ordinal_to_read += 1;
7803                next_offset += envelope_size;
7804            }
7805
7806            let next_out_of_line = decoder.next_out_of_line();
7807            let handles_before = decoder.remaining_handles();
7808            if let Some((inlined, num_bytes, num_handles)) =
7809                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7810            {
7811                let member_inline_size = <fidl::encoding::HandleType<
7812                    fidl::Event,
7813                    { fidl::ObjectType::EVENT.into_raw() },
7814                    2147483648,
7815                > as fidl::encoding::TypeMarker>::inline_size(
7816                    decoder.context
7817                );
7818                if inlined != (member_inline_size <= 4) {
7819                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7820                }
7821                let inner_offset;
7822                let mut inner_depth = depth.clone();
7823                if inlined {
7824                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7825                    inner_offset = next_offset;
7826                } else {
7827                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7828                    inner_depth.increment()?;
7829                }
7830                let val_ref =
7831                self.token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7832                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7833                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7834                {
7835                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7836                }
7837                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7838                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7839                }
7840            }
7841
7842            next_offset += envelope_size;
7843
7844            // Decode the remaining unknown envelopes.
7845            while next_offset < end_offset {
7846                _next_ordinal_to_read += 1;
7847                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7848                next_offset += envelope_size;
7849            }
7850
7851            Ok(())
7852        }
7853    }
7854
7855    impl ResourceArgs {
7856        #[inline(always)]
7857        fn max_ordinal_present(&self) -> u64 {
7858            if let Some(_) = self.bus_info {
7859                return 4;
7860            }
7861            if let Some(_) = self.offers {
7862                return 3;
7863            }
7864            if let Some(_) = self.properties {
7865                return 2;
7866            }
7867            if let Some(_) = self.name {
7868                return 1;
7869            }
7870            0
7871        }
7872    }
7873
7874    impl fidl::encoding::ResourceTypeMarker for ResourceArgs {
7875        type Borrowed<'a> = &'a mut Self;
7876        fn take_or_borrow<'a>(
7877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7878        ) -> Self::Borrowed<'a> {
7879            value
7880        }
7881    }
7882
7883    unsafe impl fidl::encoding::TypeMarker for ResourceArgs {
7884        type Owned = Self;
7885
7886        #[inline(always)]
7887        fn inline_align(_context: fidl::encoding::Context) -> usize {
7888            8
7889        }
7890
7891        #[inline(always)]
7892        fn inline_size(_context: fidl::encoding::Context) -> usize {
7893            16
7894        }
7895    }
7896
7897    unsafe impl fidl::encoding::Encode<ResourceArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
7898        for &mut ResourceArgs
7899    {
7900        unsafe fn encode(
7901            self,
7902            encoder: &mut fidl::encoding::Encoder<
7903                '_,
7904                fidl::encoding::DefaultFuchsiaResourceDialect,
7905            >,
7906            offset: usize,
7907            mut depth: fidl::encoding::Depth,
7908        ) -> fidl::Result<()> {
7909            encoder.debug_check_bounds::<ResourceArgs>(offset);
7910            // Vector header
7911            let max_ordinal: u64 = self.max_ordinal_present();
7912            encoder.write_num(max_ordinal, offset);
7913            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7914            // Calling encoder.out_of_line_offset(0) is not allowed.
7915            if max_ordinal == 0 {
7916                return Ok(());
7917            }
7918            depth.increment()?;
7919            let envelope_size = 8;
7920            let bytes_len = max_ordinal as usize * envelope_size;
7921            #[allow(unused_variables)]
7922            let offset = encoder.out_of_line_offset(bytes_len);
7923            let mut _prev_end_offset: usize = 0;
7924            if 1 > max_ordinal {
7925                return Ok(());
7926            }
7927
7928            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7929            // are envelope_size bytes.
7930            let cur_offset: usize = (1 - 1) * envelope_size;
7931
7932            // Zero reserved fields.
7933            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7934
7935            // Safety:
7936            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7937            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7938            //   envelope_size bytes, there is always sufficient room.
7939            fidl::encoding::encode_in_envelope_optional::<
7940                fidl::encoding::BoundedString<128>,
7941                fidl::encoding::DefaultFuchsiaResourceDialect,
7942            >(
7943                self.name.as_ref().map(
7944                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow,
7945                ),
7946                encoder,
7947                offset + cur_offset,
7948                depth,
7949            )?;
7950
7951            _prev_end_offset = cur_offset + envelope_size;
7952            if 2 > max_ordinal {
7953                return Ok(());
7954            }
7955
7956            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7957            // are envelope_size bytes.
7958            let cur_offset: usize = (2 - 1) * envelope_size;
7959
7960            // Zero reserved fields.
7961            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7962
7963            // Safety:
7964            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7965            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7966            //   envelope_size bytes, there is always sufficient room.
7967            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
7968            self.properties.as_ref().map(<fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::ValueTypeMarker>::borrow),
7969            encoder, offset + cur_offset, depth
7970        )?;
7971
7972            _prev_end_offset = cur_offset + envelope_size;
7973            if 3 > max_ordinal {
7974                return Ok(());
7975            }
7976
7977            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7978            // are envelope_size bytes.
7979            let cur_offset: usize = (3 - 1) * envelope_size;
7980
7981            // Zero reserved fields.
7982            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7983
7984            // Safety:
7985            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7986            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7987            //   envelope_size bytes, there is always sufficient room.
7988            fidl::encoding::encode_in_envelope_optional::<
7989                fidl::encoding::Vector<Offer, 128>,
7990                fidl::encoding::DefaultFuchsiaResourceDialect,
7991            >(
7992                self.offers.as_ref().map(
7993                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::ValueTypeMarker>::borrow,
7994                ),
7995                encoder,
7996                offset + cur_offset,
7997                depth,
7998            )?;
7999
8000            _prev_end_offset = cur_offset + envelope_size;
8001            if 4 > max_ordinal {
8002                return Ok(());
8003            }
8004
8005            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8006            // are envelope_size bytes.
8007            let cur_offset: usize = (4 - 1) * envelope_size;
8008
8009            // Zero reserved fields.
8010            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8011
8012            // Safety:
8013            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8014            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8015            //   envelope_size bytes, there is always sufficient room.
8016            fidl::encoding::encode_in_envelope_optional::<
8017                BusInfo,
8018                fidl::encoding::DefaultFuchsiaResourceDialect,
8019            >(
8020                self.bus_info.as_ref().map(<BusInfo as fidl::encoding::ValueTypeMarker>::borrow),
8021                encoder,
8022                offset + cur_offset,
8023                depth,
8024            )?;
8025
8026            _prev_end_offset = cur_offset + envelope_size;
8027
8028            Ok(())
8029        }
8030    }
8031
8032    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ResourceArgs {
8033        #[inline(always)]
8034        fn new_empty() -> Self {
8035            Self::default()
8036        }
8037
8038        unsafe fn decode(
8039            &mut self,
8040            decoder: &mut fidl::encoding::Decoder<
8041                '_,
8042                fidl::encoding::DefaultFuchsiaResourceDialect,
8043            >,
8044            offset: usize,
8045            mut depth: fidl::encoding::Depth,
8046        ) -> fidl::Result<()> {
8047            decoder.debug_check_bounds::<Self>(offset);
8048            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8049                None => return Err(fidl::Error::NotNullable),
8050                Some(len) => len,
8051            };
8052            // Calling decoder.out_of_line_offset(0) is not allowed.
8053            if len == 0 {
8054                return Ok(());
8055            };
8056            depth.increment()?;
8057            let envelope_size = 8;
8058            let bytes_len = len * envelope_size;
8059            let offset = decoder.out_of_line_offset(bytes_len)?;
8060            // Decode the envelope for each type.
8061            let mut _next_ordinal_to_read = 0;
8062            let mut next_offset = offset;
8063            let end_offset = offset + bytes_len;
8064            _next_ordinal_to_read += 1;
8065            if next_offset >= end_offset {
8066                return Ok(());
8067            }
8068
8069            // Decode unknown envelopes for gaps in ordinals.
8070            while _next_ordinal_to_read < 1 {
8071                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8072                _next_ordinal_to_read += 1;
8073                next_offset += envelope_size;
8074            }
8075
8076            let next_out_of_line = decoder.next_out_of_line();
8077            let handles_before = decoder.remaining_handles();
8078            if let Some((inlined, num_bytes, num_handles)) =
8079                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8080            {
8081                let member_inline_size =
8082                    <fidl::encoding::BoundedString<128> as fidl::encoding::TypeMarker>::inline_size(
8083                        decoder.context,
8084                    );
8085                if inlined != (member_inline_size <= 4) {
8086                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8087                }
8088                let inner_offset;
8089                let mut inner_depth = depth.clone();
8090                if inlined {
8091                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8092                    inner_offset = next_offset;
8093                } else {
8094                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8095                    inner_depth.increment()?;
8096                }
8097                let val_ref = self.name.get_or_insert_with(|| {
8098                    fidl::new_empty!(
8099                        fidl::encoding::BoundedString<128>,
8100                        fidl::encoding::DefaultFuchsiaResourceDialect
8101                    )
8102                });
8103                fidl::decode!(
8104                    fidl::encoding::BoundedString<128>,
8105                    fidl::encoding::DefaultFuchsiaResourceDialect,
8106                    val_ref,
8107                    decoder,
8108                    inner_offset,
8109                    inner_depth
8110                )?;
8111                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8112                {
8113                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8114                }
8115                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8116                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8117                }
8118            }
8119
8120            next_offset += envelope_size;
8121            _next_ordinal_to_read += 1;
8122            if next_offset >= end_offset {
8123                return Ok(());
8124            }
8125
8126            // Decode unknown envelopes for gaps in ordinals.
8127            while _next_ordinal_to_read < 2 {
8128                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8129                _next_ordinal_to_read += 1;
8130                next_offset += envelope_size;
8131            }
8132
8133            let next_out_of_line = decoder.next_out_of_line();
8134            let handles_before = decoder.remaining_handles();
8135            if let Some((inlined, num_bytes, num_handles)) =
8136                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8137            {
8138                let member_inline_size = <fidl::encoding::Vector<NodeProperty2, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8139                if inlined != (member_inline_size <= 4) {
8140                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8141                }
8142                let inner_offset;
8143                let mut inner_depth = depth.clone();
8144                if inlined {
8145                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8146                    inner_offset = next_offset;
8147                } else {
8148                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8149                    inner_depth.increment()?;
8150                }
8151                let val_ref =
8152                self.properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
8153                fidl::decode!(fidl::encoding::Vector<NodeProperty2, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8154                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8155                {
8156                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8157                }
8158                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8159                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8160                }
8161            }
8162
8163            next_offset += envelope_size;
8164            _next_ordinal_to_read += 1;
8165            if next_offset >= end_offset {
8166                return Ok(());
8167            }
8168
8169            // Decode unknown envelopes for gaps in ordinals.
8170            while _next_ordinal_to_read < 3 {
8171                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8172                _next_ordinal_to_read += 1;
8173                next_offset += envelope_size;
8174            }
8175
8176            let next_out_of_line = decoder.next_out_of_line();
8177            let handles_before = decoder.remaining_handles();
8178            if let Some((inlined, num_bytes, num_handles)) =
8179                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8180            {
8181                let member_inline_size =
8182                    <fidl::encoding::Vector<Offer, 128> as fidl::encoding::TypeMarker>::inline_size(
8183                        decoder.context,
8184                    );
8185                if inlined != (member_inline_size <= 4) {
8186                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8187                }
8188                let inner_offset;
8189                let mut inner_depth = depth.clone();
8190                if inlined {
8191                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8192                    inner_offset = next_offset;
8193                } else {
8194                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8195                    inner_depth.increment()?;
8196                }
8197                let val_ref =
8198                self.offers.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect));
8199                fidl::decode!(fidl::encoding::Vector<Offer, 128>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8200                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8201                {
8202                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8203                }
8204                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8205                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8206                }
8207            }
8208
8209            next_offset += envelope_size;
8210            _next_ordinal_to_read += 1;
8211            if next_offset >= end_offset {
8212                return Ok(());
8213            }
8214
8215            // Decode unknown envelopes for gaps in ordinals.
8216            while _next_ordinal_to_read < 4 {
8217                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8218                _next_ordinal_to_read += 1;
8219                next_offset += envelope_size;
8220            }
8221
8222            let next_out_of_line = decoder.next_out_of_line();
8223            let handles_before = decoder.remaining_handles();
8224            if let Some((inlined, num_bytes, num_handles)) =
8225                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8226            {
8227                let member_inline_size =
8228                    <BusInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8229                if inlined != (member_inline_size <= 4) {
8230                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8231                }
8232                let inner_offset;
8233                let mut inner_depth = depth.clone();
8234                if inlined {
8235                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8236                    inner_offset = next_offset;
8237                } else {
8238                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8239                    inner_depth.increment()?;
8240                }
8241                let val_ref = self.bus_info.get_or_insert_with(|| {
8242                    fidl::new_empty!(BusInfo, fidl::encoding::DefaultFuchsiaResourceDialect)
8243                });
8244                fidl::decode!(
8245                    BusInfo,
8246                    fidl::encoding::DefaultFuchsiaResourceDialect,
8247                    val_ref,
8248                    decoder,
8249                    inner_offset,
8250                    inner_depth
8251                )?;
8252                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8253                {
8254                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8255                }
8256                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8257                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8258                }
8259            }
8260
8261            next_offset += envelope_size;
8262
8263            // Decode the remaining unknown envelopes.
8264            while next_offset < end_offset {
8265                _next_ordinal_to_read += 1;
8266                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8267                next_offset += envelope_size;
8268            }
8269
8270            Ok(())
8271        }
8272    }
8273
8274    impl fidl::encoding::ResourceTypeMarker for DriverResult {
8275        type Borrowed<'a> = &'a mut Self;
8276        fn take_or_borrow<'a>(
8277            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8278        ) -> Self::Borrowed<'a> {
8279            value
8280        }
8281    }
8282
8283    unsafe impl fidl::encoding::TypeMarker for DriverResult {
8284        type Owned = Self;
8285
8286        #[inline(always)]
8287        fn inline_align(_context: fidl::encoding::Context) -> usize {
8288            8
8289        }
8290
8291        #[inline(always)]
8292        fn inline_size(_context: fidl::encoding::Context) -> usize {
8293            16
8294        }
8295    }
8296
8297    unsafe impl fidl::encoding::Encode<DriverResult, fidl::encoding::DefaultFuchsiaResourceDialect>
8298        for &mut DriverResult
8299    {
8300        #[inline]
8301        unsafe fn encode(
8302            self,
8303            encoder: &mut fidl::encoding::Encoder<
8304                '_,
8305                fidl::encoding::DefaultFuchsiaResourceDialect,
8306            >,
8307            offset: usize,
8308            _depth: fidl::encoding::Depth,
8309        ) -> fidl::Result<()> {
8310            encoder.debug_check_bounds::<DriverResult>(offset);
8311            encoder.write_num::<u64>(self.ordinal(), offset);
8312            match self {
8313                DriverResult::DriverStartedNodeToken(ref mut val) => {
8314                    fidl::encoding::encode_in_envelope::<
8315                        fidl::encoding::HandleType<
8316                            fidl::Event,
8317                            { fidl::ObjectType::EVENT.into_raw() },
8318                            2147483648,
8319                        >,
8320                        fidl::encoding::DefaultFuchsiaResourceDialect,
8321                    >(
8322                        <fidl::encoding::HandleType<
8323                            fidl::Event,
8324                            { fidl::ObjectType::EVENT.into_raw() },
8325                            2147483648,
8326                        > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8327                            val
8328                        ),
8329                        encoder,
8330                        offset + 8,
8331                        _depth,
8332                    )
8333                }
8334                DriverResult::MatchError(ref val) => fidl::encoding::encode_in_envelope::<
8335                    i32,
8336                    fidl::encoding::DefaultFuchsiaResourceDialect,
8337                >(
8338                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
8339                    encoder,
8340                    offset + 8,
8341                    _depth,
8342                ),
8343                DriverResult::StartError(ref val) => fidl::encoding::encode_in_envelope::<
8344                    i32,
8345                    fidl::encoding::DefaultFuchsiaResourceDialect,
8346                >(
8347                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(val),
8348                    encoder,
8349                    offset + 8,
8350                    _depth,
8351                ),
8352                DriverResult::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
8353            }
8354        }
8355    }
8356
8357    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for DriverResult {
8358        #[inline(always)]
8359        fn new_empty() -> Self {
8360            Self::__SourceBreaking { unknown_ordinal: 0 }
8361        }
8362
8363        #[inline]
8364        unsafe fn decode(
8365            &mut self,
8366            decoder: &mut fidl::encoding::Decoder<
8367                '_,
8368                fidl::encoding::DefaultFuchsiaResourceDialect,
8369            >,
8370            offset: usize,
8371            mut depth: fidl::encoding::Depth,
8372        ) -> fidl::Result<()> {
8373            decoder.debug_check_bounds::<Self>(offset);
8374            #[allow(unused_variables)]
8375            let next_out_of_line = decoder.next_out_of_line();
8376            let handles_before = decoder.remaining_handles();
8377            let (ordinal, inlined, num_bytes, num_handles) =
8378                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
8379
8380            let member_inline_size = match ordinal {
8381                1 => <fidl::encoding::HandleType<
8382                    fidl::Event,
8383                    { fidl::ObjectType::EVENT.into_raw() },
8384                    2147483648,
8385                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8386                2 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8387                3 => <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
8388                0 => return Err(fidl::Error::UnknownUnionTag),
8389                _ => num_bytes as usize,
8390            };
8391
8392            if inlined != (member_inline_size <= 4) {
8393                return Err(fidl::Error::InvalidInlineBitInEnvelope);
8394            }
8395            let _inner_offset;
8396            if inlined {
8397                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
8398                _inner_offset = offset + 8;
8399            } else {
8400                depth.increment()?;
8401                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8402            }
8403            match ordinal {
8404                1 => {
8405                    #[allow(irrefutable_let_patterns)]
8406                    if let DriverResult::DriverStartedNodeToken(_) = self {
8407                        // Do nothing, read the value into the object
8408                    } else {
8409                        // Initialize `self` to the right variant
8410                        *self = DriverResult::DriverStartedNodeToken(
8411                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8412                        );
8413                    }
8414                    #[allow(irrefutable_let_patterns)]
8415                    if let DriverResult::DriverStartedNodeToken(ref mut val) = self {
8416                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
8417                    } else {
8418                        unreachable!()
8419                    }
8420                }
8421                2 => {
8422                    #[allow(irrefutable_let_patterns)]
8423                    if let DriverResult::MatchError(_) = self {
8424                        // Do nothing, read the value into the object
8425                    } else {
8426                        // Initialize `self` to the right variant
8427                        *self = DriverResult::MatchError(fidl::new_empty!(
8428                            i32,
8429                            fidl::encoding::DefaultFuchsiaResourceDialect
8430                        ));
8431                    }
8432                    #[allow(irrefutable_let_patterns)]
8433                    if let DriverResult::MatchError(ref mut val) = self {
8434                        fidl::decode!(
8435                            i32,
8436                            fidl::encoding::DefaultFuchsiaResourceDialect,
8437                            val,
8438                            decoder,
8439                            _inner_offset,
8440                            depth
8441                        )?;
8442                    } else {
8443                        unreachable!()
8444                    }
8445                }
8446                3 => {
8447                    #[allow(irrefutable_let_patterns)]
8448                    if let DriverResult::StartError(_) = self {
8449                        // Do nothing, read the value into the object
8450                    } else {
8451                        // Initialize `self` to the right variant
8452                        *self = DriverResult::StartError(fidl::new_empty!(
8453                            i32,
8454                            fidl::encoding::DefaultFuchsiaResourceDialect
8455                        ));
8456                    }
8457                    #[allow(irrefutable_let_patterns)]
8458                    if let DriverResult::StartError(ref mut val) = self {
8459                        fidl::decode!(
8460                            i32,
8461                            fidl::encoding::DefaultFuchsiaResourceDialect,
8462                            val,
8463                            decoder,
8464                            _inner_offset,
8465                            depth
8466                        )?;
8467                    } else {
8468                        unreachable!()
8469                    }
8470                }
8471                #[allow(deprecated)]
8472                ordinal => {
8473                    for _ in 0..num_handles {
8474                        decoder.drop_next_handle()?;
8475                    }
8476                    *self = DriverResult::__SourceBreaking { unknown_ordinal: ordinal };
8477                }
8478            }
8479            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
8480                return Err(fidl::Error::InvalidNumBytesInEnvelope);
8481            }
8482            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8483                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8484            }
8485            Ok(())
8486        }
8487    }
8488}