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