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