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