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