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