Skip to main content

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 reads gathered for the ioctl.
25    pub ioctl_reads: Vec<IoctlReadWrite>,
26    /// The files being transfered by the ioctl.
27    pub files: Vec<FileHandle>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BinderIoctlRequest {}
31
32#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
33pub struct BinderMapVmoRequest {
34    pub vmo: fidl::Vmo,
35    pub mapped_address: u64,
36}
37
38impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BinderMapVmoRequest {}
39
40#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
41pub struct BinderRegisterThreadChannelRequest {
42    pub server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
46    for BinderRegisterThreadChannelRequest
47{
48}
49
50#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51pub struct BinderSetVmoRequest {
52    pub vmo: fidl::Vmo,
53    pub mapped_address: u64,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BinderSetVmoRequest {}
57
58#[derive(Debug, PartialEq)]
59pub struct BinderThreadIoctlRequest {
60    /// The ioctl being called.
61    pub request: u32,
62    /// Optional argument for the ioctl.
63    pub arg: u64,
64    /// The VMO to return writes for this ioctl through.
65    pub vmo: fidl::Vmo,
66    /// The reads gathered for the ioctl.
67    pub ioctl_reads: Vec<IoctlReadWrite>,
68    /// The files being transferred by the ioctl.
69    pub files: Vec<FileHandle>,
70}
71
72impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for BinderThreadIoctlRequest {}
73
74#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
75pub struct ProcessAccessorWriteBytesRequest {
76    pub address: u64,
77    pub bytes: Vec<u8>,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
81    for ProcessAccessorWriteBytesRequest
82{
83}
84
85#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
86pub struct ProcessAccessorWriteMemoryRequest {
87    pub address: u64,
88    pub content: fidl::Vmo,
89}
90
91impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
92    for ProcessAccessorWriteMemoryRequest
93{
94}
95
96#[derive(Debug, Default, PartialEq)]
97pub struct CmpRequeueRequest {
98    /// The vmo containing the first futex's word.
99    /// Mandatory
100    pub first_vmo: Option<fidl::Vmo>,
101    /// The offset in first_vmo of the first futex's word.
102    /// Mandatory
103    pub first_offset: Option<u64>,
104    /// The vmo containing the second futex's word.
105    /// Optional. If not present, the first_vmo is also used as the
106    /// second_vmo.
107    pub second_vmo: Option<fidl::Vmo>,
108    /// The offset in second_vmo of the second futex's word.
109    /// Mandatory
110    pub second_offset: Option<u64>,
111    /// Maximum number of waiters to wake. Waiters beyond this count are
112    /// moved to be waiting on the second futex instead, up to
113    /// max_requeue_count.
114    /// Mandatory
115    pub wake_count: Option<u32>,
116    /// Maximum number of waiters to re-queue (among those which were not
117    /// woken) on the second futex. In other words, maximum number of
118    /// waiters which get changed from waiting on the first futex to waiting
119    /// on the second futex instead. Waiters beyond this are left waiting on
120    /// the first futex.
121    /// Mandatory
122    pub requeue_count: Option<u32>,
123    /// Value that must match the uint32_t at first_vmo first_offset for the
124    /// requeue to occur, else no requeue occurs and error will be EAGAIN.
125    /// Optional. If not present, the requeue proceeds regardless of the
126    /// value of the uint32_t at first_vmo first_offset. In other words,
127    /// this field set/un-set chooses FUTEX_CMP_REQUEUE/FUTEX_REQUEUE
128    /// semantics respectively. In addition, this controls the semantics of
129    /// the "count" field in a success response, per differing semantics of
130    /// FUTEX_CMP_REQUEUE and FUTEX_REQUEUE return values.
131    pub cmp_val: Option<u32>,
132    #[doc(hidden)]
133    pub __source_breaking: fidl::marker::SourceBreaking,
134}
135
136impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CmpRequeueRequest {}
137
138#[derive(Debug, Default, PartialEq)]
139pub struct CmpRequeueResponse {
140    /// The number of waiters that were woken up plus the number re-queued.
141    pub count: Option<u64>,
142    #[doc(hidden)]
143    pub __source_breaking: fidl::marker::SourceBreaking,
144}
145
146impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CmpRequeueResponse {}
147
148#[derive(Debug, Default, PartialEq)]
149pub struct ContainerPowerControllerRegisterWakeWatcherRequest {
150    pub watcher: Option<fidl::EventPair>,
151    #[doc(hidden)]
152    pub __source_breaking: fidl::marker::SourceBreaking,
153}
154
155impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
156    for ContainerPowerControllerRegisterWakeWatcherRequest
157{
158}
159
160#[derive(Debug, Default, PartialEq)]
161pub struct ContainerPowerControllerWakeRequest {
162    /// (Optional): This represents a wake lease that the binder server has.
163    /// The container will ensure that this wake lease will be kept alive until
164    /// The container takes its wake lease.
165    pub power_baton: Option<fidl::NullableHandle>,
166    /// (Optional): This creates a wake lock associated with this event pair.
167    /// The container will not go back to sleep until the other end of this event pair has been
168    /// closed.
169    /// If this does not exist, then the container can sleep when it chooses after handling the
170    /// Wake call.
171    ///
172    /// The container will signal the pair of wake_lock with USER_0 when the lock has been created
173    /// in the kernel.
174    pub wake_lock: Option<fidl::EventPair>,
175    #[doc(hidden)]
176    pub __source_breaking: fidl::marker::SourceBreaking,
177}
178
179impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
180    for ContainerPowerControllerWakeRequest
181{
182}
183
184#[derive(Debug, Default, PartialEq)]
185pub struct DevBinderCloseRequest {
186    /// The Binder protocol opened previously.
187    pub binder: Option<fidl::endpoints::ClientEnd<BinderMarker>>,
188    #[doc(hidden)]
189    pub __source_breaking: fidl::marker::SourceBreaking,
190}
191
192impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevBinderCloseRequest {}
193
194#[derive(Debug, Default, PartialEq)]
195pub struct DevBinderOpenRequest {
196    /// The path to the binder device in the starnix process.
197    /// Mandatory
198    pub path: Option<Vec<u8>>,
199    /// The service giving the binder driver access to the resources of the client process.
200    pub process_accessor: Option<fidl::endpoints::ClientEnd<ProcessAccessorMarker>>,
201    /// The handle to the process that will use the binder driver. It is
202    /// used by the driver to read the data sent to the driver.
203    /// Mandatory
204    pub process: Option<fidl::Process>,
205    /// The request to the Binder protocol implementation.
206    /// Mandatory
207    pub binder: Option<fidl::endpoints::ServerEnd<BinderMarker>>,
208    #[doc(hidden)]
209    pub __source_breaking: fidl::marker::SourceBreaking,
210}
211
212impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DevBinderOpenRequest {}
213
214/// The representation of an open file that can be transferred between the
215/// binder device driver and the client.
216#[derive(Debug, Default, PartialEq)]
217pub struct FileHandle {
218    /// The handle connecting to the file protocol. If not present, the file
219    /// should behave as it is was a null file: all read must succeed with empty
220    /// content and all write must succeed. See `fdio_fd_create_null()`.
221    pub handle: Option<fidl::NullableHandle>,
222    /// Optional. The flags associated with the opened file.
223    pub flags: Option<FileFlags>,
224    /// Optional. The file descriptor to help with translation between processes.
225    pub fd: Option<i32>,
226    /// Optional. An opaque bag of handles associated with the file.
227    ///
228    /// If this field is set, handle must not be set.
229    ///
230    /// In Fuchsia, there is an expectation that there is a 1:1 mapping between a file descriptor
231    /// and a handle. In general, we do not want to violate that rule. This field is intended to
232    /// used in very limited circumstances (compatibility with Linux and Binder), where we need to
233    /// violate rule.
234    ///
235    /// When this field is used, the composite_fd library will be used to create the file descriptor
236    /// in a Fuchsia component. Such file descriptors do not support regular operations and must be
237    /// handled using the composite_fd library.
238    pub bag: Option<Vec<fidl::NullableHandle>>,
239    #[doc(hidden)]
240    pub __source_breaking: fidl::marker::SourceBreaking,
241}
242
243impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FileHandle {}
244
245#[derive(Debug, Default, PartialEq)]
246pub struct FileRequest {
247    /// The list of file descriptor the client must close.
248    pub close_requests: Option<Vec<i32>>,
249    /// The list of file descriptor the client must duplicate and transfer to
250    /// the binder driver.
251    pub get_requests: Option<Vec<i32>>,
252    /// The list of open file the client must add to its fd table, returning
253    /// the new minted file descriptors.
254    pub add_requests: Option<Vec<FileHandle>>,
255    #[doc(hidden)]
256    pub __source_breaking: fidl::marker::SourceBreaking,
257}
258
259impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FileRequest {}
260
261#[derive(Debug, Default, PartialEq)]
262pub struct FileResponse {
263    /// The list of open file retriever for the `get_requests`.
264    pub get_responses: Option<Vec<FileHandle>>,
265    /// The list of file descriptors minted for the `add_requests`.
266    pub add_responses: Option<Vec<i32>>,
267    #[doc(hidden)]
268    pub __source_breaking: fidl::marker::SourceBreaking,
269}
270
271impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FileResponse {}
272
273#[derive(Debug, Default, PartialEq)]
274pub struct RemoteControllerStartRequest {
275    pub dev_binder: Option<fidl::endpoints::ClientEnd<DevBinderMarker>>,
276    pub lutex_controller: Option<fidl::endpoints::ClientEnd<LutexControllerMarker>>,
277    pub container_power_controller:
278        Option<fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>>,
279    #[doc(hidden)]
280    pub __source_breaking: fidl::marker::SourceBreaking,
281}
282
283impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
284    for RemoteControllerStartRequest
285{
286}
287
288#[derive(Debug, Default, PartialEq)]
289pub struct UnixDomainSocketWriteRequest {
290    pub data: Option<Vec<u8>>,
291    pub handles: Option<Vec<fidl::NullableHandle>>,
292    #[doc(hidden)]
293    pub __source_breaking: fidl::marker::SourceBreaking,
294}
295
296impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
297    for UnixDomainSocketWriteRequest
298{
299}
300
301#[derive(Debug, Default, PartialEq)]
302pub struct UnixDomainSocketGetEventResponse {
303    pub event: Option<fidl::EventPair>,
304    #[doc(hidden)]
305    pub __source_breaking: fidl::marker::SourceBreaking,
306}
307
308impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
309    for UnixDomainSocketGetEventResponse
310{
311}
312
313#[derive(Debug, Default, PartialEq)]
314pub struct UnixDomainSocketReadResponse {
315    pub data: Option<Vec<u8>>,
316    pub data_original_length: Option<u64>,
317    pub handles: Option<Vec<fidl::NullableHandle>>,
318    #[doc(hidden)]
319    pub __source_breaking: fidl::marker::SourceBreaking,
320}
321
322impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
323    for UnixDomainSocketReadResponse
324{
325}
326
327#[derive(Debug, Default, PartialEq)]
328pub struct WaitBitsetRequest {
329    /// The vmo containing the shared address of the futex.
330    /// Mandatory
331    pub vmo: Option<fidl::Vmo>,
332    /// The offset in the vmo where the shared address of the futex is.
333    /// Mandatory
334    pub offset: Option<u64>,
335    /// The expected value of the futex.
336    /// Mandatory
337    pub value: Option<u32>,
338    /// The bit mask.
339    /// Optional. If not present, as mask with all bits present will be used.
340    pub mask: Option<u32>,
341    /// The deadline for the wait operation.
342    /// Optional. If not present, the operation can block indefinitely.
343    pub deadline: Option<i64>,
344    #[doc(hidden)]
345    pub __source_breaking: fidl::marker::SourceBreaking,
346}
347
348impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WaitBitsetRequest {}
349
350#[derive(Debug, Default, PartialEq)]
351pub struct WakeBitsetRequest {
352    /// The vmo containing the shared address of the futex.
353    /// Mandatory
354    pub vmo: Option<fidl::Vmo>,
355    /// The offset in the vmo where the shared address of the futex is.
356    /// Mandatory
357    pub offset: Option<u64>,
358    /// Maximum number of waiter to wake.
359    /// Mandatory
360    pub count: Option<u32>,
361    /// The bit mask.
362    /// Optional. If not present, as mask with all bits present will be used.
363    pub mask: Option<u32>,
364    #[doc(hidden)]
365    pub __source_breaking: fidl::marker::SourceBreaking,
366}
367
368impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WakeBitsetRequest {}
369
370#[derive(Debug, Default, PartialEq)]
371pub struct WakeResponse {
372    /// The number of waiters that were woken up.
373    pub count: Option<u64>,
374    #[doc(hidden)]
375    pub __source_breaking: fidl::marker::SourceBreaking,
376}
377
378impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WakeResponse {}
379
380#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
381pub struct BinderMarker;
382
383impl fidl::endpoints::ProtocolMarker for BinderMarker {
384    type Proxy = BinderProxy;
385    type RequestStream = BinderRequestStream;
386    #[cfg(target_os = "fuchsia")]
387    type SynchronousProxy = BinderSynchronousProxy;
388
389    const DEBUG_NAME: &'static str = "(anonymous) Binder";
390}
391pub type BinderMapVmoResult = Result<(), fidl_fuchsia_posix::Errno>;
392pub type BinderIoctlResult = Result<Vec<IoctlReadWrite>, fidl_fuchsia_posix::Errno>;
393pub type BinderRegisterThreadChannelResult = Result<(), fidl_fuchsia_posix::Errno>;
394
395pub trait BinderProxyInterface: Send + Sync {
396    fn r#set_vmo(&self, vmo: fidl::Vmo, mapped_address: u64) -> Result<(), fidl::Error>;
397    type MapVmoResponseFut: std::future::Future<Output = Result<BinderMapVmoResult, fidl::Error>>
398        + Send;
399    fn r#map_vmo(&self, vmo: fidl::Vmo, mapped_address: u64) -> Self::MapVmoResponseFut;
400    type IoctlResponseFut: std::future::Future<Output = Result<BinderIoctlResult, fidl::Error>>
401        + Send;
402    fn r#ioctl(
403        &self,
404        tid: u64,
405        request: u32,
406        arg: u64,
407        vmo: fidl::Vmo,
408        ioctl_reads: &[IoctlReadWrite],
409        files: Vec<FileHandle>,
410    ) -> Self::IoctlResponseFut;
411    type RegisterThreadChannelResponseFut: std::future::Future<Output = Result<BinderRegisterThreadChannelResult, fidl::Error>>
412        + Send;
413    fn r#register_thread_channel(
414        &self,
415        server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
416    ) -> Self::RegisterThreadChannelResponseFut;
417}
418#[derive(Debug)]
419#[cfg(target_os = "fuchsia")]
420pub struct BinderSynchronousProxy {
421    client: fidl::client::sync::Client,
422}
423
424#[cfg(target_os = "fuchsia")]
425impl fidl::endpoints::SynchronousProxy for BinderSynchronousProxy {
426    type Proxy = BinderProxy;
427    type Protocol = BinderMarker;
428
429    fn from_channel(inner: fidl::Channel) -> Self {
430        Self::new(inner)
431    }
432
433    fn into_channel(self) -> fidl::Channel {
434        self.client.into_channel()
435    }
436
437    fn as_channel(&self) -> &fidl::Channel {
438        self.client.as_channel()
439    }
440}
441
442#[cfg(target_os = "fuchsia")]
443impl BinderSynchronousProxy {
444    pub fn new(channel: fidl::Channel) -> Self {
445        Self { client: fidl::client::sync::Client::new(channel) }
446    }
447
448    pub fn into_channel(self) -> fidl::Channel {
449        self.client.into_channel()
450    }
451
452    /// Waits until an event arrives and returns it. It is safe for other
453    /// threads to make concurrent requests while waiting for an event.
454    pub fn wait_for_event(
455        &self,
456        deadline: zx::MonotonicInstant,
457    ) -> Result<BinderEvent, fidl::Error> {
458        BinderEvent::decode(self.client.wait_for_event::<BinderMarker>(deadline)?)
459    }
460
461    /// Set the VMO to used as a share resource between the driver and the
462    /// client. `mapped_address` is the address where the vmo is mapped in the
463    /// client address space.
464    ///
465    /// The driver handles the other requests of the client concurrently, so it
466    /// can handle an ioctl before the VMO is mapped. Clients should use
467    /// `MapVmo` instead.
468    pub fn r#set_vmo(
469        &self,
470        mut vmo: fidl::Vmo,
471        mut mapped_address: u64,
472    ) -> Result<(), fidl::Error> {
473        self.client.send::<BinderSetVmoRequest>(
474            (vmo, mapped_address),
475            0x43ee5d8f7d3acbf6,
476            fidl::encoding::DynamicFlags::FLEXIBLE,
477        )
478    }
479
480    /// Maps the VMO used as a shared resource between the driver and the
481    /// client. `mapped_address` is the address where the VMO is mapped in the
482    /// client address space.
483    ///
484    /// Responds once the VMO is mapped. The driver handles the other requests
485    /// of the client concurrently, so the client must wait for the response
486    /// before sending any ioctl that needs the VMO.
487    pub fn r#map_vmo(
488        &self,
489        mut vmo: fidl::Vmo,
490        mut mapped_address: u64,
491        ___deadline: zx::MonotonicInstant,
492    ) -> Result<BinderMapVmoResult, fidl::Error> {
493        let _response = self
494            .client
495            .send_query::<BinderMapVmoRequest, fidl::encoding::FlexibleResultType<
496                fidl::encoding::EmptyStruct,
497                fidl_fuchsia_posix::Errno,
498            >, BinderMarker>(
499                (vmo, mapped_address),
500                0x169c824ba0a5141f,
501                fidl::encoding::DynamicFlags::FLEXIBLE,
502                ___deadline,
503            )?
504            .into_result::<BinderMarker>("map_vmo")?;
505        Ok(_response.map(|x| x))
506    }
507
508    /// Processes a Binder ioctl. This message returns writes for the calling thread
509    /// that must be processed to correctly handle the ioctl.
510    pub fn r#ioctl(
511        &self,
512        mut tid: u64,
513        mut request: u32,
514        mut arg: u64,
515        mut vmo: fidl::Vmo,
516        mut ioctl_reads: &[IoctlReadWrite],
517        mut files: Vec<FileHandle>,
518        ___deadline: zx::MonotonicInstant,
519    ) -> Result<BinderIoctlResult, fidl::Error> {
520        let _response = self.client.send_query::<
521            BinderIoctlRequest,
522            fidl::encoding::FlexibleResultType<BinderIoctlResponse, fidl_fuchsia_posix::Errno>,
523            BinderMarker,
524        >(
525            (tid, request, arg, vmo, ioctl_reads, files.as_mut(),),
526            0x1032021e21310000,
527            fidl::encoding::DynamicFlags::FLEXIBLE,
528            ___deadline,
529        )?
530        .into_result::<BinderMarker>("ioctl")?;
531        Ok(_response.map(|x| x.ioctl_writes))
532    }
533
534    /// Registers a dedicated 1:1 channel for synchronous Binder transactions.
535    pub fn r#register_thread_channel(
536        &self,
537        mut server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
538        ___deadline: zx::MonotonicInstant,
539    ) -> Result<BinderRegisterThreadChannelResult, fidl::Error> {
540        let _response = self
541            .client
542            .send_query::<BinderRegisterThreadChannelRequest, fidl::encoding::FlexibleResultType<
543                fidl::encoding::EmptyStruct,
544                fidl_fuchsia_posix::Errno,
545            >, BinderMarker>(
546                (server_end,),
547                0x1eeeec1ff5de0b47,
548                fidl::encoding::DynamicFlags::FLEXIBLE,
549                ___deadline,
550            )?
551            .into_result::<BinderMarker>("register_thread_channel")?;
552        Ok(_response.map(|x| x))
553    }
554}
555
556#[cfg(target_os = "fuchsia")]
557impl From<BinderSynchronousProxy> for zx::NullableHandle {
558    fn from(value: BinderSynchronousProxy) -> Self {
559        value.into_channel().into()
560    }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl From<fidl::Channel> for BinderSynchronousProxy {
565    fn from(value: fidl::Channel) -> Self {
566        Self::new(value)
567    }
568}
569
570#[cfg(target_os = "fuchsia")]
571impl fidl::endpoints::FromClient for BinderSynchronousProxy {
572    type Protocol = BinderMarker;
573
574    fn from_client(value: fidl::endpoints::ClientEnd<BinderMarker>) -> Self {
575        Self::new(value.into_channel())
576    }
577}
578
579#[derive(Debug, Clone)]
580pub struct BinderProxy {
581    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
582}
583
584impl fidl::endpoints::Proxy for BinderProxy {
585    type Protocol = BinderMarker;
586
587    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
588        Self::new(inner)
589    }
590
591    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
592        self.client.into_channel().map_err(|client| Self { client })
593    }
594
595    fn as_channel(&self) -> &::fidl::AsyncChannel {
596        self.client.as_channel()
597    }
598}
599
600impl BinderProxy {
601    /// Create a new Proxy for fuchsia.starnix.binder/Binder.
602    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
603        let protocol_name = <BinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
604        Self { client: fidl::client::Client::new(channel, protocol_name) }
605    }
606
607    /// Get a Stream of events from the remote end of the protocol.
608    ///
609    /// # Panics
610    ///
611    /// Panics if the event stream was already taken.
612    pub fn take_event_stream(&self) -> BinderEventStream {
613        BinderEventStream { event_receiver: self.client.take_event_receiver() }
614    }
615
616    /// Set the VMO to used as a share resource between the driver and the
617    /// client. `mapped_address` is the address where the vmo is mapped in the
618    /// client address space.
619    ///
620    /// The driver handles the other requests of the client concurrently, so it
621    /// can handle an ioctl before the VMO is mapped. Clients should use
622    /// `MapVmo` instead.
623    pub fn r#set_vmo(
624        &self,
625        mut vmo: fidl::Vmo,
626        mut mapped_address: u64,
627    ) -> Result<(), fidl::Error> {
628        BinderProxyInterface::r#set_vmo(self, vmo, mapped_address)
629    }
630
631    /// Maps the VMO used as a shared resource between the driver and the
632    /// client. `mapped_address` is the address where the VMO is mapped in the
633    /// client address space.
634    ///
635    /// Responds once the VMO is mapped. The driver handles the other requests
636    /// of the client concurrently, so the client must wait for the response
637    /// before sending any ioctl that needs the VMO.
638    pub fn r#map_vmo(
639        &self,
640        mut vmo: fidl::Vmo,
641        mut mapped_address: u64,
642    ) -> fidl::client::QueryResponseFut<
643        BinderMapVmoResult,
644        fidl::encoding::DefaultFuchsiaResourceDialect,
645    > {
646        BinderProxyInterface::r#map_vmo(self, vmo, mapped_address)
647    }
648
649    /// Processes a Binder ioctl. This message returns writes for the calling thread
650    /// that must be processed to correctly handle the ioctl.
651    pub fn r#ioctl(
652        &self,
653        mut tid: u64,
654        mut request: u32,
655        mut arg: u64,
656        mut vmo: fidl::Vmo,
657        mut ioctl_reads: &[IoctlReadWrite],
658        mut files: Vec<FileHandle>,
659    ) -> fidl::client::QueryResponseFut<
660        BinderIoctlResult,
661        fidl::encoding::DefaultFuchsiaResourceDialect,
662    > {
663        BinderProxyInterface::r#ioctl(self, tid, request, arg, vmo, ioctl_reads, files)
664    }
665
666    /// Registers a dedicated 1:1 channel for synchronous Binder transactions.
667    pub fn r#register_thread_channel(
668        &self,
669        mut server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
670    ) -> fidl::client::QueryResponseFut<
671        BinderRegisterThreadChannelResult,
672        fidl::encoding::DefaultFuchsiaResourceDialect,
673    > {
674        BinderProxyInterface::r#register_thread_channel(self, server_end)
675    }
676}
677
678impl BinderProxyInterface for BinderProxy {
679    fn r#set_vmo(&self, mut vmo: fidl::Vmo, mut mapped_address: u64) -> Result<(), fidl::Error> {
680        self.client.send::<BinderSetVmoRequest>(
681            (vmo, mapped_address),
682            0x43ee5d8f7d3acbf6,
683            fidl::encoding::DynamicFlags::FLEXIBLE,
684        )
685    }
686
687    type MapVmoResponseFut = fidl::client::QueryResponseFut<
688        BinderMapVmoResult,
689        fidl::encoding::DefaultFuchsiaResourceDialect,
690    >;
691    fn r#map_vmo(&self, mut vmo: fidl::Vmo, mut mapped_address: u64) -> Self::MapVmoResponseFut {
692        fn _decode(
693            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
694        ) -> Result<BinderMapVmoResult, fidl::Error> {
695            let _response = fidl::client::decode_transaction_body::<
696                fidl::encoding::FlexibleResultType<
697                    fidl::encoding::EmptyStruct,
698                    fidl_fuchsia_posix::Errno,
699                >,
700                fidl::encoding::DefaultFuchsiaResourceDialect,
701                0x169c824ba0a5141f,
702            >(_buf?)?
703            .into_result::<BinderMarker>("map_vmo")?;
704            Ok(_response.map(|x| x))
705        }
706        self.client.send_query_and_decode::<BinderMapVmoRequest, BinderMapVmoResult>(
707            (vmo, mapped_address),
708            0x169c824ba0a5141f,
709            fidl::encoding::DynamicFlags::FLEXIBLE,
710            _decode,
711        )
712    }
713
714    type IoctlResponseFut = fidl::client::QueryResponseFut<
715        BinderIoctlResult,
716        fidl::encoding::DefaultFuchsiaResourceDialect,
717    >;
718    fn r#ioctl(
719        &self,
720        mut tid: u64,
721        mut request: u32,
722        mut arg: u64,
723        mut vmo: fidl::Vmo,
724        mut ioctl_reads: &[IoctlReadWrite],
725        mut files: Vec<FileHandle>,
726    ) -> Self::IoctlResponseFut {
727        fn _decode(
728            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
729        ) -> Result<BinderIoctlResult, fidl::Error> {
730            let _response = fidl::client::decode_transaction_body::<
731                fidl::encoding::FlexibleResultType<BinderIoctlResponse, fidl_fuchsia_posix::Errno>,
732                fidl::encoding::DefaultFuchsiaResourceDialect,
733                0x1032021e21310000,
734            >(_buf?)?
735            .into_result::<BinderMarker>("ioctl")?;
736            Ok(_response.map(|x| x.ioctl_writes))
737        }
738        self.client.send_query_and_decode::<BinderIoctlRequest, BinderIoctlResult>(
739            (tid, request, arg, vmo, ioctl_reads, files.as_mut()),
740            0x1032021e21310000,
741            fidl::encoding::DynamicFlags::FLEXIBLE,
742            _decode,
743        )
744    }
745
746    type RegisterThreadChannelResponseFut = fidl::client::QueryResponseFut<
747        BinderRegisterThreadChannelResult,
748        fidl::encoding::DefaultFuchsiaResourceDialect,
749    >;
750    fn r#register_thread_channel(
751        &self,
752        mut server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
753    ) -> Self::RegisterThreadChannelResponseFut {
754        fn _decode(
755            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
756        ) -> Result<BinderRegisterThreadChannelResult, fidl::Error> {
757            let _response = fidl::client::decode_transaction_body::<
758                fidl::encoding::FlexibleResultType<
759                    fidl::encoding::EmptyStruct,
760                    fidl_fuchsia_posix::Errno,
761                >,
762                fidl::encoding::DefaultFuchsiaResourceDialect,
763                0x1eeeec1ff5de0b47,
764            >(_buf?)?
765            .into_result::<BinderMarker>("register_thread_channel")?;
766            Ok(_response.map(|x| x))
767        }
768        self.client.send_query_and_decode::<
769            BinderRegisterThreadChannelRequest,
770            BinderRegisterThreadChannelResult,
771        >(
772            (server_end,),
773            0x1eeeec1ff5de0b47,
774            fidl::encoding::DynamicFlags::FLEXIBLE,
775            _decode,
776        )
777    }
778}
779
780pub struct BinderEventStream {
781    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
782}
783
784impl std::marker::Unpin for BinderEventStream {}
785
786impl futures::stream::FusedStream for BinderEventStream {
787    fn is_terminated(&self) -> bool {
788        self.event_receiver.is_terminated()
789    }
790}
791
792impl futures::Stream for BinderEventStream {
793    type Item = Result<BinderEvent, fidl::Error>;
794
795    fn poll_next(
796        mut self: std::pin::Pin<&mut Self>,
797        cx: &mut std::task::Context<'_>,
798    ) -> std::task::Poll<Option<Self::Item>> {
799        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
800            &mut self.event_receiver,
801            cx
802        )?) {
803            Some(buf) => std::task::Poll::Ready(Some(BinderEvent::decode(buf))),
804            None => std::task::Poll::Ready(None),
805        }
806    }
807}
808
809#[derive(Debug)]
810pub enum BinderEvent {
811    #[non_exhaustive]
812    _UnknownEvent {
813        /// Ordinal of the event that was sent.
814        ordinal: u64,
815    },
816}
817
818impl BinderEvent {
819    /// Decodes a message buffer as a [`BinderEvent`].
820    fn decode(
821        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
822    ) -> Result<BinderEvent, fidl::Error> {
823        let (bytes, _handles) = buf.split_mut();
824        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
825        debug_assert_eq!(tx_header.tx_id, 0);
826        match tx_header.ordinal {
827            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
828                Ok(BinderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
829            }
830            _ => Err(fidl::Error::UnknownOrdinal {
831                ordinal: tx_header.ordinal,
832                protocol_name: <BinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
833            }),
834        }
835    }
836}
837
838/// A Stream of incoming requests for fuchsia.starnix.binder/Binder.
839pub struct BinderRequestStream {
840    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
841    is_terminated: bool,
842}
843
844impl std::marker::Unpin for BinderRequestStream {}
845
846impl futures::stream::FusedStream for BinderRequestStream {
847    fn is_terminated(&self) -> bool {
848        self.is_terminated
849    }
850}
851
852impl fidl::endpoints::RequestStream for BinderRequestStream {
853    type Protocol = BinderMarker;
854    type ControlHandle = BinderControlHandle;
855
856    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
857        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
858    }
859
860    fn control_handle(&self) -> Self::ControlHandle {
861        BinderControlHandle { inner: self.inner.clone() }
862    }
863
864    fn into_inner(
865        self,
866    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
867    {
868        (self.inner, self.is_terminated)
869    }
870
871    fn from_inner(
872        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
873        is_terminated: bool,
874    ) -> Self {
875        Self { inner, is_terminated }
876    }
877}
878
879impl futures::Stream for BinderRequestStream {
880    type Item = Result<BinderRequest, fidl::Error>;
881
882    fn poll_next(
883        mut self: std::pin::Pin<&mut Self>,
884        cx: &mut std::task::Context<'_>,
885    ) -> std::task::Poll<Option<Self::Item>> {
886        let this = &mut *self;
887        if this.inner.check_shutdown(cx) {
888            this.is_terminated = true;
889            return std::task::Poll::Ready(None);
890        }
891        if this.is_terminated {
892            panic!("polled BinderRequestStream after completion");
893        }
894        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
895            |bytes, handles| {
896                match this.inner.channel().read_etc(cx, bytes, handles) {
897                    std::task::Poll::Ready(Ok(())) => {}
898                    std::task::Poll::Pending => return std::task::Poll::Pending,
899                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
900                        this.is_terminated = true;
901                        return std::task::Poll::Ready(None);
902                    }
903                    std::task::Poll::Ready(Err(e)) => {
904                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
905                            e.into(),
906                        ))));
907                    }
908                }
909
910                // A message has been received from the channel
911                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
912
913                std::task::Poll::Ready(Some(match header.ordinal {
914                    0x43ee5d8f7d3acbf6 => {
915                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
916                        let mut req = fidl::new_empty!(
917                            BinderSetVmoRequest,
918                            fidl::encoding::DefaultFuchsiaResourceDialect
919                        );
920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BinderSetVmoRequest>(&header, _body_bytes, handles, &mut req)?;
921                        let control_handle = BinderControlHandle { inner: this.inner.clone() };
922                        Ok(BinderRequest::SetVmo {
923                            vmo: req.vmo,
924                            mapped_address: req.mapped_address,
925
926                            control_handle,
927                        })
928                    }
929                    0x169c824ba0a5141f => {
930                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
931                        let mut req = fidl::new_empty!(
932                            BinderMapVmoRequest,
933                            fidl::encoding::DefaultFuchsiaResourceDialect
934                        );
935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BinderMapVmoRequest>(&header, _body_bytes, handles, &mut req)?;
936                        let control_handle = BinderControlHandle { inner: this.inner.clone() };
937                        Ok(BinderRequest::MapVmo {
938                            vmo: req.vmo,
939                            mapped_address: req.mapped_address,
940
941                            responder: BinderMapVmoResponder {
942                                control_handle: std::mem::ManuallyDrop::new(control_handle),
943                                tx_id: header.tx_id,
944                            },
945                        })
946                    }
947                    0x1032021e21310000 => {
948                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
949                        let mut req = fidl::new_empty!(
950                            BinderIoctlRequest,
951                            fidl::encoding::DefaultFuchsiaResourceDialect
952                        );
953                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BinderIoctlRequest>(&header, _body_bytes, handles, &mut req)?;
954                        let control_handle = BinderControlHandle { inner: this.inner.clone() };
955                        Ok(BinderRequest::Ioctl {
956                            tid: req.tid,
957                            request: req.request,
958                            arg: req.arg,
959                            vmo: req.vmo,
960                            ioctl_reads: req.ioctl_reads,
961                            files: req.files,
962
963                            responder: BinderIoctlResponder {
964                                control_handle: std::mem::ManuallyDrop::new(control_handle),
965                                tx_id: header.tx_id,
966                            },
967                        })
968                    }
969                    0x1eeeec1ff5de0b47 => {
970                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
971                        let mut req = fidl::new_empty!(
972                            BinderRegisterThreadChannelRequest,
973                            fidl::encoding::DefaultFuchsiaResourceDialect
974                        );
975                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BinderRegisterThreadChannelRequest>(&header, _body_bytes, handles, &mut req)?;
976                        let control_handle = BinderControlHandle { inner: this.inner.clone() };
977                        Ok(BinderRequest::RegisterThreadChannel {
978                            server_end: req.server_end,
979
980                            responder: BinderRegisterThreadChannelResponder {
981                                control_handle: std::mem::ManuallyDrop::new(control_handle),
982                                tx_id: header.tx_id,
983                            },
984                        })
985                    }
986                    _ if header.tx_id == 0
987                        && header
988                            .dynamic_flags()
989                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
990                    {
991                        Ok(BinderRequest::_UnknownMethod {
992                            ordinal: header.ordinal,
993                            control_handle: BinderControlHandle { inner: this.inner.clone() },
994                            method_type: fidl::MethodType::OneWay,
995                        })
996                    }
997                    _ if header
998                        .dynamic_flags()
999                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1000                    {
1001                        this.inner.send_framework_err(
1002                            fidl::encoding::FrameworkErr::UnknownMethod,
1003                            header.tx_id,
1004                            header.ordinal,
1005                            header.dynamic_flags(),
1006                            (bytes, handles),
1007                        )?;
1008                        Ok(BinderRequest::_UnknownMethod {
1009                            ordinal: header.ordinal,
1010                            control_handle: BinderControlHandle { inner: this.inner.clone() },
1011                            method_type: fidl::MethodType::TwoWay,
1012                        })
1013                    }
1014                    _ => Err(fidl::Error::UnknownOrdinal {
1015                        ordinal: header.ordinal,
1016                        protocol_name:
1017                            <BinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1018                    }),
1019                }))
1020            },
1021        )
1022    }
1023}
1024
1025/// An opened connection to a binder driver.
1026#[derive(Debug)]
1027pub enum BinderRequest {
1028    /// Set the VMO to used as a share resource between the driver and the
1029    /// client. `mapped_address` is the address where the vmo is mapped in the
1030    /// client address space.
1031    ///
1032    /// The driver handles the other requests of the client concurrently, so it
1033    /// can handle an ioctl before the VMO is mapped. Clients should use
1034    /// `MapVmo` instead.
1035    SetVmo { vmo: fidl::Vmo, mapped_address: u64, control_handle: BinderControlHandle },
1036    /// Maps the VMO used as a shared resource between the driver and the
1037    /// client. `mapped_address` is the address where the VMO is mapped in the
1038    /// client address space.
1039    ///
1040    /// Responds once the VMO is mapped. The driver handles the other requests
1041    /// of the client concurrently, so the client must wait for the response
1042    /// before sending any ioctl that needs the VMO.
1043    MapVmo { vmo: fidl::Vmo, mapped_address: u64, responder: BinderMapVmoResponder },
1044    /// Processes a Binder ioctl. This message returns writes for the calling thread
1045    /// that must be processed to correctly handle the ioctl.
1046    Ioctl {
1047        tid: u64,
1048        request: u32,
1049        arg: u64,
1050        vmo: fidl::Vmo,
1051        ioctl_reads: Vec<IoctlReadWrite>,
1052        files: Vec<FileHandle>,
1053        responder: BinderIoctlResponder,
1054    },
1055    /// Registers a dedicated 1:1 channel for synchronous Binder transactions.
1056    RegisterThreadChannel {
1057        server_end: fidl::endpoints::ServerEnd<BinderThreadMarker>,
1058        responder: BinderRegisterThreadChannelResponder,
1059    },
1060    /// An interaction was received which does not match any known method.
1061    #[non_exhaustive]
1062    _UnknownMethod {
1063        /// Ordinal of the method that was called.
1064        ordinal: u64,
1065        control_handle: BinderControlHandle,
1066        method_type: fidl::MethodType,
1067    },
1068}
1069
1070impl BinderRequest {
1071    #[allow(irrefutable_let_patterns)]
1072    pub fn into_set_vmo(self) -> Option<(fidl::Vmo, u64, BinderControlHandle)> {
1073        if let BinderRequest::SetVmo { vmo, mapped_address, control_handle } = self {
1074            Some((vmo, mapped_address, control_handle))
1075        } else {
1076            None
1077        }
1078    }
1079
1080    #[allow(irrefutable_let_patterns)]
1081    pub fn into_map_vmo(self) -> Option<(fidl::Vmo, u64, BinderMapVmoResponder)> {
1082        if let BinderRequest::MapVmo { vmo, mapped_address, responder } = self {
1083            Some((vmo, mapped_address, responder))
1084        } else {
1085            None
1086        }
1087    }
1088
1089    #[allow(irrefutable_let_patterns)]
1090    pub fn into_ioctl(
1091        self,
1092    ) -> Option<(
1093        u64,
1094        u32,
1095        u64,
1096        fidl::Vmo,
1097        Vec<IoctlReadWrite>,
1098        Vec<FileHandle>,
1099        BinderIoctlResponder,
1100    )> {
1101        if let BinderRequest::Ioctl { tid, request, arg, vmo, ioctl_reads, files, responder } = self
1102        {
1103            Some((tid, request, arg, vmo, ioctl_reads, files, responder))
1104        } else {
1105            None
1106        }
1107    }
1108
1109    #[allow(irrefutable_let_patterns)]
1110    pub fn into_register_thread_channel(
1111        self,
1112    ) -> Option<(
1113        fidl::endpoints::ServerEnd<BinderThreadMarker>,
1114        BinderRegisterThreadChannelResponder,
1115    )> {
1116        if let BinderRequest::RegisterThreadChannel { server_end, responder } = self {
1117            Some((server_end, responder))
1118        } else {
1119            None
1120        }
1121    }
1122
1123    /// Name of the method defined in FIDL
1124    pub fn method_name(&self) -> &'static str {
1125        match *self {
1126            BinderRequest::SetVmo { .. } => "set_vmo",
1127            BinderRequest::MapVmo { .. } => "map_vmo",
1128            BinderRequest::Ioctl { .. } => "ioctl",
1129            BinderRequest::RegisterThreadChannel { .. } => "register_thread_channel",
1130            BinderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1131                "unknown one-way method"
1132            }
1133            BinderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1134                "unknown two-way method"
1135            }
1136        }
1137    }
1138}
1139
1140#[derive(Debug, Clone)]
1141pub struct BinderControlHandle {
1142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1143}
1144
1145impl BinderControlHandle {
1146    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1147        self.inner.shutdown_with_epitaph(status.into())
1148    }
1149}
1150
1151impl fidl::endpoints::ControlHandle for BinderControlHandle {
1152    fn shutdown(&self) {
1153        self.inner.shutdown()
1154    }
1155
1156    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1157        self.inner.shutdown_with_epitaph(status)
1158    }
1159
1160    fn is_closed(&self) -> bool {
1161        self.inner.channel().is_closed()
1162    }
1163    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1164        self.inner.channel().on_closed()
1165    }
1166
1167    #[cfg(target_os = "fuchsia")]
1168    fn signal_peer(
1169        &self,
1170        clear_mask: zx::Signals,
1171        set_mask: zx::Signals,
1172    ) -> Result<(), zx_status::Status> {
1173        use fidl::Peered;
1174        self.inner.channel().signal_peer(clear_mask, set_mask)
1175    }
1176}
1177
1178impl BinderControlHandle {}
1179
1180#[must_use = "FIDL methods require a response to be sent"]
1181#[derive(Debug)]
1182pub struct BinderMapVmoResponder {
1183    control_handle: std::mem::ManuallyDrop<BinderControlHandle>,
1184    tx_id: u32,
1185}
1186
1187/// Set the the channel to be shutdown (see [`BinderControlHandle::shutdown`])
1188/// if the responder is dropped without sending a response, so that the client
1189/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1190impl std::ops::Drop for BinderMapVmoResponder {
1191    fn drop(&mut self) {
1192        self.control_handle.shutdown();
1193        // Safety: drops once, never accessed again
1194        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1195    }
1196}
1197
1198impl fidl::endpoints::Responder for BinderMapVmoResponder {
1199    type ControlHandle = BinderControlHandle;
1200
1201    fn control_handle(&self) -> &BinderControlHandle {
1202        &self.control_handle
1203    }
1204
1205    fn drop_without_shutdown(mut self) {
1206        // Safety: drops once, never accessed again due to mem::forget
1207        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1208        // Prevent Drop from running (which would shut down the channel)
1209        std::mem::forget(self);
1210    }
1211}
1212
1213impl BinderMapVmoResponder {
1214    /// Sends a response to the FIDL transaction.
1215    ///
1216    /// Sets the channel to shutdown if an error occurs.
1217    pub fn send(
1218        self,
1219        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1220    ) -> Result<(), fidl::Error> {
1221        let _result = self.send_raw(result);
1222        if _result.is_err() {
1223            self.control_handle.shutdown();
1224        }
1225        self.drop_without_shutdown();
1226        _result
1227    }
1228
1229    /// Similar to "send" but does not shutdown the channel if an error occurs.
1230    pub fn send_no_shutdown_on_err(
1231        self,
1232        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1233    ) -> Result<(), fidl::Error> {
1234        let _result = self.send_raw(result);
1235        self.drop_without_shutdown();
1236        _result
1237    }
1238
1239    fn send_raw(
1240        &self,
1241        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1242    ) -> Result<(), fidl::Error> {
1243        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1244            fidl::encoding::EmptyStruct,
1245            fidl_fuchsia_posix::Errno,
1246        >>(
1247            fidl::encoding::FlexibleResult::new(result),
1248            self.tx_id,
1249            0x169c824ba0a5141f,
1250            fidl::encoding::DynamicFlags::FLEXIBLE,
1251        )
1252    }
1253}
1254
1255#[must_use = "FIDL methods require a response to be sent"]
1256#[derive(Debug)]
1257pub struct BinderIoctlResponder {
1258    control_handle: std::mem::ManuallyDrop<BinderControlHandle>,
1259    tx_id: u32,
1260}
1261
1262/// Set the the channel to be shutdown (see [`BinderControlHandle::shutdown`])
1263/// if the responder is dropped without sending a response, so that the client
1264/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1265impl std::ops::Drop for BinderIoctlResponder {
1266    fn drop(&mut self) {
1267        self.control_handle.shutdown();
1268        // Safety: drops once, never accessed again
1269        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1270    }
1271}
1272
1273impl fidl::endpoints::Responder for BinderIoctlResponder {
1274    type ControlHandle = BinderControlHandle;
1275
1276    fn control_handle(&self) -> &BinderControlHandle {
1277        &self.control_handle
1278    }
1279
1280    fn drop_without_shutdown(mut self) {
1281        // Safety: drops once, never accessed again due to mem::forget
1282        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1283        // Prevent Drop from running (which would shut down the channel)
1284        std::mem::forget(self);
1285    }
1286}
1287
1288impl BinderIoctlResponder {
1289    /// Sends a response to the FIDL transaction.
1290    ///
1291    /// Sets the channel to shutdown if an error occurs.
1292    pub fn send(
1293        self,
1294        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1295    ) -> Result<(), fidl::Error> {
1296        let _result = self.send_raw(result);
1297        if _result.is_err() {
1298            self.control_handle.shutdown();
1299        }
1300        self.drop_without_shutdown();
1301        _result
1302    }
1303
1304    /// Similar to "send" but does not shutdown the channel if an error occurs.
1305    pub fn send_no_shutdown_on_err(
1306        self,
1307        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1308    ) -> Result<(), fidl::Error> {
1309        let _result = self.send_raw(result);
1310        self.drop_without_shutdown();
1311        _result
1312    }
1313
1314    fn send_raw(
1315        &self,
1316        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1317    ) -> Result<(), fidl::Error> {
1318        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1319            BinderIoctlResponse,
1320            fidl_fuchsia_posix::Errno,
1321        >>(
1322            fidl::encoding::FlexibleResult::new(result.map(|ioctl_writes| (ioctl_writes,))),
1323            self.tx_id,
1324            0x1032021e21310000,
1325            fidl::encoding::DynamicFlags::FLEXIBLE,
1326        )
1327    }
1328}
1329
1330#[must_use = "FIDL methods require a response to be sent"]
1331#[derive(Debug)]
1332pub struct BinderRegisterThreadChannelResponder {
1333    control_handle: std::mem::ManuallyDrop<BinderControlHandle>,
1334    tx_id: u32,
1335}
1336
1337/// Set the the channel to be shutdown (see [`BinderControlHandle::shutdown`])
1338/// if the responder is dropped without sending a response, so that the client
1339/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1340impl std::ops::Drop for BinderRegisterThreadChannelResponder {
1341    fn drop(&mut self) {
1342        self.control_handle.shutdown();
1343        // Safety: drops once, never accessed again
1344        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1345    }
1346}
1347
1348impl fidl::endpoints::Responder for BinderRegisterThreadChannelResponder {
1349    type ControlHandle = BinderControlHandle;
1350
1351    fn control_handle(&self) -> &BinderControlHandle {
1352        &self.control_handle
1353    }
1354
1355    fn drop_without_shutdown(mut self) {
1356        // Safety: drops once, never accessed again due to mem::forget
1357        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1358        // Prevent Drop from running (which would shut down the channel)
1359        std::mem::forget(self);
1360    }
1361}
1362
1363impl BinderRegisterThreadChannelResponder {
1364    /// Sends a response to the FIDL transaction.
1365    ///
1366    /// Sets the channel to shutdown if an error occurs.
1367    pub fn send(
1368        self,
1369        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1370    ) -> Result<(), fidl::Error> {
1371        let _result = self.send_raw(result);
1372        if _result.is_err() {
1373            self.control_handle.shutdown();
1374        }
1375        self.drop_without_shutdown();
1376        _result
1377    }
1378
1379    /// Similar to "send" but does not shutdown the channel if an error occurs.
1380    pub fn send_no_shutdown_on_err(
1381        self,
1382        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1383    ) -> Result<(), fidl::Error> {
1384        let _result = self.send_raw(result);
1385        self.drop_without_shutdown();
1386        _result
1387    }
1388
1389    fn send_raw(
1390        &self,
1391        mut result: Result<(), fidl_fuchsia_posix::Errno>,
1392    ) -> Result<(), fidl::Error> {
1393        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1394            fidl::encoding::EmptyStruct,
1395            fidl_fuchsia_posix::Errno,
1396        >>(
1397            fidl::encoding::FlexibleResult::new(result),
1398            self.tx_id,
1399            0x1eeeec1ff5de0b47,
1400            fidl::encoding::DynamicFlags::FLEXIBLE,
1401        )
1402    }
1403}
1404
1405#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1406pub struct BinderThreadMarker;
1407
1408impl fidl::endpoints::ProtocolMarker for BinderThreadMarker {
1409    type Proxy = BinderThreadProxy;
1410    type RequestStream = BinderThreadRequestStream;
1411    #[cfg(target_os = "fuchsia")]
1412    type SynchronousProxy = BinderThreadSynchronousProxy;
1413
1414    const DEBUG_NAME: &'static str = "(anonymous) BinderThread";
1415}
1416pub type BinderThreadIoctlResult = Result<Vec<IoctlReadWrite>, fidl_fuchsia_posix::Errno>;
1417
1418pub trait BinderThreadProxyInterface: Send + Sync {
1419    type IoctlResponseFut: std::future::Future<Output = Result<BinderThreadIoctlResult, fidl::Error>>
1420        + Send;
1421    fn r#ioctl(
1422        &self,
1423        request: u32,
1424        arg: u64,
1425        vmo: fidl::Vmo,
1426        ioctl_reads: &[IoctlReadWrite],
1427        files: Vec<FileHandle>,
1428    ) -> Self::IoctlResponseFut;
1429}
1430#[derive(Debug)]
1431#[cfg(target_os = "fuchsia")]
1432pub struct BinderThreadSynchronousProxy {
1433    client: fidl::client::sync::Client,
1434}
1435
1436#[cfg(target_os = "fuchsia")]
1437impl fidl::endpoints::SynchronousProxy for BinderThreadSynchronousProxy {
1438    type Proxy = BinderThreadProxy;
1439    type Protocol = BinderThreadMarker;
1440
1441    fn from_channel(inner: fidl::Channel) -> Self {
1442        Self::new(inner)
1443    }
1444
1445    fn into_channel(self) -> fidl::Channel {
1446        self.client.into_channel()
1447    }
1448
1449    fn as_channel(&self) -> &fidl::Channel {
1450        self.client.as_channel()
1451    }
1452}
1453
1454#[cfg(target_os = "fuchsia")]
1455impl BinderThreadSynchronousProxy {
1456    pub fn new(channel: fidl::Channel) -> Self {
1457        Self { client: fidl::client::sync::Client::new(channel) }
1458    }
1459
1460    pub fn into_channel(self) -> fidl::Channel {
1461        self.client.into_channel()
1462    }
1463
1464    /// Waits until an event arrives and returns it. It is safe for other
1465    /// threads to make concurrent requests while waiting for an event.
1466    pub fn wait_for_event(
1467        &self,
1468        deadline: zx::MonotonicInstant,
1469    ) -> Result<BinderThreadEvent, fidl::Error> {
1470        BinderThreadEvent::decode(self.client.wait_for_event::<BinderThreadMarker>(deadline)?)
1471    }
1472
1473    /// Processes a Binder ioctl on a dedicated worker thread.
1474    pub fn r#ioctl(
1475        &self,
1476        mut request: u32,
1477        mut arg: u64,
1478        mut vmo: fidl::Vmo,
1479        mut ioctl_reads: &[IoctlReadWrite],
1480        mut files: Vec<FileHandle>,
1481        ___deadline: zx::MonotonicInstant,
1482    ) -> Result<BinderThreadIoctlResult, fidl::Error> {
1483        let _response = self
1484            .client
1485            .send_query::<BinderThreadIoctlRequest, fidl::encoding::FlexibleResultType<
1486                BinderThreadIoctlResponse,
1487                fidl_fuchsia_posix::Errno,
1488            >, BinderThreadMarker>(
1489                (request, arg, vmo, ioctl_reads, files.as_mut()),
1490                0x6b9dcc61092989e4,
1491                fidl::encoding::DynamicFlags::FLEXIBLE,
1492                ___deadline,
1493            )?
1494            .into_result::<BinderThreadMarker>("ioctl")?;
1495        Ok(_response.map(|x| x.ioctl_writes))
1496    }
1497}
1498
1499#[cfg(target_os = "fuchsia")]
1500impl From<BinderThreadSynchronousProxy> for zx::NullableHandle {
1501    fn from(value: BinderThreadSynchronousProxy) -> Self {
1502        value.into_channel().into()
1503    }
1504}
1505
1506#[cfg(target_os = "fuchsia")]
1507impl From<fidl::Channel> for BinderThreadSynchronousProxy {
1508    fn from(value: fidl::Channel) -> Self {
1509        Self::new(value)
1510    }
1511}
1512
1513#[cfg(target_os = "fuchsia")]
1514impl fidl::endpoints::FromClient for BinderThreadSynchronousProxy {
1515    type Protocol = BinderThreadMarker;
1516
1517    fn from_client(value: fidl::endpoints::ClientEnd<BinderThreadMarker>) -> Self {
1518        Self::new(value.into_channel())
1519    }
1520}
1521
1522#[derive(Debug, Clone)]
1523pub struct BinderThreadProxy {
1524    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1525}
1526
1527impl fidl::endpoints::Proxy for BinderThreadProxy {
1528    type Protocol = BinderThreadMarker;
1529
1530    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1531        Self::new(inner)
1532    }
1533
1534    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1535        self.client.into_channel().map_err(|client| Self { client })
1536    }
1537
1538    fn as_channel(&self) -> &::fidl::AsyncChannel {
1539        self.client.as_channel()
1540    }
1541}
1542
1543impl BinderThreadProxy {
1544    /// Create a new Proxy for fuchsia.starnix.binder/BinderThread.
1545    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1546        let protocol_name = <BinderThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1547        Self { client: fidl::client::Client::new(channel, protocol_name) }
1548    }
1549
1550    /// Get a Stream of events from the remote end of the protocol.
1551    ///
1552    /// # Panics
1553    ///
1554    /// Panics if the event stream was already taken.
1555    pub fn take_event_stream(&self) -> BinderThreadEventStream {
1556        BinderThreadEventStream { event_receiver: self.client.take_event_receiver() }
1557    }
1558
1559    /// Processes a Binder ioctl on a dedicated worker thread.
1560    pub fn r#ioctl(
1561        &self,
1562        mut request: u32,
1563        mut arg: u64,
1564        mut vmo: fidl::Vmo,
1565        mut ioctl_reads: &[IoctlReadWrite],
1566        mut files: Vec<FileHandle>,
1567    ) -> fidl::client::QueryResponseFut<
1568        BinderThreadIoctlResult,
1569        fidl::encoding::DefaultFuchsiaResourceDialect,
1570    > {
1571        BinderThreadProxyInterface::r#ioctl(self, request, arg, vmo, ioctl_reads, files)
1572    }
1573}
1574
1575impl BinderThreadProxyInterface for BinderThreadProxy {
1576    type IoctlResponseFut = fidl::client::QueryResponseFut<
1577        BinderThreadIoctlResult,
1578        fidl::encoding::DefaultFuchsiaResourceDialect,
1579    >;
1580    fn r#ioctl(
1581        &self,
1582        mut request: u32,
1583        mut arg: u64,
1584        mut vmo: fidl::Vmo,
1585        mut ioctl_reads: &[IoctlReadWrite],
1586        mut files: Vec<FileHandle>,
1587    ) -> Self::IoctlResponseFut {
1588        fn _decode(
1589            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1590        ) -> Result<BinderThreadIoctlResult, fidl::Error> {
1591            let _response = fidl::client::decode_transaction_body::<
1592                fidl::encoding::FlexibleResultType<
1593                    BinderThreadIoctlResponse,
1594                    fidl_fuchsia_posix::Errno,
1595                >,
1596                fidl::encoding::DefaultFuchsiaResourceDialect,
1597                0x6b9dcc61092989e4,
1598            >(_buf?)?
1599            .into_result::<BinderThreadMarker>("ioctl")?;
1600            Ok(_response.map(|x| x.ioctl_writes))
1601        }
1602        self.client.send_query_and_decode::<BinderThreadIoctlRequest, BinderThreadIoctlResult>(
1603            (request, arg, vmo, ioctl_reads, files.as_mut()),
1604            0x6b9dcc61092989e4,
1605            fidl::encoding::DynamicFlags::FLEXIBLE,
1606            _decode,
1607        )
1608    }
1609}
1610
1611pub struct BinderThreadEventStream {
1612    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1613}
1614
1615impl std::marker::Unpin for BinderThreadEventStream {}
1616
1617impl futures::stream::FusedStream for BinderThreadEventStream {
1618    fn is_terminated(&self) -> bool {
1619        self.event_receiver.is_terminated()
1620    }
1621}
1622
1623impl futures::Stream for BinderThreadEventStream {
1624    type Item = Result<BinderThreadEvent, fidl::Error>;
1625
1626    fn poll_next(
1627        mut self: std::pin::Pin<&mut Self>,
1628        cx: &mut std::task::Context<'_>,
1629    ) -> std::task::Poll<Option<Self::Item>> {
1630        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1631            &mut self.event_receiver,
1632            cx
1633        )?) {
1634            Some(buf) => std::task::Poll::Ready(Some(BinderThreadEvent::decode(buf))),
1635            None => std::task::Poll::Ready(None),
1636        }
1637    }
1638}
1639
1640#[derive(Debug)]
1641pub enum BinderThreadEvent {
1642    #[non_exhaustive]
1643    _UnknownEvent {
1644        /// Ordinal of the event that was sent.
1645        ordinal: u64,
1646    },
1647}
1648
1649impl BinderThreadEvent {
1650    /// Decodes a message buffer as a [`BinderThreadEvent`].
1651    fn decode(
1652        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1653    ) -> Result<BinderThreadEvent, fidl::Error> {
1654        let (bytes, _handles) = buf.split_mut();
1655        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1656        debug_assert_eq!(tx_header.tx_id, 0);
1657        match tx_header.ordinal {
1658            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1659                Ok(BinderThreadEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1660            }
1661            _ => Err(fidl::Error::UnknownOrdinal {
1662                ordinal: tx_header.ordinal,
1663                protocol_name: <BinderThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1664            }),
1665        }
1666    }
1667}
1668
1669/// A Stream of incoming requests for fuchsia.starnix.binder/BinderThread.
1670pub struct BinderThreadRequestStream {
1671    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1672    is_terminated: bool,
1673}
1674
1675impl std::marker::Unpin for BinderThreadRequestStream {}
1676
1677impl futures::stream::FusedStream for BinderThreadRequestStream {
1678    fn is_terminated(&self) -> bool {
1679        self.is_terminated
1680    }
1681}
1682
1683impl fidl::endpoints::RequestStream for BinderThreadRequestStream {
1684    type Protocol = BinderThreadMarker;
1685    type ControlHandle = BinderThreadControlHandle;
1686
1687    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1688        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1689    }
1690
1691    fn control_handle(&self) -> Self::ControlHandle {
1692        BinderThreadControlHandle { inner: self.inner.clone() }
1693    }
1694
1695    fn into_inner(
1696        self,
1697    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1698    {
1699        (self.inner, self.is_terminated)
1700    }
1701
1702    fn from_inner(
1703        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1704        is_terminated: bool,
1705    ) -> Self {
1706        Self { inner, is_terminated }
1707    }
1708}
1709
1710impl futures::Stream for BinderThreadRequestStream {
1711    type Item = Result<BinderThreadRequest, fidl::Error>;
1712
1713    fn poll_next(
1714        mut self: std::pin::Pin<&mut Self>,
1715        cx: &mut std::task::Context<'_>,
1716    ) -> std::task::Poll<Option<Self::Item>> {
1717        let this = &mut *self;
1718        if this.inner.check_shutdown(cx) {
1719            this.is_terminated = true;
1720            return std::task::Poll::Ready(None);
1721        }
1722        if this.is_terminated {
1723            panic!("polled BinderThreadRequestStream after completion");
1724        }
1725        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1726            |bytes, handles| {
1727                match this.inner.channel().read_etc(cx, bytes, handles) {
1728                    std::task::Poll::Ready(Ok(())) => {}
1729                    std::task::Poll::Pending => return std::task::Poll::Pending,
1730                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1731                        this.is_terminated = true;
1732                        return std::task::Poll::Ready(None);
1733                    }
1734                    std::task::Poll::Ready(Err(e)) => {
1735                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1736                            e.into(),
1737                        ))));
1738                    }
1739                }
1740
1741                // A message has been received from the channel
1742                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1743
1744                std::task::Poll::Ready(Some(match header.ordinal {
1745                    0x6b9dcc61092989e4 => {
1746                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1747                        let mut req = fidl::new_empty!(
1748                            BinderThreadIoctlRequest,
1749                            fidl::encoding::DefaultFuchsiaResourceDialect
1750                        );
1751                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BinderThreadIoctlRequest>(&header, _body_bytes, handles, &mut req)?;
1752                        let control_handle =
1753                            BinderThreadControlHandle { inner: this.inner.clone() };
1754                        Ok(BinderThreadRequest::Ioctl {
1755                            request: req.request,
1756                            arg: req.arg,
1757                            vmo: req.vmo,
1758                            ioctl_reads: req.ioctl_reads,
1759                            files: req.files,
1760
1761                            responder: BinderThreadIoctlResponder {
1762                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1763                                tx_id: header.tx_id,
1764                            },
1765                        })
1766                    }
1767                    _ if header.tx_id == 0
1768                        && header
1769                            .dynamic_flags()
1770                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1771                    {
1772                        Ok(BinderThreadRequest::_UnknownMethod {
1773                            ordinal: header.ordinal,
1774                            control_handle: BinderThreadControlHandle { inner: this.inner.clone() },
1775                            method_type: fidl::MethodType::OneWay,
1776                        })
1777                    }
1778                    _ if header
1779                        .dynamic_flags()
1780                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1781                    {
1782                        this.inner.send_framework_err(
1783                            fidl::encoding::FrameworkErr::UnknownMethod,
1784                            header.tx_id,
1785                            header.ordinal,
1786                            header.dynamic_flags(),
1787                            (bytes, handles),
1788                        )?;
1789                        Ok(BinderThreadRequest::_UnknownMethod {
1790                            ordinal: header.ordinal,
1791                            control_handle: BinderThreadControlHandle { inner: this.inner.clone() },
1792                            method_type: fidl::MethodType::TwoWay,
1793                        })
1794                    }
1795                    _ => Err(fidl::Error::UnknownOrdinal {
1796                        ordinal: header.ordinal,
1797                        protocol_name:
1798                            <BinderThreadMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1799                    }),
1800                }))
1801            },
1802        )
1803    }
1804}
1805
1806/// Dedicated per-thread Binder channel for synchronous 1:1 IPC.
1807#[derive(Debug)]
1808pub enum BinderThreadRequest {
1809    /// Processes a Binder ioctl on a dedicated worker thread.
1810    Ioctl {
1811        request: u32,
1812        arg: u64,
1813        vmo: fidl::Vmo,
1814        ioctl_reads: Vec<IoctlReadWrite>,
1815        files: Vec<FileHandle>,
1816        responder: BinderThreadIoctlResponder,
1817    },
1818    /// An interaction was received which does not match any known method.
1819    #[non_exhaustive]
1820    _UnknownMethod {
1821        /// Ordinal of the method that was called.
1822        ordinal: u64,
1823        control_handle: BinderThreadControlHandle,
1824        method_type: fidl::MethodType,
1825    },
1826}
1827
1828impl BinderThreadRequest {
1829    #[allow(irrefutable_let_patterns)]
1830    pub fn into_ioctl(
1831        self,
1832    ) -> Option<(
1833        u32,
1834        u64,
1835        fidl::Vmo,
1836        Vec<IoctlReadWrite>,
1837        Vec<FileHandle>,
1838        BinderThreadIoctlResponder,
1839    )> {
1840        if let BinderThreadRequest::Ioctl { request, arg, vmo, ioctl_reads, files, responder } =
1841            self
1842        {
1843            Some((request, arg, vmo, ioctl_reads, files, responder))
1844        } else {
1845            None
1846        }
1847    }
1848
1849    /// Name of the method defined in FIDL
1850    pub fn method_name(&self) -> &'static str {
1851        match *self {
1852            BinderThreadRequest::Ioctl { .. } => "ioctl",
1853            BinderThreadRequest::_UnknownMethod {
1854                method_type: fidl::MethodType::OneWay, ..
1855            } => "unknown one-way method",
1856            BinderThreadRequest::_UnknownMethod {
1857                method_type: fidl::MethodType::TwoWay, ..
1858            } => "unknown two-way method",
1859        }
1860    }
1861}
1862
1863#[derive(Debug, Clone)]
1864pub struct BinderThreadControlHandle {
1865    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1866}
1867
1868impl BinderThreadControlHandle {
1869    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1870        self.inner.shutdown_with_epitaph(status.into())
1871    }
1872}
1873
1874impl fidl::endpoints::ControlHandle for BinderThreadControlHandle {
1875    fn shutdown(&self) {
1876        self.inner.shutdown()
1877    }
1878
1879    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1880        self.inner.shutdown_with_epitaph(status)
1881    }
1882
1883    fn is_closed(&self) -> bool {
1884        self.inner.channel().is_closed()
1885    }
1886    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1887        self.inner.channel().on_closed()
1888    }
1889
1890    #[cfg(target_os = "fuchsia")]
1891    fn signal_peer(
1892        &self,
1893        clear_mask: zx::Signals,
1894        set_mask: zx::Signals,
1895    ) -> Result<(), zx_status::Status> {
1896        use fidl::Peered;
1897        self.inner.channel().signal_peer(clear_mask, set_mask)
1898    }
1899}
1900
1901impl BinderThreadControlHandle {}
1902
1903#[must_use = "FIDL methods require a response to be sent"]
1904#[derive(Debug)]
1905pub struct BinderThreadIoctlResponder {
1906    control_handle: std::mem::ManuallyDrop<BinderThreadControlHandle>,
1907    tx_id: u32,
1908}
1909
1910/// Set the the channel to be shutdown (see [`BinderThreadControlHandle::shutdown`])
1911/// if the responder is dropped without sending a response, so that the client
1912/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1913impl std::ops::Drop for BinderThreadIoctlResponder {
1914    fn drop(&mut self) {
1915        self.control_handle.shutdown();
1916        // Safety: drops once, never accessed again
1917        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1918    }
1919}
1920
1921impl fidl::endpoints::Responder for BinderThreadIoctlResponder {
1922    type ControlHandle = BinderThreadControlHandle;
1923
1924    fn control_handle(&self) -> &BinderThreadControlHandle {
1925        &self.control_handle
1926    }
1927
1928    fn drop_without_shutdown(mut self) {
1929        // Safety: drops once, never accessed again due to mem::forget
1930        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1931        // Prevent Drop from running (which would shut down the channel)
1932        std::mem::forget(self);
1933    }
1934}
1935
1936impl BinderThreadIoctlResponder {
1937    /// Sends a response to the FIDL transaction.
1938    ///
1939    /// Sets the channel to shutdown if an error occurs.
1940    pub fn send(
1941        self,
1942        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1943    ) -> Result<(), fidl::Error> {
1944        let _result = self.send_raw(result);
1945        if _result.is_err() {
1946            self.control_handle.shutdown();
1947        }
1948        self.drop_without_shutdown();
1949        _result
1950    }
1951
1952    /// Similar to "send" but does not shutdown the channel if an error occurs.
1953    pub fn send_no_shutdown_on_err(
1954        self,
1955        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1956    ) -> Result<(), fidl::Error> {
1957        let _result = self.send_raw(result);
1958        self.drop_without_shutdown();
1959        _result
1960    }
1961
1962    fn send_raw(
1963        &self,
1964        mut result: Result<&[IoctlReadWrite], fidl_fuchsia_posix::Errno>,
1965    ) -> Result<(), fidl::Error> {
1966        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1967            BinderThreadIoctlResponse,
1968            fidl_fuchsia_posix::Errno,
1969        >>(
1970            fidl::encoding::FlexibleResult::new(result.map(|ioctl_writes| (ioctl_writes,))),
1971            self.tx_id,
1972            0x6b9dcc61092989e4,
1973            fidl::encoding::DynamicFlags::FLEXIBLE,
1974        )
1975    }
1976}
1977
1978#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1979pub struct ContainerPowerControllerMarker;
1980
1981impl fidl::endpoints::ProtocolMarker for ContainerPowerControllerMarker {
1982    type Proxy = ContainerPowerControllerProxy;
1983    type RequestStream = ContainerPowerControllerRequestStream;
1984    #[cfg(target_os = "fuchsia")]
1985    type SynchronousProxy = ContainerPowerControllerSynchronousProxy;
1986
1987    const DEBUG_NAME: &'static str = "fuchsia.starnix.binder.ContainerPowerController";
1988}
1989impl fidl::endpoints::DiscoverableProtocolMarker for ContainerPowerControllerMarker {}
1990
1991pub trait ContainerPowerControllerProxyInterface: Send + Sync {
1992    fn r#wake(&self, payload: ContainerPowerControllerWakeRequest) -> Result<(), fidl::Error>;
1993    type RegisterWakeWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
1994        + Send;
1995    fn r#register_wake_watcher(
1996        &self,
1997        payload: ContainerPowerControllerRegisterWakeWatcherRequest,
1998    ) -> Self::RegisterWakeWatcherResponseFut;
1999}
2000#[derive(Debug)]
2001#[cfg(target_os = "fuchsia")]
2002pub struct ContainerPowerControllerSynchronousProxy {
2003    client: fidl::client::sync::Client,
2004}
2005
2006#[cfg(target_os = "fuchsia")]
2007impl fidl::endpoints::SynchronousProxy for ContainerPowerControllerSynchronousProxy {
2008    type Proxy = ContainerPowerControllerProxy;
2009    type Protocol = ContainerPowerControllerMarker;
2010
2011    fn from_channel(inner: fidl::Channel) -> Self {
2012        Self::new(inner)
2013    }
2014
2015    fn into_channel(self) -> fidl::Channel {
2016        self.client.into_channel()
2017    }
2018
2019    fn as_channel(&self) -> &fidl::Channel {
2020        self.client.as_channel()
2021    }
2022}
2023
2024#[cfg(target_os = "fuchsia")]
2025impl ContainerPowerControllerSynchronousProxy {
2026    pub fn new(channel: fidl::Channel) -> Self {
2027        Self { client: fidl::client::sync::Client::new(channel) }
2028    }
2029
2030    pub fn into_channel(self) -> fidl::Channel {
2031        self.client.into_channel()
2032    }
2033
2034    /// Waits until an event arrives and returns it. It is safe for other
2035    /// threads to make concurrent requests while waiting for an event.
2036    pub fn wait_for_event(
2037        &self,
2038        deadline: zx::MonotonicInstant,
2039    ) -> Result<ContainerPowerControllerEvent, fidl::Error> {
2040        ContainerPowerControllerEvent::decode(
2041            self.client.wait_for_event::<ContainerPowerControllerMarker>(deadline)?,
2042        )
2043    }
2044
2045    /// This requests that the container wakes up to service requests.
2046    pub fn r#wake(
2047        &self,
2048        mut payload: ContainerPowerControllerWakeRequest,
2049    ) -> Result<(), fidl::Error> {
2050        self.client.send::<ContainerPowerControllerWakeRequest>(
2051            &mut payload,
2052            0x31dc1b2d1e00a094,
2053            fidl::encoding::DynamicFlags::FLEXIBLE,
2054        )
2055    }
2056
2057    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
2058    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
2059    ///
2060    /// The kernel returns AWAKE upon initial registration of the eventpair.
2061    pub fn r#register_wake_watcher(
2062        &self,
2063        mut payload: ContainerPowerControllerRegisterWakeWatcherRequest,
2064        ___deadline: zx::MonotonicInstant,
2065    ) -> Result<(), fidl::Error> {
2066        let _response = self.client.send_query::<
2067            ContainerPowerControllerRegisterWakeWatcherRequest,
2068            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2069            ContainerPowerControllerMarker,
2070        >(
2071            &mut payload,
2072            0x5a08c36d7c9c5703,
2073            fidl::encoding::DynamicFlags::FLEXIBLE,
2074            ___deadline,
2075        )?
2076        .into_result::<ContainerPowerControllerMarker>("register_wake_watcher")?;
2077        Ok(_response)
2078    }
2079}
2080
2081#[cfg(target_os = "fuchsia")]
2082impl From<ContainerPowerControllerSynchronousProxy> for zx::NullableHandle {
2083    fn from(value: ContainerPowerControllerSynchronousProxy) -> Self {
2084        value.into_channel().into()
2085    }
2086}
2087
2088#[cfg(target_os = "fuchsia")]
2089impl From<fidl::Channel> for ContainerPowerControllerSynchronousProxy {
2090    fn from(value: fidl::Channel) -> Self {
2091        Self::new(value)
2092    }
2093}
2094
2095#[cfg(target_os = "fuchsia")]
2096impl fidl::endpoints::FromClient for ContainerPowerControllerSynchronousProxy {
2097    type Protocol = ContainerPowerControllerMarker;
2098
2099    fn from_client(value: fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>) -> Self {
2100        Self::new(value.into_channel())
2101    }
2102}
2103
2104#[derive(Debug, Clone)]
2105pub struct ContainerPowerControllerProxy {
2106    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2107}
2108
2109impl fidl::endpoints::Proxy for ContainerPowerControllerProxy {
2110    type Protocol = ContainerPowerControllerMarker;
2111
2112    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2113        Self::new(inner)
2114    }
2115
2116    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2117        self.client.into_channel().map_err(|client| Self { client })
2118    }
2119
2120    fn as_channel(&self) -> &::fidl::AsyncChannel {
2121        self.client.as_channel()
2122    }
2123}
2124
2125impl ContainerPowerControllerProxy {
2126    /// Create a new Proxy for fuchsia.starnix.binder/ContainerPowerController.
2127    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2128        let protocol_name =
2129            <ContainerPowerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2130        Self { client: fidl::client::Client::new(channel, protocol_name) }
2131    }
2132
2133    /// Get a Stream of events from the remote end of the protocol.
2134    ///
2135    /// # Panics
2136    ///
2137    /// Panics if the event stream was already taken.
2138    pub fn take_event_stream(&self) -> ContainerPowerControllerEventStream {
2139        ContainerPowerControllerEventStream { event_receiver: self.client.take_event_receiver() }
2140    }
2141
2142    /// This requests that the container wakes up to service requests.
2143    pub fn r#wake(
2144        &self,
2145        mut payload: ContainerPowerControllerWakeRequest,
2146    ) -> Result<(), fidl::Error> {
2147        ContainerPowerControllerProxyInterface::r#wake(self, payload)
2148    }
2149
2150    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
2151    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
2152    ///
2153    /// The kernel returns AWAKE upon initial registration of the eventpair.
2154    pub fn r#register_wake_watcher(
2155        &self,
2156        mut payload: ContainerPowerControllerRegisterWakeWatcherRequest,
2157    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2158        ContainerPowerControllerProxyInterface::r#register_wake_watcher(self, payload)
2159    }
2160}
2161
2162impl ContainerPowerControllerProxyInterface for ContainerPowerControllerProxy {
2163    fn r#wake(&self, mut payload: ContainerPowerControllerWakeRequest) -> Result<(), fidl::Error> {
2164        self.client.send::<ContainerPowerControllerWakeRequest>(
2165            &mut payload,
2166            0x31dc1b2d1e00a094,
2167            fidl::encoding::DynamicFlags::FLEXIBLE,
2168        )
2169    }
2170
2171    type RegisterWakeWatcherResponseFut =
2172        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2173    fn r#register_wake_watcher(
2174        &self,
2175        mut payload: ContainerPowerControllerRegisterWakeWatcherRequest,
2176    ) -> Self::RegisterWakeWatcherResponseFut {
2177        fn _decode(
2178            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2179        ) -> Result<(), fidl::Error> {
2180            let _response = fidl::client::decode_transaction_body::<
2181                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2182                fidl::encoding::DefaultFuchsiaResourceDialect,
2183                0x5a08c36d7c9c5703,
2184            >(_buf?)?
2185            .into_result::<ContainerPowerControllerMarker>("register_wake_watcher")?;
2186            Ok(_response)
2187        }
2188        self.client.send_query_and_decode::<ContainerPowerControllerRegisterWakeWatcherRequest, ()>(
2189            &mut payload,
2190            0x5a08c36d7c9c5703,
2191            fidl::encoding::DynamicFlags::FLEXIBLE,
2192            _decode,
2193        )
2194    }
2195}
2196
2197pub struct ContainerPowerControllerEventStream {
2198    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2199}
2200
2201impl std::marker::Unpin for ContainerPowerControllerEventStream {}
2202
2203impl futures::stream::FusedStream for ContainerPowerControllerEventStream {
2204    fn is_terminated(&self) -> bool {
2205        self.event_receiver.is_terminated()
2206    }
2207}
2208
2209impl futures::Stream for ContainerPowerControllerEventStream {
2210    type Item = Result<ContainerPowerControllerEvent, fidl::Error>;
2211
2212    fn poll_next(
2213        mut self: std::pin::Pin<&mut Self>,
2214        cx: &mut std::task::Context<'_>,
2215    ) -> std::task::Poll<Option<Self::Item>> {
2216        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2217            &mut self.event_receiver,
2218            cx
2219        )?) {
2220            Some(buf) => std::task::Poll::Ready(Some(ContainerPowerControllerEvent::decode(buf))),
2221            None => std::task::Poll::Ready(None),
2222        }
2223    }
2224}
2225
2226#[derive(Debug)]
2227pub enum ContainerPowerControllerEvent {
2228    #[non_exhaustive]
2229    _UnknownEvent {
2230        /// Ordinal of the event that was sent.
2231        ordinal: u64,
2232    },
2233}
2234
2235impl ContainerPowerControllerEvent {
2236    /// Decodes a message buffer as a [`ContainerPowerControllerEvent`].
2237    fn decode(
2238        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2239    ) -> Result<ContainerPowerControllerEvent, fidl::Error> {
2240        let (bytes, _handles) = buf.split_mut();
2241        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2242        debug_assert_eq!(tx_header.tx_id, 0);
2243        match tx_header.ordinal {
2244            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2245                Ok(ContainerPowerControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2246            }
2247            _ => Err(fidl::Error::UnknownOrdinal {
2248                ordinal: tx_header.ordinal,
2249                protocol_name:
2250                    <ContainerPowerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2251            }),
2252        }
2253    }
2254}
2255
2256/// A Stream of incoming requests for fuchsia.starnix.binder/ContainerPowerController.
2257pub struct ContainerPowerControllerRequestStream {
2258    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2259    is_terminated: bool,
2260}
2261
2262impl std::marker::Unpin for ContainerPowerControllerRequestStream {}
2263
2264impl futures::stream::FusedStream for ContainerPowerControllerRequestStream {
2265    fn is_terminated(&self) -> bool {
2266        self.is_terminated
2267    }
2268}
2269
2270impl fidl::endpoints::RequestStream for ContainerPowerControllerRequestStream {
2271    type Protocol = ContainerPowerControllerMarker;
2272    type ControlHandle = ContainerPowerControllerControlHandle;
2273
2274    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2275        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2276    }
2277
2278    fn control_handle(&self) -> Self::ControlHandle {
2279        ContainerPowerControllerControlHandle { inner: self.inner.clone() }
2280    }
2281
2282    fn into_inner(
2283        self,
2284    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2285    {
2286        (self.inner, self.is_terminated)
2287    }
2288
2289    fn from_inner(
2290        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2291        is_terminated: bool,
2292    ) -> Self {
2293        Self { inner, is_terminated }
2294    }
2295}
2296
2297impl futures::Stream for ContainerPowerControllerRequestStream {
2298    type Item = Result<ContainerPowerControllerRequest, fidl::Error>;
2299
2300    fn poll_next(
2301        mut self: std::pin::Pin<&mut Self>,
2302        cx: &mut std::task::Context<'_>,
2303    ) -> std::task::Poll<Option<Self::Item>> {
2304        let this = &mut *self;
2305        if this.inner.check_shutdown(cx) {
2306            this.is_terminated = true;
2307            return std::task::Poll::Ready(None);
2308        }
2309        if this.is_terminated {
2310            panic!("polled ContainerPowerControllerRequestStream after completion");
2311        }
2312        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2313            |bytes, handles| {
2314                match this.inner.channel().read_etc(cx, bytes, handles) {
2315                    std::task::Poll::Ready(Ok(())) => {}
2316                    std::task::Poll::Pending => return std::task::Poll::Pending,
2317                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2318                        this.is_terminated = true;
2319                        return std::task::Poll::Ready(None);
2320                    }
2321                    std::task::Poll::Ready(Err(e)) => {
2322                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2323                            e.into(),
2324                        ))));
2325                    }
2326                }
2327
2328                // A message has been received from the channel
2329                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2330
2331                std::task::Poll::Ready(Some(match header.ordinal {
2332                0x31dc1b2d1e00a094 => {
2333                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2334                    let mut req = fidl::new_empty!(ContainerPowerControllerWakeRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2335                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ContainerPowerControllerWakeRequest>(&header, _body_bytes, handles, &mut req)?;
2336                    let control_handle = ContainerPowerControllerControlHandle {
2337                        inner: this.inner.clone(),
2338                    };
2339                    Ok(ContainerPowerControllerRequest::Wake {payload: req,
2340                        control_handle,
2341                    })
2342                }
2343                0x5a08c36d7c9c5703 => {
2344                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2345                    let mut req = fidl::new_empty!(ContainerPowerControllerRegisterWakeWatcherRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2346                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ContainerPowerControllerRegisterWakeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
2347                    let control_handle = ContainerPowerControllerControlHandle {
2348                        inner: this.inner.clone(),
2349                    };
2350                    Ok(ContainerPowerControllerRequest::RegisterWakeWatcher {payload: req,
2351                        responder: ContainerPowerControllerRegisterWakeWatcherResponder {
2352                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2353                            tx_id: header.tx_id,
2354                        },
2355                    })
2356                }
2357                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2358                    Ok(ContainerPowerControllerRequest::_UnknownMethod {
2359                        ordinal: header.ordinal,
2360                        control_handle: ContainerPowerControllerControlHandle { inner: this.inner.clone() },
2361                        method_type: fidl::MethodType::OneWay,
2362                    })
2363                }
2364                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2365                    this.inner.send_framework_err(
2366                        fidl::encoding::FrameworkErr::UnknownMethod,
2367                        header.tx_id,
2368                        header.ordinal,
2369                        header.dynamic_flags(),
2370                        (bytes, handles),
2371                    )?;
2372                    Ok(ContainerPowerControllerRequest::_UnknownMethod {
2373                        ordinal: header.ordinal,
2374                        control_handle: ContainerPowerControllerControlHandle { inner: this.inner.clone() },
2375                        method_type: fidl::MethodType::TwoWay,
2376                    })
2377                }
2378                _ => Err(fidl::Error::UnknownOrdinal {
2379                    ordinal: header.ordinal,
2380                    protocol_name: <ContainerPowerControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2381                }),
2382            }))
2383            },
2384        )
2385    }
2386}
2387
2388/// Protocol that allows a binder server to request changes to the container's power state.
2389#[derive(Debug)]
2390pub enum ContainerPowerControllerRequest {
2391    /// This requests that the container wakes up to service requests.
2392    Wake {
2393        payload: ContainerPowerControllerWakeRequest,
2394        control_handle: ContainerPowerControllerControlHandle,
2395    },
2396    /// Registers an eventpair that will be signaled when the container is suspended or resumed.
2397    /// The signals are ASLEEP(USER_1) and AWAKE(USER_0).
2398    ///
2399    /// The kernel returns AWAKE upon initial registration of the eventpair.
2400    RegisterWakeWatcher {
2401        payload: ContainerPowerControllerRegisterWakeWatcherRequest,
2402        responder: ContainerPowerControllerRegisterWakeWatcherResponder,
2403    },
2404    /// An interaction was received which does not match any known method.
2405    #[non_exhaustive]
2406    _UnknownMethod {
2407        /// Ordinal of the method that was called.
2408        ordinal: u64,
2409        control_handle: ContainerPowerControllerControlHandle,
2410        method_type: fidl::MethodType,
2411    },
2412}
2413
2414impl ContainerPowerControllerRequest {
2415    #[allow(irrefutable_let_patterns)]
2416    pub fn into_wake(
2417        self,
2418    ) -> Option<(ContainerPowerControllerWakeRequest, ContainerPowerControllerControlHandle)> {
2419        if let ContainerPowerControllerRequest::Wake { payload, control_handle } = self {
2420            Some((payload, control_handle))
2421        } else {
2422            None
2423        }
2424    }
2425
2426    #[allow(irrefutable_let_patterns)]
2427    pub fn into_register_wake_watcher(
2428        self,
2429    ) -> Option<(
2430        ContainerPowerControllerRegisterWakeWatcherRequest,
2431        ContainerPowerControllerRegisterWakeWatcherResponder,
2432    )> {
2433        if let ContainerPowerControllerRequest::RegisterWakeWatcher { payload, responder } = self {
2434            Some((payload, responder))
2435        } else {
2436            None
2437        }
2438    }
2439
2440    /// Name of the method defined in FIDL
2441    pub fn method_name(&self) -> &'static str {
2442        match *self {
2443            ContainerPowerControllerRequest::Wake { .. } => "wake",
2444            ContainerPowerControllerRequest::RegisterWakeWatcher { .. } => "register_wake_watcher",
2445            ContainerPowerControllerRequest::_UnknownMethod {
2446                method_type: fidl::MethodType::OneWay,
2447                ..
2448            } => "unknown one-way method",
2449            ContainerPowerControllerRequest::_UnknownMethod {
2450                method_type: fidl::MethodType::TwoWay,
2451                ..
2452            } => "unknown two-way method",
2453        }
2454    }
2455}
2456
2457#[derive(Debug, Clone)]
2458pub struct ContainerPowerControllerControlHandle {
2459    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2460}
2461
2462impl ContainerPowerControllerControlHandle {
2463    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2464        self.inner.shutdown_with_epitaph(status.into())
2465    }
2466}
2467
2468impl fidl::endpoints::ControlHandle for ContainerPowerControllerControlHandle {
2469    fn shutdown(&self) {
2470        self.inner.shutdown()
2471    }
2472
2473    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2474        self.inner.shutdown_with_epitaph(status)
2475    }
2476
2477    fn is_closed(&self) -> bool {
2478        self.inner.channel().is_closed()
2479    }
2480    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2481        self.inner.channel().on_closed()
2482    }
2483
2484    #[cfg(target_os = "fuchsia")]
2485    fn signal_peer(
2486        &self,
2487        clear_mask: zx::Signals,
2488        set_mask: zx::Signals,
2489    ) -> Result<(), zx_status::Status> {
2490        use fidl::Peered;
2491        self.inner.channel().signal_peer(clear_mask, set_mask)
2492    }
2493}
2494
2495impl ContainerPowerControllerControlHandle {}
2496
2497#[must_use = "FIDL methods require a response to be sent"]
2498#[derive(Debug)]
2499pub struct ContainerPowerControllerRegisterWakeWatcherResponder {
2500    control_handle: std::mem::ManuallyDrop<ContainerPowerControllerControlHandle>,
2501    tx_id: u32,
2502}
2503
2504/// Set the the channel to be shutdown (see [`ContainerPowerControllerControlHandle::shutdown`])
2505/// if the responder is dropped without sending a response, so that the client
2506/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2507impl std::ops::Drop for ContainerPowerControllerRegisterWakeWatcherResponder {
2508    fn drop(&mut self) {
2509        self.control_handle.shutdown();
2510        // Safety: drops once, never accessed again
2511        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2512    }
2513}
2514
2515impl fidl::endpoints::Responder for ContainerPowerControllerRegisterWakeWatcherResponder {
2516    type ControlHandle = ContainerPowerControllerControlHandle;
2517
2518    fn control_handle(&self) -> &ContainerPowerControllerControlHandle {
2519        &self.control_handle
2520    }
2521
2522    fn drop_without_shutdown(mut self) {
2523        // Safety: drops once, never accessed again due to mem::forget
2524        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2525        // Prevent Drop from running (which would shut down the channel)
2526        std::mem::forget(self);
2527    }
2528}
2529
2530impl ContainerPowerControllerRegisterWakeWatcherResponder {
2531    /// Sends a response to the FIDL transaction.
2532    ///
2533    /// Sets the channel to shutdown if an error occurs.
2534    pub fn send(self) -> Result<(), fidl::Error> {
2535        let _result = self.send_raw();
2536        if _result.is_err() {
2537            self.control_handle.shutdown();
2538        }
2539        self.drop_without_shutdown();
2540        _result
2541    }
2542
2543    /// Similar to "send" but does not shutdown the channel if an error occurs.
2544    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2545        let _result = self.send_raw();
2546        self.drop_without_shutdown();
2547        _result
2548    }
2549
2550    fn send_raw(&self) -> Result<(), fidl::Error> {
2551        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2552            fidl::encoding::Flexible::new(()),
2553            self.tx_id,
2554            0x5a08c36d7c9c5703,
2555            fidl::encoding::DynamicFlags::FLEXIBLE,
2556        )
2557    }
2558}
2559
2560#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2561pub struct DevBinderMarker;
2562
2563impl fidl::endpoints::ProtocolMarker for DevBinderMarker {
2564    type Proxy = DevBinderProxy;
2565    type RequestStream = DevBinderRequestStream;
2566    #[cfg(target_os = "fuchsia")]
2567    type SynchronousProxy = DevBinderSynchronousProxy;
2568
2569    const DEBUG_NAME: &'static str = "fuchsia.starnix.binder.DevBinder";
2570}
2571impl fidl::endpoints::DiscoverableProtocolMarker for DevBinderMarker {}
2572
2573pub trait DevBinderProxyInterface: Send + Sync {
2574    fn r#open(&self, payload: DevBinderOpenRequest) -> Result<(), fidl::Error>;
2575    fn r#close(&self, payload: DevBinderCloseRequest) -> Result<(), fidl::Error>;
2576}
2577#[derive(Debug)]
2578#[cfg(target_os = "fuchsia")]
2579pub struct DevBinderSynchronousProxy {
2580    client: fidl::client::sync::Client,
2581}
2582
2583#[cfg(target_os = "fuchsia")]
2584impl fidl::endpoints::SynchronousProxy for DevBinderSynchronousProxy {
2585    type Proxy = DevBinderProxy;
2586    type Protocol = DevBinderMarker;
2587
2588    fn from_channel(inner: fidl::Channel) -> Self {
2589        Self::new(inner)
2590    }
2591
2592    fn into_channel(self) -> fidl::Channel {
2593        self.client.into_channel()
2594    }
2595
2596    fn as_channel(&self) -> &fidl::Channel {
2597        self.client.as_channel()
2598    }
2599}
2600
2601#[cfg(target_os = "fuchsia")]
2602impl DevBinderSynchronousProxy {
2603    pub fn new(channel: fidl::Channel) -> Self {
2604        Self { client: fidl::client::sync::Client::new(channel) }
2605    }
2606
2607    pub fn into_channel(self) -> fidl::Channel {
2608        self.client.into_channel()
2609    }
2610
2611    /// Waits until an event arrives and returns it. It is safe for other
2612    /// threads to make concurrent requests while waiting for an event.
2613    pub fn wait_for_event(
2614        &self,
2615        deadline: zx::MonotonicInstant,
2616    ) -> Result<DevBinderEvent, fidl::Error> {
2617        DevBinderEvent::decode(self.client.wait_for_event::<DevBinderMarker>(deadline)?)
2618    }
2619
2620    /// Open the binder device node.
2621    pub fn r#open(&self, mut payload: DevBinderOpenRequest) -> Result<(), fidl::Error> {
2622        self.client.send::<DevBinderOpenRequest>(
2623            &mut payload,
2624            0x250f5ee034977685,
2625            fidl::encoding::DynamicFlags::FLEXIBLE,
2626        )
2627    }
2628
2629    /// Close the binder device node, previously opened with `Open`. The handle
2630    /// is passed back to the service so that it can identify the device being
2631    /// closed.
2632    pub fn r#close(&self, mut payload: DevBinderCloseRequest) -> Result<(), fidl::Error> {
2633        self.client.send::<DevBinderCloseRequest>(
2634            &mut payload,
2635            0x50b39ce5c9bae3b1,
2636            fidl::encoding::DynamicFlags::FLEXIBLE,
2637        )
2638    }
2639}
2640
2641#[cfg(target_os = "fuchsia")]
2642impl From<DevBinderSynchronousProxy> for zx::NullableHandle {
2643    fn from(value: DevBinderSynchronousProxy) -> Self {
2644        value.into_channel().into()
2645    }
2646}
2647
2648#[cfg(target_os = "fuchsia")]
2649impl From<fidl::Channel> for DevBinderSynchronousProxy {
2650    fn from(value: fidl::Channel) -> Self {
2651        Self::new(value)
2652    }
2653}
2654
2655#[cfg(target_os = "fuchsia")]
2656impl fidl::endpoints::FromClient for DevBinderSynchronousProxy {
2657    type Protocol = DevBinderMarker;
2658
2659    fn from_client(value: fidl::endpoints::ClientEnd<DevBinderMarker>) -> Self {
2660        Self::new(value.into_channel())
2661    }
2662}
2663
2664#[derive(Debug, Clone)]
2665pub struct DevBinderProxy {
2666    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2667}
2668
2669impl fidl::endpoints::Proxy for DevBinderProxy {
2670    type Protocol = DevBinderMarker;
2671
2672    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2673        Self::new(inner)
2674    }
2675
2676    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2677        self.client.into_channel().map_err(|client| Self { client })
2678    }
2679
2680    fn as_channel(&self) -> &::fidl::AsyncChannel {
2681        self.client.as_channel()
2682    }
2683}
2684
2685impl DevBinderProxy {
2686    /// Create a new Proxy for fuchsia.starnix.binder/DevBinder.
2687    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2688        let protocol_name = <DevBinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2689        Self { client: fidl::client::Client::new(channel, protocol_name) }
2690    }
2691
2692    /// Get a Stream of events from the remote end of the protocol.
2693    ///
2694    /// # Panics
2695    ///
2696    /// Panics if the event stream was already taken.
2697    pub fn take_event_stream(&self) -> DevBinderEventStream {
2698        DevBinderEventStream { event_receiver: self.client.take_event_receiver() }
2699    }
2700
2701    /// Open the binder device node.
2702    pub fn r#open(&self, mut payload: DevBinderOpenRequest) -> Result<(), fidl::Error> {
2703        DevBinderProxyInterface::r#open(self, payload)
2704    }
2705
2706    /// Close the binder device node, previously opened with `Open`. The handle
2707    /// is passed back to the service so that it can identify the device being
2708    /// closed.
2709    pub fn r#close(&self, mut payload: DevBinderCloseRequest) -> Result<(), fidl::Error> {
2710        DevBinderProxyInterface::r#close(self, payload)
2711    }
2712}
2713
2714impl DevBinderProxyInterface for DevBinderProxy {
2715    fn r#open(&self, mut payload: DevBinderOpenRequest) -> Result<(), fidl::Error> {
2716        self.client.send::<DevBinderOpenRequest>(
2717            &mut payload,
2718            0x250f5ee034977685,
2719            fidl::encoding::DynamicFlags::FLEXIBLE,
2720        )
2721    }
2722
2723    fn r#close(&self, mut payload: DevBinderCloseRequest) -> Result<(), fidl::Error> {
2724        self.client.send::<DevBinderCloseRequest>(
2725            &mut payload,
2726            0x50b39ce5c9bae3b1,
2727            fidl::encoding::DynamicFlags::FLEXIBLE,
2728        )
2729    }
2730}
2731
2732pub struct DevBinderEventStream {
2733    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2734}
2735
2736impl std::marker::Unpin for DevBinderEventStream {}
2737
2738impl futures::stream::FusedStream for DevBinderEventStream {
2739    fn is_terminated(&self) -> bool {
2740        self.event_receiver.is_terminated()
2741    }
2742}
2743
2744impl futures::Stream for DevBinderEventStream {
2745    type Item = Result<DevBinderEvent, fidl::Error>;
2746
2747    fn poll_next(
2748        mut self: std::pin::Pin<&mut Self>,
2749        cx: &mut std::task::Context<'_>,
2750    ) -> std::task::Poll<Option<Self::Item>> {
2751        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2752            &mut self.event_receiver,
2753            cx
2754        )?) {
2755            Some(buf) => std::task::Poll::Ready(Some(DevBinderEvent::decode(buf))),
2756            None => std::task::Poll::Ready(None),
2757        }
2758    }
2759}
2760
2761#[derive(Debug)]
2762pub enum DevBinderEvent {
2763    #[non_exhaustive]
2764    _UnknownEvent {
2765        /// Ordinal of the event that was sent.
2766        ordinal: u64,
2767    },
2768}
2769
2770impl DevBinderEvent {
2771    /// Decodes a message buffer as a [`DevBinderEvent`].
2772    fn decode(
2773        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2774    ) -> Result<DevBinderEvent, fidl::Error> {
2775        let (bytes, _handles) = buf.split_mut();
2776        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2777        debug_assert_eq!(tx_header.tx_id, 0);
2778        match tx_header.ordinal {
2779            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2780                Ok(DevBinderEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2781            }
2782            _ => Err(fidl::Error::UnknownOrdinal {
2783                ordinal: tx_header.ordinal,
2784                protocol_name: <DevBinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2785            }),
2786        }
2787    }
2788}
2789
2790/// A Stream of incoming requests for fuchsia.starnix.binder/DevBinder.
2791pub struct DevBinderRequestStream {
2792    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2793    is_terminated: bool,
2794}
2795
2796impl std::marker::Unpin for DevBinderRequestStream {}
2797
2798impl futures::stream::FusedStream for DevBinderRequestStream {
2799    fn is_terminated(&self) -> bool {
2800        self.is_terminated
2801    }
2802}
2803
2804impl fidl::endpoints::RequestStream for DevBinderRequestStream {
2805    type Protocol = DevBinderMarker;
2806    type ControlHandle = DevBinderControlHandle;
2807
2808    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2809        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2810    }
2811
2812    fn control_handle(&self) -> Self::ControlHandle {
2813        DevBinderControlHandle { inner: self.inner.clone() }
2814    }
2815
2816    fn into_inner(
2817        self,
2818    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2819    {
2820        (self.inner, self.is_terminated)
2821    }
2822
2823    fn from_inner(
2824        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2825        is_terminated: bool,
2826    ) -> Self {
2827        Self { inner, is_terminated }
2828    }
2829}
2830
2831impl futures::Stream for DevBinderRequestStream {
2832    type Item = Result<DevBinderRequest, fidl::Error>;
2833
2834    fn poll_next(
2835        mut self: std::pin::Pin<&mut Self>,
2836        cx: &mut std::task::Context<'_>,
2837    ) -> std::task::Poll<Option<Self::Item>> {
2838        let this = &mut *self;
2839        if this.inner.check_shutdown(cx) {
2840            this.is_terminated = true;
2841            return std::task::Poll::Ready(None);
2842        }
2843        if this.is_terminated {
2844            panic!("polled DevBinderRequestStream after completion");
2845        }
2846        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2847            |bytes, handles| {
2848                match this.inner.channel().read_etc(cx, bytes, handles) {
2849                    std::task::Poll::Ready(Ok(())) => {}
2850                    std::task::Poll::Pending => return std::task::Poll::Pending,
2851                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2852                        this.is_terminated = true;
2853                        return std::task::Poll::Ready(None);
2854                    }
2855                    std::task::Poll::Ready(Err(e)) => {
2856                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2857                            e.into(),
2858                        ))));
2859                    }
2860                }
2861
2862                // A message has been received from the channel
2863                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2864
2865                std::task::Poll::Ready(Some(match header.ordinal {
2866                    0x250f5ee034977685 => {
2867                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2868                        let mut req = fidl::new_empty!(
2869                            DevBinderOpenRequest,
2870                            fidl::encoding::DefaultFuchsiaResourceDialect
2871                        );
2872                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevBinderOpenRequest>(&header, _body_bytes, handles, &mut req)?;
2873                        let control_handle = DevBinderControlHandle { inner: this.inner.clone() };
2874                        Ok(DevBinderRequest::Open { payload: req, control_handle })
2875                    }
2876                    0x50b39ce5c9bae3b1 => {
2877                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2878                        let mut req = fidl::new_empty!(
2879                            DevBinderCloseRequest,
2880                            fidl::encoding::DefaultFuchsiaResourceDialect
2881                        );
2882                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DevBinderCloseRequest>(&header, _body_bytes, handles, &mut req)?;
2883                        let control_handle = DevBinderControlHandle { inner: this.inner.clone() };
2884                        Ok(DevBinderRequest::Close { payload: req, control_handle })
2885                    }
2886                    _ if header.tx_id == 0
2887                        && header
2888                            .dynamic_flags()
2889                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2890                    {
2891                        Ok(DevBinderRequest::_UnknownMethod {
2892                            ordinal: header.ordinal,
2893                            control_handle: DevBinderControlHandle { inner: this.inner.clone() },
2894                            method_type: fidl::MethodType::OneWay,
2895                        })
2896                    }
2897                    _ if header
2898                        .dynamic_flags()
2899                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2900                    {
2901                        this.inner.send_framework_err(
2902                            fidl::encoding::FrameworkErr::UnknownMethod,
2903                            header.tx_id,
2904                            header.ordinal,
2905                            header.dynamic_flags(),
2906                            (bytes, handles),
2907                        )?;
2908                        Ok(DevBinderRequest::_UnknownMethod {
2909                            ordinal: header.ordinal,
2910                            control_handle: DevBinderControlHandle { inner: this.inner.clone() },
2911                            method_type: fidl::MethodType::TwoWay,
2912                        })
2913                    }
2914                    _ => Err(fidl::Error::UnknownOrdinal {
2915                        ordinal: header.ordinal,
2916                        protocol_name:
2917                            <DevBinderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2918                    }),
2919                }))
2920            },
2921        )
2922    }
2923}
2924
2925/// Give access to the binder nodes.
2926#[derive(Debug)]
2927pub enum DevBinderRequest {
2928    /// Open the binder device node.
2929    Open { payload: DevBinderOpenRequest, control_handle: DevBinderControlHandle },
2930    /// Close the binder device node, previously opened with `Open`. The handle
2931    /// is passed back to the service so that it can identify the device being
2932    /// closed.
2933    Close { payload: DevBinderCloseRequest, control_handle: DevBinderControlHandle },
2934    /// An interaction was received which does not match any known method.
2935    #[non_exhaustive]
2936    _UnknownMethod {
2937        /// Ordinal of the method that was called.
2938        ordinal: u64,
2939        control_handle: DevBinderControlHandle,
2940        method_type: fidl::MethodType,
2941    },
2942}
2943
2944impl DevBinderRequest {
2945    #[allow(irrefutable_let_patterns)]
2946    pub fn into_open(self) -> Option<(DevBinderOpenRequest, DevBinderControlHandle)> {
2947        if let DevBinderRequest::Open { payload, control_handle } = self {
2948            Some((payload, control_handle))
2949        } else {
2950            None
2951        }
2952    }
2953
2954    #[allow(irrefutable_let_patterns)]
2955    pub fn into_close(self) -> Option<(DevBinderCloseRequest, DevBinderControlHandle)> {
2956        if let DevBinderRequest::Close { payload, control_handle } = self {
2957            Some((payload, control_handle))
2958        } else {
2959            None
2960        }
2961    }
2962
2963    /// Name of the method defined in FIDL
2964    pub fn method_name(&self) -> &'static str {
2965        match *self {
2966            DevBinderRequest::Open { .. } => "open",
2967            DevBinderRequest::Close { .. } => "close",
2968            DevBinderRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
2969                "unknown one-way method"
2970            }
2971            DevBinderRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
2972                "unknown two-way method"
2973            }
2974        }
2975    }
2976}
2977
2978#[derive(Debug, Clone)]
2979pub struct DevBinderControlHandle {
2980    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2981}
2982
2983impl DevBinderControlHandle {
2984    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2985        self.inner.shutdown_with_epitaph(status.into())
2986    }
2987}
2988
2989impl fidl::endpoints::ControlHandle for DevBinderControlHandle {
2990    fn shutdown(&self) {
2991        self.inner.shutdown()
2992    }
2993
2994    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2995        self.inner.shutdown_with_epitaph(status)
2996    }
2997
2998    fn is_closed(&self) -> bool {
2999        self.inner.channel().is_closed()
3000    }
3001    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3002        self.inner.channel().on_closed()
3003    }
3004
3005    #[cfg(target_os = "fuchsia")]
3006    fn signal_peer(
3007        &self,
3008        clear_mask: zx::Signals,
3009        set_mask: zx::Signals,
3010    ) -> Result<(), zx_status::Status> {
3011        use fidl::Peered;
3012        self.inner.channel().signal_peer(clear_mask, set_mask)
3013    }
3014}
3015
3016impl DevBinderControlHandle {}
3017
3018#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3019pub struct LutexControllerMarker;
3020
3021impl fidl::endpoints::ProtocolMarker for LutexControllerMarker {
3022    type Proxy = LutexControllerProxy;
3023    type RequestStream = LutexControllerRequestStream;
3024    #[cfg(target_os = "fuchsia")]
3025    type SynchronousProxy = LutexControllerSynchronousProxy;
3026
3027    const DEBUG_NAME: &'static str = "fuchsia.starnix.binder.LutexController";
3028}
3029impl fidl::endpoints::DiscoverableProtocolMarker for LutexControllerMarker {}
3030pub type LutexControllerWaitBitsetResult = Result<(), fidl_fuchsia_posix::Errno>;
3031pub type LutexControllerWakeBitsetResult = Result<WakeResponse, fidl_fuchsia_posix::Errno>;
3032pub type LutexControllerCmpRequeueResult = Result<CmpRequeueResponse, fidl_fuchsia_posix::Errno>;
3033
3034pub trait LutexControllerProxyInterface: Send + Sync {
3035    type WaitBitsetResponseFut: std::future::Future<Output = Result<LutexControllerWaitBitsetResult, fidl::Error>>
3036        + Send;
3037    fn r#wait_bitset(&self, payload: WaitBitsetRequest) -> Self::WaitBitsetResponseFut;
3038    type WakeBitsetResponseFut: std::future::Future<Output = Result<LutexControllerWakeBitsetResult, fidl::Error>>
3039        + Send;
3040    fn r#wake_bitset(&self, payload: WakeBitsetRequest) -> Self::WakeBitsetResponseFut;
3041    type CmpRequeueResponseFut: std::future::Future<Output = Result<LutexControllerCmpRequeueResult, fidl::Error>>
3042        + Send;
3043    fn r#cmp_requeue(&self, payload: CmpRequeueRequest) -> Self::CmpRequeueResponseFut;
3044}
3045#[derive(Debug)]
3046#[cfg(target_os = "fuchsia")]
3047pub struct LutexControllerSynchronousProxy {
3048    client: fidl::client::sync::Client,
3049}
3050
3051#[cfg(target_os = "fuchsia")]
3052impl fidl::endpoints::SynchronousProxy for LutexControllerSynchronousProxy {
3053    type Proxy = LutexControllerProxy;
3054    type Protocol = LutexControllerMarker;
3055
3056    fn from_channel(inner: fidl::Channel) -> Self {
3057        Self::new(inner)
3058    }
3059
3060    fn into_channel(self) -> fidl::Channel {
3061        self.client.into_channel()
3062    }
3063
3064    fn as_channel(&self) -> &fidl::Channel {
3065        self.client.as_channel()
3066    }
3067}
3068
3069#[cfg(target_os = "fuchsia")]
3070impl LutexControllerSynchronousProxy {
3071    pub fn new(channel: fidl::Channel) -> Self {
3072        Self { client: fidl::client::sync::Client::new(channel) }
3073    }
3074
3075    pub fn into_channel(self) -> fidl::Channel {
3076        self.client.into_channel()
3077    }
3078
3079    /// Waits until an event arrives and returns it. It is safe for other
3080    /// threads to make concurrent requests while waiting for an event.
3081    pub fn wait_for_event(
3082        &self,
3083        deadline: zx::MonotonicInstant,
3084    ) -> Result<LutexControllerEvent, fidl::Error> {
3085        LutexControllerEvent::decode(self.client.wait_for_event::<LutexControllerMarker>(deadline)?)
3086    }
3087
3088    /// FUTEX_WAIT_BITSET command
3089    pub fn r#wait_bitset(
3090        &self,
3091        mut payload: WaitBitsetRequest,
3092        ___deadline: zx::MonotonicInstant,
3093    ) -> Result<LutexControllerWaitBitsetResult, fidl::Error> {
3094        let _response = self
3095            .client
3096            .send_query::<WaitBitsetRequest, fidl::encoding::FlexibleResultType<
3097                fidl::encoding::EmptyStruct,
3098                fidl_fuchsia_posix::Errno,
3099            >, LutexControllerMarker>(
3100                &mut payload,
3101                0x489feee6787d11b1,
3102                fidl::encoding::DynamicFlags::FLEXIBLE,
3103                ___deadline,
3104            )?
3105            .into_result::<LutexControllerMarker>("wait_bitset")?;
3106        Ok(_response.map(|x| x))
3107    }
3108
3109    /// FUTEX_WAKE_BITSET command
3110    pub fn r#wake_bitset(
3111        &self,
3112        mut payload: WakeBitsetRequest,
3113        ___deadline: zx::MonotonicInstant,
3114    ) -> Result<LutexControllerWakeBitsetResult, fidl::Error> {
3115        let _response = self.client.send_query::<
3116            WakeBitsetRequest,
3117            fidl::encoding::FlexibleResultType<WakeResponse, fidl_fuchsia_posix::Errno>,
3118            LutexControllerMarker,
3119        >(
3120            &mut payload,
3121            0x58309f6ebcb0d8eb,
3122            fidl::encoding::DynamicFlags::FLEXIBLE,
3123            ___deadline,
3124        )?
3125        .into_result::<LutexControllerMarker>("wake_bitset")?;
3126        Ok(_response.map(|x| x))
3127    }
3128
3129    /// FUTEX_CMP_REQUEUE and FUTEX_REQUEUE commands
3130    pub fn r#cmp_requeue(
3131        &self,
3132        mut payload: CmpRequeueRequest,
3133        ___deadline: zx::MonotonicInstant,
3134    ) -> Result<LutexControllerCmpRequeueResult, fidl::Error> {
3135        let _response = self.client.send_query::<
3136            CmpRequeueRequest,
3137            fidl::encoding::FlexibleResultType<CmpRequeueResponse, fidl_fuchsia_posix::Errno>,
3138            LutexControllerMarker,
3139        >(
3140            &mut payload,
3141            0x38e55a7315bef4b5,
3142            fidl::encoding::DynamicFlags::FLEXIBLE,
3143            ___deadline,
3144        )?
3145        .into_result::<LutexControllerMarker>("cmp_requeue")?;
3146        Ok(_response.map(|x| x))
3147    }
3148}
3149
3150#[cfg(target_os = "fuchsia")]
3151impl From<LutexControllerSynchronousProxy> for zx::NullableHandle {
3152    fn from(value: LutexControllerSynchronousProxy) -> Self {
3153        value.into_channel().into()
3154    }
3155}
3156
3157#[cfg(target_os = "fuchsia")]
3158impl From<fidl::Channel> for LutexControllerSynchronousProxy {
3159    fn from(value: fidl::Channel) -> Self {
3160        Self::new(value)
3161    }
3162}
3163
3164#[cfg(target_os = "fuchsia")]
3165impl fidl::endpoints::FromClient for LutexControllerSynchronousProxy {
3166    type Protocol = LutexControllerMarker;
3167
3168    fn from_client(value: fidl::endpoints::ClientEnd<LutexControllerMarker>) -> Self {
3169        Self::new(value.into_channel())
3170    }
3171}
3172
3173#[derive(Debug, Clone)]
3174pub struct LutexControllerProxy {
3175    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3176}
3177
3178impl fidl::endpoints::Proxy for LutexControllerProxy {
3179    type Protocol = LutexControllerMarker;
3180
3181    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3182        Self::new(inner)
3183    }
3184
3185    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3186        self.client.into_channel().map_err(|client| Self { client })
3187    }
3188
3189    fn as_channel(&self) -> &::fidl::AsyncChannel {
3190        self.client.as_channel()
3191    }
3192}
3193
3194impl LutexControllerProxy {
3195    /// Create a new Proxy for fuchsia.starnix.binder/LutexController.
3196    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3197        let protocol_name = <LutexControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3198        Self { client: fidl::client::Client::new(channel, protocol_name) }
3199    }
3200
3201    /// Get a Stream of events from the remote end of the protocol.
3202    ///
3203    /// # Panics
3204    ///
3205    /// Panics if the event stream was already taken.
3206    pub fn take_event_stream(&self) -> LutexControllerEventStream {
3207        LutexControllerEventStream { event_receiver: self.client.take_event_receiver() }
3208    }
3209
3210    /// FUTEX_WAIT_BITSET command
3211    pub fn r#wait_bitset(
3212        &self,
3213        mut payload: WaitBitsetRequest,
3214    ) -> fidl::client::QueryResponseFut<
3215        LutexControllerWaitBitsetResult,
3216        fidl::encoding::DefaultFuchsiaResourceDialect,
3217    > {
3218        LutexControllerProxyInterface::r#wait_bitset(self, payload)
3219    }
3220
3221    /// FUTEX_WAKE_BITSET command
3222    pub fn r#wake_bitset(
3223        &self,
3224        mut payload: WakeBitsetRequest,
3225    ) -> fidl::client::QueryResponseFut<
3226        LutexControllerWakeBitsetResult,
3227        fidl::encoding::DefaultFuchsiaResourceDialect,
3228    > {
3229        LutexControllerProxyInterface::r#wake_bitset(self, payload)
3230    }
3231
3232    /// FUTEX_CMP_REQUEUE and FUTEX_REQUEUE commands
3233    pub fn r#cmp_requeue(
3234        &self,
3235        mut payload: CmpRequeueRequest,
3236    ) -> fidl::client::QueryResponseFut<
3237        LutexControllerCmpRequeueResult,
3238        fidl::encoding::DefaultFuchsiaResourceDialect,
3239    > {
3240        LutexControllerProxyInterface::r#cmp_requeue(self, payload)
3241    }
3242}
3243
3244impl LutexControllerProxyInterface for LutexControllerProxy {
3245    type WaitBitsetResponseFut = fidl::client::QueryResponseFut<
3246        LutexControllerWaitBitsetResult,
3247        fidl::encoding::DefaultFuchsiaResourceDialect,
3248    >;
3249    fn r#wait_bitset(&self, mut payload: WaitBitsetRequest) -> Self::WaitBitsetResponseFut {
3250        fn _decode(
3251            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3252        ) -> Result<LutexControllerWaitBitsetResult, fidl::Error> {
3253            let _response = fidl::client::decode_transaction_body::<
3254                fidl::encoding::FlexibleResultType<
3255                    fidl::encoding::EmptyStruct,
3256                    fidl_fuchsia_posix::Errno,
3257                >,
3258                fidl::encoding::DefaultFuchsiaResourceDialect,
3259                0x489feee6787d11b1,
3260            >(_buf?)?
3261            .into_result::<LutexControllerMarker>("wait_bitset")?;
3262            Ok(_response.map(|x| x))
3263        }
3264        self.client.send_query_and_decode::<WaitBitsetRequest, LutexControllerWaitBitsetResult>(
3265            &mut payload,
3266            0x489feee6787d11b1,
3267            fidl::encoding::DynamicFlags::FLEXIBLE,
3268            _decode,
3269        )
3270    }
3271
3272    type WakeBitsetResponseFut = fidl::client::QueryResponseFut<
3273        LutexControllerWakeBitsetResult,
3274        fidl::encoding::DefaultFuchsiaResourceDialect,
3275    >;
3276    fn r#wake_bitset(&self, mut payload: WakeBitsetRequest) -> Self::WakeBitsetResponseFut {
3277        fn _decode(
3278            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3279        ) -> Result<LutexControllerWakeBitsetResult, fidl::Error> {
3280            let _response = fidl::client::decode_transaction_body::<
3281                fidl::encoding::FlexibleResultType<WakeResponse, fidl_fuchsia_posix::Errno>,
3282                fidl::encoding::DefaultFuchsiaResourceDialect,
3283                0x58309f6ebcb0d8eb,
3284            >(_buf?)?
3285            .into_result::<LutexControllerMarker>("wake_bitset")?;
3286            Ok(_response.map(|x| x))
3287        }
3288        self.client.send_query_and_decode::<WakeBitsetRequest, LutexControllerWakeBitsetResult>(
3289            &mut payload,
3290            0x58309f6ebcb0d8eb,
3291            fidl::encoding::DynamicFlags::FLEXIBLE,
3292            _decode,
3293        )
3294    }
3295
3296    type CmpRequeueResponseFut = fidl::client::QueryResponseFut<
3297        LutexControllerCmpRequeueResult,
3298        fidl::encoding::DefaultFuchsiaResourceDialect,
3299    >;
3300    fn r#cmp_requeue(&self, mut payload: CmpRequeueRequest) -> Self::CmpRequeueResponseFut {
3301        fn _decode(
3302            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3303        ) -> Result<LutexControllerCmpRequeueResult, fidl::Error> {
3304            let _response = fidl::client::decode_transaction_body::<
3305                fidl::encoding::FlexibleResultType<CmpRequeueResponse, fidl_fuchsia_posix::Errno>,
3306                fidl::encoding::DefaultFuchsiaResourceDialect,
3307                0x38e55a7315bef4b5,
3308            >(_buf?)?
3309            .into_result::<LutexControllerMarker>("cmp_requeue")?;
3310            Ok(_response.map(|x| x))
3311        }
3312        self.client.send_query_and_decode::<CmpRequeueRequest, LutexControllerCmpRequeueResult>(
3313            &mut payload,
3314            0x38e55a7315bef4b5,
3315            fidl::encoding::DynamicFlags::FLEXIBLE,
3316            _decode,
3317        )
3318    }
3319}
3320
3321pub struct LutexControllerEventStream {
3322    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3323}
3324
3325impl std::marker::Unpin for LutexControllerEventStream {}
3326
3327impl futures::stream::FusedStream for LutexControllerEventStream {
3328    fn is_terminated(&self) -> bool {
3329        self.event_receiver.is_terminated()
3330    }
3331}
3332
3333impl futures::Stream for LutexControllerEventStream {
3334    type Item = Result<LutexControllerEvent, fidl::Error>;
3335
3336    fn poll_next(
3337        mut self: std::pin::Pin<&mut Self>,
3338        cx: &mut std::task::Context<'_>,
3339    ) -> std::task::Poll<Option<Self::Item>> {
3340        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3341            &mut self.event_receiver,
3342            cx
3343        )?) {
3344            Some(buf) => std::task::Poll::Ready(Some(LutexControllerEvent::decode(buf))),
3345            None => std::task::Poll::Ready(None),
3346        }
3347    }
3348}
3349
3350#[derive(Debug)]
3351pub enum LutexControllerEvent {
3352    #[non_exhaustive]
3353    _UnknownEvent {
3354        /// Ordinal of the event that was sent.
3355        ordinal: u64,
3356    },
3357}
3358
3359impl LutexControllerEvent {
3360    /// Decodes a message buffer as a [`LutexControllerEvent`].
3361    fn decode(
3362        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3363    ) -> Result<LutexControllerEvent, fidl::Error> {
3364        let (bytes, _handles) = buf.split_mut();
3365        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3366        debug_assert_eq!(tx_header.tx_id, 0);
3367        match tx_header.ordinal {
3368            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3369                Ok(LutexControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3370            }
3371            _ => Err(fidl::Error::UnknownOrdinal {
3372                ordinal: tx_header.ordinal,
3373                protocol_name:
3374                    <LutexControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3375            }),
3376        }
3377    }
3378}
3379
3380/// A Stream of incoming requests for fuchsia.starnix.binder/LutexController.
3381pub struct LutexControllerRequestStream {
3382    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3383    is_terminated: bool,
3384}
3385
3386impl std::marker::Unpin for LutexControllerRequestStream {}
3387
3388impl futures::stream::FusedStream for LutexControllerRequestStream {
3389    fn is_terminated(&self) -> bool {
3390        self.is_terminated
3391    }
3392}
3393
3394impl fidl::endpoints::RequestStream for LutexControllerRequestStream {
3395    type Protocol = LutexControllerMarker;
3396    type ControlHandle = LutexControllerControlHandle;
3397
3398    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3399        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3400    }
3401
3402    fn control_handle(&self) -> Self::ControlHandle {
3403        LutexControllerControlHandle { inner: self.inner.clone() }
3404    }
3405
3406    fn into_inner(
3407        self,
3408    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3409    {
3410        (self.inner, self.is_terminated)
3411    }
3412
3413    fn from_inner(
3414        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3415        is_terminated: bool,
3416    ) -> Self {
3417        Self { inner, is_terminated }
3418    }
3419}
3420
3421impl futures::Stream for LutexControllerRequestStream {
3422    type Item = Result<LutexControllerRequest, fidl::Error>;
3423
3424    fn poll_next(
3425        mut self: std::pin::Pin<&mut Self>,
3426        cx: &mut std::task::Context<'_>,
3427    ) -> std::task::Poll<Option<Self::Item>> {
3428        let this = &mut *self;
3429        if this.inner.check_shutdown(cx) {
3430            this.is_terminated = true;
3431            return std::task::Poll::Ready(None);
3432        }
3433        if this.is_terminated {
3434            panic!("polled LutexControllerRequestStream after completion");
3435        }
3436        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3437            |bytes, handles| {
3438                match this.inner.channel().read_etc(cx, bytes, handles) {
3439                    std::task::Poll::Ready(Ok(())) => {}
3440                    std::task::Poll::Pending => return std::task::Poll::Pending,
3441                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3442                        this.is_terminated = true;
3443                        return std::task::Poll::Ready(None);
3444                    }
3445                    std::task::Poll::Ready(Err(e)) => {
3446                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3447                            e.into(),
3448                        ))));
3449                    }
3450                }
3451
3452                // A message has been received from the channel
3453                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3454
3455                std::task::Poll::Ready(Some(match header.ordinal {
3456                    0x489feee6787d11b1 => {
3457                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3458                        let mut req = fidl::new_empty!(
3459                            WaitBitsetRequest,
3460                            fidl::encoding::DefaultFuchsiaResourceDialect
3461                        );
3462                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WaitBitsetRequest>(&header, _body_bytes, handles, &mut req)?;
3463                        let control_handle =
3464                            LutexControllerControlHandle { inner: this.inner.clone() };
3465                        Ok(LutexControllerRequest::WaitBitset {
3466                            payload: req,
3467                            responder: LutexControllerWaitBitsetResponder {
3468                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3469                                tx_id: header.tx_id,
3470                            },
3471                        })
3472                    }
3473                    0x58309f6ebcb0d8eb => {
3474                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3475                        let mut req = fidl::new_empty!(
3476                            WakeBitsetRequest,
3477                            fidl::encoding::DefaultFuchsiaResourceDialect
3478                        );
3479                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WakeBitsetRequest>(&header, _body_bytes, handles, &mut req)?;
3480                        let control_handle =
3481                            LutexControllerControlHandle { inner: this.inner.clone() };
3482                        Ok(LutexControllerRequest::WakeBitset {
3483                            payload: req,
3484                            responder: LutexControllerWakeBitsetResponder {
3485                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3486                                tx_id: header.tx_id,
3487                            },
3488                        })
3489                    }
3490                    0x38e55a7315bef4b5 => {
3491                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3492                        let mut req = fidl::new_empty!(
3493                            CmpRequeueRequest,
3494                            fidl::encoding::DefaultFuchsiaResourceDialect
3495                        );
3496                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CmpRequeueRequest>(&header, _body_bytes, handles, &mut req)?;
3497                        let control_handle =
3498                            LutexControllerControlHandle { inner: this.inner.clone() };
3499                        Ok(LutexControllerRequest::CmpRequeue {
3500                            payload: req,
3501                            responder: LutexControllerCmpRequeueResponder {
3502                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3503                                tx_id: header.tx_id,
3504                            },
3505                        })
3506                    }
3507                    _ if header.tx_id == 0
3508                        && header
3509                            .dynamic_flags()
3510                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3511                    {
3512                        Ok(LutexControllerRequest::_UnknownMethod {
3513                            ordinal: header.ordinal,
3514                            control_handle: LutexControllerControlHandle {
3515                                inner: this.inner.clone(),
3516                            },
3517                            method_type: fidl::MethodType::OneWay,
3518                        })
3519                    }
3520                    _ if header
3521                        .dynamic_flags()
3522                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3523                    {
3524                        this.inner.send_framework_err(
3525                            fidl::encoding::FrameworkErr::UnknownMethod,
3526                            header.tx_id,
3527                            header.ordinal,
3528                            header.dynamic_flags(),
3529                            (bytes, handles),
3530                        )?;
3531                        Ok(LutexControllerRequest::_UnknownMethod {
3532                            ordinal: header.ordinal,
3533                            control_handle: LutexControllerControlHandle {
3534                                inner: this.inner.clone(),
3535                            },
3536                            method_type: fidl::MethodType::TwoWay,
3537                        })
3538                    }
3539                    _ => Err(fidl::Error::UnknownOrdinal {
3540                        ordinal: header.ordinal,
3541                        protocol_name:
3542                            <LutexControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3543                    }),
3544                }))
3545            },
3546        )
3547    }
3548}
3549
3550/// Protocol that allows a Fuchsia component to interact with the Linux futexes
3551/// of a process running inside starnix.
3552#[derive(Debug)]
3553pub enum LutexControllerRequest {
3554    /// FUTEX_WAIT_BITSET command
3555    WaitBitset { payload: WaitBitsetRequest, responder: LutexControllerWaitBitsetResponder },
3556    /// FUTEX_WAKE_BITSET command
3557    WakeBitset { payload: WakeBitsetRequest, responder: LutexControllerWakeBitsetResponder },
3558    /// FUTEX_CMP_REQUEUE and FUTEX_REQUEUE commands
3559    CmpRequeue { payload: CmpRequeueRequest, responder: LutexControllerCmpRequeueResponder },
3560    /// An interaction was received which does not match any known method.
3561    #[non_exhaustive]
3562    _UnknownMethod {
3563        /// Ordinal of the method that was called.
3564        ordinal: u64,
3565        control_handle: LutexControllerControlHandle,
3566        method_type: fidl::MethodType,
3567    },
3568}
3569
3570impl LutexControllerRequest {
3571    #[allow(irrefutable_let_patterns)]
3572    pub fn into_wait_bitset(
3573        self,
3574    ) -> Option<(WaitBitsetRequest, LutexControllerWaitBitsetResponder)> {
3575        if let LutexControllerRequest::WaitBitset { payload, responder } = self {
3576            Some((payload, responder))
3577        } else {
3578            None
3579        }
3580    }
3581
3582    #[allow(irrefutable_let_patterns)]
3583    pub fn into_wake_bitset(
3584        self,
3585    ) -> Option<(WakeBitsetRequest, LutexControllerWakeBitsetResponder)> {
3586        if let LutexControllerRequest::WakeBitset { payload, responder } = self {
3587            Some((payload, responder))
3588        } else {
3589            None
3590        }
3591    }
3592
3593    #[allow(irrefutable_let_patterns)]
3594    pub fn into_cmp_requeue(
3595        self,
3596    ) -> Option<(CmpRequeueRequest, LutexControllerCmpRequeueResponder)> {
3597        if let LutexControllerRequest::CmpRequeue { payload, responder } = self {
3598            Some((payload, responder))
3599        } else {
3600            None
3601        }
3602    }
3603
3604    /// Name of the method defined in FIDL
3605    pub fn method_name(&self) -> &'static str {
3606        match *self {
3607            LutexControllerRequest::WaitBitset { .. } => "wait_bitset",
3608            LutexControllerRequest::WakeBitset { .. } => "wake_bitset",
3609            LutexControllerRequest::CmpRequeue { .. } => "cmp_requeue",
3610            LutexControllerRequest::_UnknownMethod {
3611                method_type: fidl::MethodType::OneWay,
3612                ..
3613            } => "unknown one-way method",
3614            LutexControllerRequest::_UnknownMethod {
3615                method_type: fidl::MethodType::TwoWay,
3616                ..
3617            } => "unknown two-way method",
3618        }
3619    }
3620}
3621
3622#[derive(Debug, Clone)]
3623pub struct LutexControllerControlHandle {
3624    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3625}
3626
3627impl LutexControllerControlHandle {
3628    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
3629        self.inner.shutdown_with_epitaph(status.into())
3630    }
3631}
3632
3633impl fidl::endpoints::ControlHandle for LutexControllerControlHandle {
3634    fn shutdown(&self) {
3635        self.inner.shutdown()
3636    }
3637
3638    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
3639        self.inner.shutdown_with_epitaph(status)
3640    }
3641
3642    fn is_closed(&self) -> bool {
3643        self.inner.channel().is_closed()
3644    }
3645    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3646        self.inner.channel().on_closed()
3647    }
3648
3649    #[cfg(target_os = "fuchsia")]
3650    fn signal_peer(
3651        &self,
3652        clear_mask: zx::Signals,
3653        set_mask: zx::Signals,
3654    ) -> Result<(), zx_status::Status> {
3655        use fidl::Peered;
3656        self.inner.channel().signal_peer(clear_mask, set_mask)
3657    }
3658}
3659
3660impl LutexControllerControlHandle {}
3661
3662#[must_use = "FIDL methods require a response to be sent"]
3663#[derive(Debug)]
3664pub struct LutexControllerWaitBitsetResponder {
3665    control_handle: std::mem::ManuallyDrop<LutexControllerControlHandle>,
3666    tx_id: u32,
3667}
3668
3669/// Set the the channel to be shutdown (see [`LutexControllerControlHandle::shutdown`])
3670/// if the responder is dropped without sending a response, so that the client
3671/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3672impl std::ops::Drop for LutexControllerWaitBitsetResponder {
3673    fn drop(&mut self) {
3674        self.control_handle.shutdown();
3675        // Safety: drops once, never accessed again
3676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3677    }
3678}
3679
3680impl fidl::endpoints::Responder for LutexControllerWaitBitsetResponder {
3681    type ControlHandle = LutexControllerControlHandle;
3682
3683    fn control_handle(&self) -> &LutexControllerControlHandle {
3684        &self.control_handle
3685    }
3686
3687    fn drop_without_shutdown(mut self) {
3688        // Safety: drops once, never accessed again due to mem::forget
3689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3690        // Prevent Drop from running (which would shut down the channel)
3691        std::mem::forget(self);
3692    }
3693}
3694
3695impl LutexControllerWaitBitsetResponder {
3696    /// Sends a response to the FIDL transaction.
3697    ///
3698    /// Sets the channel to shutdown if an error occurs.
3699    pub fn send(
3700        self,
3701        mut result: Result<(), fidl_fuchsia_posix::Errno>,
3702    ) -> Result<(), fidl::Error> {
3703        let _result = self.send_raw(result);
3704        if _result.is_err() {
3705            self.control_handle.shutdown();
3706        }
3707        self.drop_without_shutdown();
3708        _result
3709    }
3710
3711    /// Similar to "send" but does not shutdown the channel if an error occurs.
3712    pub fn send_no_shutdown_on_err(
3713        self,
3714        mut result: Result<(), fidl_fuchsia_posix::Errno>,
3715    ) -> Result<(), fidl::Error> {
3716        let _result = self.send_raw(result);
3717        self.drop_without_shutdown();
3718        _result
3719    }
3720
3721    fn send_raw(
3722        &self,
3723        mut result: Result<(), fidl_fuchsia_posix::Errno>,
3724    ) -> Result<(), fidl::Error> {
3725        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3726            fidl::encoding::EmptyStruct,
3727            fidl_fuchsia_posix::Errno,
3728        >>(
3729            fidl::encoding::FlexibleResult::new(result),
3730            self.tx_id,
3731            0x489feee6787d11b1,
3732            fidl::encoding::DynamicFlags::FLEXIBLE,
3733        )
3734    }
3735}
3736
3737#[must_use = "FIDL methods require a response to be sent"]
3738#[derive(Debug)]
3739pub struct LutexControllerWakeBitsetResponder {
3740    control_handle: std::mem::ManuallyDrop<LutexControllerControlHandle>,
3741    tx_id: u32,
3742}
3743
3744/// Set the the channel to be shutdown (see [`LutexControllerControlHandle::shutdown`])
3745/// if the responder is dropped without sending a response, so that the client
3746/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3747impl std::ops::Drop for LutexControllerWakeBitsetResponder {
3748    fn drop(&mut self) {
3749        self.control_handle.shutdown();
3750        // Safety: drops once, never accessed again
3751        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3752    }
3753}
3754
3755impl fidl::endpoints::Responder for LutexControllerWakeBitsetResponder {
3756    type ControlHandle = LutexControllerControlHandle;
3757
3758    fn control_handle(&self) -> &LutexControllerControlHandle {
3759        &self.control_handle
3760    }
3761
3762    fn drop_without_shutdown(mut self) {
3763        // Safety: drops once, never accessed again due to mem::forget
3764        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3765        // Prevent Drop from running (which would shut down the channel)
3766        std::mem::forget(self);
3767    }
3768}
3769
3770impl LutexControllerWakeBitsetResponder {
3771    /// Sends a response to the FIDL transaction.
3772    ///
3773    /// Sets the channel to shutdown if an error occurs.
3774    pub fn send(
3775        self,
3776        mut result: Result<WakeResponse, fidl_fuchsia_posix::Errno>,
3777    ) -> Result<(), fidl::Error> {
3778        let _result = self.send_raw(result);
3779        if _result.is_err() {
3780            self.control_handle.shutdown();
3781        }
3782        self.drop_without_shutdown();
3783        _result
3784    }
3785
3786    /// Similar to "send" but does not shutdown the channel if an error occurs.
3787    pub fn send_no_shutdown_on_err(
3788        self,
3789        mut result: Result<WakeResponse, fidl_fuchsia_posix::Errno>,
3790    ) -> Result<(), fidl::Error> {
3791        let _result = self.send_raw(result);
3792        self.drop_without_shutdown();
3793        _result
3794    }
3795
3796    fn send_raw(
3797        &self,
3798        mut result: Result<WakeResponse, fidl_fuchsia_posix::Errno>,
3799    ) -> Result<(), fidl::Error> {
3800        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3801            WakeResponse,
3802            fidl_fuchsia_posix::Errno,
3803        >>(
3804            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
3805            self.tx_id,
3806            0x58309f6ebcb0d8eb,
3807            fidl::encoding::DynamicFlags::FLEXIBLE,
3808        )
3809    }
3810}
3811
3812#[must_use = "FIDL methods require a response to be sent"]
3813#[derive(Debug)]
3814pub struct LutexControllerCmpRequeueResponder {
3815    control_handle: std::mem::ManuallyDrop<LutexControllerControlHandle>,
3816    tx_id: u32,
3817}
3818
3819/// Set the the channel to be shutdown (see [`LutexControllerControlHandle::shutdown`])
3820/// if the responder is dropped without sending a response, so that the client
3821/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3822impl std::ops::Drop for LutexControllerCmpRequeueResponder {
3823    fn drop(&mut self) {
3824        self.control_handle.shutdown();
3825        // Safety: drops once, never accessed again
3826        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3827    }
3828}
3829
3830impl fidl::endpoints::Responder for LutexControllerCmpRequeueResponder {
3831    type ControlHandle = LutexControllerControlHandle;
3832
3833    fn control_handle(&self) -> &LutexControllerControlHandle {
3834        &self.control_handle
3835    }
3836
3837    fn drop_without_shutdown(mut self) {
3838        // Safety: drops once, never accessed again due to mem::forget
3839        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3840        // Prevent Drop from running (which would shut down the channel)
3841        std::mem::forget(self);
3842    }
3843}
3844
3845impl LutexControllerCmpRequeueResponder {
3846    /// Sends a response to the FIDL transaction.
3847    ///
3848    /// Sets the channel to shutdown if an error occurs.
3849    pub fn send(
3850        self,
3851        mut result: Result<CmpRequeueResponse, fidl_fuchsia_posix::Errno>,
3852    ) -> Result<(), fidl::Error> {
3853        let _result = self.send_raw(result);
3854        if _result.is_err() {
3855            self.control_handle.shutdown();
3856        }
3857        self.drop_without_shutdown();
3858        _result
3859    }
3860
3861    /// Similar to "send" but does not shutdown the channel if an error occurs.
3862    pub fn send_no_shutdown_on_err(
3863        self,
3864        mut result: Result<CmpRequeueResponse, fidl_fuchsia_posix::Errno>,
3865    ) -> Result<(), fidl::Error> {
3866        let _result = self.send_raw(result);
3867        self.drop_without_shutdown();
3868        _result
3869    }
3870
3871    fn send_raw(
3872        &self,
3873        mut result: Result<CmpRequeueResponse, fidl_fuchsia_posix::Errno>,
3874    ) -> Result<(), fidl::Error> {
3875        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3876            CmpRequeueResponse,
3877            fidl_fuchsia_posix::Errno,
3878        >>(
3879            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
3880            self.tx_id,
3881            0x38e55a7315bef4b5,
3882            fidl::encoding::DynamicFlags::FLEXIBLE,
3883        )
3884    }
3885}
3886
3887#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3888pub struct ProcessAccessorMarker;
3889
3890impl fidl::endpoints::ProtocolMarker for ProcessAccessorMarker {
3891    type Proxy = ProcessAccessorProxy;
3892    type RequestStream = ProcessAccessorRequestStream;
3893    #[cfg(target_os = "fuchsia")]
3894    type SynchronousProxy = ProcessAccessorSynchronousProxy;
3895
3896    const DEBUG_NAME: &'static str = "(anonymous) ProcessAccessor";
3897}
3898pub type ProcessAccessorWriteMemoryResult = Result<(), fidl_fuchsia_posix::Errno>;
3899pub type ProcessAccessorWriteBytesResult = Result<(), fidl_fuchsia_posix::Errno>;
3900pub type ProcessAccessorFileRequestResult = Result<FileResponse, fidl_fuchsia_posix::Errno>;
3901
3902pub trait ProcessAccessorProxyInterface: Send + Sync {
3903    type WriteMemoryResponseFut: std::future::Future<Output = Result<ProcessAccessorWriteMemoryResult, fidl::Error>>
3904        + Send;
3905    fn r#write_memory(&self, address: u64, content: fidl::Vmo) -> Self::WriteMemoryResponseFut;
3906    type WriteBytesResponseFut: std::future::Future<Output = Result<ProcessAccessorWriteBytesResult, fidl::Error>>
3907        + Send;
3908    fn r#write_bytes(&self, address: u64, bytes: &[u8]) -> Self::WriteBytesResponseFut;
3909    type FileRequestResponseFut: std::future::Future<Output = Result<ProcessAccessorFileRequestResult, fidl::Error>>
3910        + Send;
3911    fn r#file_request(&self, payload: FileRequest) -> Self::FileRequestResponseFut;
3912}
3913#[derive(Debug)]
3914#[cfg(target_os = "fuchsia")]
3915pub struct ProcessAccessorSynchronousProxy {
3916    client: fidl::client::sync::Client,
3917}
3918
3919#[cfg(target_os = "fuchsia")]
3920impl fidl::endpoints::SynchronousProxy for ProcessAccessorSynchronousProxy {
3921    type Proxy = ProcessAccessorProxy;
3922    type Protocol = ProcessAccessorMarker;
3923
3924    fn from_channel(inner: fidl::Channel) -> Self {
3925        Self::new(inner)
3926    }
3927
3928    fn into_channel(self) -> fidl::Channel {
3929        self.client.into_channel()
3930    }
3931
3932    fn as_channel(&self) -> &fidl::Channel {
3933        self.client.as_channel()
3934    }
3935}
3936
3937#[cfg(target_os = "fuchsia")]
3938impl ProcessAccessorSynchronousProxy {
3939    pub fn new(channel: fidl::Channel) -> Self {
3940        Self { client: fidl::client::sync::Client::new(channel) }
3941    }
3942
3943    pub fn into_channel(self) -> fidl::Channel {
3944        self.client.into_channel()
3945    }
3946
3947    /// Waits until an event arrives and returns it. It is safe for other
3948    /// threads to make concurrent requests while waiting for an event.
3949    pub fn wait_for_event(
3950        &self,
3951        deadline: zx::MonotonicInstant,
3952    ) -> Result<ProcessAccessorEvent, fidl::Error> {
3953        ProcessAccessorEvent::decode(self.client.wait_for_event::<ProcessAccessorMarker>(deadline)?)
3954    }
3955
3956    /// Writes the contents of `content` to `address` in the process memory,
3957    /// using the vmo content size to determine the number of bytes to write.
3958    pub fn r#write_memory(
3959        &self,
3960        mut address: u64,
3961        mut content: fidl::Vmo,
3962        ___deadline: zx::MonotonicInstant,
3963    ) -> Result<ProcessAccessorWriteMemoryResult, fidl::Error> {
3964        let _response = self
3965            .client
3966            .send_query::<ProcessAccessorWriteMemoryRequest, fidl::encoding::FlexibleResultType<
3967                fidl::encoding::EmptyStruct,
3968                fidl_fuchsia_posix::Errno,
3969            >, ProcessAccessorMarker>(
3970                (address, content),
3971                0x666cda7c6b6d4819,
3972                fidl::encoding::DynamicFlags::FLEXIBLE,
3973                ___deadline,
3974            )?
3975            .into_result::<ProcessAccessorMarker>("write_memory")?;
3976        Ok(_response.map(|x| x))
3977    }
3978
3979    /// Writes the contents of `bytes` to `address` in the process memory.
3980    /// `WriteBytes` is functionally equivalent to `WriteMemory`, but is
3981    /// optimized for small writes of less than `MAX_WRITE_BYTES`.
3982    pub fn r#write_bytes(
3983        &self,
3984        mut address: u64,
3985        mut bytes: &[u8],
3986        ___deadline: zx::MonotonicInstant,
3987    ) -> Result<ProcessAccessorWriteBytesResult, fidl::Error> {
3988        let _response = self
3989            .client
3990            .send_query::<ProcessAccessorWriteBytesRequest, fidl::encoding::FlexibleResultType<
3991                fidl::encoding::EmptyStruct,
3992                fidl_fuchsia_posix::Errno,
3993            >, ProcessAccessorMarker>(
3994                (address, bytes),
3995                0x6f94296329cb8d17,
3996                fidl::encoding::DynamicFlags::FLEXIBLE,
3997                ___deadline,
3998            )?
3999            .into_result::<ProcessAccessorMarker>("write_bytes")?;
4000        Ok(_response.map(|x| x))
4001    }
4002
4003    /// Execute the given `request` and returns the associated `response`. Any
4004    /// failure will interrupt further processing and fail this operation and
4005    /// the associated errno will be then returned.
4006    /// The implementator of this protocol should handle these requests as best
4007    /// it can so that a failure doesn't have visible side-effects.
4008    pub fn r#file_request(
4009        &self,
4010        mut payload: FileRequest,
4011        ___deadline: zx::MonotonicInstant,
4012    ) -> Result<ProcessAccessorFileRequestResult, fidl::Error> {
4013        let _response = self.client.send_query::<
4014            FileRequest,
4015            fidl::encoding::FlexibleResultType<FileResponse, fidl_fuchsia_posix::Errno>,
4016            ProcessAccessorMarker,
4017        >(
4018            &mut payload,
4019            0xd42103a37c3f0a,
4020            fidl::encoding::DynamicFlags::FLEXIBLE,
4021            ___deadline,
4022        )?
4023        .into_result::<ProcessAccessorMarker>("file_request")?;
4024        Ok(_response.map(|x| x))
4025    }
4026}
4027
4028#[cfg(target_os = "fuchsia")]
4029impl From<ProcessAccessorSynchronousProxy> for zx::NullableHandle {
4030    fn from(value: ProcessAccessorSynchronousProxy) -> Self {
4031        value.into_channel().into()
4032    }
4033}
4034
4035#[cfg(target_os = "fuchsia")]
4036impl From<fidl::Channel> for ProcessAccessorSynchronousProxy {
4037    fn from(value: fidl::Channel) -> Self {
4038        Self::new(value)
4039    }
4040}
4041
4042#[cfg(target_os = "fuchsia")]
4043impl fidl::endpoints::FromClient for ProcessAccessorSynchronousProxy {
4044    type Protocol = ProcessAccessorMarker;
4045
4046    fn from_client(value: fidl::endpoints::ClientEnd<ProcessAccessorMarker>) -> Self {
4047        Self::new(value.into_channel())
4048    }
4049}
4050
4051#[derive(Debug, Clone)]
4052pub struct ProcessAccessorProxy {
4053    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4054}
4055
4056impl fidl::endpoints::Proxy for ProcessAccessorProxy {
4057    type Protocol = ProcessAccessorMarker;
4058
4059    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4060        Self::new(inner)
4061    }
4062
4063    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4064        self.client.into_channel().map_err(|client| Self { client })
4065    }
4066
4067    fn as_channel(&self) -> &::fidl::AsyncChannel {
4068        self.client.as_channel()
4069    }
4070}
4071
4072impl ProcessAccessorProxy {
4073    /// Create a new Proxy for fuchsia.starnix.binder/ProcessAccessor.
4074    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4075        let protocol_name = <ProcessAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4076        Self { client: fidl::client::Client::new(channel, protocol_name) }
4077    }
4078
4079    /// Get a Stream of events from the remote end of the protocol.
4080    ///
4081    /// # Panics
4082    ///
4083    /// Panics if the event stream was already taken.
4084    pub fn take_event_stream(&self) -> ProcessAccessorEventStream {
4085        ProcessAccessorEventStream { event_receiver: self.client.take_event_receiver() }
4086    }
4087
4088    /// Writes the contents of `content` to `address` in the process memory,
4089    /// using the vmo content size to determine the number of bytes to write.
4090    pub fn r#write_memory(
4091        &self,
4092        mut address: u64,
4093        mut content: fidl::Vmo,
4094    ) -> fidl::client::QueryResponseFut<
4095        ProcessAccessorWriteMemoryResult,
4096        fidl::encoding::DefaultFuchsiaResourceDialect,
4097    > {
4098        ProcessAccessorProxyInterface::r#write_memory(self, address, content)
4099    }
4100
4101    /// Writes the contents of `bytes` to `address` in the process memory.
4102    /// `WriteBytes` is functionally equivalent to `WriteMemory`, but is
4103    /// optimized for small writes of less than `MAX_WRITE_BYTES`.
4104    pub fn r#write_bytes(
4105        &self,
4106        mut address: u64,
4107        mut bytes: &[u8],
4108    ) -> fidl::client::QueryResponseFut<
4109        ProcessAccessorWriteBytesResult,
4110        fidl::encoding::DefaultFuchsiaResourceDialect,
4111    > {
4112        ProcessAccessorProxyInterface::r#write_bytes(self, address, bytes)
4113    }
4114
4115    /// Execute the given `request` and returns the associated `response`. Any
4116    /// failure will interrupt further processing and fail this operation and
4117    /// the associated errno will be then returned.
4118    /// The implementator of this protocol should handle these requests as best
4119    /// it can so that a failure doesn't have visible side-effects.
4120    pub fn r#file_request(
4121        &self,
4122        mut payload: FileRequest,
4123    ) -> fidl::client::QueryResponseFut<
4124        ProcessAccessorFileRequestResult,
4125        fidl::encoding::DefaultFuchsiaResourceDialect,
4126    > {
4127        ProcessAccessorProxyInterface::r#file_request(self, payload)
4128    }
4129}
4130
4131impl ProcessAccessorProxyInterface for ProcessAccessorProxy {
4132    type WriteMemoryResponseFut = fidl::client::QueryResponseFut<
4133        ProcessAccessorWriteMemoryResult,
4134        fidl::encoding::DefaultFuchsiaResourceDialect,
4135    >;
4136    fn r#write_memory(
4137        &self,
4138        mut address: u64,
4139        mut content: fidl::Vmo,
4140    ) -> Self::WriteMemoryResponseFut {
4141        fn _decode(
4142            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4143        ) -> Result<ProcessAccessorWriteMemoryResult, fidl::Error> {
4144            let _response = fidl::client::decode_transaction_body::<
4145                fidl::encoding::FlexibleResultType<
4146                    fidl::encoding::EmptyStruct,
4147                    fidl_fuchsia_posix::Errno,
4148                >,
4149                fidl::encoding::DefaultFuchsiaResourceDialect,
4150                0x666cda7c6b6d4819,
4151            >(_buf?)?
4152            .into_result::<ProcessAccessorMarker>("write_memory")?;
4153            Ok(_response.map(|x| x))
4154        }
4155        self.client.send_query_and_decode::<
4156            ProcessAccessorWriteMemoryRequest,
4157            ProcessAccessorWriteMemoryResult,
4158        >(
4159            (address, content,),
4160            0x666cda7c6b6d4819,
4161            fidl::encoding::DynamicFlags::FLEXIBLE,
4162            _decode,
4163        )
4164    }
4165
4166    type WriteBytesResponseFut = fidl::client::QueryResponseFut<
4167        ProcessAccessorWriteBytesResult,
4168        fidl::encoding::DefaultFuchsiaResourceDialect,
4169    >;
4170    fn r#write_bytes(&self, mut address: u64, mut bytes: &[u8]) -> Self::WriteBytesResponseFut {
4171        fn _decode(
4172            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4173        ) -> Result<ProcessAccessorWriteBytesResult, fidl::Error> {
4174            let _response = fidl::client::decode_transaction_body::<
4175                fidl::encoding::FlexibleResultType<
4176                    fidl::encoding::EmptyStruct,
4177                    fidl_fuchsia_posix::Errno,
4178                >,
4179                fidl::encoding::DefaultFuchsiaResourceDialect,
4180                0x6f94296329cb8d17,
4181            >(_buf?)?
4182            .into_result::<ProcessAccessorMarker>("write_bytes")?;
4183            Ok(_response.map(|x| x))
4184        }
4185        self.client.send_query_and_decode::<
4186            ProcessAccessorWriteBytesRequest,
4187            ProcessAccessorWriteBytesResult,
4188        >(
4189            (address, bytes,),
4190            0x6f94296329cb8d17,
4191            fidl::encoding::DynamicFlags::FLEXIBLE,
4192            _decode,
4193        )
4194    }
4195
4196    type FileRequestResponseFut = fidl::client::QueryResponseFut<
4197        ProcessAccessorFileRequestResult,
4198        fidl::encoding::DefaultFuchsiaResourceDialect,
4199    >;
4200    fn r#file_request(&self, mut payload: FileRequest) -> Self::FileRequestResponseFut {
4201        fn _decode(
4202            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
4203        ) -> Result<ProcessAccessorFileRequestResult, fidl::Error> {
4204            let _response = fidl::client::decode_transaction_body::<
4205                fidl::encoding::FlexibleResultType<FileResponse, fidl_fuchsia_posix::Errno>,
4206                fidl::encoding::DefaultFuchsiaResourceDialect,
4207                0xd42103a37c3f0a,
4208            >(_buf?)?
4209            .into_result::<ProcessAccessorMarker>("file_request")?;
4210            Ok(_response.map(|x| x))
4211        }
4212        self.client.send_query_and_decode::<FileRequest, ProcessAccessorFileRequestResult>(
4213            &mut payload,
4214            0xd42103a37c3f0a,
4215            fidl::encoding::DynamicFlags::FLEXIBLE,
4216            _decode,
4217        )
4218    }
4219}
4220
4221pub struct ProcessAccessorEventStream {
4222    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4223}
4224
4225impl std::marker::Unpin for ProcessAccessorEventStream {}
4226
4227impl futures::stream::FusedStream for ProcessAccessorEventStream {
4228    fn is_terminated(&self) -> bool {
4229        self.event_receiver.is_terminated()
4230    }
4231}
4232
4233impl futures::Stream for ProcessAccessorEventStream {
4234    type Item = Result<ProcessAccessorEvent, fidl::Error>;
4235
4236    fn poll_next(
4237        mut self: std::pin::Pin<&mut Self>,
4238        cx: &mut std::task::Context<'_>,
4239    ) -> std::task::Poll<Option<Self::Item>> {
4240        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4241            &mut self.event_receiver,
4242            cx
4243        )?) {
4244            Some(buf) => std::task::Poll::Ready(Some(ProcessAccessorEvent::decode(buf))),
4245            None => std::task::Poll::Ready(None),
4246        }
4247    }
4248}
4249
4250#[derive(Debug)]
4251pub enum ProcessAccessorEvent {
4252    #[non_exhaustive]
4253    _UnknownEvent {
4254        /// Ordinal of the event that was sent.
4255        ordinal: u64,
4256    },
4257}
4258
4259impl ProcessAccessorEvent {
4260    /// Decodes a message buffer as a [`ProcessAccessorEvent`].
4261    fn decode(
4262        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4263    ) -> Result<ProcessAccessorEvent, fidl::Error> {
4264        let (bytes, _handles) = buf.split_mut();
4265        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4266        debug_assert_eq!(tx_header.tx_id, 0);
4267        match tx_header.ordinal {
4268            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4269                Ok(ProcessAccessorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4270            }
4271            _ => Err(fidl::Error::UnknownOrdinal {
4272                ordinal: tx_header.ordinal,
4273                protocol_name:
4274                    <ProcessAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4275            }),
4276        }
4277    }
4278}
4279
4280/// A Stream of incoming requests for fuchsia.starnix.binder/ProcessAccessor.
4281pub struct ProcessAccessorRequestStream {
4282    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4283    is_terminated: bool,
4284}
4285
4286impl std::marker::Unpin for ProcessAccessorRequestStream {}
4287
4288impl futures::stream::FusedStream for ProcessAccessorRequestStream {
4289    fn is_terminated(&self) -> bool {
4290        self.is_terminated
4291    }
4292}
4293
4294impl fidl::endpoints::RequestStream for ProcessAccessorRequestStream {
4295    type Protocol = ProcessAccessorMarker;
4296    type ControlHandle = ProcessAccessorControlHandle;
4297
4298    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
4299        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
4300    }
4301
4302    fn control_handle(&self) -> Self::ControlHandle {
4303        ProcessAccessorControlHandle { inner: self.inner.clone() }
4304    }
4305
4306    fn into_inner(
4307        self,
4308    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
4309    {
4310        (self.inner, self.is_terminated)
4311    }
4312
4313    fn from_inner(
4314        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4315        is_terminated: bool,
4316    ) -> Self {
4317        Self { inner, is_terminated }
4318    }
4319}
4320
4321impl futures::Stream for ProcessAccessorRequestStream {
4322    type Item = Result<ProcessAccessorRequest, fidl::Error>;
4323
4324    fn poll_next(
4325        mut self: std::pin::Pin<&mut Self>,
4326        cx: &mut std::task::Context<'_>,
4327    ) -> std::task::Poll<Option<Self::Item>> {
4328        let this = &mut *self;
4329        if this.inner.check_shutdown(cx) {
4330            this.is_terminated = true;
4331            return std::task::Poll::Ready(None);
4332        }
4333        if this.is_terminated {
4334            panic!("polled ProcessAccessorRequestStream after completion");
4335        }
4336        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
4337            |bytes, handles| {
4338                match this.inner.channel().read_etc(cx, bytes, handles) {
4339                    std::task::Poll::Ready(Ok(())) => {}
4340                    std::task::Poll::Pending => return std::task::Poll::Pending,
4341                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
4342                        this.is_terminated = true;
4343                        return std::task::Poll::Ready(None);
4344                    }
4345                    std::task::Poll::Ready(Err(e)) => {
4346                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
4347                            e.into(),
4348                        ))));
4349                    }
4350                }
4351
4352                // A message has been received from the channel
4353                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4354
4355                std::task::Poll::Ready(Some(match header.ordinal {
4356                    0x666cda7c6b6d4819 => {
4357                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4358                        let mut req = fidl::new_empty!(
4359                            ProcessAccessorWriteMemoryRequest,
4360                            fidl::encoding::DefaultFuchsiaResourceDialect
4361                        );
4362                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProcessAccessorWriteMemoryRequest>(&header, _body_bytes, handles, &mut req)?;
4363                        let control_handle =
4364                            ProcessAccessorControlHandle { inner: this.inner.clone() };
4365                        Ok(ProcessAccessorRequest::WriteMemory {
4366                            address: req.address,
4367                            content: req.content,
4368
4369                            responder: ProcessAccessorWriteMemoryResponder {
4370                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4371                                tx_id: header.tx_id,
4372                            },
4373                        })
4374                    }
4375                    0x6f94296329cb8d17 => {
4376                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4377                        let mut req = fidl::new_empty!(
4378                            ProcessAccessorWriteBytesRequest,
4379                            fidl::encoding::DefaultFuchsiaResourceDialect
4380                        );
4381                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ProcessAccessorWriteBytesRequest>(&header, _body_bytes, handles, &mut req)?;
4382                        let control_handle =
4383                            ProcessAccessorControlHandle { inner: this.inner.clone() };
4384                        Ok(ProcessAccessorRequest::WriteBytes {
4385                            address: req.address,
4386                            bytes: req.bytes,
4387
4388                            responder: ProcessAccessorWriteBytesResponder {
4389                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4390                                tx_id: header.tx_id,
4391                            },
4392                        })
4393                    }
4394                    0xd42103a37c3f0a => {
4395                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4396                        let mut req = fidl::new_empty!(
4397                            FileRequest,
4398                            fidl::encoding::DefaultFuchsiaResourceDialect
4399                        );
4400                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FileRequest>(&header, _body_bytes, handles, &mut req)?;
4401                        let control_handle =
4402                            ProcessAccessorControlHandle { inner: this.inner.clone() };
4403                        Ok(ProcessAccessorRequest::FileRequest {
4404                            payload: req,
4405                            responder: ProcessAccessorFileRequestResponder {
4406                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4407                                tx_id: header.tx_id,
4408                            },
4409                        })
4410                    }
4411                    _ if header.tx_id == 0
4412                        && header
4413                            .dynamic_flags()
4414                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4415                    {
4416                        Ok(ProcessAccessorRequest::_UnknownMethod {
4417                            ordinal: header.ordinal,
4418                            control_handle: ProcessAccessorControlHandle {
4419                                inner: this.inner.clone(),
4420                            },
4421                            method_type: fidl::MethodType::OneWay,
4422                        })
4423                    }
4424                    _ if header
4425                        .dynamic_flags()
4426                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4427                    {
4428                        this.inner.send_framework_err(
4429                            fidl::encoding::FrameworkErr::UnknownMethod,
4430                            header.tx_id,
4431                            header.ordinal,
4432                            header.dynamic_flags(),
4433                            (bytes, handles),
4434                        )?;
4435                        Ok(ProcessAccessorRequest::_UnknownMethod {
4436                            ordinal: header.ordinal,
4437                            control_handle: ProcessAccessorControlHandle {
4438                                inner: this.inner.clone(),
4439                            },
4440                            method_type: fidl::MethodType::TwoWay,
4441                        })
4442                    }
4443                    _ => Err(fidl::Error::UnknownOrdinal {
4444                        ordinal: header.ordinal,
4445                        protocol_name:
4446                            <ProcessAccessorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4447                    }),
4448                }))
4449            },
4450        )
4451    }
4452}
4453
4454/// Protocol that gives the binder driver access to the client process'
4455/// resources.
4456#[derive(Debug)]
4457pub enum ProcessAccessorRequest {
4458    /// Writes the contents of `content` to `address` in the process memory,
4459    /// using the vmo content size to determine the number of bytes to write.
4460    WriteMemory { address: u64, content: fidl::Vmo, responder: ProcessAccessorWriteMemoryResponder },
4461    /// Writes the contents of `bytes` to `address` in the process memory.
4462    /// `WriteBytes` is functionally equivalent to `WriteMemory`, but is
4463    /// optimized for small writes of less than `MAX_WRITE_BYTES`.
4464    WriteBytes { address: u64, bytes: Vec<u8>, responder: ProcessAccessorWriteBytesResponder },
4465    /// Execute the given `request` and returns the associated `response`. Any
4466    /// failure will interrupt further processing and fail this operation and
4467    /// the associated errno will be then returned.
4468    /// The implementator of this protocol should handle these requests as best
4469    /// it can so that a failure doesn't have visible side-effects.
4470    FileRequest { payload: FileRequest, responder: ProcessAccessorFileRequestResponder },
4471    /// An interaction was received which does not match any known method.
4472    #[non_exhaustive]
4473    _UnknownMethod {
4474        /// Ordinal of the method that was called.
4475        ordinal: u64,
4476        control_handle: ProcessAccessorControlHandle,
4477        method_type: fidl::MethodType,
4478    },
4479}
4480
4481impl ProcessAccessorRequest {
4482    #[allow(irrefutable_let_patterns)]
4483    pub fn into_write_memory(
4484        self,
4485    ) -> Option<(u64, fidl::Vmo, ProcessAccessorWriteMemoryResponder)> {
4486        if let ProcessAccessorRequest::WriteMemory { address, content, responder } = self {
4487            Some((address, content, responder))
4488        } else {
4489            None
4490        }
4491    }
4492
4493    #[allow(irrefutable_let_patterns)]
4494    pub fn into_write_bytes(self) -> Option<(u64, Vec<u8>, ProcessAccessorWriteBytesResponder)> {
4495        if let ProcessAccessorRequest::WriteBytes { address, bytes, responder } = self {
4496            Some((address, bytes, responder))
4497        } else {
4498            None
4499        }
4500    }
4501
4502    #[allow(irrefutable_let_patterns)]
4503    pub fn into_file_request(self) -> Option<(FileRequest, ProcessAccessorFileRequestResponder)> {
4504        if let ProcessAccessorRequest::FileRequest { payload, responder } = self {
4505            Some((payload, responder))
4506        } else {
4507            None
4508        }
4509    }
4510
4511    /// Name of the method defined in FIDL
4512    pub fn method_name(&self) -> &'static str {
4513        match *self {
4514            ProcessAccessorRequest::WriteMemory { .. } => "write_memory",
4515            ProcessAccessorRequest::WriteBytes { .. } => "write_bytes",
4516            ProcessAccessorRequest::FileRequest { .. } => "file_request",
4517            ProcessAccessorRequest::_UnknownMethod {
4518                method_type: fidl::MethodType::OneWay,
4519                ..
4520            } => "unknown one-way method",
4521            ProcessAccessorRequest::_UnknownMethod {
4522                method_type: fidl::MethodType::TwoWay,
4523                ..
4524            } => "unknown two-way method",
4525        }
4526    }
4527}
4528
4529#[derive(Debug, Clone)]
4530pub struct ProcessAccessorControlHandle {
4531    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4532}
4533
4534impl ProcessAccessorControlHandle {
4535    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
4536        self.inner.shutdown_with_epitaph(status.into())
4537    }
4538}
4539
4540impl fidl::endpoints::ControlHandle for ProcessAccessorControlHandle {
4541    fn shutdown(&self) {
4542        self.inner.shutdown()
4543    }
4544
4545    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
4546        self.inner.shutdown_with_epitaph(status)
4547    }
4548
4549    fn is_closed(&self) -> bool {
4550        self.inner.channel().is_closed()
4551    }
4552    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4553        self.inner.channel().on_closed()
4554    }
4555
4556    #[cfg(target_os = "fuchsia")]
4557    fn signal_peer(
4558        &self,
4559        clear_mask: zx::Signals,
4560        set_mask: zx::Signals,
4561    ) -> Result<(), zx_status::Status> {
4562        use fidl::Peered;
4563        self.inner.channel().signal_peer(clear_mask, set_mask)
4564    }
4565}
4566
4567impl ProcessAccessorControlHandle {}
4568
4569#[must_use = "FIDL methods require a response to be sent"]
4570#[derive(Debug)]
4571pub struct ProcessAccessorWriteMemoryResponder {
4572    control_handle: std::mem::ManuallyDrop<ProcessAccessorControlHandle>,
4573    tx_id: u32,
4574}
4575
4576/// Set the the channel to be shutdown (see [`ProcessAccessorControlHandle::shutdown`])
4577/// if the responder is dropped without sending a response, so that the client
4578/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4579impl std::ops::Drop for ProcessAccessorWriteMemoryResponder {
4580    fn drop(&mut self) {
4581        self.control_handle.shutdown();
4582        // Safety: drops once, never accessed again
4583        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4584    }
4585}
4586
4587impl fidl::endpoints::Responder for ProcessAccessorWriteMemoryResponder {
4588    type ControlHandle = ProcessAccessorControlHandle;
4589
4590    fn control_handle(&self) -> &ProcessAccessorControlHandle {
4591        &self.control_handle
4592    }
4593
4594    fn drop_without_shutdown(mut self) {
4595        // Safety: drops once, never accessed again due to mem::forget
4596        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4597        // Prevent Drop from running (which would shut down the channel)
4598        std::mem::forget(self);
4599    }
4600}
4601
4602impl ProcessAccessorWriteMemoryResponder {
4603    /// Sends a response to the FIDL transaction.
4604    ///
4605    /// Sets the channel to shutdown if an error occurs.
4606    pub fn send(
4607        self,
4608        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4609    ) -> Result<(), fidl::Error> {
4610        let _result = self.send_raw(result);
4611        if _result.is_err() {
4612            self.control_handle.shutdown();
4613        }
4614        self.drop_without_shutdown();
4615        _result
4616    }
4617
4618    /// Similar to "send" but does not shutdown the channel if an error occurs.
4619    pub fn send_no_shutdown_on_err(
4620        self,
4621        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4622    ) -> Result<(), fidl::Error> {
4623        let _result = self.send_raw(result);
4624        self.drop_without_shutdown();
4625        _result
4626    }
4627
4628    fn send_raw(
4629        &self,
4630        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4631    ) -> Result<(), fidl::Error> {
4632        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4633            fidl::encoding::EmptyStruct,
4634            fidl_fuchsia_posix::Errno,
4635        >>(
4636            fidl::encoding::FlexibleResult::new(result),
4637            self.tx_id,
4638            0x666cda7c6b6d4819,
4639            fidl::encoding::DynamicFlags::FLEXIBLE,
4640        )
4641    }
4642}
4643
4644#[must_use = "FIDL methods require a response to be sent"]
4645#[derive(Debug)]
4646pub struct ProcessAccessorWriteBytesResponder {
4647    control_handle: std::mem::ManuallyDrop<ProcessAccessorControlHandle>,
4648    tx_id: u32,
4649}
4650
4651/// Set the the channel to be shutdown (see [`ProcessAccessorControlHandle::shutdown`])
4652/// if the responder is dropped without sending a response, so that the client
4653/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4654impl std::ops::Drop for ProcessAccessorWriteBytesResponder {
4655    fn drop(&mut self) {
4656        self.control_handle.shutdown();
4657        // Safety: drops once, never accessed again
4658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4659    }
4660}
4661
4662impl fidl::endpoints::Responder for ProcessAccessorWriteBytesResponder {
4663    type ControlHandle = ProcessAccessorControlHandle;
4664
4665    fn control_handle(&self) -> &ProcessAccessorControlHandle {
4666        &self.control_handle
4667    }
4668
4669    fn drop_without_shutdown(mut self) {
4670        // Safety: drops once, never accessed again due to mem::forget
4671        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4672        // Prevent Drop from running (which would shut down the channel)
4673        std::mem::forget(self);
4674    }
4675}
4676
4677impl ProcessAccessorWriteBytesResponder {
4678    /// Sends a response to the FIDL transaction.
4679    ///
4680    /// Sets the channel to shutdown if an error occurs.
4681    pub fn send(
4682        self,
4683        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4684    ) -> Result<(), fidl::Error> {
4685        let _result = self.send_raw(result);
4686        if _result.is_err() {
4687            self.control_handle.shutdown();
4688        }
4689        self.drop_without_shutdown();
4690        _result
4691    }
4692
4693    /// Similar to "send" but does not shutdown the channel if an error occurs.
4694    pub fn send_no_shutdown_on_err(
4695        self,
4696        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4697    ) -> Result<(), fidl::Error> {
4698        let _result = self.send_raw(result);
4699        self.drop_without_shutdown();
4700        _result
4701    }
4702
4703    fn send_raw(
4704        &self,
4705        mut result: Result<(), fidl_fuchsia_posix::Errno>,
4706    ) -> Result<(), fidl::Error> {
4707        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4708            fidl::encoding::EmptyStruct,
4709            fidl_fuchsia_posix::Errno,
4710        >>(
4711            fidl::encoding::FlexibleResult::new(result),
4712            self.tx_id,
4713            0x6f94296329cb8d17,
4714            fidl::encoding::DynamicFlags::FLEXIBLE,
4715        )
4716    }
4717}
4718
4719#[must_use = "FIDL methods require a response to be sent"]
4720#[derive(Debug)]
4721pub struct ProcessAccessorFileRequestResponder {
4722    control_handle: std::mem::ManuallyDrop<ProcessAccessorControlHandle>,
4723    tx_id: u32,
4724}
4725
4726/// Set the the channel to be shutdown (see [`ProcessAccessorControlHandle::shutdown`])
4727/// if the responder is dropped without sending a response, so that the client
4728/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4729impl std::ops::Drop for ProcessAccessorFileRequestResponder {
4730    fn drop(&mut self) {
4731        self.control_handle.shutdown();
4732        // Safety: drops once, never accessed again
4733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4734    }
4735}
4736
4737impl fidl::endpoints::Responder for ProcessAccessorFileRequestResponder {
4738    type ControlHandle = ProcessAccessorControlHandle;
4739
4740    fn control_handle(&self) -> &ProcessAccessorControlHandle {
4741        &self.control_handle
4742    }
4743
4744    fn drop_without_shutdown(mut self) {
4745        // Safety: drops once, never accessed again due to mem::forget
4746        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4747        // Prevent Drop from running (which would shut down the channel)
4748        std::mem::forget(self);
4749    }
4750}
4751
4752impl ProcessAccessorFileRequestResponder {
4753    /// Sends a response to the FIDL transaction.
4754    ///
4755    /// Sets the channel to shutdown if an error occurs.
4756    pub fn send(
4757        self,
4758        mut result: Result<FileResponse, fidl_fuchsia_posix::Errno>,
4759    ) -> Result<(), fidl::Error> {
4760        let _result = self.send_raw(result);
4761        if _result.is_err() {
4762            self.control_handle.shutdown();
4763        }
4764        self.drop_without_shutdown();
4765        _result
4766    }
4767
4768    /// Similar to "send" but does not shutdown the channel if an error occurs.
4769    pub fn send_no_shutdown_on_err(
4770        self,
4771        mut result: Result<FileResponse, fidl_fuchsia_posix::Errno>,
4772    ) -> Result<(), fidl::Error> {
4773        let _result = self.send_raw(result);
4774        self.drop_without_shutdown();
4775        _result
4776    }
4777
4778    fn send_raw(
4779        &self,
4780        mut result: Result<FileResponse, fidl_fuchsia_posix::Errno>,
4781    ) -> Result<(), fidl::Error> {
4782        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
4783            FileResponse,
4784            fidl_fuchsia_posix::Errno,
4785        >>(
4786            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
4787            self.tx_id,
4788            0xd42103a37c3f0a,
4789            fidl::encoding::DynamicFlags::FLEXIBLE,
4790        )
4791    }
4792}
4793
4794#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
4795pub struct RemoteControllerMarker;
4796
4797impl fidl::endpoints::ProtocolMarker for RemoteControllerMarker {
4798    type Proxy = RemoteControllerProxy;
4799    type RequestStream = RemoteControllerRequestStream;
4800    #[cfg(target_os = "fuchsia")]
4801    type SynchronousProxy = RemoteControllerSynchronousProxy;
4802
4803    const DEBUG_NAME: &'static str = "fuchsia.starnix.binder.RemoteController";
4804}
4805impl fidl::endpoints::DiscoverableProtocolMarker for RemoteControllerMarker {}
4806
4807pub trait RemoteControllerProxyInterface: Send + Sync {
4808    fn r#start(&self, payload: RemoteControllerStartRequest) -> Result<(), fidl::Error>;
4809}
4810#[derive(Debug)]
4811#[cfg(target_os = "fuchsia")]
4812pub struct RemoteControllerSynchronousProxy {
4813    client: fidl::client::sync::Client,
4814}
4815
4816#[cfg(target_os = "fuchsia")]
4817impl fidl::endpoints::SynchronousProxy for RemoteControllerSynchronousProxy {
4818    type Proxy = RemoteControllerProxy;
4819    type Protocol = RemoteControllerMarker;
4820
4821    fn from_channel(inner: fidl::Channel) -> Self {
4822        Self::new(inner)
4823    }
4824
4825    fn into_channel(self) -> fidl::Channel {
4826        self.client.into_channel()
4827    }
4828
4829    fn as_channel(&self) -> &fidl::Channel {
4830        self.client.as_channel()
4831    }
4832}
4833
4834#[cfg(target_os = "fuchsia")]
4835impl RemoteControllerSynchronousProxy {
4836    pub fn new(channel: fidl::Channel) -> Self {
4837        Self { client: fidl::client::sync::Client::new(channel) }
4838    }
4839
4840    pub fn into_channel(self) -> fidl::Channel {
4841        self.client.into_channel()
4842    }
4843
4844    /// Waits until an event arrives and returns it. It is safe for other
4845    /// threads to make concurrent requests while waiting for an event.
4846    pub fn wait_for_event(
4847        &self,
4848        deadline: zx::MonotonicInstant,
4849    ) -> Result<RemoteControllerEvent, fidl::Error> {
4850        RemoteControllerEvent::decode(
4851            self.client.wait_for_event::<RemoteControllerMarker>(deadline)?,
4852        )
4853    }
4854
4855    /// Called by the Starnix kernel when it requires the remote Fuchsia
4856    /// component to start servicing the binder protocol.
4857    pub fn r#start(&self, mut payload: RemoteControllerStartRequest) -> Result<(), fidl::Error> {
4858        self.client.send::<RemoteControllerStartRequest>(
4859            &mut payload,
4860            0x72ecbe863c65f4cf,
4861            fidl::encoding::DynamicFlags::FLEXIBLE,
4862        )
4863    }
4864}
4865
4866#[cfg(target_os = "fuchsia")]
4867impl From<RemoteControllerSynchronousProxy> for zx::NullableHandle {
4868    fn from(value: RemoteControllerSynchronousProxy) -> Self {
4869        value.into_channel().into()
4870    }
4871}
4872
4873#[cfg(target_os = "fuchsia")]
4874impl From<fidl::Channel> for RemoteControllerSynchronousProxy {
4875    fn from(value: fidl::Channel) -> Self {
4876        Self::new(value)
4877    }
4878}
4879
4880#[cfg(target_os = "fuchsia")]
4881impl fidl::endpoints::FromClient for RemoteControllerSynchronousProxy {
4882    type Protocol = RemoteControllerMarker;
4883
4884    fn from_client(value: fidl::endpoints::ClientEnd<RemoteControllerMarker>) -> Self {
4885        Self::new(value.into_channel())
4886    }
4887}
4888
4889#[derive(Debug, Clone)]
4890pub struct RemoteControllerProxy {
4891    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
4892}
4893
4894impl fidl::endpoints::Proxy for RemoteControllerProxy {
4895    type Protocol = RemoteControllerMarker;
4896
4897    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
4898        Self::new(inner)
4899    }
4900
4901    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
4902        self.client.into_channel().map_err(|client| Self { client })
4903    }
4904
4905    fn as_channel(&self) -> &::fidl::AsyncChannel {
4906        self.client.as_channel()
4907    }
4908}
4909
4910impl RemoteControllerProxy {
4911    /// Create a new Proxy for fuchsia.starnix.binder/RemoteController.
4912    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
4913        let protocol_name = <RemoteControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
4914        Self { client: fidl::client::Client::new(channel, protocol_name) }
4915    }
4916
4917    /// Get a Stream of events from the remote end of the protocol.
4918    ///
4919    /// # Panics
4920    ///
4921    /// Panics if the event stream was already taken.
4922    pub fn take_event_stream(&self) -> RemoteControllerEventStream {
4923        RemoteControllerEventStream { event_receiver: self.client.take_event_receiver() }
4924    }
4925
4926    /// Called by the Starnix kernel when it requires the remote Fuchsia
4927    /// component to start servicing the binder protocol.
4928    pub fn r#start(&self, mut payload: RemoteControllerStartRequest) -> Result<(), fidl::Error> {
4929        RemoteControllerProxyInterface::r#start(self, payload)
4930    }
4931}
4932
4933impl RemoteControllerProxyInterface for RemoteControllerProxy {
4934    fn r#start(&self, mut payload: RemoteControllerStartRequest) -> Result<(), fidl::Error> {
4935        self.client.send::<RemoteControllerStartRequest>(
4936            &mut payload,
4937            0x72ecbe863c65f4cf,
4938            fidl::encoding::DynamicFlags::FLEXIBLE,
4939        )
4940    }
4941}
4942
4943pub struct RemoteControllerEventStream {
4944    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
4945}
4946
4947impl std::marker::Unpin for RemoteControllerEventStream {}
4948
4949impl futures::stream::FusedStream for RemoteControllerEventStream {
4950    fn is_terminated(&self) -> bool {
4951        self.event_receiver.is_terminated()
4952    }
4953}
4954
4955impl futures::Stream for RemoteControllerEventStream {
4956    type Item = Result<RemoteControllerEvent, fidl::Error>;
4957
4958    fn poll_next(
4959        mut self: std::pin::Pin<&mut Self>,
4960        cx: &mut std::task::Context<'_>,
4961    ) -> std::task::Poll<Option<Self::Item>> {
4962        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
4963            &mut self.event_receiver,
4964            cx
4965        )?) {
4966            Some(buf) => std::task::Poll::Ready(Some(RemoteControllerEvent::decode(buf))),
4967            None => std::task::Poll::Ready(None),
4968        }
4969    }
4970}
4971
4972#[derive(Debug)]
4973pub enum RemoteControllerEvent {
4974    #[non_exhaustive]
4975    _UnknownEvent {
4976        /// Ordinal of the event that was sent.
4977        ordinal: u64,
4978    },
4979}
4980
4981impl RemoteControllerEvent {
4982    /// Decodes a message buffer as a [`RemoteControllerEvent`].
4983    fn decode(
4984        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
4985    ) -> Result<RemoteControllerEvent, fidl::Error> {
4986        let (bytes, _handles) = buf.split_mut();
4987        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
4988        debug_assert_eq!(tx_header.tx_id, 0);
4989        match tx_header.ordinal {
4990            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
4991                Ok(RemoteControllerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
4992            }
4993            _ => Err(fidl::Error::UnknownOrdinal {
4994                ordinal: tx_header.ordinal,
4995                protocol_name:
4996                    <RemoteControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4997            }),
4998        }
4999    }
5000}
5001
5002/// A Stream of incoming requests for fuchsia.starnix.binder/RemoteController.
5003pub struct RemoteControllerRequestStream {
5004    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5005    is_terminated: bool,
5006}
5007
5008impl std::marker::Unpin for RemoteControllerRequestStream {}
5009
5010impl futures::stream::FusedStream for RemoteControllerRequestStream {
5011    fn is_terminated(&self) -> bool {
5012        self.is_terminated
5013    }
5014}
5015
5016impl fidl::endpoints::RequestStream for RemoteControllerRequestStream {
5017    type Protocol = RemoteControllerMarker;
5018    type ControlHandle = RemoteControllerControlHandle;
5019
5020    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5021        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5022    }
5023
5024    fn control_handle(&self) -> Self::ControlHandle {
5025        RemoteControllerControlHandle { inner: self.inner.clone() }
5026    }
5027
5028    fn into_inner(
5029        self,
5030    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5031    {
5032        (self.inner, self.is_terminated)
5033    }
5034
5035    fn from_inner(
5036        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5037        is_terminated: bool,
5038    ) -> Self {
5039        Self { inner, is_terminated }
5040    }
5041}
5042
5043impl futures::Stream for RemoteControllerRequestStream {
5044    type Item = Result<RemoteControllerRequest, fidl::Error>;
5045
5046    fn poll_next(
5047        mut self: std::pin::Pin<&mut Self>,
5048        cx: &mut std::task::Context<'_>,
5049    ) -> std::task::Poll<Option<Self::Item>> {
5050        let this = &mut *self;
5051        if this.inner.check_shutdown(cx) {
5052            this.is_terminated = true;
5053            return std::task::Poll::Ready(None);
5054        }
5055        if this.is_terminated {
5056            panic!("polled RemoteControllerRequestStream after completion");
5057        }
5058        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5059            |bytes, handles| {
5060                match this.inner.channel().read_etc(cx, bytes, handles) {
5061                    std::task::Poll::Ready(Ok(())) => {}
5062                    std::task::Poll::Pending => return std::task::Poll::Pending,
5063                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5064                        this.is_terminated = true;
5065                        return std::task::Poll::Ready(None);
5066                    }
5067                    std::task::Poll::Ready(Err(e)) => {
5068                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5069                            e.into(),
5070                        ))));
5071                    }
5072                }
5073
5074                // A message has been received from the channel
5075                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5076
5077                std::task::Poll::Ready(Some(match header.ordinal {
5078                    0x72ecbe863c65f4cf => {
5079                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5080                        let mut req = fidl::new_empty!(
5081                            RemoteControllerStartRequest,
5082                            fidl::encoding::DefaultFuchsiaResourceDialect
5083                        );
5084                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteControllerStartRequest>(&header, _body_bytes, handles, &mut req)?;
5085                        let control_handle =
5086                            RemoteControllerControlHandle { inner: this.inner.clone() };
5087                        Ok(RemoteControllerRequest::Start { payload: req, control_handle })
5088                    }
5089                    _ if header.tx_id == 0
5090                        && header
5091                            .dynamic_flags()
5092                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5093                    {
5094                        Ok(RemoteControllerRequest::_UnknownMethod {
5095                            ordinal: header.ordinal,
5096                            control_handle: RemoteControllerControlHandle {
5097                                inner: this.inner.clone(),
5098                            },
5099                            method_type: fidl::MethodType::OneWay,
5100                        })
5101                    }
5102                    _ if header
5103                        .dynamic_flags()
5104                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5105                    {
5106                        this.inner.send_framework_err(
5107                            fidl::encoding::FrameworkErr::UnknownMethod,
5108                            header.tx_id,
5109                            header.ordinal,
5110                            header.dynamic_flags(),
5111                            (bytes, handles),
5112                        )?;
5113                        Ok(RemoteControllerRequest::_UnknownMethod {
5114                            ordinal: header.ordinal,
5115                            control_handle: RemoteControllerControlHandle {
5116                                inner: this.inner.clone(),
5117                            },
5118                            method_type: fidl::MethodType::TwoWay,
5119                        })
5120                    }
5121                    _ => Err(fidl::Error::UnknownOrdinal {
5122                        ordinal: header.ordinal,
5123                        protocol_name:
5124                            <RemoteControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5125                    }),
5126                }))
5127            },
5128        )
5129    }
5130}
5131
5132/// Protocol that allows Starnix to control binder servers and clients in other
5133/// Fuchsia components.
5134#[derive(Debug)]
5135pub enum RemoteControllerRequest {
5136    /// Called by the Starnix kernel when it requires the remote Fuchsia
5137    /// component to start servicing the binder protocol.
5138    Start { payload: RemoteControllerStartRequest, control_handle: RemoteControllerControlHandle },
5139    /// An interaction was received which does not match any known method.
5140    #[non_exhaustive]
5141    _UnknownMethod {
5142        /// Ordinal of the method that was called.
5143        ordinal: u64,
5144        control_handle: RemoteControllerControlHandle,
5145        method_type: fidl::MethodType,
5146    },
5147}
5148
5149impl RemoteControllerRequest {
5150    #[allow(irrefutable_let_patterns)]
5151    pub fn into_start(
5152        self,
5153    ) -> Option<(RemoteControllerStartRequest, RemoteControllerControlHandle)> {
5154        if let RemoteControllerRequest::Start { payload, control_handle } = self {
5155            Some((payload, control_handle))
5156        } else {
5157            None
5158        }
5159    }
5160
5161    /// Name of the method defined in FIDL
5162    pub fn method_name(&self) -> &'static str {
5163        match *self {
5164            RemoteControllerRequest::Start { .. } => "start",
5165            RemoteControllerRequest::_UnknownMethod {
5166                method_type: fidl::MethodType::OneWay,
5167                ..
5168            } => "unknown one-way method",
5169            RemoteControllerRequest::_UnknownMethod {
5170                method_type: fidl::MethodType::TwoWay,
5171                ..
5172            } => "unknown two-way method",
5173        }
5174    }
5175}
5176
5177#[derive(Debug, Clone)]
5178pub struct RemoteControllerControlHandle {
5179    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5180}
5181
5182impl RemoteControllerControlHandle {
5183    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
5184        self.inner.shutdown_with_epitaph(status.into())
5185    }
5186}
5187
5188impl fidl::endpoints::ControlHandle for RemoteControllerControlHandle {
5189    fn shutdown(&self) {
5190        self.inner.shutdown()
5191    }
5192
5193    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
5194        self.inner.shutdown_with_epitaph(status)
5195    }
5196
5197    fn is_closed(&self) -> bool {
5198        self.inner.channel().is_closed()
5199    }
5200    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5201        self.inner.channel().on_closed()
5202    }
5203
5204    #[cfg(target_os = "fuchsia")]
5205    fn signal_peer(
5206        &self,
5207        clear_mask: zx::Signals,
5208        set_mask: zx::Signals,
5209    ) -> Result<(), zx_status::Status> {
5210        use fidl::Peered;
5211        self.inner.channel().signal_peer(clear_mask, set_mask)
5212    }
5213}
5214
5215impl RemoteControllerControlHandle {}
5216
5217#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5218pub struct UnixDomainSocketMarker;
5219
5220impl fidl::endpoints::ProtocolMarker for UnixDomainSocketMarker {
5221    type Proxy = UnixDomainSocketProxy;
5222    type RequestStream = UnixDomainSocketRequestStream;
5223    #[cfg(target_os = "fuchsia")]
5224    type SynchronousProxy = UnixDomainSocketSynchronousProxy;
5225
5226    const DEBUG_NAME: &'static str = "fuchsia.starnix.binder.UnixDomainSocket";
5227}
5228impl fidl::endpoints::DiscoverableProtocolMarker for UnixDomainSocketMarker {}
5229pub type UnixDomainSocketGetEventResult = Result<UnixDomainSocketGetEventResponse, i32>;
5230pub type UnixDomainSocketReadResult = Result<UnixDomainSocketReadResponse, i32>;
5231pub type UnixDomainSocketWriteResult = Result<UnixDomainSocketWriteResponse, i32>;
5232
5233pub trait UnixDomainSocketProxyInterface: Send + Sync {
5234    fn r#clone(
5235        &self,
5236        request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
5237    ) -> Result<(), fidl::Error>;
5238    type CloseResponseFut: std::future::Future<
5239            Output = Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error>,
5240        > + Send;
5241    fn r#close(&self) -> Self::CloseResponseFut;
5242    type QueryResponseFut: std::future::Future<Output = Result<Vec<u8>, fidl::Error>> + Send;
5243    fn r#query(&self) -> Self::QueryResponseFut;
5244    type GetEventResponseFut: std::future::Future<Output = Result<UnixDomainSocketGetEventResult, fidl::Error>>
5245        + Send;
5246    fn r#get_event(&self, payload: &UnixDomainSocketGetEventRequest) -> Self::GetEventResponseFut;
5247    type ReadResponseFut: std::future::Future<Output = Result<UnixDomainSocketReadResult, fidl::Error>>
5248        + Send;
5249    fn r#read(&self, payload: &UnixDomainSocketReadRequest) -> Self::ReadResponseFut;
5250    type WriteResponseFut: std::future::Future<Output = Result<UnixDomainSocketWriteResult, fidl::Error>>
5251        + Send;
5252    fn r#write(&self, payload: UnixDomainSocketWriteRequest) -> Self::WriteResponseFut;
5253}
5254#[derive(Debug)]
5255#[cfg(target_os = "fuchsia")]
5256pub struct UnixDomainSocketSynchronousProxy {
5257    client: fidl::client::sync::Client,
5258}
5259
5260#[cfg(target_os = "fuchsia")]
5261impl fidl::endpoints::SynchronousProxy for UnixDomainSocketSynchronousProxy {
5262    type Proxy = UnixDomainSocketProxy;
5263    type Protocol = UnixDomainSocketMarker;
5264
5265    fn from_channel(inner: fidl::Channel) -> Self {
5266        Self::new(inner)
5267    }
5268
5269    fn into_channel(self) -> fidl::Channel {
5270        self.client.into_channel()
5271    }
5272
5273    fn as_channel(&self) -> &fidl::Channel {
5274        self.client.as_channel()
5275    }
5276}
5277
5278#[cfg(target_os = "fuchsia")]
5279impl UnixDomainSocketSynchronousProxy {
5280    pub fn new(channel: fidl::Channel) -> Self {
5281        Self { client: fidl::client::sync::Client::new(channel) }
5282    }
5283
5284    pub fn into_channel(self) -> fidl::Channel {
5285        self.client.into_channel()
5286    }
5287
5288    /// Waits until an event arrives and returns it. It is safe for other
5289    /// threads to make concurrent requests while waiting for an event.
5290    pub fn wait_for_event(
5291        &self,
5292        deadline: zx::MonotonicInstant,
5293    ) -> Result<UnixDomainSocketEvent, fidl::Error> {
5294        UnixDomainSocketEvent::decode(
5295            self.client.wait_for_event::<UnixDomainSocketMarker>(deadline)?,
5296        )
5297    }
5298
5299    pub fn r#clone(
5300        &self,
5301        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
5302    ) -> Result<(), fidl::Error> {
5303        self.client.send::<fidl_fuchsia_unknown::CloneableCloneRequest>(
5304            (request,),
5305            0x20d8a7aba2168a79,
5306            fidl::encoding::DynamicFlags::empty(),
5307        )
5308    }
5309
5310    /// Terminates the connection.
5311    ///
5312    /// After calling `Close`, the client must not send any other requests.
5313    ///
5314    /// Servers, after sending the status response, should close the connection
5315    /// regardless of status and without sending an epitaph.
5316    ///
5317    /// Closing the client end of the channel should be semantically equivalent
5318    /// to calling `Close` without knowing when the close has completed or its
5319    /// status.
5320    pub fn r#close(
5321        &self,
5322        ___deadline: zx::MonotonicInstant,
5323    ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
5324        let _response = self.client.send_query::<
5325            fidl::encoding::EmptyPayload,
5326            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5327            UnixDomainSocketMarker,
5328        >(
5329            (),
5330            0x5ac5d459ad7f657e,
5331            fidl::encoding::DynamicFlags::empty(),
5332            ___deadline,
5333        )?;
5334        Ok(_response.map(|x| x))
5335    }
5336
5337    pub fn r#query(&self, ___deadline: zx::MonotonicInstant) -> Result<Vec<u8>, fidl::Error> {
5338        let _response = self.client.send_query::<
5339            fidl::encoding::EmptyPayload,
5340            fidl_fuchsia_unknown::QueryableQueryResponse,
5341            UnixDomainSocketMarker,
5342        >(
5343            (),
5344            0x2658edee9decfc06,
5345            fidl::encoding::DynamicFlags::empty(),
5346            ___deadline,
5347        )?;
5348        Ok(_response.protocol)
5349    }
5350
5351    /// Returns an EventPair that will allow Starnix to wait on the socket. This event must use:
5352    /// - `fio.FileSignal.READABLE` to signal that a message is available.
5353    /// - `fio.FileSignal.WRITABLE` to signal that it can accept a new message.
5354    /// - `ZX_EVENTPAIR_PEER_CLOSED` to signal that it is closed.
5355    pub fn r#get_event(
5356        &self,
5357        mut payload: &UnixDomainSocketGetEventRequest,
5358        ___deadline: zx::MonotonicInstant,
5359    ) -> Result<UnixDomainSocketGetEventResult, fidl::Error> {
5360        let _response = self.client.send_query::<
5361            UnixDomainSocketGetEventRequest,
5362            fidl::encoding::FlexibleResultType<UnixDomainSocketGetEventResponse, i32>,
5363            UnixDomainSocketMarker,
5364        >(
5365            payload,
5366            0x4d79eb8f83961b41,
5367            fidl::encoding::DynamicFlags::FLEXIBLE,
5368            ___deadline,
5369        )?
5370        .into_result::<UnixDomainSocketMarker>("get_event")?;
5371        Ok(_response.map(|x| x))
5372    }
5373
5374    /// Read a message from the socket.
5375    pub fn r#read(
5376        &self,
5377        mut payload: &UnixDomainSocketReadRequest,
5378        ___deadline: zx::MonotonicInstant,
5379    ) -> Result<UnixDomainSocketReadResult, fidl::Error> {
5380        let _response = self.client.send_query::<
5381            UnixDomainSocketReadRequest,
5382            fidl::encoding::FlexibleResultType<UnixDomainSocketReadResponse, i32>,
5383            UnixDomainSocketMarker,
5384        >(
5385            payload,
5386            0x65ece02b0a73a069,
5387            fidl::encoding::DynamicFlags::FLEXIBLE,
5388            ___deadline,
5389        )?
5390        .into_result::<UnixDomainSocketMarker>("read")?;
5391        Ok(_response.map(|x| x))
5392    }
5393
5394    /// Write a message to the socket.
5395    pub fn r#write(
5396        &self,
5397        mut payload: UnixDomainSocketWriteRequest,
5398        ___deadline: zx::MonotonicInstant,
5399    ) -> Result<UnixDomainSocketWriteResult, fidl::Error> {
5400        let _response = self.client.send_query::<
5401            UnixDomainSocketWriteRequest,
5402            fidl::encoding::FlexibleResultType<UnixDomainSocketWriteResponse, i32>,
5403            UnixDomainSocketMarker,
5404        >(
5405            &mut payload,
5406            0x2339b58d4b835aee,
5407            fidl::encoding::DynamicFlags::FLEXIBLE,
5408            ___deadline,
5409        )?
5410        .into_result::<UnixDomainSocketMarker>("write")?;
5411        Ok(_response.map(|x| x))
5412    }
5413}
5414
5415#[cfg(target_os = "fuchsia")]
5416impl From<UnixDomainSocketSynchronousProxy> for zx::NullableHandle {
5417    fn from(value: UnixDomainSocketSynchronousProxy) -> Self {
5418        value.into_channel().into()
5419    }
5420}
5421
5422#[cfg(target_os = "fuchsia")]
5423impl From<fidl::Channel> for UnixDomainSocketSynchronousProxy {
5424    fn from(value: fidl::Channel) -> Self {
5425        Self::new(value)
5426    }
5427}
5428
5429#[cfg(target_os = "fuchsia")]
5430impl fidl::endpoints::FromClient for UnixDomainSocketSynchronousProxy {
5431    type Protocol = UnixDomainSocketMarker;
5432
5433    fn from_client(value: fidl::endpoints::ClientEnd<UnixDomainSocketMarker>) -> Self {
5434        Self::new(value.into_channel())
5435    }
5436}
5437
5438#[derive(Debug, Clone)]
5439pub struct UnixDomainSocketProxy {
5440    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5441}
5442
5443impl fidl::endpoints::Proxy for UnixDomainSocketProxy {
5444    type Protocol = UnixDomainSocketMarker;
5445
5446    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5447        Self::new(inner)
5448    }
5449
5450    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5451        self.client.into_channel().map_err(|client| Self { client })
5452    }
5453
5454    fn as_channel(&self) -> &::fidl::AsyncChannel {
5455        self.client.as_channel()
5456    }
5457}
5458
5459impl UnixDomainSocketProxy {
5460    /// Create a new Proxy for fuchsia.starnix.binder/UnixDomainSocket.
5461    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5462        let protocol_name = <UnixDomainSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5463        Self { client: fidl::client::Client::new(channel, protocol_name) }
5464    }
5465
5466    /// Get a Stream of events from the remote end of the protocol.
5467    ///
5468    /// # Panics
5469    ///
5470    /// Panics if the event stream was already taken.
5471    pub fn take_event_stream(&self) -> UnixDomainSocketEventStream {
5472        UnixDomainSocketEventStream { event_receiver: self.client.take_event_receiver() }
5473    }
5474
5475    pub fn r#clone(
5476        &self,
5477        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
5478    ) -> Result<(), fidl::Error> {
5479        UnixDomainSocketProxyInterface::r#clone(self, request)
5480    }
5481
5482    /// Terminates the connection.
5483    ///
5484    /// After calling `Close`, the client must not send any other requests.
5485    ///
5486    /// Servers, after sending the status response, should close the connection
5487    /// regardless of status and without sending an epitaph.
5488    ///
5489    /// Closing the client end of the channel should be semantically equivalent
5490    /// to calling `Close` without knowing when the close has completed or its
5491    /// status.
5492    pub fn r#close(
5493        &self,
5494    ) -> fidl::client::QueryResponseFut<
5495        fidl_fuchsia_unknown::CloseableCloseResult,
5496        fidl::encoding::DefaultFuchsiaResourceDialect,
5497    > {
5498        UnixDomainSocketProxyInterface::r#close(self)
5499    }
5500
5501    pub fn r#query(
5502        &self,
5503    ) -> fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>
5504    {
5505        UnixDomainSocketProxyInterface::r#query(self)
5506    }
5507
5508    /// Returns an EventPair that will allow Starnix to wait on the socket. This event must use:
5509    /// - `fio.FileSignal.READABLE` to signal that a message is available.
5510    /// - `fio.FileSignal.WRITABLE` to signal that it can accept a new message.
5511    /// - `ZX_EVENTPAIR_PEER_CLOSED` to signal that it is closed.
5512    pub fn r#get_event(
5513        &self,
5514        mut payload: &UnixDomainSocketGetEventRequest,
5515    ) -> fidl::client::QueryResponseFut<
5516        UnixDomainSocketGetEventResult,
5517        fidl::encoding::DefaultFuchsiaResourceDialect,
5518    > {
5519        UnixDomainSocketProxyInterface::r#get_event(self, payload)
5520    }
5521
5522    /// Read a message from the socket.
5523    pub fn r#read(
5524        &self,
5525        mut payload: &UnixDomainSocketReadRequest,
5526    ) -> fidl::client::QueryResponseFut<
5527        UnixDomainSocketReadResult,
5528        fidl::encoding::DefaultFuchsiaResourceDialect,
5529    > {
5530        UnixDomainSocketProxyInterface::r#read(self, payload)
5531    }
5532
5533    /// Write a message to the socket.
5534    pub fn r#write(
5535        &self,
5536        mut payload: UnixDomainSocketWriteRequest,
5537    ) -> fidl::client::QueryResponseFut<
5538        UnixDomainSocketWriteResult,
5539        fidl::encoding::DefaultFuchsiaResourceDialect,
5540    > {
5541        UnixDomainSocketProxyInterface::r#write(self, payload)
5542    }
5543}
5544
5545impl UnixDomainSocketProxyInterface for UnixDomainSocketProxy {
5546    fn r#clone(
5547        &self,
5548        mut request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
5549    ) -> Result<(), fidl::Error> {
5550        self.client.send::<fidl_fuchsia_unknown::CloneableCloneRequest>(
5551            (request,),
5552            0x20d8a7aba2168a79,
5553            fidl::encoding::DynamicFlags::empty(),
5554        )
5555    }
5556
5557    type CloseResponseFut = fidl::client::QueryResponseFut<
5558        fidl_fuchsia_unknown::CloseableCloseResult,
5559        fidl::encoding::DefaultFuchsiaResourceDialect,
5560    >;
5561    fn r#close(&self) -> Self::CloseResponseFut {
5562        fn _decode(
5563            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5564        ) -> Result<fidl_fuchsia_unknown::CloseableCloseResult, fidl::Error> {
5565            let _response = fidl::client::decode_transaction_body::<
5566                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
5567                fidl::encoding::DefaultFuchsiaResourceDialect,
5568                0x5ac5d459ad7f657e,
5569            >(_buf?)?;
5570            Ok(_response.map(|x| x))
5571        }
5572        self.client.send_query_and_decode::<
5573            fidl::encoding::EmptyPayload,
5574            fidl_fuchsia_unknown::CloseableCloseResult,
5575        >(
5576            (),
5577            0x5ac5d459ad7f657e,
5578            fidl::encoding::DynamicFlags::empty(),
5579            _decode,
5580        )
5581    }
5582
5583    type QueryResponseFut =
5584        fidl::client::QueryResponseFut<Vec<u8>, fidl::encoding::DefaultFuchsiaResourceDialect>;
5585    fn r#query(&self) -> Self::QueryResponseFut {
5586        fn _decode(
5587            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5588        ) -> Result<Vec<u8>, fidl::Error> {
5589            let _response = fidl::client::decode_transaction_body::<
5590                fidl_fuchsia_unknown::QueryableQueryResponse,
5591                fidl::encoding::DefaultFuchsiaResourceDialect,
5592                0x2658edee9decfc06,
5593            >(_buf?)?;
5594            Ok(_response.protocol)
5595        }
5596        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<u8>>(
5597            (),
5598            0x2658edee9decfc06,
5599            fidl::encoding::DynamicFlags::empty(),
5600            _decode,
5601        )
5602    }
5603
5604    type GetEventResponseFut = fidl::client::QueryResponseFut<
5605        UnixDomainSocketGetEventResult,
5606        fidl::encoding::DefaultFuchsiaResourceDialect,
5607    >;
5608    fn r#get_event(
5609        &self,
5610        mut payload: &UnixDomainSocketGetEventRequest,
5611    ) -> Self::GetEventResponseFut {
5612        fn _decode(
5613            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5614        ) -> Result<UnixDomainSocketGetEventResult, fidl::Error> {
5615            let _response = fidl::client::decode_transaction_body::<
5616                fidl::encoding::FlexibleResultType<UnixDomainSocketGetEventResponse, i32>,
5617                fidl::encoding::DefaultFuchsiaResourceDialect,
5618                0x4d79eb8f83961b41,
5619            >(_buf?)?
5620            .into_result::<UnixDomainSocketMarker>("get_event")?;
5621            Ok(_response.map(|x| x))
5622        }
5623        self.client.send_query_and_decode::<
5624            UnixDomainSocketGetEventRequest,
5625            UnixDomainSocketGetEventResult,
5626        >(
5627            payload,
5628            0x4d79eb8f83961b41,
5629            fidl::encoding::DynamicFlags::FLEXIBLE,
5630            _decode,
5631        )
5632    }
5633
5634    type ReadResponseFut = fidl::client::QueryResponseFut<
5635        UnixDomainSocketReadResult,
5636        fidl::encoding::DefaultFuchsiaResourceDialect,
5637    >;
5638    fn r#read(&self, mut payload: &UnixDomainSocketReadRequest) -> Self::ReadResponseFut {
5639        fn _decode(
5640            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5641        ) -> Result<UnixDomainSocketReadResult, fidl::Error> {
5642            let _response = fidl::client::decode_transaction_body::<
5643                fidl::encoding::FlexibleResultType<UnixDomainSocketReadResponse, i32>,
5644                fidl::encoding::DefaultFuchsiaResourceDialect,
5645                0x65ece02b0a73a069,
5646            >(_buf?)?
5647            .into_result::<UnixDomainSocketMarker>("read")?;
5648            Ok(_response.map(|x| x))
5649        }
5650        self.client
5651            .send_query_and_decode::<UnixDomainSocketReadRequest, UnixDomainSocketReadResult>(
5652                payload,
5653                0x65ece02b0a73a069,
5654                fidl::encoding::DynamicFlags::FLEXIBLE,
5655                _decode,
5656            )
5657    }
5658
5659    type WriteResponseFut = fidl::client::QueryResponseFut<
5660        UnixDomainSocketWriteResult,
5661        fidl::encoding::DefaultFuchsiaResourceDialect,
5662    >;
5663    fn r#write(&self, mut payload: UnixDomainSocketWriteRequest) -> Self::WriteResponseFut {
5664        fn _decode(
5665            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5666        ) -> Result<UnixDomainSocketWriteResult, fidl::Error> {
5667            let _response = fidl::client::decode_transaction_body::<
5668                fidl::encoding::FlexibleResultType<UnixDomainSocketWriteResponse, i32>,
5669                fidl::encoding::DefaultFuchsiaResourceDialect,
5670                0x2339b58d4b835aee,
5671            >(_buf?)?
5672            .into_result::<UnixDomainSocketMarker>("write")?;
5673            Ok(_response.map(|x| x))
5674        }
5675        self.client
5676            .send_query_and_decode::<UnixDomainSocketWriteRequest, UnixDomainSocketWriteResult>(
5677                &mut payload,
5678                0x2339b58d4b835aee,
5679                fidl::encoding::DynamicFlags::FLEXIBLE,
5680                _decode,
5681            )
5682    }
5683}
5684
5685pub struct UnixDomainSocketEventStream {
5686    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5687}
5688
5689impl std::marker::Unpin for UnixDomainSocketEventStream {}
5690
5691impl futures::stream::FusedStream for UnixDomainSocketEventStream {
5692    fn is_terminated(&self) -> bool {
5693        self.event_receiver.is_terminated()
5694    }
5695}
5696
5697impl futures::Stream for UnixDomainSocketEventStream {
5698    type Item = Result<UnixDomainSocketEvent, fidl::Error>;
5699
5700    fn poll_next(
5701        mut self: std::pin::Pin<&mut Self>,
5702        cx: &mut std::task::Context<'_>,
5703    ) -> std::task::Poll<Option<Self::Item>> {
5704        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5705            &mut self.event_receiver,
5706            cx
5707        )?) {
5708            Some(buf) => std::task::Poll::Ready(Some(UnixDomainSocketEvent::decode(buf))),
5709            None => std::task::Poll::Ready(None),
5710        }
5711    }
5712}
5713
5714#[derive(Debug)]
5715pub enum UnixDomainSocketEvent {
5716    #[non_exhaustive]
5717    _UnknownEvent {
5718        /// Ordinal of the event that was sent.
5719        ordinal: u64,
5720    },
5721}
5722
5723impl UnixDomainSocketEvent {
5724    /// Decodes a message buffer as a [`UnixDomainSocketEvent`].
5725    fn decode(
5726        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5727    ) -> Result<UnixDomainSocketEvent, fidl::Error> {
5728        let (bytes, _handles) = buf.split_mut();
5729        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5730        debug_assert_eq!(tx_header.tx_id, 0);
5731        match tx_header.ordinal {
5732            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
5733                Ok(UnixDomainSocketEvent::_UnknownEvent { ordinal: tx_header.ordinal })
5734            }
5735            _ => Err(fidl::Error::UnknownOrdinal {
5736                ordinal: tx_header.ordinal,
5737                protocol_name:
5738                    <UnixDomainSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5739            }),
5740        }
5741    }
5742}
5743
5744/// A Stream of incoming requests for fuchsia.starnix.binder/UnixDomainSocket.
5745pub struct UnixDomainSocketRequestStream {
5746    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5747    is_terminated: bool,
5748}
5749
5750impl std::marker::Unpin for UnixDomainSocketRequestStream {}
5751
5752impl futures::stream::FusedStream for UnixDomainSocketRequestStream {
5753    fn is_terminated(&self) -> bool {
5754        self.is_terminated
5755    }
5756}
5757
5758impl fidl::endpoints::RequestStream for UnixDomainSocketRequestStream {
5759    type Protocol = UnixDomainSocketMarker;
5760    type ControlHandle = UnixDomainSocketControlHandle;
5761
5762    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5763        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5764    }
5765
5766    fn control_handle(&self) -> Self::ControlHandle {
5767        UnixDomainSocketControlHandle { inner: self.inner.clone() }
5768    }
5769
5770    fn into_inner(
5771        self,
5772    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5773    {
5774        (self.inner, self.is_terminated)
5775    }
5776
5777    fn from_inner(
5778        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5779        is_terminated: bool,
5780    ) -> Self {
5781        Self { inner, is_terminated }
5782    }
5783}
5784
5785impl futures::Stream for UnixDomainSocketRequestStream {
5786    type Item = Result<UnixDomainSocketRequest, fidl::Error>;
5787
5788    fn poll_next(
5789        mut self: std::pin::Pin<&mut Self>,
5790        cx: &mut std::task::Context<'_>,
5791    ) -> std::task::Poll<Option<Self::Item>> {
5792        let this = &mut *self;
5793        if this.inner.check_shutdown(cx) {
5794            this.is_terminated = true;
5795            return std::task::Poll::Ready(None);
5796        }
5797        if this.is_terminated {
5798            panic!("polled UnixDomainSocketRequestStream after completion");
5799        }
5800        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5801            |bytes, handles| {
5802                match this.inner.channel().read_etc(cx, bytes, handles) {
5803                    std::task::Poll::Ready(Ok(())) => {}
5804                    std::task::Poll::Pending => return std::task::Poll::Pending,
5805                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5806                        this.is_terminated = true;
5807                        return std::task::Poll::Ready(None);
5808                    }
5809                    std::task::Poll::Ready(Err(e)) => {
5810                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5811                            e.into(),
5812                        ))));
5813                    }
5814                }
5815
5816                // A message has been received from the channel
5817                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5818
5819                std::task::Poll::Ready(Some(match header.ordinal {
5820                    0x20d8a7aba2168a79 => {
5821                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5822                        let mut req = fidl::new_empty!(
5823                            fidl_fuchsia_unknown::CloneableCloneRequest,
5824                            fidl::encoding::DefaultFuchsiaResourceDialect
5825                        );
5826                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl_fuchsia_unknown::CloneableCloneRequest>(&header, _body_bytes, handles, &mut req)?;
5827                        let control_handle =
5828                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5829                        Ok(UnixDomainSocketRequest::Clone { request: req.request, control_handle })
5830                    }
5831                    0x5ac5d459ad7f657e => {
5832                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5833                        let mut req = fidl::new_empty!(
5834                            fidl::encoding::EmptyPayload,
5835                            fidl::encoding::DefaultFuchsiaResourceDialect
5836                        );
5837                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5838                        let control_handle =
5839                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5840                        Ok(UnixDomainSocketRequest::Close {
5841                            responder: UnixDomainSocketCloseResponder {
5842                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5843                                tx_id: header.tx_id,
5844                            },
5845                        })
5846                    }
5847                    0x2658edee9decfc06 => {
5848                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5849                        let mut req = fidl::new_empty!(
5850                            fidl::encoding::EmptyPayload,
5851                            fidl::encoding::DefaultFuchsiaResourceDialect
5852                        );
5853                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
5854                        let control_handle =
5855                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5856                        Ok(UnixDomainSocketRequest::Query {
5857                            responder: UnixDomainSocketQueryResponder {
5858                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5859                                tx_id: header.tx_id,
5860                            },
5861                        })
5862                    }
5863                    0x4d79eb8f83961b41 => {
5864                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5865                        let mut req = fidl::new_empty!(
5866                            UnixDomainSocketGetEventRequest,
5867                            fidl::encoding::DefaultFuchsiaResourceDialect
5868                        );
5869                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UnixDomainSocketGetEventRequest>(&header, _body_bytes, handles, &mut req)?;
5870                        let control_handle =
5871                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5872                        Ok(UnixDomainSocketRequest::GetEvent {
5873                            payload: req,
5874                            responder: UnixDomainSocketGetEventResponder {
5875                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5876                                tx_id: header.tx_id,
5877                            },
5878                        })
5879                    }
5880                    0x65ece02b0a73a069 => {
5881                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5882                        let mut req = fidl::new_empty!(
5883                            UnixDomainSocketReadRequest,
5884                            fidl::encoding::DefaultFuchsiaResourceDialect
5885                        );
5886                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UnixDomainSocketReadRequest>(&header, _body_bytes, handles, &mut req)?;
5887                        let control_handle =
5888                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5889                        Ok(UnixDomainSocketRequest::Read {
5890                            payload: req,
5891                            responder: UnixDomainSocketReadResponder {
5892                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5893                                tx_id: header.tx_id,
5894                            },
5895                        })
5896                    }
5897                    0x2339b58d4b835aee => {
5898                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
5899                        let mut req = fidl::new_empty!(
5900                            UnixDomainSocketWriteRequest,
5901                            fidl::encoding::DefaultFuchsiaResourceDialect
5902                        );
5903                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UnixDomainSocketWriteRequest>(&header, _body_bytes, handles, &mut req)?;
5904                        let control_handle =
5905                            UnixDomainSocketControlHandle { inner: this.inner.clone() };
5906                        Ok(UnixDomainSocketRequest::Write {
5907                            payload: req,
5908                            responder: UnixDomainSocketWriteResponder {
5909                                control_handle: std::mem::ManuallyDrop::new(control_handle),
5910                                tx_id: header.tx_id,
5911                            },
5912                        })
5913                    }
5914                    _ if header.tx_id == 0
5915                        && header
5916                            .dynamic_flags()
5917                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5918                    {
5919                        Ok(UnixDomainSocketRequest::_UnknownMethod {
5920                            ordinal: header.ordinal,
5921                            control_handle: UnixDomainSocketControlHandle {
5922                                inner: this.inner.clone(),
5923                            },
5924                            method_type: fidl::MethodType::OneWay,
5925                        })
5926                    }
5927                    _ if header
5928                        .dynamic_flags()
5929                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
5930                    {
5931                        this.inner.send_framework_err(
5932                            fidl::encoding::FrameworkErr::UnknownMethod,
5933                            header.tx_id,
5934                            header.ordinal,
5935                            header.dynamic_flags(),
5936                            (bytes, handles),
5937                        )?;
5938                        Ok(UnixDomainSocketRequest::_UnknownMethod {
5939                            ordinal: header.ordinal,
5940                            control_handle: UnixDomainSocketControlHandle {
5941                                inner: this.inner.clone(),
5942                            },
5943                            method_type: fidl::MethodType::TwoWay,
5944                        })
5945                    }
5946                    _ => Err(fidl::Error::UnknownOrdinal {
5947                        ordinal: header.ordinal,
5948                        protocol_name:
5949                            <UnixDomainSocketMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5950                    }),
5951                }))
5952            },
5953        )
5954    }
5955}
5956
5957/// A Unix Domain Socket
5958///
5959/// This protocol is used to implement a unix domain socket in a Fuchsia
5960/// Component that will be able to communicate with a socket in Starnix. That
5961/// socket will be able to transmit file descriptors.
5962#[derive(Debug)]
5963pub enum UnixDomainSocketRequest {
5964    Clone {
5965        request: fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
5966        control_handle: UnixDomainSocketControlHandle,
5967    },
5968    /// Terminates the connection.
5969    ///
5970    /// After calling `Close`, the client must not send any other requests.
5971    ///
5972    /// Servers, after sending the status response, should close the connection
5973    /// regardless of status and without sending an epitaph.
5974    ///
5975    /// Closing the client end of the channel should be semantically equivalent
5976    /// to calling `Close` without knowing when the close has completed or its
5977    /// status.
5978    Close {
5979        responder: UnixDomainSocketCloseResponder,
5980    },
5981    Query {
5982        responder: UnixDomainSocketQueryResponder,
5983    },
5984    /// Returns an EventPair that will allow Starnix to wait on the socket. This event must use:
5985    /// - `fio.FileSignal.READABLE` to signal that a message is available.
5986    /// - `fio.FileSignal.WRITABLE` to signal that it can accept a new message.
5987    /// - `ZX_EVENTPAIR_PEER_CLOSED` to signal that it is closed.
5988    GetEvent {
5989        payload: UnixDomainSocketGetEventRequest,
5990        responder: UnixDomainSocketGetEventResponder,
5991    },
5992    /// Read a message from the socket.
5993    Read {
5994        payload: UnixDomainSocketReadRequest,
5995        responder: UnixDomainSocketReadResponder,
5996    },
5997    /// Write a message to the socket.
5998    Write {
5999        payload: UnixDomainSocketWriteRequest,
6000        responder: UnixDomainSocketWriteResponder,
6001    },
6002    /// An interaction was received which does not match any known method.
6003    #[non_exhaustive]
6004    _UnknownMethod {
6005        /// Ordinal of the method that was called.
6006        ordinal: u64,
6007        control_handle: UnixDomainSocketControlHandle,
6008        method_type: fidl::MethodType,
6009    },
6010}
6011
6012impl UnixDomainSocketRequest {
6013    #[allow(irrefutable_let_patterns)]
6014    pub fn into_clone(
6015        self,
6016    ) -> Option<(
6017        fidl::endpoints::ServerEnd<fidl_fuchsia_unknown::CloneableMarker>,
6018        UnixDomainSocketControlHandle,
6019    )> {
6020        if let UnixDomainSocketRequest::Clone { request, control_handle } = self {
6021            Some((request, control_handle))
6022        } else {
6023            None
6024        }
6025    }
6026
6027    #[allow(irrefutable_let_patterns)]
6028    pub fn into_close(self) -> Option<(UnixDomainSocketCloseResponder)> {
6029        if let UnixDomainSocketRequest::Close { responder } = self {
6030            Some((responder))
6031        } else {
6032            None
6033        }
6034    }
6035
6036    #[allow(irrefutable_let_patterns)]
6037    pub fn into_query(self) -> Option<(UnixDomainSocketQueryResponder)> {
6038        if let UnixDomainSocketRequest::Query { responder } = self {
6039            Some((responder))
6040        } else {
6041            None
6042        }
6043    }
6044
6045    #[allow(irrefutable_let_patterns)]
6046    pub fn into_get_event(
6047        self,
6048    ) -> Option<(UnixDomainSocketGetEventRequest, UnixDomainSocketGetEventResponder)> {
6049        if let UnixDomainSocketRequest::GetEvent { payload, responder } = self {
6050            Some((payload, responder))
6051        } else {
6052            None
6053        }
6054    }
6055
6056    #[allow(irrefutable_let_patterns)]
6057    pub fn into_read(self) -> Option<(UnixDomainSocketReadRequest, UnixDomainSocketReadResponder)> {
6058        if let UnixDomainSocketRequest::Read { payload, responder } = self {
6059            Some((payload, responder))
6060        } else {
6061            None
6062        }
6063    }
6064
6065    #[allow(irrefutable_let_patterns)]
6066    pub fn into_write(
6067        self,
6068    ) -> Option<(UnixDomainSocketWriteRequest, UnixDomainSocketWriteResponder)> {
6069        if let UnixDomainSocketRequest::Write { payload, responder } = self {
6070            Some((payload, responder))
6071        } else {
6072            None
6073        }
6074    }
6075
6076    /// Name of the method defined in FIDL
6077    pub fn method_name(&self) -> &'static str {
6078        match *self {
6079            UnixDomainSocketRequest::Clone { .. } => "clone",
6080            UnixDomainSocketRequest::Close { .. } => "close",
6081            UnixDomainSocketRequest::Query { .. } => "query",
6082            UnixDomainSocketRequest::GetEvent { .. } => "get_event",
6083            UnixDomainSocketRequest::Read { .. } => "read",
6084            UnixDomainSocketRequest::Write { .. } => "write",
6085            UnixDomainSocketRequest::_UnknownMethod {
6086                method_type: fidl::MethodType::OneWay,
6087                ..
6088            } => "unknown one-way method",
6089            UnixDomainSocketRequest::_UnknownMethod {
6090                method_type: fidl::MethodType::TwoWay,
6091                ..
6092            } => "unknown two-way method",
6093        }
6094    }
6095}
6096
6097#[derive(Debug, Clone)]
6098pub struct UnixDomainSocketControlHandle {
6099    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6100}
6101
6102impl UnixDomainSocketControlHandle {
6103    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
6104        self.inner.shutdown_with_epitaph(status.into())
6105    }
6106}
6107
6108impl fidl::endpoints::ControlHandle for UnixDomainSocketControlHandle {
6109    fn shutdown(&self) {
6110        self.inner.shutdown()
6111    }
6112
6113    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
6114        self.inner.shutdown_with_epitaph(status)
6115    }
6116
6117    fn is_closed(&self) -> bool {
6118        self.inner.channel().is_closed()
6119    }
6120    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6121        self.inner.channel().on_closed()
6122    }
6123
6124    #[cfg(target_os = "fuchsia")]
6125    fn signal_peer(
6126        &self,
6127        clear_mask: zx::Signals,
6128        set_mask: zx::Signals,
6129    ) -> Result<(), zx_status::Status> {
6130        use fidl::Peered;
6131        self.inner.channel().signal_peer(clear_mask, set_mask)
6132    }
6133}
6134
6135impl UnixDomainSocketControlHandle {}
6136
6137#[must_use = "FIDL methods require a response to be sent"]
6138#[derive(Debug)]
6139pub struct UnixDomainSocketCloseResponder {
6140    control_handle: std::mem::ManuallyDrop<UnixDomainSocketControlHandle>,
6141    tx_id: u32,
6142}
6143
6144/// Set the the channel to be shutdown (see [`UnixDomainSocketControlHandle::shutdown`])
6145/// if the responder is dropped without sending a response, so that the client
6146/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6147impl std::ops::Drop for UnixDomainSocketCloseResponder {
6148    fn drop(&mut self) {
6149        self.control_handle.shutdown();
6150        // Safety: drops once, never accessed again
6151        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6152    }
6153}
6154
6155impl fidl::endpoints::Responder for UnixDomainSocketCloseResponder {
6156    type ControlHandle = UnixDomainSocketControlHandle;
6157
6158    fn control_handle(&self) -> &UnixDomainSocketControlHandle {
6159        &self.control_handle
6160    }
6161
6162    fn drop_without_shutdown(mut self) {
6163        // Safety: drops once, never accessed again due to mem::forget
6164        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6165        // Prevent Drop from running (which would shut down the channel)
6166        std::mem::forget(self);
6167    }
6168}
6169
6170impl UnixDomainSocketCloseResponder {
6171    /// Sends a response to the FIDL transaction.
6172    ///
6173    /// Sets the channel to shutdown if an error occurs.
6174    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6175        let _result = self.send_raw(result);
6176        if _result.is_err() {
6177            self.control_handle.shutdown();
6178        }
6179        self.drop_without_shutdown();
6180        _result
6181    }
6182
6183    /// Similar to "send" but does not shutdown the channel if an error occurs.
6184    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6185        let _result = self.send_raw(result);
6186        self.drop_without_shutdown();
6187        _result
6188    }
6189
6190    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
6191        self.control_handle
6192            .inner
6193            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
6194                result,
6195                self.tx_id,
6196                0x5ac5d459ad7f657e,
6197                fidl::encoding::DynamicFlags::empty(),
6198            )
6199    }
6200}
6201
6202#[must_use = "FIDL methods require a response to be sent"]
6203#[derive(Debug)]
6204pub struct UnixDomainSocketQueryResponder {
6205    control_handle: std::mem::ManuallyDrop<UnixDomainSocketControlHandle>,
6206    tx_id: u32,
6207}
6208
6209/// Set the the channel to be shutdown (see [`UnixDomainSocketControlHandle::shutdown`])
6210/// if the responder is dropped without sending a response, so that the client
6211/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6212impl std::ops::Drop for UnixDomainSocketQueryResponder {
6213    fn drop(&mut self) {
6214        self.control_handle.shutdown();
6215        // Safety: drops once, never accessed again
6216        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6217    }
6218}
6219
6220impl fidl::endpoints::Responder for UnixDomainSocketQueryResponder {
6221    type ControlHandle = UnixDomainSocketControlHandle;
6222
6223    fn control_handle(&self) -> &UnixDomainSocketControlHandle {
6224        &self.control_handle
6225    }
6226
6227    fn drop_without_shutdown(mut self) {
6228        // Safety: drops once, never accessed again due to mem::forget
6229        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6230        // Prevent Drop from running (which would shut down the channel)
6231        std::mem::forget(self);
6232    }
6233}
6234
6235impl UnixDomainSocketQueryResponder {
6236    /// Sends a response to the FIDL transaction.
6237    ///
6238    /// Sets the channel to shutdown if an error occurs.
6239    pub fn send(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
6240        let _result = self.send_raw(protocol);
6241        if _result.is_err() {
6242            self.control_handle.shutdown();
6243        }
6244        self.drop_without_shutdown();
6245        _result
6246    }
6247
6248    /// Similar to "send" but does not shutdown the channel if an error occurs.
6249    pub fn send_no_shutdown_on_err(self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
6250        let _result = self.send_raw(protocol);
6251        self.drop_without_shutdown();
6252        _result
6253    }
6254
6255    fn send_raw(&self, mut protocol: &[u8]) -> Result<(), fidl::Error> {
6256        self.control_handle.inner.send::<fidl_fuchsia_unknown::QueryableQueryResponse>(
6257            (protocol,),
6258            self.tx_id,
6259            0x2658edee9decfc06,
6260            fidl::encoding::DynamicFlags::empty(),
6261        )
6262    }
6263}
6264
6265#[must_use = "FIDL methods require a response to be sent"]
6266#[derive(Debug)]
6267pub struct UnixDomainSocketGetEventResponder {
6268    control_handle: std::mem::ManuallyDrop<UnixDomainSocketControlHandle>,
6269    tx_id: u32,
6270}
6271
6272/// Set the the channel to be shutdown (see [`UnixDomainSocketControlHandle::shutdown`])
6273/// if the responder is dropped without sending a response, so that the client
6274/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6275impl std::ops::Drop for UnixDomainSocketGetEventResponder {
6276    fn drop(&mut self) {
6277        self.control_handle.shutdown();
6278        // Safety: drops once, never accessed again
6279        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6280    }
6281}
6282
6283impl fidl::endpoints::Responder for UnixDomainSocketGetEventResponder {
6284    type ControlHandle = UnixDomainSocketControlHandle;
6285
6286    fn control_handle(&self) -> &UnixDomainSocketControlHandle {
6287        &self.control_handle
6288    }
6289
6290    fn drop_without_shutdown(mut self) {
6291        // Safety: drops once, never accessed again due to mem::forget
6292        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6293        // Prevent Drop from running (which would shut down the channel)
6294        std::mem::forget(self);
6295    }
6296}
6297
6298impl UnixDomainSocketGetEventResponder {
6299    /// Sends a response to the FIDL transaction.
6300    ///
6301    /// Sets the channel to shutdown if an error occurs.
6302    pub fn send(
6303        self,
6304        mut result: Result<UnixDomainSocketGetEventResponse, i32>,
6305    ) -> Result<(), fidl::Error> {
6306        let _result = self.send_raw(result);
6307        if _result.is_err() {
6308            self.control_handle.shutdown();
6309        }
6310        self.drop_without_shutdown();
6311        _result
6312    }
6313
6314    /// Similar to "send" but does not shutdown the channel if an error occurs.
6315    pub fn send_no_shutdown_on_err(
6316        self,
6317        mut result: Result<UnixDomainSocketGetEventResponse, i32>,
6318    ) -> Result<(), fidl::Error> {
6319        let _result = self.send_raw(result);
6320        self.drop_without_shutdown();
6321        _result
6322    }
6323
6324    fn send_raw(
6325        &self,
6326        mut result: Result<UnixDomainSocketGetEventResponse, i32>,
6327    ) -> Result<(), fidl::Error> {
6328        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6329            UnixDomainSocketGetEventResponse,
6330            i32,
6331        >>(
6332            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
6333            self.tx_id,
6334            0x4d79eb8f83961b41,
6335            fidl::encoding::DynamicFlags::FLEXIBLE,
6336        )
6337    }
6338}
6339
6340#[must_use = "FIDL methods require a response to be sent"]
6341#[derive(Debug)]
6342pub struct UnixDomainSocketReadResponder {
6343    control_handle: std::mem::ManuallyDrop<UnixDomainSocketControlHandle>,
6344    tx_id: u32,
6345}
6346
6347/// Set the the channel to be shutdown (see [`UnixDomainSocketControlHandle::shutdown`])
6348/// if the responder is dropped without sending a response, so that the client
6349/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6350impl std::ops::Drop for UnixDomainSocketReadResponder {
6351    fn drop(&mut self) {
6352        self.control_handle.shutdown();
6353        // Safety: drops once, never accessed again
6354        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6355    }
6356}
6357
6358impl fidl::endpoints::Responder for UnixDomainSocketReadResponder {
6359    type ControlHandle = UnixDomainSocketControlHandle;
6360
6361    fn control_handle(&self) -> &UnixDomainSocketControlHandle {
6362        &self.control_handle
6363    }
6364
6365    fn drop_without_shutdown(mut self) {
6366        // Safety: drops once, never accessed again due to mem::forget
6367        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6368        // Prevent Drop from running (which would shut down the channel)
6369        std::mem::forget(self);
6370    }
6371}
6372
6373impl UnixDomainSocketReadResponder {
6374    /// Sends a response to the FIDL transaction.
6375    ///
6376    /// Sets the channel to shutdown if an error occurs.
6377    pub fn send(
6378        self,
6379        mut result: Result<UnixDomainSocketReadResponse, i32>,
6380    ) -> Result<(), fidl::Error> {
6381        let _result = self.send_raw(result);
6382        if _result.is_err() {
6383            self.control_handle.shutdown();
6384        }
6385        self.drop_without_shutdown();
6386        _result
6387    }
6388
6389    /// Similar to "send" but does not shutdown the channel if an error occurs.
6390    pub fn send_no_shutdown_on_err(
6391        self,
6392        mut result: Result<UnixDomainSocketReadResponse, i32>,
6393    ) -> Result<(), fidl::Error> {
6394        let _result = self.send_raw(result);
6395        self.drop_without_shutdown();
6396        _result
6397    }
6398
6399    fn send_raw(
6400        &self,
6401        mut result: Result<UnixDomainSocketReadResponse, i32>,
6402    ) -> Result<(), fidl::Error> {
6403        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6404            UnixDomainSocketReadResponse,
6405            i32,
6406        >>(
6407            fidl::encoding::FlexibleResult::new(result.as_mut().map_err(|e| *e)),
6408            self.tx_id,
6409            0x65ece02b0a73a069,
6410            fidl::encoding::DynamicFlags::FLEXIBLE,
6411        )
6412    }
6413}
6414
6415#[must_use = "FIDL methods require a response to be sent"]
6416#[derive(Debug)]
6417pub struct UnixDomainSocketWriteResponder {
6418    control_handle: std::mem::ManuallyDrop<UnixDomainSocketControlHandle>,
6419    tx_id: u32,
6420}
6421
6422/// Set the the channel to be shutdown (see [`UnixDomainSocketControlHandle::shutdown`])
6423/// if the responder is dropped without sending a response, so that the client
6424/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6425impl std::ops::Drop for UnixDomainSocketWriteResponder {
6426    fn drop(&mut self) {
6427        self.control_handle.shutdown();
6428        // Safety: drops once, never accessed again
6429        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6430    }
6431}
6432
6433impl fidl::endpoints::Responder for UnixDomainSocketWriteResponder {
6434    type ControlHandle = UnixDomainSocketControlHandle;
6435
6436    fn control_handle(&self) -> &UnixDomainSocketControlHandle {
6437        &self.control_handle
6438    }
6439
6440    fn drop_without_shutdown(mut self) {
6441        // Safety: drops once, never accessed again due to mem::forget
6442        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6443        // Prevent Drop from running (which would shut down the channel)
6444        std::mem::forget(self);
6445    }
6446}
6447
6448impl UnixDomainSocketWriteResponder {
6449    /// Sends a response to the FIDL transaction.
6450    ///
6451    /// Sets the channel to shutdown if an error occurs.
6452    pub fn send(
6453        self,
6454        mut result: Result<&UnixDomainSocketWriteResponse, i32>,
6455    ) -> Result<(), fidl::Error> {
6456        let _result = self.send_raw(result);
6457        if _result.is_err() {
6458            self.control_handle.shutdown();
6459        }
6460        self.drop_without_shutdown();
6461        _result
6462    }
6463
6464    /// Similar to "send" but does not shutdown the channel if an error occurs.
6465    pub fn send_no_shutdown_on_err(
6466        self,
6467        mut result: Result<&UnixDomainSocketWriteResponse, i32>,
6468    ) -> Result<(), fidl::Error> {
6469        let _result = self.send_raw(result);
6470        self.drop_without_shutdown();
6471        _result
6472    }
6473
6474    fn send_raw(
6475        &self,
6476        mut result: Result<&UnixDomainSocketWriteResponse, i32>,
6477    ) -> Result<(), fidl::Error> {
6478        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
6479            UnixDomainSocketWriteResponse,
6480            i32,
6481        >>(
6482            fidl::encoding::FlexibleResult::new(result),
6483            self.tx_id,
6484            0x2339b58d4b835aee,
6485            fidl::encoding::DynamicFlags::FLEXIBLE,
6486        )
6487    }
6488}
6489
6490mod internal {
6491    use super::*;
6492
6493    impl fidl::encoding::ResourceTypeMarker for BinderIoctlRequest {
6494        type Borrowed<'a> = &'a mut Self;
6495        fn take_or_borrow<'a>(
6496            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6497        ) -> Self::Borrowed<'a> {
6498            value
6499        }
6500    }
6501
6502    unsafe impl fidl::encoding::TypeMarker for BinderIoctlRequest {
6503        type Owned = Self;
6504
6505        #[inline(always)]
6506        fn inline_align(_context: fidl::encoding::Context) -> usize {
6507            8
6508        }
6509
6510        #[inline(always)]
6511        fn inline_size(_context: fidl::encoding::Context) -> usize {
6512            64
6513        }
6514    }
6515
6516    unsafe impl
6517        fidl::encoding::Encode<BinderIoctlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6518        for &mut BinderIoctlRequest
6519    {
6520        #[inline]
6521        unsafe fn encode(
6522            self,
6523            encoder: &mut fidl::encoding::Encoder<
6524                '_,
6525                fidl::encoding::DefaultFuchsiaResourceDialect,
6526            >,
6527            offset: usize,
6528            _depth: fidl::encoding::Depth,
6529        ) -> fidl::Result<()> {
6530            encoder.debug_check_bounds::<BinderIoctlRequest>(offset);
6531            // Delegate to tuple encoding.
6532            fidl::encoding::Encode::<BinderIoctlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6533                (
6534                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.tid),
6535                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.request),
6536                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.arg),
6537                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
6538                    <fidl::encoding::Vector<IoctlReadWrite, 16> as fidl::encoding::ValueTypeMarker>::borrow(&self.ioctl_reads),
6539                    <fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.files),
6540                ),
6541                encoder, offset, _depth
6542            )
6543        }
6544    }
6545    unsafe impl<
6546        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
6547        T1: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
6548        T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
6549        T3: fidl::encoding::Encode<
6550                fidl::encoding::HandleType<
6551                    fidl::Vmo,
6552                    { fidl::ObjectType::VMO.into_raw() },
6553                    2147483648,
6554                >,
6555                fidl::encoding::DefaultFuchsiaResourceDialect,
6556            >,
6557        T4: fidl::encoding::Encode<
6558                fidl::encoding::Vector<IoctlReadWrite, 16>,
6559                fidl::encoding::DefaultFuchsiaResourceDialect,
6560            >,
6561        T5: fidl::encoding::Encode<
6562                fidl::encoding::Vector<FileHandle, 16>,
6563                fidl::encoding::DefaultFuchsiaResourceDialect,
6564            >,
6565    > fidl::encoding::Encode<BinderIoctlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6566        for (T0, T1, T2, T3, T4, T5)
6567    {
6568        #[inline]
6569        unsafe fn encode(
6570            self,
6571            encoder: &mut fidl::encoding::Encoder<
6572                '_,
6573                fidl::encoding::DefaultFuchsiaResourceDialect,
6574            >,
6575            offset: usize,
6576            depth: fidl::encoding::Depth,
6577        ) -> fidl::Result<()> {
6578            encoder.debug_check_bounds::<BinderIoctlRequest>(offset);
6579            // Zero out padding regions. There's no need to apply masks
6580            // because the unmasked parts will be overwritten by fields.
6581            unsafe {
6582                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
6583                (ptr as *mut u64).write_unaligned(0);
6584            }
6585            unsafe {
6586                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
6587                (ptr as *mut u64).write_unaligned(0);
6588            }
6589            // Write the fields.
6590            self.0.encode(encoder, offset + 0, depth)?;
6591            self.1.encode(encoder, offset + 8, depth)?;
6592            self.2.encode(encoder, offset + 16, depth)?;
6593            self.3.encode(encoder, offset + 24, depth)?;
6594            self.4.encode(encoder, offset + 32, depth)?;
6595            self.5.encode(encoder, offset + 48, depth)?;
6596            Ok(())
6597        }
6598    }
6599
6600    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6601        for BinderIoctlRequest
6602    {
6603        #[inline(always)]
6604        fn new_empty() -> Self {
6605            Self {
6606                tid: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
6607                request: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
6608                arg: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
6609                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6610                ioctl_reads: fidl::new_empty!(fidl::encoding::Vector<IoctlReadWrite, 16>, fidl::encoding::DefaultFuchsiaResourceDialect),
6611                files: fidl::new_empty!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect),
6612            }
6613        }
6614
6615        #[inline]
6616        unsafe fn decode(
6617            &mut self,
6618            decoder: &mut fidl::encoding::Decoder<
6619                '_,
6620                fidl::encoding::DefaultFuchsiaResourceDialect,
6621            >,
6622            offset: usize,
6623            _depth: fidl::encoding::Depth,
6624        ) -> fidl::Result<()> {
6625            decoder.debug_check_bounds::<Self>(offset);
6626            // Verify that padding bytes are zero.
6627            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
6628            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6629            let mask = 0xffffffff00000000u64;
6630            let maskedval = padval & mask;
6631            if maskedval != 0 {
6632                return Err(fidl::Error::NonZeroPadding {
6633                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
6634                });
6635            }
6636            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
6637            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6638            let mask = 0xffffffff00000000u64;
6639            let maskedval = padval & mask;
6640            if maskedval != 0 {
6641                return Err(fidl::Error::NonZeroPadding {
6642                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
6643                });
6644            }
6645            fidl::decode!(
6646                u64,
6647                fidl::encoding::DefaultFuchsiaResourceDialect,
6648                &mut self.tid,
6649                decoder,
6650                offset + 0,
6651                _depth
6652            )?;
6653            fidl::decode!(
6654                u32,
6655                fidl::encoding::DefaultFuchsiaResourceDialect,
6656                &mut self.request,
6657                decoder,
6658                offset + 8,
6659                _depth
6660            )?;
6661            fidl::decode!(
6662                u64,
6663                fidl::encoding::DefaultFuchsiaResourceDialect,
6664                &mut self.arg,
6665                decoder,
6666                offset + 16,
6667                _depth
6668            )?;
6669            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 24, _depth)?;
6670            fidl::decode!(fidl::encoding::Vector<IoctlReadWrite, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ioctl_reads, decoder, offset + 32, _depth)?;
6671            fidl::decode!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.files, decoder, offset + 48, _depth)?;
6672            Ok(())
6673        }
6674    }
6675
6676    impl fidl::encoding::ResourceTypeMarker for BinderMapVmoRequest {
6677        type Borrowed<'a> = &'a mut Self;
6678        fn take_or_borrow<'a>(
6679            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6680        ) -> Self::Borrowed<'a> {
6681            value
6682        }
6683    }
6684
6685    unsafe impl fidl::encoding::TypeMarker for BinderMapVmoRequest {
6686        type Owned = Self;
6687
6688        #[inline(always)]
6689        fn inline_align(_context: fidl::encoding::Context) -> usize {
6690            8
6691        }
6692
6693        #[inline(always)]
6694        fn inline_size(_context: fidl::encoding::Context) -> usize {
6695            16
6696        }
6697    }
6698
6699    unsafe impl
6700        fidl::encoding::Encode<BinderMapVmoRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6701        for &mut BinderMapVmoRequest
6702    {
6703        #[inline]
6704        unsafe fn encode(
6705            self,
6706            encoder: &mut fidl::encoding::Encoder<
6707                '_,
6708                fidl::encoding::DefaultFuchsiaResourceDialect,
6709            >,
6710            offset: usize,
6711            _depth: fidl::encoding::Depth,
6712        ) -> fidl::Result<()> {
6713            encoder.debug_check_bounds::<BinderMapVmoRequest>(offset);
6714            // Delegate to tuple encoding.
6715            fidl::encoding::Encode::<
6716                BinderMapVmoRequest,
6717                fidl::encoding::DefaultFuchsiaResourceDialect,
6718            >::encode(
6719                (
6720                    <fidl::encoding::HandleType<
6721                        fidl::Vmo,
6722                        { fidl::ObjectType::VMO.into_raw() },
6723                        2147483648,
6724                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6725                        &mut self.vmo
6726                    ),
6727                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.mapped_address),
6728                ),
6729                encoder,
6730                offset,
6731                _depth,
6732            )
6733        }
6734    }
6735    unsafe impl<
6736        T0: fidl::encoding::Encode<
6737                fidl::encoding::HandleType<
6738                    fidl::Vmo,
6739                    { fidl::ObjectType::VMO.into_raw() },
6740                    2147483648,
6741                >,
6742                fidl::encoding::DefaultFuchsiaResourceDialect,
6743            >,
6744        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
6745    > fidl::encoding::Encode<BinderMapVmoRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6746        for (T0, T1)
6747    {
6748        #[inline]
6749        unsafe fn encode(
6750            self,
6751            encoder: &mut fidl::encoding::Encoder<
6752                '_,
6753                fidl::encoding::DefaultFuchsiaResourceDialect,
6754            >,
6755            offset: usize,
6756            depth: fidl::encoding::Depth,
6757        ) -> fidl::Result<()> {
6758            encoder.debug_check_bounds::<BinderMapVmoRequest>(offset);
6759            // Zero out padding regions. There's no need to apply masks
6760            // because the unmasked parts will be overwritten by fields.
6761            unsafe {
6762                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
6763                (ptr as *mut u64).write_unaligned(0);
6764            }
6765            // Write the fields.
6766            self.0.encode(encoder, offset + 0, depth)?;
6767            self.1.encode(encoder, offset + 8, depth)?;
6768            Ok(())
6769        }
6770    }
6771
6772    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6773        for BinderMapVmoRequest
6774    {
6775        #[inline(always)]
6776        fn new_empty() -> Self {
6777            Self {
6778                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
6779                mapped_address: fidl::new_empty!(
6780                    u64,
6781                    fidl::encoding::DefaultFuchsiaResourceDialect
6782                ),
6783            }
6784        }
6785
6786        #[inline]
6787        unsafe fn decode(
6788            &mut self,
6789            decoder: &mut fidl::encoding::Decoder<
6790                '_,
6791                fidl::encoding::DefaultFuchsiaResourceDialect,
6792            >,
6793            offset: usize,
6794            _depth: fidl::encoding::Depth,
6795        ) -> fidl::Result<()> {
6796            decoder.debug_check_bounds::<Self>(offset);
6797            // Verify that padding bytes are zero.
6798            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
6799            let padval = unsafe { (ptr as *const u64).read_unaligned() };
6800            let mask = 0xffffffff00000000u64;
6801            let maskedval = padval & mask;
6802            if maskedval != 0 {
6803                return Err(fidl::Error::NonZeroPadding {
6804                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
6805                });
6806            }
6807            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
6808            fidl::decode!(
6809                u64,
6810                fidl::encoding::DefaultFuchsiaResourceDialect,
6811                &mut self.mapped_address,
6812                decoder,
6813                offset + 8,
6814                _depth
6815            )?;
6816            Ok(())
6817        }
6818    }
6819
6820    impl fidl::encoding::ResourceTypeMarker for BinderRegisterThreadChannelRequest {
6821        type Borrowed<'a> = &'a mut Self;
6822        fn take_or_borrow<'a>(
6823            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6824        ) -> Self::Borrowed<'a> {
6825            value
6826        }
6827    }
6828
6829    unsafe impl fidl::encoding::TypeMarker for BinderRegisterThreadChannelRequest {
6830        type Owned = Self;
6831
6832        #[inline(always)]
6833        fn inline_align(_context: fidl::encoding::Context) -> usize {
6834            4
6835        }
6836
6837        #[inline(always)]
6838        fn inline_size(_context: fidl::encoding::Context) -> usize {
6839            4
6840        }
6841    }
6842
6843    unsafe impl
6844        fidl::encoding::Encode<
6845            BinderRegisterThreadChannelRequest,
6846            fidl::encoding::DefaultFuchsiaResourceDialect,
6847        > for &mut BinderRegisterThreadChannelRequest
6848    {
6849        #[inline]
6850        unsafe fn encode(
6851            self,
6852            encoder: &mut fidl::encoding::Encoder<
6853                '_,
6854                fidl::encoding::DefaultFuchsiaResourceDialect,
6855            >,
6856            offset: usize,
6857            _depth: fidl::encoding::Depth,
6858        ) -> fidl::Result<()> {
6859            encoder.debug_check_bounds::<BinderRegisterThreadChannelRequest>(offset);
6860            // Delegate to tuple encoding.
6861            fidl::encoding::Encode::<BinderRegisterThreadChannelRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
6862                (
6863                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderThreadMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server_end),
6864                ),
6865                encoder, offset, _depth
6866            )
6867        }
6868    }
6869    unsafe impl<
6870        T0: fidl::encoding::Encode<
6871                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderThreadMarker>>,
6872                fidl::encoding::DefaultFuchsiaResourceDialect,
6873            >,
6874    >
6875        fidl::encoding::Encode<
6876            BinderRegisterThreadChannelRequest,
6877            fidl::encoding::DefaultFuchsiaResourceDialect,
6878        > for (T0,)
6879    {
6880        #[inline]
6881        unsafe fn encode(
6882            self,
6883            encoder: &mut fidl::encoding::Encoder<
6884                '_,
6885                fidl::encoding::DefaultFuchsiaResourceDialect,
6886            >,
6887            offset: usize,
6888            depth: fidl::encoding::Depth,
6889        ) -> fidl::Result<()> {
6890            encoder.debug_check_bounds::<BinderRegisterThreadChannelRequest>(offset);
6891            // Zero out padding regions. There's no need to apply masks
6892            // because the unmasked parts will be overwritten by fields.
6893            // Write the fields.
6894            self.0.encode(encoder, offset + 0, depth)?;
6895            Ok(())
6896        }
6897    }
6898
6899    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6900        for BinderRegisterThreadChannelRequest
6901    {
6902        #[inline(always)]
6903        fn new_empty() -> Self {
6904            Self {
6905                server_end: fidl::new_empty!(
6906                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderThreadMarker>>,
6907                    fidl::encoding::DefaultFuchsiaResourceDialect
6908                ),
6909            }
6910        }
6911
6912        #[inline]
6913        unsafe fn decode(
6914            &mut self,
6915            decoder: &mut fidl::encoding::Decoder<
6916                '_,
6917                fidl::encoding::DefaultFuchsiaResourceDialect,
6918            >,
6919            offset: usize,
6920            _depth: fidl::encoding::Depth,
6921        ) -> fidl::Result<()> {
6922            decoder.debug_check_bounds::<Self>(offset);
6923            // Verify that padding bytes are zero.
6924            fidl::decode!(
6925                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderThreadMarker>>,
6926                fidl::encoding::DefaultFuchsiaResourceDialect,
6927                &mut self.server_end,
6928                decoder,
6929                offset + 0,
6930                _depth
6931            )?;
6932            Ok(())
6933        }
6934    }
6935
6936    impl fidl::encoding::ResourceTypeMarker for BinderSetVmoRequest {
6937        type Borrowed<'a> = &'a mut Self;
6938        fn take_or_borrow<'a>(
6939            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6940        ) -> Self::Borrowed<'a> {
6941            value
6942        }
6943    }
6944
6945    unsafe impl fidl::encoding::TypeMarker for BinderSetVmoRequest {
6946        type Owned = Self;
6947
6948        #[inline(always)]
6949        fn inline_align(_context: fidl::encoding::Context) -> usize {
6950            8
6951        }
6952
6953        #[inline(always)]
6954        fn inline_size(_context: fidl::encoding::Context) -> usize {
6955            16
6956        }
6957    }
6958
6959    unsafe impl
6960        fidl::encoding::Encode<BinderSetVmoRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
6961        for &mut BinderSetVmoRequest
6962    {
6963        #[inline]
6964        unsafe fn encode(
6965            self,
6966            encoder: &mut fidl::encoding::Encoder<
6967                '_,
6968                fidl::encoding::DefaultFuchsiaResourceDialect,
6969            >,
6970            offset: usize,
6971            _depth: fidl::encoding::Depth,
6972        ) -> fidl::Result<()> {
6973            encoder.debug_check_bounds::<BinderSetVmoRequest>(offset);
6974            // Delegate to tuple encoding.
6975            fidl::encoding::Encode::<
6976                BinderSetVmoRequest,
6977                fidl::encoding::DefaultFuchsiaResourceDialect,
6978            >::encode(
6979                (
6980                    <fidl::encoding::HandleType<
6981                        fidl::Vmo,
6982                        { fidl::ObjectType::VMO.into_raw() },
6983                        2147483648,
6984                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
6985                        &mut self.vmo
6986                    ),
6987                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.mapped_address),
6988                ),
6989                encoder,
6990                offset,
6991                _depth,
6992            )
6993        }
6994    }
6995    unsafe impl<
6996        T0: fidl::encoding::Encode<
6997                fidl::encoding::HandleType<
6998                    fidl::Vmo,
6999                    { fidl::ObjectType::VMO.into_raw() },
7000                    2147483648,
7001                >,
7002                fidl::encoding::DefaultFuchsiaResourceDialect,
7003            >,
7004        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7005    > fidl::encoding::Encode<BinderSetVmoRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7006        for (T0, T1)
7007    {
7008        #[inline]
7009        unsafe fn encode(
7010            self,
7011            encoder: &mut fidl::encoding::Encoder<
7012                '_,
7013                fidl::encoding::DefaultFuchsiaResourceDialect,
7014            >,
7015            offset: usize,
7016            depth: fidl::encoding::Depth,
7017        ) -> fidl::Result<()> {
7018            encoder.debug_check_bounds::<BinderSetVmoRequest>(offset);
7019            // Zero out padding regions. There's no need to apply masks
7020            // because the unmasked parts will be overwritten by fields.
7021            unsafe {
7022                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7023                (ptr as *mut u64).write_unaligned(0);
7024            }
7025            // Write the fields.
7026            self.0.encode(encoder, offset + 0, depth)?;
7027            self.1.encode(encoder, offset + 8, depth)?;
7028            Ok(())
7029        }
7030    }
7031
7032    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7033        for BinderSetVmoRequest
7034    {
7035        #[inline(always)]
7036        fn new_empty() -> Self {
7037            Self {
7038                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7039                mapped_address: fidl::new_empty!(
7040                    u64,
7041                    fidl::encoding::DefaultFuchsiaResourceDialect
7042                ),
7043            }
7044        }
7045
7046        #[inline]
7047        unsafe fn decode(
7048            &mut self,
7049            decoder: &mut fidl::encoding::Decoder<
7050                '_,
7051                fidl::encoding::DefaultFuchsiaResourceDialect,
7052            >,
7053            offset: usize,
7054            _depth: fidl::encoding::Depth,
7055        ) -> fidl::Result<()> {
7056            decoder.debug_check_bounds::<Self>(offset);
7057            // Verify that padding bytes are zero.
7058            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7059            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7060            let mask = 0xffffffff00000000u64;
7061            let maskedval = padval & mask;
7062            if maskedval != 0 {
7063                return Err(fidl::Error::NonZeroPadding {
7064                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7065                });
7066            }
7067            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 0, _depth)?;
7068            fidl::decode!(
7069                u64,
7070                fidl::encoding::DefaultFuchsiaResourceDialect,
7071                &mut self.mapped_address,
7072                decoder,
7073                offset + 8,
7074                _depth
7075            )?;
7076            Ok(())
7077        }
7078    }
7079
7080    impl fidl::encoding::ResourceTypeMarker for BinderThreadIoctlRequest {
7081        type Borrowed<'a> = &'a mut Self;
7082        fn take_or_borrow<'a>(
7083            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7084        ) -> Self::Borrowed<'a> {
7085            value
7086        }
7087    }
7088
7089    unsafe impl fidl::encoding::TypeMarker for BinderThreadIoctlRequest {
7090        type Owned = Self;
7091
7092        #[inline(always)]
7093        fn inline_align(_context: fidl::encoding::Context) -> usize {
7094            8
7095        }
7096
7097        #[inline(always)]
7098        fn inline_size(_context: fidl::encoding::Context) -> usize {
7099            56
7100        }
7101    }
7102
7103    unsafe impl
7104        fidl::encoding::Encode<
7105            BinderThreadIoctlRequest,
7106            fidl::encoding::DefaultFuchsiaResourceDialect,
7107        > for &mut BinderThreadIoctlRequest
7108    {
7109        #[inline]
7110        unsafe fn encode(
7111            self,
7112            encoder: &mut fidl::encoding::Encoder<
7113                '_,
7114                fidl::encoding::DefaultFuchsiaResourceDialect,
7115            >,
7116            offset: usize,
7117            _depth: fidl::encoding::Depth,
7118        ) -> fidl::Result<()> {
7119            encoder.debug_check_bounds::<BinderThreadIoctlRequest>(offset);
7120            // Delegate to tuple encoding.
7121            fidl::encoding::Encode::<BinderThreadIoctlRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
7122                (
7123                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.request),
7124                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.arg),
7125                    <fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmo),
7126                    <fidl::encoding::Vector<IoctlReadWrite, 16> as fidl::encoding::ValueTypeMarker>::borrow(&self.ioctl_reads),
7127                    <fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.files),
7128                ),
7129                encoder, offset, _depth
7130            )
7131        }
7132    }
7133    unsafe impl<
7134        T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
7135        T1: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7136        T2: fidl::encoding::Encode<
7137                fidl::encoding::HandleType<
7138                    fidl::Vmo,
7139                    { fidl::ObjectType::VMO.into_raw() },
7140                    2147483648,
7141                >,
7142                fidl::encoding::DefaultFuchsiaResourceDialect,
7143            >,
7144        T3: fidl::encoding::Encode<
7145                fidl::encoding::Vector<IoctlReadWrite, 16>,
7146                fidl::encoding::DefaultFuchsiaResourceDialect,
7147            >,
7148        T4: fidl::encoding::Encode<
7149                fidl::encoding::Vector<FileHandle, 16>,
7150                fidl::encoding::DefaultFuchsiaResourceDialect,
7151            >,
7152    >
7153        fidl::encoding::Encode<
7154            BinderThreadIoctlRequest,
7155            fidl::encoding::DefaultFuchsiaResourceDialect,
7156        > for (T0, T1, T2, T3, T4)
7157    {
7158        #[inline]
7159        unsafe fn encode(
7160            self,
7161            encoder: &mut fidl::encoding::Encoder<
7162                '_,
7163                fidl::encoding::DefaultFuchsiaResourceDialect,
7164            >,
7165            offset: usize,
7166            depth: fidl::encoding::Depth,
7167        ) -> fidl::Result<()> {
7168            encoder.debug_check_bounds::<BinderThreadIoctlRequest>(offset);
7169            // Zero out padding regions. There's no need to apply masks
7170            // because the unmasked parts will be overwritten by fields.
7171            unsafe {
7172                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
7173                (ptr as *mut u64).write_unaligned(0);
7174            }
7175            unsafe {
7176                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
7177                (ptr as *mut u64).write_unaligned(0);
7178            }
7179            // Write the fields.
7180            self.0.encode(encoder, offset + 0, depth)?;
7181            self.1.encode(encoder, offset + 8, depth)?;
7182            self.2.encode(encoder, offset + 16, depth)?;
7183            self.3.encode(encoder, offset + 24, depth)?;
7184            self.4.encode(encoder, offset + 40, depth)?;
7185            Ok(())
7186        }
7187    }
7188
7189    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7190        for BinderThreadIoctlRequest
7191    {
7192        #[inline(always)]
7193        fn new_empty() -> Self {
7194            Self {
7195                request: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
7196                arg: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
7197                vmo: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7198                ioctl_reads: fidl::new_empty!(fidl::encoding::Vector<IoctlReadWrite, 16>, fidl::encoding::DefaultFuchsiaResourceDialect),
7199                files: fidl::new_empty!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect),
7200            }
7201        }
7202
7203        #[inline]
7204        unsafe fn decode(
7205            &mut self,
7206            decoder: &mut fidl::encoding::Decoder<
7207                '_,
7208                fidl::encoding::DefaultFuchsiaResourceDialect,
7209            >,
7210            offset: usize,
7211            _depth: fidl::encoding::Depth,
7212        ) -> fidl::Result<()> {
7213            decoder.debug_check_bounds::<Self>(offset);
7214            // Verify that padding bytes are zero.
7215            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
7216            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7217            let mask = 0xffffffff00000000u64;
7218            let maskedval = padval & mask;
7219            if maskedval != 0 {
7220                return Err(fidl::Error::NonZeroPadding {
7221                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
7222                });
7223            }
7224            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
7225            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7226            let mask = 0xffffffff00000000u64;
7227            let maskedval = padval & mask;
7228            if maskedval != 0 {
7229                return Err(fidl::Error::NonZeroPadding {
7230                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
7231                });
7232            }
7233            fidl::decode!(
7234                u32,
7235                fidl::encoding::DefaultFuchsiaResourceDialect,
7236                &mut self.request,
7237                decoder,
7238                offset + 0,
7239                _depth
7240            )?;
7241            fidl::decode!(
7242                u64,
7243                fidl::encoding::DefaultFuchsiaResourceDialect,
7244                &mut self.arg,
7245                decoder,
7246                offset + 8,
7247                _depth
7248            )?;
7249            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo, decoder, offset + 16, _depth)?;
7250            fidl::decode!(fidl::encoding::Vector<IoctlReadWrite, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ioctl_reads, decoder, offset + 24, _depth)?;
7251            fidl::decode!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.files, decoder, offset + 40, _depth)?;
7252            Ok(())
7253        }
7254    }
7255
7256    impl fidl::encoding::ResourceTypeMarker for ProcessAccessorWriteBytesRequest {
7257        type Borrowed<'a> = &'a mut Self;
7258        fn take_or_borrow<'a>(
7259            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7260        ) -> Self::Borrowed<'a> {
7261            value
7262        }
7263    }
7264
7265    unsafe impl fidl::encoding::TypeMarker for ProcessAccessorWriteBytesRequest {
7266        type Owned = Self;
7267
7268        #[inline(always)]
7269        fn inline_align(_context: fidl::encoding::Context) -> usize {
7270            8
7271        }
7272
7273        #[inline(always)]
7274        fn inline_size(_context: fidl::encoding::Context) -> usize {
7275            24
7276        }
7277    }
7278
7279    unsafe impl
7280        fidl::encoding::Encode<
7281            ProcessAccessorWriteBytesRequest,
7282            fidl::encoding::DefaultFuchsiaResourceDialect,
7283        > for &mut ProcessAccessorWriteBytesRequest
7284    {
7285        #[inline]
7286        unsafe fn encode(
7287            self,
7288            encoder: &mut fidl::encoding::Encoder<
7289                '_,
7290                fidl::encoding::DefaultFuchsiaResourceDialect,
7291            >,
7292            offset: usize,
7293            _depth: fidl::encoding::Depth,
7294        ) -> fidl::Result<()> {
7295            encoder.debug_check_bounds::<ProcessAccessorWriteBytesRequest>(offset);
7296            // Delegate to tuple encoding.
7297            fidl::encoding::Encode::<
7298                ProcessAccessorWriteBytesRequest,
7299                fidl::encoding::DefaultFuchsiaResourceDialect,
7300            >::encode(
7301                (
7302                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.address),
7303                    <fidl::encoding::Vector<u8, 32768> as fidl::encoding::ValueTypeMarker>::borrow(
7304                        &self.bytes,
7305                    ),
7306                ),
7307                encoder,
7308                offset,
7309                _depth,
7310            )
7311        }
7312    }
7313    unsafe impl<
7314        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7315        T1: fidl::encoding::Encode<
7316                fidl::encoding::Vector<u8, 32768>,
7317                fidl::encoding::DefaultFuchsiaResourceDialect,
7318            >,
7319    >
7320        fidl::encoding::Encode<
7321            ProcessAccessorWriteBytesRequest,
7322            fidl::encoding::DefaultFuchsiaResourceDialect,
7323        > for (T0, T1)
7324    {
7325        #[inline]
7326        unsafe fn encode(
7327            self,
7328            encoder: &mut fidl::encoding::Encoder<
7329                '_,
7330                fidl::encoding::DefaultFuchsiaResourceDialect,
7331            >,
7332            offset: usize,
7333            depth: fidl::encoding::Depth,
7334        ) -> fidl::Result<()> {
7335            encoder.debug_check_bounds::<ProcessAccessorWriteBytesRequest>(offset);
7336            // Zero out padding regions. There's no need to apply masks
7337            // because the unmasked parts will be overwritten by fields.
7338            // Write the fields.
7339            self.0.encode(encoder, offset + 0, depth)?;
7340            self.1.encode(encoder, offset + 8, depth)?;
7341            Ok(())
7342        }
7343    }
7344
7345    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7346        for ProcessAccessorWriteBytesRequest
7347    {
7348        #[inline(always)]
7349        fn new_empty() -> Self {
7350            Self {
7351                address: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
7352                bytes: fidl::new_empty!(fidl::encoding::Vector<u8, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect),
7353            }
7354        }
7355
7356        #[inline]
7357        unsafe fn decode(
7358            &mut self,
7359            decoder: &mut fidl::encoding::Decoder<
7360                '_,
7361                fidl::encoding::DefaultFuchsiaResourceDialect,
7362            >,
7363            offset: usize,
7364            _depth: fidl::encoding::Depth,
7365        ) -> fidl::Result<()> {
7366            decoder.debug_check_bounds::<Self>(offset);
7367            // Verify that padding bytes are zero.
7368            fidl::decode!(
7369                u64,
7370                fidl::encoding::DefaultFuchsiaResourceDialect,
7371                &mut self.address,
7372                decoder,
7373                offset + 0,
7374                _depth
7375            )?;
7376            fidl::decode!(fidl::encoding::Vector<u8, 32768>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.bytes, decoder, offset + 8, _depth)?;
7377            Ok(())
7378        }
7379    }
7380
7381    impl fidl::encoding::ResourceTypeMarker for ProcessAccessorWriteMemoryRequest {
7382        type Borrowed<'a> = &'a mut Self;
7383        fn take_or_borrow<'a>(
7384            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7385        ) -> Self::Borrowed<'a> {
7386            value
7387        }
7388    }
7389
7390    unsafe impl fidl::encoding::TypeMarker for ProcessAccessorWriteMemoryRequest {
7391        type Owned = Self;
7392
7393        #[inline(always)]
7394        fn inline_align(_context: fidl::encoding::Context) -> usize {
7395            8
7396        }
7397
7398        #[inline(always)]
7399        fn inline_size(_context: fidl::encoding::Context) -> usize {
7400            16
7401        }
7402    }
7403
7404    unsafe impl
7405        fidl::encoding::Encode<
7406            ProcessAccessorWriteMemoryRequest,
7407            fidl::encoding::DefaultFuchsiaResourceDialect,
7408        > for &mut ProcessAccessorWriteMemoryRequest
7409    {
7410        #[inline]
7411        unsafe fn encode(
7412            self,
7413            encoder: &mut fidl::encoding::Encoder<
7414                '_,
7415                fidl::encoding::DefaultFuchsiaResourceDialect,
7416            >,
7417            offset: usize,
7418            _depth: fidl::encoding::Depth,
7419        ) -> fidl::Result<()> {
7420            encoder.debug_check_bounds::<ProcessAccessorWriteMemoryRequest>(offset);
7421            // Delegate to tuple encoding.
7422            fidl::encoding::Encode::<
7423                ProcessAccessorWriteMemoryRequest,
7424                fidl::encoding::DefaultFuchsiaResourceDialect,
7425            >::encode(
7426                (
7427                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.address),
7428                    <fidl::encoding::HandleType<
7429                        fidl::Vmo,
7430                        { fidl::ObjectType::VMO.into_raw() },
7431                        2147483648,
7432                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
7433                        &mut self.content
7434                    ),
7435                ),
7436                encoder,
7437                offset,
7438                _depth,
7439            )
7440        }
7441    }
7442    unsafe impl<
7443        T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
7444        T1: fidl::encoding::Encode<
7445                fidl::encoding::HandleType<
7446                    fidl::Vmo,
7447                    { fidl::ObjectType::VMO.into_raw() },
7448                    2147483648,
7449                >,
7450                fidl::encoding::DefaultFuchsiaResourceDialect,
7451            >,
7452    >
7453        fidl::encoding::Encode<
7454            ProcessAccessorWriteMemoryRequest,
7455            fidl::encoding::DefaultFuchsiaResourceDialect,
7456        > for (T0, T1)
7457    {
7458        #[inline]
7459        unsafe fn encode(
7460            self,
7461            encoder: &mut fidl::encoding::Encoder<
7462                '_,
7463                fidl::encoding::DefaultFuchsiaResourceDialect,
7464            >,
7465            offset: usize,
7466            depth: fidl::encoding::Depth,
7467        ) -> fidl::Result<()> {
7468            encoder.debug_check_bounds::<ProcessAccessorWriteMemoryRequest>(offset);
7469            // Zero out padding regions. There's no need to apply masks
7470            // because the unmasked parts will be overwritten by fields.
7471            unsafe {
7472                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
7473                (ptr as *mut u64).write_unaligned(0);
7474            }
7475            // Write the fields.
7476            self.0.encode(encoder, offset + 0, depth)?;
7477            self.1.encode(encoder, offset + 8, depth)?;
7478            Ok(())
7479        }
7480    }
7481
7482    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7483        for ProcessAccessorWriteMemoryRequest
7484    {
7485        #[inline(always)]
7486        fn new_empty() -> Self {
7487            Self {
7488                address: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
7489                content: fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
7490            }
7491        }
7492
7493        #[inline]
7494        unsafe fn decode(
7495            &mut self,
7496            decoder: &mut fidl::encoding::Decoder<
7497                '_,
7498                fidl::encoding::DefaultFuchsiaResourceDialect,
7499            >,
7500            offset: usize,
7501            _depth: fidl::encoding::Depth,
7502        ) -> fidl::Result<()> {
7503            decoder.debug_check_bounds::<Self>(offset);
7504            // Verify that padding bytes are zero.
7505            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
7506            let padval = unsafe { (ptr as *const u64).read_unaligned() };
7507            let mask = 0xffffffff00000000u64;
7508            let maskedval = padval & mask;
7509            if maskedval != 0 {
7510                return Err(fidl::Error::NonZeroPadding {
7511                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
7512                });
7513            }
7514            fidl::decode!(
7515                u64,
7516                fidl::encoding::DefaultFuchsiaResourceDialect,
7517                &mut self.address,
7518                decoder,
7519                offset + 0,
7520                _depth
7521            )?;
7522            fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.content, decoder, offset + 8, _depth)?;
7523            Ok(())
7524        }
7525    }
7526
7527    impl CmpRequeueRequest {
7528        #[inline(always)]
7529        fn max_ordinal_present(&self) -> u64 {
7530            if let Some(_) = self.cmp_val {
7531                return 7;
7532            }
7533            if let Some(_) = self.requeue_count {
7534                return 6;
7535            }
7536            if let Some(_) = self.wake_count {
7537                return 5;
7538            }
7539            if let Some(_) = self.second_offset {
7540                return 4;
7541            }
7542            if let Some(_) = self.second_vmo {
7543                return 3;
7544            }
7545            if let Some(_) = self.first_offset {
7546                return 2;
7547            }
7548            if let Some(_) = self.first_vmo {
7549                return 1;
7550            }
7551            0
7552        }
7553    }
7554
7555    impl fidl::encoding::ResourceTypeMarker for CmpRequeueRequest {
7556        type Borrowed<'a> = &'a mut Self;
7557        fn take_or_borrow<'a>(
7558            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
7559        ) -> Self::Borrowed<'a> {
7560            value
7561        }
7562    }
7563
7564    unsafe impl fidl::encoding::TypeMarker for CmpRequeueRequest {
7565        type Owned = Self;
7566
7567        #[inline(always)]
7568        fn inline_align(_context: fidl::encoding::Context) -> usize {
7569            8
7570        }
7571
7572        #[inline(always)]
7573        fn inline_size(_context: fidl::encoding::Context) -> usize {
7574            16
7575        }
7576    }
7577
7578    unsafe impl
7579        fidl::encoding::Encode<CmpRequeueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
7580        for &mut CmpRequeueRequest
7581    {
7582        unsafe fn encode(
7583            self,
7584            encoder: &mut fidl::encoding::Encoder<
7585                '_,
7586                fidl::encoding::DefaultFuchsiaResourceDialect,
7587            >,
7588            offset: usize,
7589            mut depth: fidl::encoding::Depth,
7590        ) -> fidl::Result<()> {
7591            encoder.debug_check_bounds::<CmpRequeueRequest>(offset);
7592            // Vector header
7593            let max_ordinal: u64 = self.max_ordinal_present();
7594            encoder.write_num(max_ordinal, offset);
7595            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
7596            // Calling encoder.out_of_line_offset(0) is not allowed.
7597            if max_ordinal == 0 {
7598                return Ok(());
7599            }
7600            depth.increment()?;
7601            let envelope_size = 8;
7602            let bytes_len = max_ordinal as usize * envelope_size;
7603            #[allow(unused_variables)]
7604            let offset = encoder.out_of_line_offset(bytes_len);
7605            let mut _prev_end_offset: usize = 0;
7606            if 1 > max_ordinal {
7607                return Ok(());
7608            }
7609
7610            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7611            // are envelope_size bytes.
7612            let cur_offset: usize = (1 - 1) * envelope_size;
7613
7614            // Zero reserved fields.
7615            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7616
7617            // Safety:
7618            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7619            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7620            //   envelope_size bytes, there is always sufficient room.
7621            fidl::encoding::encode_in_envelope_optional::<
7622                fidl::encoding::HandleType<
7623                    fidl::Vmo,
7624                    { fidl::ObjectType::VMO.into_raw() },
7625                    2147483648,
7626                >,
7627                fidl::encoding::DefaultFuchsiaResourceDialect,
7628            >(
7629                self.first_vmo.as_mut().map(
7630                    <fidl::encoding::HandleType<
7631                        fidl::Vmo,
7632                        { fidl::ObjectType::VMO.into_raw() },
7633                        2147483648,
7634                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7635                ),
7636                encoder,
7637                offset + cur_offset,
7638                depth,
7639            )?;
7640
7641            _prev_end_offset = cur_offset + envelope_size;
7642            if 2 > max_ordinal {
7643                return Ok(());
7644            }
7645
7646            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7647            // are envelope_size bytes.
7648            let cur_offset: usize = (2 - 1) * envelope_size;
7649
7650            // Zero reserved fields.
7651            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7652
7653            // Safety:
7654            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7655            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7656            //   envelope_size bytes, there is always sufficient room.
7657            fidl::encoding::encode_in_envelope_optional::<
7658                u64,
7659                fidl::encoding::DefaultFuchsiaResourceDialect,
7660            >(
7661                self.first_offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7662                encoder,
7663                offset + cur_offset,
7664                depth,
7665            )?;
7666
7667            _prev_end_offset = cur_offset + envelope_size;
7668            if 3 > max_ordinal {
7669                return Ok(());
7670            }
7671
7672            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7673            // are envelope_size bytes.
7674            let cur_offset: usize = (3 - 1) * envelope_size;
7675
7676            // Zero reserved fields.
7677            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7678
7679            // Safety:
7680            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7681            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7682            //   envelope_size bytes, there is always sufficient room.
7683            fidl::encoding::encode_in_envelope_optional::<
7684                fidl::encoding::HandleType<
7685                    fidl::Vmo,
7686                    { fidl::ObjectType::VMO.into_raw() },
7687                    2147483648,
7688                >,
7689                fidl::encoding::DefaultFuchsiaResourceDialect,
7690            >(
7691                self.second_vmo.as_mut().map(
7692                    <fidl::encoding::HandleType<
7693                        fidl::Vmo,
7694                        { fidl::ObjectType::VMO.into_raw() },
7695                        2147483648,
7696                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
7697                ),
7698                encoder,
7699                offset + cur_offset,
7700                depth,
7701            )?;
7702
7703            _prev_end_offset = cur_offset + envelope_size;
7704            if 4 > max_ordinal {
7705                return Ok(());
7706            }
7707
7708            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7709            // are envelope_size bytes.
7710            let cur_offset: usize = (4 - 1) * envelope_size;
7711
7712            // Zero reserved fields.
7713            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7714
7715            // Safety:
7716            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7717            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7718            //   envelope_size bytes, there is always sufficient room.
7719            fidl::encoding::encode_in_envelope_optional::<
7720                u64,
7721                fidl::encoding::DefaultFuchsiaResourceDialect,
7722            >(
7723                self.second_offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
7724                encoder,
7725                offset + cur_offset,
7726                depth,
7727            )?;
7728
7729            _prev_end_offset = cur_offset + envelope_size;
7730            if 5 > max_ordinal {
7731                return Ok(());
7732            }
7733
7734            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7735            // are envelope_size bytes.
7736            let cur_offset: usize = (5 - 1) * envelope_size;
7737
7738            // Zero reserved fields.
7739            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7740
7741            // Safety:
7742            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7743            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7744            //   envelope_size bytes, there is always sufficient room.
7745            fidl::encoding::encode_in_envelope_optional::<
7746                u32,
7747                fidl::encoding::DefaultFuchsiaResourceDialect,
7748            >(
7749                self.wake_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7750                encoder,
7751                offset + cur_offset,
7752                depth,
7753            )?;
7754
7755            _prev_end_offset = cur_offset + envelope_size;
7756            if 6 > max_ordinal {
7757                return Ok(());
7758            }
7759
7760            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7761            // are envelope_size bytes.
7762            let cur_offset: usize = (6 - 1) * envelope_size;
7763
7764            // Zero reserved fields.
7765            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7766
7767            // Safety:
7768            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7769            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7770            //   envelope_size bytes, there is always sufficient room.
7771            fidl::encoding::encode_in_envelope_optional::<
7772                u32,
7773                fidl::encoding::DefaultFuchsiaResourceDialect,
7774            >(
7775                self.requeue_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7776                encoder,
7777                offset + cur_offset,
7778                depth,
7779            )?;
7780
7781            _prev_end_offset = cur_offset + envelope_size;
7782            if 7 > max_ordinal {
7783                return Ok(());
7784            }
7785
7786            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
7787            // are envelope_size bytes.
7788            let cur_offset: usize = (7 - 1) * envelope_size;
7789
7790            // Zero reserved fields.
7791            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
7792
7793            // Safety:
7794            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
7795            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
7796            //   envelope_size bytes, there is always sufficient room.
7797            fidl::encoding::encode_in_envelope_optional::<
7798                u32,
7799                fidl::encoding::DefaultFuchsiaResourceDialect,
7800            >(
7801                self.cmp_val.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
7802                encoder,
7803                offset + cur_offset,
7804                depth,
7805            )?;
7806
7807            _prev_end_offset = cur_offset + envelope_size;
7808
7809            Ok(())
7810        }
7811    }
7812
7813    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
7814        for CmpRequeueRequest
7815    {
7816        #[inline(always)]
7817        fn new_empty() -> Self {
7818            Self::default()
7819        }
7820
7821        unsafe fn decode(
7822            &mut self,
7823            decoder: &mut fidl::encoding::Decoder<
7824                '_,
7825                fidl::encoding::DefaultFuchsiaResourceDialect,
7826            >,
7827            offset: usize,
7828            mut depth: fidl::encoding::Depth,
7829        ) -> fidl::Result<()> {
7830            decoder.debug_check_bounds::<Self>(offset);
7831            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
7832                None => return Err(fidl::Error::NotNullable),
7833                Some(len) => len,
7834            };
7835            // Calling decoder.out_of_line_offset(0) is not allowed.
7836            if len == 0 {
7837                return Ok(());
7838            };
7839            depth.increment()?;
7840            let envelope_size = 8;
7841            let bytes_len = len * envelope_size;
7842            let offset = decoder.out_of_line_offset(bytes_len)?;
7843            // Decode the envelope for each type.
7844            let mut _next_ordinal_to_read = 0;
7845            let mut next_offset = offset;
7846            let end_offset = offset + bytes_len;
7847            _next_ordinal_to_read += 1;
7848            if next_offset >= end_offset {
7849                return Ok(());
7850            }
7851
7852            // Decode unknown envelopes for gaps in ordinals.
7853            while _next_ordinal_to_read < 1 {
7854                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7855                _next_ordinal_to_read += 1;
7856                next_offset += envelope_size;
7857            }
7858
7859            let next_out_of_line = decoder.next_out_of_line();
7860            let handles_before = decoder.remaining_handles();
7861            if let Some((inlined, num_bytes, num_handles)) =
7862                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7863            {
7864                let member_inline_size = <fidl::encoding::HandleType<
7865                    fidl::Vmo,
7866                    { fidl::ObjectType::VMO.into_raw() },
7867                    2147483648,
7868                > as fidl::encoding::TypeMarker>::inline_size(
7869                    decoder.context
7870                );
7871                if inlined != (member_inline_size <= 4) {
7872                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7873                }
7874                let inner_offset;
7875                let mut inner_depth = depth.clone();
7876                if inlined {
7877                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7878                    inner_offset = next_offset;
7879                } else {
7880                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7881                    inner_depth.increment()?;
7882                }
7883                let val_ref =
7884                self.first_vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7885                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7886                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7887                {
7888                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7889                }
7890                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7891                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7892                }
7893            }
7894
7895            next_offset += envelope_size;
7896            _next_ordinal_to_read += 1;
7897            if next_offset >= end_offset {
7898                return Ok(());
7899            }
7900
7901            // Decode unknown envelopes for gaps in ordinals.
7902            while _next_ordinal_to_read < 2 {
7903                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7904                _next_ordinal_to_read += 1;
7905                next_offset += envelope_size;
7906            }
7907
7908            let next_out_of_line = decoder.next_out_of_line();
7909            let handles_before = decoder.remaining_handles();
7910            if let Some((inlined, num_bytes, num_handles)) =
7911                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7912            {
7913                let member_inline_size =
7914                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
7915                if inlined != (member_inline_size <= 4) {
7916                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7917                }
7918                let inner_offset;
7919                let mut inner_depth = depth.clone();
7920                if inlined {
7921                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7922                    inner_offset = next_offset;
7923                } else {
7924                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7925                    inner_depth.increment()?;
7926                }
7927                let val_ref = self.first_offset.get_or_insert_with(|| {
7928                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
7929                });
7930                fidl::decode!(
7931                    u64,
7932                    fidl::encoding::DefaultFuchsiaResourceDialect,
7933                    val_ref,
7934                    decoder,
7935                    inner_offset,
7936                    inner_depth
7937                )?;
7938                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7939                {
7940                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7941                }
7942                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7943                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7944                }
7945            }
7946
7947            next_offset += envelope_size;
7948            _next_ordinal_to_read += 1;
7949            if next_offset >= end_offset {
7950                return Ok(());
7951            }
7952
7953            // Decode unknown envelopes for gaps in ordinals.
7954            while _next_ordinal_to_read < 3 {
7955                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
7956                _next_ordinal_to_read += 1;
7957                next_offset += envelope_size;
7958            }
7959
7960            let next_out_of_line = decoder.next_out_of_line();
7961            let handles_before = decoder.remaining_handles();
7962            if let Some((inlined, num_bytes, num_handles)) =
7963                fidl::encoding::decode_envelope_header(decoder, next_offset)?
7964            {
7965                let member_inline_size = <fidl::encoding::HandleType<
7966                    fidl::Vmo,
7967                    { fidl::ObjectType::VMO.into_raw() },
7968                    2147483648,
7969                > as fidl::encoding::TypeMarker>::inline_size(
7970                    decoder.context
7971                );
7972                if inlined != (member_inline_size <= 4) {
7973                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
7974                }
7975                let inner_offset;
7976                let mut inner_depth = depth.clone();
7977                if inlined {
7978                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
7979                    inner_offset = next_offset;
7980                } else {
7981                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
7982                    inner_depth.increment()?;
7983                }
7984                let val_ref =
7985                self.second_vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
7986                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
7987                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
7988                {
7989                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
7990                }
7991                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
7992                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
7993                }
7994            }
7995
7996            next_offset += envelope_size;
7997            _next_ordinal_to_read += 1;
7998            if next_offset >= end_offset {
7999                return Ok(());
8000            }
8001
8002            // Decode unknown envelopes for gaps in ordinals.
8003            while _next_ordinal_to_read < 4 {
8004                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8005                _next_ordinal_to_read += 1;
8006                next_offset += envelope_size;
8007            }
8008
8009            let next_out_of_line = decoder.next_out_of_line();
8010            let handles_before = decoder.remaining_handles();
8011            if let Some((inlined, num_bytes, num_handles)) =
8012                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8013            {
8014                let member_inline_size =
8015                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8016                if inlined != (member_inline_size <= 4) {
8017                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8018                }
8019                let inner_offset;
8020                let mut inner_depth = depth.clone();
8021                if inlined {
8022                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8023                    inner_offset = next_offset;
8024                } else {
8025                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8026                    inner_depth.increment()?;
8027                }
8028                let val_ref = self.second_offset.get_or_insert_with(|| {
8029                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8030                });
8031                fidl::decode!(
8032                    u64,
8033                    fidl::encoding::DefaultFuchsiaResourceDialect,
8034                    val_ref,
8035                    decoder,
8036                    inner_offset,
8037                    inner_depth
8038                )?;
8039                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8040                {
8041                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8042                }
8043                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8044                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8045                }
8046            }
8047
8048            next_offset += envelope_size;
8049            _next_ordinal_to_read += 1;
8050            if next_offset >= end_offset {
8051                return Ok(());
8052            }
8053
8054            // Decode unknown envelopes for gaps in ordinals.
8055            while _next_ordinal_to_read < 5 {
8056                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8057                _next_ordinal_to_read += 1;
8058                next_offset += envelope_size;
8059            }
8060
8061            let next_out_of_line = decoder.next_out_of_line();
8062            let handles_before = decoder.remaining_handles();
8063            if let Some((inlined, num_bytes, num_handles)) =
8064                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8065            {
8066                let member_inline_size =
8067                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8068                if inlined != (member_inline_size <= 4) {
8069                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8070                }
8071                let inner_offset;
8072                let mut inner_depth = depth.clone();
8073                if inlined {
8074                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8075                    inner_offset = next_offset;
8076                } else {
8077                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8078                    inner_depth.increment()?;
8079                }
8080                let val_ref = self.wake_count.get_or_insert_with(|| {
8081                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
8082                });
8083                fidl::decode!(
8084                    u32,
8085                    fidl::encoding::DefaultFuchsiaResourceDialect,
8086                    val_ref,
8087                    decoder,
8088                    inner_offset,
8089                    inner_depth
8090                )?;
8091                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8092                {
8093                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8094                }
8095                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8096                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8097                }
8098            }
8099
8100            next_offset += envelope_size;
8101            _next_ordinal_to_read += 1;
8102            if next_offset >= end_offset {
8103                return Ok(());
8104            }
8105
8106            // Decode unknown envelopes for gaps in ordinals.
8107            while _next_ordinal_to_read < 6 {
8108                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8109                _next_ordinal_to_read += 1;
8110                next_offset += envelope_size;
8111            }
8112
8113            let next_out_of_line = decoder.next_out_of_line();
8114            let handles_before = decoder.remaining_handles();
8115            if let Some((inlined, num_bytes, num_handles)) =
8116                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8117            {
8118                let member_inline_size =
8119                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8120                if inlined != (member_inline_size <= 4) {
8121                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8122                }
8123                let inner_offset;
8124                let mut inner_depth = depth.clone();
8125                if inlined {
8126                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8127                    inner_offset = next_offset;
8128                } else {
8129                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8130                    inner_depth.increment()?;
8131                }
8132                let val_ref = self.requeue_count.get_or_insert_with(|| {
8133                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
8134                });
8135                fidl::decode!(
8136                    u32,
8137                    fidl::encoding::DefaultFuchsiaResourceDialect,
8138                    val_ref,
8139                    decoder,
8140                    inner_offset,
8141                    inner_depth
8142                )?;
8143                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8144                {
8145                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8146                }
8147                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8148                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8149                }
8150            }
8151
8152            next_offset += envelope_size;
8153            _next_ordinal_to_read += 1;
8154            if next_offset >= end_offset {
8155                return Ok(());
8156            }
8157
8158            // Decode unknown envelopes for gaps in ordinals.
8159            while _next_ordinal_to_read < 7 {
8160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8161                _next_ordinal_to_read += 1;
8162                next_offset += envelope_size;
8163            }
8164
8165            let next_out_of_line = decoder.next_out_of_line();
8166            let handles_before = decoder.remaining_handles();
8167            if let Some((inlined, num_bytes, num_handles)) =
8168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8169            {
8170                let member_inline_size =
8171                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8172                if inlined != (member_inline_size <= 4) {
8173                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8174                }
8175                let inner_offset;
8176                let mut inner_depth = depth.clone();
8177                if inlined {
8178                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8179                    inner_offset = next_offset;
8180                } else {
8181                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8182                    inner_depth.increment()?;
8183                }
8184                let val_ref = self.cmp_val.get_or_insert_with(|| {
8185                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
8186                });
8187                fidl::decode!(
8188                    u32,
8189                    fidl::encoding::DefaultFuchsiaResourceDialect,
8190                    val_ref,
8191                    decoder,
8192                    inner_offset,
8193                    inner_depth
8194                )?;
8195                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8196                {
8197                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8198                }
8199                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8200                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8201                }
8202            }
8203
8204            next_offset += envelope_size;
8205
8206            // Decode the remaining unknown envelopes.
8207            while next_offset < end_offset {
8208                _next_ordinal_to_read += 1;
8209                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8210                next_offset += envelope_size;
8211            }
8212
8213            Ok(())
8214        }
8215    }
8216
8217    impl CmpRequeueResponse {
8218        #[inline(always)]
8219        fn max_ordinal_present(&self) -> u64 {
8220            if let Some(_) = self.count {
8221                return 1;
8222            }
8223            0
8224        }
8225    }
8226
8227    impl fidl::encoding::ResourceTypeMarker for CmpRequeueResponse {
8228        type Borrowed<'a> = &'a mut Self;
8229        fn take_or_borrow<'a>(
8230            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8231        ) -> Self::Borrowed<'a> {
8232            value
8233        }
8234    }
8235
8236    unsafe impl fidl::encoding::TypeMarker for CmpRequeueResponse {
8237        type Owned = Self;
8238
8239        #[inline(always)]
8240        fn inline_align(_context: fidl::encoding::Context) -> usize {
8241            8
8242        }
8243
8244        #[inline(always)]
8245        fn inline_size(_context: fidl::encoding::Context) -> usize {
8246            16
8247        }
8248    }
8249
8250    unsafe impl
8251        fidl::encoding::Encode<CmpRequeueResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
8252        for &mut CmpRequeueResponse
8253    {
8254        unsafe fn encode(
8255            self,
8256            encoder: &mut fidl::encoding::Encoder<
8257                '_,
8258                fidl::encoding::DefaultFuchsiaResourceDialect,
8259            >,
8260            offset: usize,
8261            mut depth: fidl::encoding::Depth,
8262        ) -> fidl::Result<()> {
8263            encoder.debug_check_bounds::<CmpRequeueResponse>(offset);
8264            // Vector header
8265            let max_ordinal: u64 = self.max_ordinal_present();
8266            encoder.write_num(max_ordinal, offset);
8267            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8268            // Calling encoder.out_of_line_offset(0) is not allowed.
8269            if max_ordinal == 0 {
8270                return Ok(());
8271            }
8272            depth.increment()?;
8273            let envelope_size = 8;
8274            let bytes_len = max_ordinal as usize * envelope_size;
8275            #[allow(unused_variables)]
8276            let offset = encoder.out_of_line_offset(bytes_len);
8277            let mut _prev_end_offset: usize = 0;
8278            if 1 > max_ordinal {
8279                return Ok(());
8280            }
8281
8282            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8283            // are envelope_size bytes.
8284            let cur_offset: usize = (1 - 1) * envelope_size;
8285
8286            // Zero reserved fields.
8287            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8288
8289            // Safety:
8290            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8291            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8292            //   envelope_size bytes, there is always sufficient room.
8293            fidl::encoding::encode_in_envelope_optional::<
8294                u64,
8295                fidl::encoding::DefaultFuchsiaResourceDialect,
8296            >(
8297                self.count.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
8298                encoder,
8299                offset + cur_offset,
8300                depth,
8301            )?;
8302
8303            _prev_end_offset = cur_offset + envelope_size;
8304
8305            Ok(())
8306        }
8307    }
8308
8309    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8310        for CmpRequeueResponse
8311    {
8312        #[inline(always)]
8313        fn new_empty() -> Self {
8314            Self::default()
8315        }
8316
8317        unsafe fn decode(
8318            &mut self,
8319            decoder: &mut fidl::encoding::Decoder<
8320                '_,
8321                fidl::encoding::DefaultFuchsiaResourceDialect,
8322            >,
8323            offset: usize,
8324            mut depth: fidl::encoding::Depth,
8325        ) -> fidl::Result<()> {
8326            decoder.debug_check_bounds::<Self>(offset);
8327            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8328                None => return Err(fidl::Error::NotNullable),
8329                Some(len) => len,
8330            };
8331            // Calling decoder.out_of_line_offset(0) is not allowed.
8332            if len == 0 {
8333                return Ok(());
8334            };
8335            depth.increment()?;
8336            let envelope_size = 8;
8337            let bytes_len = len * envelope_size;
8338            let offset = decoder.out_of_line_offset(bytes_len)?;
8339            // Decode the envelope for each type.
8340            let mut _next_ordinal_to_read = 0;
8341            let mut next_offset = offset;
8342            let end_offset = offset + bytes_len;
8343            _next_ordinal_to_read += 1;
8344            if next_offset >= end_offset {
8345                return Ok(());
8346            }
8347
8348            // Decode unknown envelopes for gaps in ordinals.
8349            while _next_ordinal_to_read < 1 {
8350                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8351                _next_ordinal_to_read += 1;
8352                next_offset += envelope_size;
8353            }
8354
8355            let next_out_of_line = decoder.next_out_of_line();
8356            let handles_before = decoder.remaining_handles();
8357            if let Some((inlined, num_bytes, num_handles)) =
8358                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8359            {
8360                let member_inline_size =
8361                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
8362                if inlined != (member_inline_size <= 4) {
8363                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8364                }
8365                let inner_offset;
8366                let mut inner_depth = depth.clone();
8367                if inlined {
8368                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8369                    inner_offset = next_offset;
8370                } else {
8371                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8372                    inner_depth.increment()?;
8373                }
8374                let val_ref = self.count.get_or_insert_with(|| {
8375                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
8376                });
8377                fidl::decode!(
8378                    u64,
8379                    fidl::encoding::DefaultFuchsiaResourceDialect,
8380                    val_ref,
8381                    decoder,
8382                    inner_offset,
8383                    inner_depth
8384                )?;
8385                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8386                {
8387                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8388                }
8389                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8390                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8391                }
8392            }
8393
8394            next_offset += envelope_size;
8395
8396            // Decode the remaining unknown envelopes.
8397            while next_offset < end_offset {
8398                _next_ordinal_to_read += 1;
8399                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8400                next_offset += envelope_size;
8401            }
8402
8403            Ok(())
8404        }
8405    }
8406
8407    impl ContainerPowerControllerRegisterWakeWatcherRequest {
8408        #[inline(always)]
8409        fn max_ordinal_present(&self) -> u64 {
8410            if let Some(_) = self.watcher {
8411                return 1;
8412            }
8413            0
8414        }
8415    }
8416
8417    impl fidl::encoding::ResourceTypeMarker for ContainerPowerControllerRegisterWakeWatcherRequest {
8418        type Borrowed<'a> = &'a mut Self;
8419        fn take_or_borrow<'a>(
8420            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8421        ) -> Self::Borrowed<'a> {
8422            value
8423        }
8424    }
8425
8426    unsafe impl fidl::encoding::TypeMarker for ContainerPowerControllerRegisterWakeWatcherRequest {
8427        type Owned = Self;
8428
8429        #[inline(always)]
8430        fn inline_align(_context: fidl::encoding::Context) -> usize {
8431            8
8432        }
8433
8434        #[inline(always)]
8435        fn inline_size(_context: fidl::encoding::Context) -> usize {
8436            16
8437        }
8438    }
8439
8440    unsafe impl
8441        fidl::encoding::Encode<
8442            ContainerPowerControllerRegisterWakeWatcherRequest,
8443            fidl::encoding::DefaultFuchsiaResourceDialect,
8444        > for &mut ContainerPowerControllerRegisterWakeWatcherRequest
8445    {
8446        unsafe fn encode(
8447            self,
8448            encoder: &mut fidl::encoding::Encoder<
8449                '_,
8450                fidl::encoding::DefaultFuchsiaResourceDialect,
8451            >,
8452            offset: usize,
8453            mut depth: fidl::encoding::Depth,
8454        ) -> fidl::Result<()> {
8455            encoder
8456                .debug_check_bounds::<ContainerPowerControllerRegisterWakeWatcherRequest>(offset);
8457            // Vector header
8458            let max_ordinal: u64 = self.max_ordinal_present();
8459            encoder.write_num(max_ordinal, offset);
8460            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8461            // Calling encoder.out_of_line_offset(0) is not allowed.
8462            if max_ordinal == 0 {
8463                return Ok(());
8464            }
8465            depth.increment()?;
8466            let envelope_size = 8;
8467            let bytes_len = max_ordinal as usize * envelope_size;
8468            #[allow(unused_variables)]
8469            let offset = encoder.out_of_line_offset(bytes_len);
8470            let mut _prev_end_offset: usize = 0;
8471            if 1 > max_ordinal {
8472                return Ok(());
8473            }
8474
8475            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8476            // are envelope_size bytes.
8477            let cur_offset: usize = (1 - 1) * envelope_size;
8478
8479            // Zero reserved fields.
8480            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8481
8482            // Safety:
8483            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8484            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8485            //   envelope_size bytes, there is always sufficient room.
8486            fidl::encoding::encode_in_envelope_optional::<
8487                fidl::encoding::HandleType<
8488                    fidl::EventPair,
8489                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8490                    2147483648,
8491                >,
8492                fidl::encoding::DefaultFuchsiaResourceDialect,
8493            >(
8494                self.watcher.as_mut().map(
8495                    <fidl::encoding::HandleType<
8496                        fidl::EventPair,
8497                        { fidl::ObjectType::EVENTPAIR.into_raw() },
8498                        2147483648,
8499                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8500                ),
8501                encoder,
8502                offset + cur_offset,
8503                depth,
8504            )?;
8505
8506            _prev_end_offset = cur_offset + envelope_size;
8507
8508            Ok(())
8509        }
8510    }
8511
8512    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8513        for ContainerPowerControllerRegisterWakeWatcherRequest
8514    {
8515        #[inline(always)]
8516        fn new_empty() -> Self {
8517            Self::default()
8518        }
8519
8520        unsafe fn decode(
8521            &mut self,
8522            decoder: &mut fidl::encoding::Decoder<
8523                '_,
8524                fidl::encoding::DefaultFuchsiaResourceDialect,
8525            >,
8526            offset: usize,
8527            mut depth: fidl::encoding::Depth,
8528        ) -> fidl::Result<()> {
8529            decoder.debug_check_bounds::<Self>(offset);
8530            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8531                None => return Err(fidl::Error::NotNullable),
8532                Some(len) => len,
8533            };
8534            // Calling decoder.out_of_line_offset(0) is not allowed.
8535            if len == 0 {
8536                return Ok(());
8537            };
8538            depth.increment()?;
8539            let envelope_size = 8;
8540            let bytes_len = len * envelope_size;
8541            let offset = decoder.out_of_line_offset(bytes_len)?;
8542            // Decode the envelope for each type.
8543            let mut _next_ordinal_to_read = 0;
8544            let mut next_offset = offset;
8545            let end_offset = offset + bytes_len;
8546            _next_ordinal_to_read += 1;
8547            if next_offset >= end_offset {
8548                return Ok(());
8549            }
8550
8551            // Decode unknown envelopes for gaps in ordinals.
8552            while _next_ordinal_to_read < 1 {
8553                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8554                _next_ordinal_to_read += 1;
8555                next_offset += envelope_size;
8556            }
8557
8558            let next_out_of_line = decoder.next_out_of_line();
8559            let handles_before = decoder.remaining_handles();
8560            if let Some((inlined, num_bytes, num_handles)) =
8561                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8562            {
8563                let member_inline_size = <fidl::encoding::HandleType<
8564                    fidl::EventPair,
8565                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8566                    2147483648,
8567                > as fidl::encoding::TypeMarker>::inline_size(
8568                    decoder.context
8569                );
8570                if inlined != (member_inline_size <= 4) {
8571                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8572                }
8573                let inner_offset;
8574                let mut inner_depth = depth.clone();
8575                if inlined {
8576                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8577                    inner_offset = next_offset;
8578                } else {
8579                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8580                    inner_depth.increment()?;
8581                }
8582                let val_ref =
8583                self.watcher.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8584                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8585                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8586                {
8587                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8588                }
8589                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8590                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8591                }
8592            }
8593
8594            next_offset += envelope_size;
8595
8596            // Decode the remaining unknown envelopes.
8597            while next_offset < end_offset {
8598                _next_ordinal_to_read += 1;
8599                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8600                next_offset += envelope_size;
8601            }
8602
8603            Ok(())
8604        }
8605    }
8606
8607    impl ContainerPowerControllerWakeRequest {
8608        #[inline(always)]
8609        fn max_ordinal_present(&self) -> u64 {
8610            if let Some(_) = self.wake_lock {
8611                return 2;
8612            }
8613            if let Some(_) = self.power_baton {
8614                return 1;
8615            }
8616            0
8617        }
8618    }
8619
8620    impl fidl::encoding::ResourceTypeMarker for ContainerPowerControllerWakeRequest {
8621        type Borrowed<'a> = &'a mut Self;
8622        fn take_or_borrow<'a>(
8623            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8624        ) -> Self::Borrowed<'a> {
8625            value
8626        }
8627    }
8628
8629    unsafe impl fidl::encoding::TypeMarker for ContainerPowerControllerWakeRequest {
8630        type Owned = Self;
8631
8632        #[inline(always)]
8633        fn inline_align(_context: fidl::encoding::Context) -> usize {
8634            8
8635        }
8636
8637        #[inline(always)]
8638        fn inline_size(_context: fidl::encoding::Context) -> usize {
8639            16
8640        }
8641    }
8642
8643    unsafe impl
8644        fidl::encoding::Encode<
8645            ContainerPowerControllerWakeRequest,
8646            fidl::encoding::DefaultFuchsiaResourceDialect,
8647        > for &mut ContainerPowerControllerWakeRequest
8648    {
8649        unsafe fn encode(
8650            self,
8651            encoder: &mut fidl::encoding::Encoder<
8652                '_,
8653                fidl::encoding::DefaultFuchsiaResourceDialect,
8654            >,
8655            offset: usize,
8656            mut depth: fidl::encoding::Depth,
8657        ) -> fidl::Result<()> {
8658            encoder.debug_check_bounds::<ContainerPowerControllerWakeRequest>(offset);
8659            // Vector header
8660            let max_ordinal: u64 = self.max_ordinal_present();
8661            encoder.write_num(max_ordinal, offset);
8662            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8663            // Calling encoder.out_of_line_offset(0) is not allowed.
8664            if max_ordinal == 0 {
8665                return Ok(());
8666            }
8667            depth.increment()?;
8668            let envelope_size = 8;
8669            let bytes_len = max_ordinal as usize * envelope_size;
8670            #[allow(unused_variables)]
8671            let offset = encoder.out_of_line_offset(bytes_len);
8672            let mut _prev_end_offset: usize = 0;
8673            if 1 > max_ordinal {
8674                return Ok(());
8675            }
8676
8677            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8678            // are envelope_size bytes.
8679            let cur_offset: usize = (1 - 1) * envelope_size;
8680
8681            // Zero reserved fields.
8682            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8683
8684            // Safety:
8685            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8686            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8687            //   envelope_size bytes, there is always sufficient room.
8688            fidl::encoding::encode_in_envelope_optional::<
8689                fidl::encoding::HandleType<
8690                    fidl::NullableHandle,
8691                    { fidl::ObjectType::NONE.into_raw() },
8692                    2147483648,
8693                >,
8694                fidl::encoding::DefaultFuchsiaResourceDialect,
8695            >(
8696                self.power_baton.as_mut().map(
8697                    <fidl::encoding::HandleType<
8698                        fidl::NullableHandle,
8699                        { fidl::ObjectType::NONE.into_raw() },
8700                        2147483648,
8701                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8702                ),
8703                encoder,
8704                offset + cur_offset,
8705                depth,
8706            )?;
8707
8708            _prev_end_offset = cur_offset + envelope_size;
8709            if 2 > max_ordinal {
8710                return Ok(());
8711            }
8712
8713            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8714            // are envelope_size bytes.
8715            let cur_offset: usize = (2 - 1) * envelope_size;
8716
8717            // Zero reserved fields.
8718            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8719
8720            // Safety:
8721            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8722            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8723            //   envelope_size bytes, there is always sufficient room.
8724            fidl::encoding::encode_in_envelope_optional::<
8725                fidl::encoding::HandleType<
8726                    fidl::EventPair,
8727                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8728                    2147483648,
8729                >,
8730                fidl::encoding::DefaultFuchsiaResourceDialect,
8731            >(
8732                self.wake_lock.as_mut().map(
8733                    <fidl::encoding::HandleType<
8734                        fidl::EventPair,
8735                        { fidl::ObjectType::EVENTPAIR.into_raw() },
8736                        2147483648,
8737                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
8738                ),
8739                encoder,
8740                offset + cur_offset,
8741                depth,
8742            )?;
8743
8744            _prev_end_offset = cur_offset + envelope_size;
8745
8746            Ok(())
8747        }
8748    }
8749
8750    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8751        for ContainerPowerControllerWakeRequest
8752    {
8753        #[inline(always)]
8754        fn new_empty() -> Self {
8755            Self::default()
8756        }
8757
8758        unsafe fn decode(
8759            &mut self,
8760            decoder: &mut fidl::encoding::Decoder<
8761                '_,
8762                fidl::encoding::DefaultFuchsiaResourceDialect,
8763            >,
8764            offset: usize,
8765            mut depth: fidl::encoding::Depth,
8766        ) -> fidl::Result<()> {
8767            decoder.debug_check_bounds::<Self>(offset);
8768            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
8769                None => return Err(fidl::Error::NotNullable),
8770                Some(len) => len,
8771            };
8772            // Calling decoder.out_of_line_offset(0) is not allowed.
8773            if len == 0 {
8774                return Ok(());
8775            };
8776            depth.increment()?;
8777            let envelope_size = 8;
8778            let bytes_len = len * envelope_size;
8779            let offset = decoder.out_of_line_offset(bytes_len)?;
8780            // Decode the envelope for each type.
8781            let mut _next_ordinal_to_read = 0;
8782            let mut next_offset = offset;
8783            let end_offset = offset + bytes_len;
8784            _next_ordinal_to_read += 1;
8785            if next_offset >= end_offset {
8786                return Ok(());
8787            }
8788
8789            // Decode unknown envelopes for gaps in ordinals.
8790            while _next_ordinal_to_read < 1 {
8791                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8792                _next_ordinal_to_read += 1;
8793                next_offset += envelope_size;
8794            }
8795
8796            let next_out_of_line = decoder.next_out_of_line();
8797            let handles_before = decoder.remaining_handles();
8798            if let Some((inlined, num_bytes, num_handles)) =
8799                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8800            {
8801                let member_inline_size = <fidl::encoding::HandleType<
8802                    fidl::NullableHandle,
8803                    { fidl::ObjectType::NONE.into_raw() },
8804                    2147483648,
8805                > as fidl::encoding::TypeMarker>::inline_size(
8806                    decoder.context
8807                );
8808                if inlined != (member_inline_size <= 4) {
8809                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8810                }
8811                let inner_offset;
8812                let mut inner_depth = depth.clone();
8813                if inlined {
8814                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8815                    inner_offset = next_offset;
8816                } else {
8817                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8818                    inner_depth.increment()?;
8819                }
8820                let val_ref =
8821                self.power_baton.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8822                fidl::decode!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8823                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8824                {
8825                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8826                }
8827                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8828                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8829                }
8830            }
8831
8832            next_offset += envelope_size;
8833            _next_ordinal_to_read += 1;
8834            if next_offset >= end_offset {
8835                return Ok(());
8836            }
8837
8838            // Decode unknown envelopes for gaps in ordinals.
8839            while _next_ordinal_to_read < 2 {
8840                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8841                _next_ordinal_to_read += 1;
8842                next_offset += envelope_size;
8843            }
8844
8845            let next_out_of_line = decoder.next_out_of_line();
8846            let handles_before = decoder.remaining_handles();
8847            if let Some((inlined, num_bytes, num_handles)) =
8848                fidl::encoding::decode_envelope_header(decoder, next_offset)?
8849            {
8850                let member_inline_size = <fidl::encoding::HandleType<
8851                    fidl::EventPair,
8852                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8853                    2147483648,
8854                > as fidl::encoding::TypeMarker>::inline_size(
8855                    decoder.context
8856                );
8857                if inlined != (member_inline_size <= 4) {
8858                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
8859                }
8860                let inner_offset;
8861                let mut inner_depth = depth.clone();
8862                if inlined {
8863                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
8864                    inner_offset = next_offset;
8865                } else {
8866                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
8867                    inner_depth.increment()?;
8868                }
8869                let val_ref =
8870                self.wake_lock.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
8871                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
8872                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
8873                {
8874                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
8875                }
8876                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
8877                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
8878                }
8879            }
8880
8881            next_offset += envelope_size;
8882
8883            // Decode the remaining unknown envelopes.
8884            while next_offset < end_offset {
8885                _next_ordinal_to_read += 1;
8886                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
8887                next_offset += envelope_size;
8888            }
8889
8890            Ok(())
8891        }
8892    }
8893
8894    impl DevBinderCloseRequest {
8895        #[inline(always)]
8896        fn max_ordinal_present(&self) -> u64 {
8897            if let Some(_) = self.binder {
8898                return 1;
8899            }
8900            0
8901        }
8902    }
8903
8904    impl fidl::encoding::ResourceTypeMarker for DevBinderCloseRequest {
8905        type Borrowed<'a> = &'a mut Self;
8906        fn take_or_borrow<'a>(
8907            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8908        ) -> Self::Borrowed<'a> {
8909            value
8910        }
8911    }
8912
8913    unsafe impl fidl::encoding::TypeMarker for DevBinderCloseRequest {
8914        type Owned = Self;
8915
8916        #[inline(always)]
8917        fn inline_align(_context: fidl::encoding::Context) -> usize {
8918            8
8919        }
8920
8921        #[inline(always)]
8922        fn inline_size(_context: fidl::encoding::Context) -> usize {
8923            16
8924        }
8925    }
8926
8927    unsafe impl
8928        fidl::encoding::Encode<DevBinderCloseRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
8929        for &mut DevBinderCloseRequest
8930    {
8931        unsafe fn encode(
8932            self,
8933            encoder: &mut fidl::encoding::Encoder<
8934                '_,
8935                fidl::encoding::DefaultFuchsiaResourceDialect,
8936            >,
8937            offset: usize,
8938            mut depth: fidl::encoding::Depth,
8939        ) -> fidl::Result<()> {
8940            encoder.debug_check_bounds::<DevBinderCloseRequest>(offset);
8941            // Vector header
8942            let max_ordinal: u64 = self.max_ordinal_present();
8943            encoder.write_num(max_ordinal, offset);
8944            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
8945            // Calling encoder.out_of_line_offset(0) is not allowed.
8946            if max_ordinal == 0 {
8947                return Ok(());
8948            }
8949            depth.increment()?;
8950            let envelope_size = 8;
8951            let bytes_len = max_ordinal as usize * envelope_size;
8952            #[allow(unused_variables)]
8953            let offset = encoder.out_of_line_offset(bytes_len);
8954            let mut _prev_end_offset: usize = 0;
8955            if 1 > max_ordinal {
8956                return Ok(());
8957            }
8958
8959            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
8960            // are envelope_size bytes.
8961            let cur_offset: usize = (1 - 1) * envelope_size;
8962
8963            // Zero reserved fields.
8964            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
8965
8966            // Safety:
8967            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
8968            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
8969            //   envelope_size bytes, there is always sufficient room.
8970            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BinderMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
8971            self.binder.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BinderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
8972            encoder, offset + cur_offset, depth
8973        )?;
8974
8975            _prev_end_offset = cur_offset + envelope_size;
8976
8977            Ok(())
8978        }
8979    }
8980
8981    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8982        for DevBinderCloseRequest
8983    {
8984        #[inline(always)]
8985        fn new_empty() -> Self {
8986            Self::default()
8987        }
8988
8989        unsafe fn decode(
8990            &mut self,
8991            decoder: &mut fidl::encoding::Decoder<
8992                '_,
8993                fidl::encoding::DefaultFuchsiaResourceDialect,
8994            >,
8995            offset: usize,
8996            mut depth: fidl::encoding::Depth,
8997        ) -> fidl::Result<()> {
8998            decoder.debug_check_bounds::<Self>(offset);
8999            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9000                None => return Err(fidl::Error::NotNullable),
9001                Some(len) => len,
9002            };
9003            // Calling decoder.out_of_line_offset(0) is not allowed.
9004            if len == 0 {
9005                return Ok(());
9006            };
9007            depth.increment()?;
9008            let envelope_size = 8;
9009            let bytes_len = len * envelope_size;
9010            let offset = decoder.out_of_line_offset(bytes_len)?;
9011            // Decode the envelope for each type.
9012            let mut _next_ordinal_to_read = 0;
9013            let mut next_offset = offset;
9014            let end_offset = offset + bytes_len;
9015            _next_ordinal_to_read += 1;
9016            if next_offset >= end_offset {
9017                return Ok(());
9018            }
9019
9020            // Decode unknown envelopes for gaps in ordinals.
9021            while _next_ordinal_to_read < 1 {
9022                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9023                _next_ordinal_to_read += 1;
9024                next_offset += envelope_size;
9025            }
9026
9027            let next_out_of_line = decoder.next_out_of_line();
9028            let handles_before = decoder.remaining_handles();
9029            if let Some((inlined, num_bytes, num_handles)) =
9030                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9031            {
9032                let member_inline_size = <fidl::encoding::Endpoint<
9033                    fidl::endpoints::ClientEnd<BinderMarker>,
9034                > as fidl::encoding::TypeMarker>::inline_size(
9035                    decoder.context
9036                );
9037                if inlined != (member_inline_size <= 4) {
9038                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9039                }
9040                let inner_offset;
9041                let mut inner_depth = depth.clone();
9042                if inlined {
9043                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9044                    inner_offset = next_offset;
9045                } else {
9046                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9047                    inner_depth.increment()?;
9048                }
9049                let val_ref = self.binder.get_or_insert_with(|| {
9050                    fidl::new_empty!(
9051                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BinderMarker>>,
9052                        fidl::encoding::DefaultFuchsiaResourceDialect
9053                    )
9054                });
9055                fidl::decode!(
9056                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BinderMarker>>,
9057                    fidl::encoding::DefaultFuchsiaResourceDialect,
9058                    val_ref,
9059                    decoder,
9060                    inner_offset,
9061                    inner_depth
9062                )?;
9063                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9064                {
9065                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9066                }
9067                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9068                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9069                }
9070            }
9071
9072            next_offset += envelope_size;
9073
9074            // Decode the remaining unknown envelopes.
9075            while next_offset < end_offset {
9076                _next_ordinal_to_read += 1;
9077                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9078                next_offset += envelope_size;
9079            }
9080
9081            Ok(())
9082        }
9083    }
9084
9085    impl DevBinderOpenRequest {
9086        #[inline(always)]
9087        fn max_ordinal_present(&self) -> u64 {
9088            if let Some(_) = self.binder {
9089                return 4;
9090            }
9091            if let Some(_) = self.process {
9092                return 3;
9093            }
9094            if let Some(_) = self.process_accessor {
9095                return 2;
9096            }
9097            if let Some(_) = self.path {
9098                return 1;
9099            }
9100            0
9101        }
9102    }
9103
9104    impl fidl::encoding::ResourceTypeMarker for DevBinderOpenRequest {
9105        type Borrowed<'a> = &'a mut Self;
9106        fn take_or_borrow<'a>(
9107            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9108        ) -> Self::Borrowed<'a> {
9109            value
9110        }
9111    }
9112
9113    unsafe impl fidl::encoding::TypeMarker for DevBinderOpenRequest {
9114        type Owned = Self;
9115
9116        #[inline(always)]
9117        fn inline_align(_context: fidl::encoding::Context) -> usize {
9118            8
9119        }
9120
9121        #[inline(always)]
9122        fn inline_size(_context: fidl::encoding::Context) -> usize {
9123            16
9124        }
9125    }
9126
9127    unsafe impl
9128        fidl::encoding::Encode<DevBinderOpenRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
9129        for &mut DevBinderOpenRequest
9130    {
9131        unsafe fn encode(
9132            self,
9133            encoder: &mut fidl::encoding::Encoder<
9134                '_,
9135                fidl::encoding::DefaultFuchsiaResourceDialect,
9136            >,
9137            offset: usize,
9138            mut depth: fidl::encoding::Depth,
9139        ) -> fidl::Result<()> {
9140            encoder.debug_check_bounds::<DevBinderOpenRequest>(offset);
9141            // Vector header
9142            let max_ordinal: u64 = self.max_ordinal_present();
9143            encoder.write_num(max_ordinal, offset);
9144            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9145            // Calling encoder.out_of_line_offset(0) is not allowed.
9146            if max_ordinal == 0 {
9147                return Ok(());
9148            }
9149            depth.increment()?;
9150            let envelope_size = 8;
9151            let bytes_len = max_ordinal as usize * envelope_size;
9152            #[allow(unused_variables)]
9153            let offset = encoder.out_of_line_offset(bytes_len);
9154            let mut _prev_end_offset: usize = 0;
9155            if 1 > max_ordinal {
9156                return Ok(());
9157            }
9158
9159            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9160            // are envelope_size bytes.
9161            let cur_offset: usize = (1 - 1) * envelope_size;
9162
9163            // Zero reserved fields.
9164            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9165
9166            // Safety:
9167            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9168            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9169            //   envelope_size bytes, there is always sufficient room.
9170            fidl::encoding::encode_in_envelope_optional::<
9171                fidl::encoding::Vector<u8, 4095>,
9172                fidl::encoding::DefaultFuchsiaResourceDialect,
9173            >(
9174                self.path.as_ref().map(
9175                    <fidl::encoding::Vector<u8, 4095> as fidl::encoding::ValueTypeMarker>::borrow,
9176                ),
9177                encoder,
9178                offset + cur_offset,
9179                depth,
9180            )?;
9181
9182            _prev_end_offset = cur_offset + envelope_size;
9183            if 2 > max_ordinal {
9184                return Ok(());
9185            }
9186
9187            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9188            // are envelope_size bytes.
9189            let cur_offset: usize = (2 - 1) * envelope_size;
9190
9191            // Zero reserved fields.
9192            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9193
9194            // Safety:
9195            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9196            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9197            //   envelope_size bytes, there is always sufficient room.
9198            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProcessAccessorMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9199            self.process_accessor.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProcessAccessorMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9200            encoder, offset + cur_offset, depth
9201        )?;
9202
9203            _prev_end_offset = cur_offset + envelope_size;
9204            if 3 > max_ordinal {
9205                return Ok(());
9206            }
9207
9208            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9209            // are envelope_size bytes.
9210            let cur_offset: usize = (3 - 1) * envelope_size;
9211
9212            // Zero reserved fields.
9213            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9214
9215            // Safety:
9216            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9217            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9218            //   envelope_size bytes, there is always sufficient room.
9219            fidl::encoding::encode_in_envelope_optional::<
9220                fidl::encoding::HandleType<
9221                    fidl::Process,
9222                    { fidl::ObjectType::PROCESS.into_raw() },
9223                    2147483648,
9224                >,
9225                fidl::encoding::DefaultFuchsiaResourceDialect,
9226            >(
9227                self.process.as_mut().map(
9228                    <fidl::encoding::HandleType<
9229                        fidl::Process,
9230                        { fidl::ObjectType::PROCESS.into_raw() },
9231                        2147483648,
9232                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9233                ),
9234                encoder,
9235                offset + cur_offset,
9236                depth,
9237            )?;
9238
9239            _prev_end_offset = cur_offset + envelope_size;
9240            if 4 > max_ordinal {
9241                return Ok(());
9242            }
9243
9244            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9245            // are envelope_size bytes.
9246            let cur_offset: usize = (4 - 1) * envelope_size;
9247
9248            // Zero reserved fields.
9249            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9250
9251            // Safety:
9252            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9253            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9254            //   envelope_size bytes, there is always sufficient room.
9255            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
9256            self.binder.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
9257            encoder, offset + cur_offset, depth
9258        )?;
9259
9260            _prev_end_offset = cur_offset + envelope_size;
9261
9262            Ok(())
9263        }
9264    }
9265
9266    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9267        for DevBinderOpenRequest
9268    {
9269        #[inline(always)]
9270        fn new_empty() -> Self {
9271            Self::default()
9272        }
9273
9274        unsafe fn decode(
9275            &mut self,
9276            decoder: &mut fidl::encoding::Decoder<
9277                '_,
9278                fidl::encoding::DefaultFuchsiaResourceDialect,
9279            >,
9280            offset: usize,
9281            mut depth: fidl::encoding::Depth,
9282        ) -> fidl::Result<()> {
9283            decoder.debug_check_bounds::<Self>(offset);
9284            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9285                None => return Err(fidl::Error::NotNullable),
9286                Some(len) => len,
9287            };
9288            // Calling decoder.out_of_line_offset(0) is not allowed.
9289            if len == 0 {
9290                return Ok(());
9291            };
9292            depth.increment()?;
9293            let envelope_size = 8;
9294            let bytes_len = len * envelope_size;
9295            let offset = decoder.out_of_line_offset(bytes_len)?;
9296            // Decode the envelope for each type.
9297            let mut _next_ordinal_to_read = 0;
9298            let mut next_offset = offset;
9299            let end_offset = offset + bytes_len;
9300            _next_ordinal_to_read += 1;
9301            if next_offset >= end_offset {
9302                return Ok(());
9303            }
9304
9305            // Decode unknown envelopes for gaps in ordinals.
9306            while _next_ordinal_to_read < 1 {
9307                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9308                _next_ordinal_to_read += 1;
9309                next_offset += envelope_size;
9310            }
9311
9312            let next_out_of_line = decoder.next_out_of_line();
9313            let handles_before = decoder.remaining_handles();
9314            if let Some((inlined, num_bytes, num_handles)) =
9315                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9316            {
9317                let member_inline_size =
9318                    <fidl::encoding::Vector<u8, 4095> as fidl::encoding::TypeMarker>::inline_size(
9319                        decoder.context,
9320                    );
9321                if inlined != (member_inline_size <= 4) {
9322                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9323                }
9324                let inner_offset;
9325                let mut inner_depth = depth.clone();
9326                if inlined {
9327                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9328                    inner_offset = next_offset;
9329                } else {
9330                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9331                    inner_depth.increment()?;
9332                }
9333                let val_ref =
9334                self.path.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 4095>, fidl::encoding::DefaultFuchsiaResourceDialect));
9335                fidl::decode!(fidl::encoding::Vector<u8, 4095>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9336                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9337                {
9338                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9339                }
9340                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9341                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9342                }
9343            }
9344
9345            next_offset += envelope_size;
9346            _next_ordinal_to_read += 1;
9347            if next_offset >= end_offset {
9348                return Ok(());
9349            }
9350
9351            // Decode unknown envelopes for gaps in ordinals.
9352            while _next_ordinal_to_read < 2 {
9353                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9354                _next_ordinal_to_read += 1;
9355                next_offset += envelope_size;
9356            }
9357
9358            let next_out_of_line = decoder.next_out_of_line();
9359            let handles_before = decoder.remaining_handles();
9360            if let Some((inlined, num_bytes, num_handles)) =
9361                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9362            {
9363                let member_inline_size = <fidl::encoding::Endpoint<
9364                    fidl::endpoints::ClientEnd<ProcessAccessorMarker>,
9365                > as fidl::encoding::TypeMarker>::inline_size(
9366                    decoder.context
9367                );
9368                if inlined != (member_inline_size <= 4) {
9369                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9370                }
9371                let inner_offset;
9372                let mut inner_depth = depth.clone();
9373                if inlined {
9374                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9375                    inner_offset = next_offset;
9376                } else {
9377                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9378                    inner_depth.increment()?;
9379                }
9380                let val_ref = self.process_accessor.get_or_insert_with(|| {
9381                    fidl::new_empty!(
9382                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProcessAccessorMarker>>,
9383                        fidl::encoding::DefaultFuchsiaResourceDialect
9384                    )
9385                });
9386                fidl::decode!(
9387                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<ProcessAccessorMarker>>,
9388                    fidl::encoding::DefaultFuchsiaResourceDialect,
9389                    val_ref,
9390                    decoder,
9391                    inner_offset,
9392                    inner_depth
9393                )?;
9394                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9395                {
9396                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9397                }
9398                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9399                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9400                }
9401            }
9402
9403            next_offset += envelope_size;
9404            _next_ordinal_to_read += 1;
9405            if next_offset >= end_offset {
9406                return Ok(());
9407            }
9408
9409            // Decode unknown envelopes for gaps in ordinals.
9410            while _next_ordinal_to_read < 3 {
9411                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9412                _next_ordinal_to_read += 1;
9413                next_offset += envelope_size;
9414            }
9415
9416            let next_out_of_line = decoder.next_out_of_line();
9417            let handles_before = decoder.remaining_handles();
9418            if let Some((inlined, num_bytes, num_handles)) =
9419                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9420            {
9421                let member_inline_size = <fidl::encoding::HandleType<
9422                    fidl::Process,
9423                    { fidl::ObjectType::PROCESS.into_raw() },
9424                    2147483648,
9425                > as fidl::encoding::TypeMarker>::inline_size(
9426                    decoder.context
9427                );
9428                if inlined != (member_inline_size <= 4) {
9429                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9430                }
9431                let inner_offset;
9432                let mut inner_depth = depth.clone();
9433                if inlined {
9434                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9435                    inner_offset = next_offset;
9436                } else {
9437                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9438                    inner_depth.increment()?;
9439                }
9440                let val_ref =
9441                self.process.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9442                fidl::decode!(fidl::encoding::HandleType<fidl::Process, { fidl::ObjectType::PROCESS.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9443                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9444                {
9445                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9446                }
9447                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9448                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9449                }
9450            }
9451
9452            next_offset += envelope_size;
9453            _next_ordinal_to_read += 1;
9454            if next_offset >= end_offset {
9455                return Ok(());
9456            }
9457
9458            // Decode unknown envelopes for gaps in ordinals.
9459            while _next_ordinal_to_read < 4 {
9460                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9461                _next_ordinal_to_read += 1;
9462                next_offset += envelope_size;
9463            }
9464
9465            let next_out_of_line = decoder.next_out_of_line();
9466            let handles_before = decoder.remaining_handles();
9467            if let Some((inlined, num_bytes, num_handles)) =
9468                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9469            {
9470                let member_inline_size = <fidl::encoding::Endpoint<
9471                    fidl::endpoints::ServerEnd<BinderMarker>,
9472                > as fidl::encoding::TypeMarker>::inline_size(
9473                    decoder.context
9474                );
9475                if inlined != (member_inline_size <= 4) {
9476                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9477                }
9478                let inner_offset;
9479                let mut inner_depth = depth.clone();
9480                if inlined {
9481                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9482                    inner_offset = next_offset;
9483                } else {
9484                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9485                    inner_depth.increment()?;
9486                }
9487                let val_ref = self.binder.get_or_insert_with(|| {
9488                    fidl::new_empty!(
9489                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderMarker>>,
9490                        fidl::encoding::DefaultFuchsiaResourceDialect
9491                    )
9492                });
9493                fidl::decode!(
9494                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<BinderMarker>>,
9495                    fidl::encoding::DefaultFuchsiaResourceDialect,
9496                    val_ref,
9497                    decoder,
9498                    inner_offset,
9499                    inner_depth
9500                )?;
9501                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9502                {
9503                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9504                }
9505                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9506                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9507                }
9508            }
9509
9510            next_offset += envelope_size;
9511
9512            // Decode the remaining unknown envelopes.
9513            while next_offset < end_offset {
9514                _next_ordinal_to_read += 1;
9515                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9516                next_offset += envelope_size;
9517            }
9518
9519            Ok(())
9520        }
9521    }
9522
9523    impl FileHandle {
9524        #[inline(always)]
9525        fn max_ordinal_present(&self) -> u64 {
9526            if let Some(_) = self.bag {
9527                return 5;
9528            }
9529            if let Some(_) = self.fd {
9530                return 4;
9531            }
9532            if let Some(_) = self.flags {
9533                return 3;
9534            }
9535            if let Some(_) = self.handle {
9536                return 1;
9537            }
9538            0
9539        }
9540    }
9541
9542    impl fidl::encoding::ResourceTypeMarker for FileHandle {
9543        type Borrowed<'a> = &'a mut Self;
9544        fn take_or_borrow<'a>(
9545            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9546        ) -> Self::Borrowed<'a> {
9547            value
9548        }
9549    }
9550
9551    unsafe impl fidl::encoding::TypeMarker for FileHandle {
9552        type Owned = Self;
9553
9554        #[inline(always)]
9555        fn inline_align(_context: fidl::encoding::Context) -> usize {
9556            8
9557        }
9558
9559        #[inline(always)]
9560        fn inline_size(_context: fidl::encoding::Context) -> usize {
9561            16
9562        }
9563    }
9564
9565    unsafe impl fidl::encoding::Encode<FileHandle, fidl::encoding::DefaultFuchsiaResourceDialect>
9566        for &mut FileHandle
9567    {
9568        unsafe fn encode(
9569            self,
9570            encoder: &mut fidl::encoding::Encoder<
9571                '_,
9572                fidl::encoding::DefaultFuchsiaResourceDialect,
9573            >,
9574            offset: usize,
9575            mut depth: fidl::encoding::Depth,
9576        ) -> fidl::Result<()> {
9577            encoder.debug_check_bounds::<FileHandle>(offset);
9578            // Vector header
9579            let max_ordinal: u64 = self.max_ordinal_present();
9580            encoder.write_num(max_ordinal, offset);
9581            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9582            // Calling encoder.out_of_line_offset(0) is not allowed.
9583            if max_ordinal == 0 {
9584                return Ok(());
9585            }
9586            depth.increment()?;
9587            let envelope_size = 8;
9588            let bytes_len = max_ordinal as usize * envelope_size;
9589            #[allow(unused_variables)]
9590            let offset = encoder.out_of_line_offset(bytes_len);
9591            let mut _prev_end_offset: usize = 0;
9592            if 1 > max_ordinal {
9593                return Ok(());
9594            }
9595
9596            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9597            // are envelope_size bytes.
9598            let cur_offset: usize = (1 - 1) * envelope_size;
9599
9600            // Zero reserved fields.
9601            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9602
9603            // Safety:
9604            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9605            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9606            //   envelope_size bytes, there is always sufficient room.
9607            fidl::encoding::encode_in_envelope_optional::<
9608                fidl::encoding::HandleType<
9609                    fidl::NullableHandle,
9610                    { fidl::ObjectType::NONE.into_raw() },
9611                    2147483648,
9612                >,
9613                fidl::encoding::DefaultFuchsiaResourceDialect,
9614            >(
9615                self.handle.as_mut().map(
9616                    <fidl::encoding::HandleType<
9617                        fidl::NullableHandle,
9618                        { fidl::ObjectType::NONE.into_raw() },
9619                        2147483648,
9620                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9621                ),
9622                encoder,
9623                offset + cur_offset,
9624                depth,
9625            )?;
9626
9627            _prev_end_offset = cur_offset + envelope_size;
9628            if 3 > max_ordinal {
9629                return Ok(());
9630            }
9631
9632            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9633            // are envelope_size bytes.
9634            let cur_offset: usize = (3 - 1) * envelope_size;
9635
9636            // Zero reserved fields.
9637            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9638
9639            // Safety:
9640            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9641            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9642            //   envelope_size bytes, there is always sufficient room.
9643            fidl::encoding::encode_in_envelope_optional::<
9644                FileFlags,
9645                fidl::encoding::DefaultFuchsiaResourceDialect,
9646            >(
9647                self.flags.as_ref().map(<FileFlags as fidl::encoding::ValueTypeMarker>::borrow),
9648                encoder,
9649                offset + cur_offset,
9650                depth,
9651            )?;
9652
9653            _prev_end_offset = cur_offset + envelope_size;
9654            if 4 > max_ordinal {
9655                return Ok(());
9656            }
9657
9658            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9659            // are envelope_size bytes.
9660            let cur_offset: usize = (4 - 1) * envelope_size;
9661
9662            // Zero reserved fields.
9663            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9664
9665            // Safety:
9666            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9667            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9668            //   envelope_size bytes, there is always sufficient room.
9669            fidl::encoding::encode_in_envelope_optional::<
9670                i32,
9671                fidl::encoding::DefaultFuchsiaResourceDialect,
9672            >(
9673                self.fd.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
9674                encoder,
9675                offset + cur_offset,
9676                depth,
9677            )?;
9678
9679            _prev_end_offset = cur_offset + envelope_size;
9680            if 5 > max_ordinal {
9681                return Ok(());
9682            }
9683
9684            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9685            // are envelope_size bytes.
9686            let cur_offset: usize = (5 - 1) * envelope_size;
9687
9688            // Zero reserved fields.
9689            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9690
9691            // Safety:
9692            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9693            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9694            //   envelope_size bytes, there is always sufficient room.
9695            fidl::encoding::encode_in_envelope_optional::<
9696                fidl::encoding::Vector<
9697                    fidl::encoding::HandleType<
9698                        fidl::NullableHandle,
9699                        { fidl::ObjectType::NONE.into_raw() },
9700                        2147483648,
9701                    >,
9702                    4,
9703                >,
9704                fidl::encoding::DefaultFuchsiaResourceDialect,
9705            >(
9706                self.bag.as_mut().map(
9707                    <fidl::encoding::Vector<
9708                        fidl::encoding::HandleType<
9709                            fidl::NullableHandle,
9710                            { fidl::ObjectType::NONE.into_raw() },
9711                            2147483648,
9712                        >,
9713                        4,
9714                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
9715                ),
9716                encoder,
9717                offset + cur_offset,
9718                depth,
9719            )?;
9720
9721            _prev_end_offset = cur_offset + envelope_size;
9722
9723            Ok(())
9724        }
9725    }
9726
9727    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FileHandle {
9728        #[inline(always)]
9729        fn new_empty() -> Self {
9730            Self::default()
9731        }
9732
9733        unsafe fn decode(
9734            &mut self,
9735            decoder: &mut fidl::encoding::Decoder<
9736                '_,
9737                fidl::encoding::DefaultFuchsiaResourceDialect,
9738            >,
9739            offset: usize,
9740            mut depth: fidl::encoding::Depth,
9741        ) -> fidl::Result<()> {
9742            decoder.debug_check_bounds::<Self>(offset);
9743            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9744                None => return Err(fidl::Error::NotNullable),
9745                Some(len) => len,
9746            };
9747            // Calling decoder.out_of_line_offset(0) is not allowed.
9748            if len == 0 {
9749                return Ok(());
9750            };
9751            depth.increment()?;
9752            let envelope_size = 8;
9753            let bytes_len = len * envelope_size;
9754            let offset = decoder.out_of_line_offset(bytes_len)?;
9755            // Decode the envelope for each type.
9756            let mut _next_ordinal_to_read = 0;
9757            let mut next_offset = offset;
9758            let end_offset = offset + bytes_len;
9759            _next_ordinal_to_read += 1;
9760            if next_offset >= end_offset {
9761                return Ok(());
9762            }
9763
9764            // Decode unknown envelopes for gaps in ordinals.
9765            while _next_ordinal_to_read < 1 {
9766                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9767                _next_ordinal_to_read += 1;
9768                next_offset += envelope_size;
9769            }
9770
9771            let next_out_of_line = decoder.next_out_of_line();
9772            let handles_before = decoder.remaining_handles();
9773            if let Some((inlined, num_bytes, num_handles)) =
9774                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9775            {
9776                let member_inline_size = <fidl::encoding::HandleType<
9777                    fidl::NullableHandle,
9778                    { fidl::ObjectType::NONE.into_raw() },
9779                    2147483648,
9780                > as fidl::encoding::TypeMarker>::inline_size(
9781                    decoder.context
9782                );
9783                if inlined != (member_inline_size <= 4) {
9784                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9785                }
9786                let inner_offset;
9787                let mut inner_depth = depth.clone();
9788                if inlined {
9789                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9790                    inner_offset = next_offset;
9791                } else {
9792                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9793                    inner_depth.increment()?;
9794                }
9795                let val_ref =
9796                self.handle.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
9797                fidl::decode!(fidl::encoding::HandleType<fidl::NullableHandle, { fidl::ObjectType::NONE.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
9798                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9799                {
9800                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9801                }
9802                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9803                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9804                }
9805            }
9806
9807            next_offset += envelope_size;
9808            _next_ordinal_to_read += 1;
9809            if next_offset >= end_offset {
9810                return Ok(());
9811            }
9812
9813            // Decode unknown envelopes for gaps in ordinals.
9814            while _next_ordinal_to_read < 3 {
9815                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9816                _next_ordinal_to_read += 1;
9817                next_offset += envelope_size;
9818            }
9819
9820            let next_out_of_line = decoder.next_out_of_line();
9821            let handles_before = decoder.remaining_handles();
9822            if let Some((inlined, num_bytes, num_handles)) =
9823                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9824            {
9825                let member_inline_size =
9826                    <FileFlags as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9827                if inlined != (member_inline_size <= 4) {
9828                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9829                }
9830                let inner_offset;
9831                let mut inner_depth = depth.clone();
9832                if inlined {
9833                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9834                    inner_offset = next_offset;
9835                } else {
9836                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9837                    inner_depth.increment()?;
9838                }
9839                let val_ref = self.flags.get_or_insert_with(|| {
9840                    fidl::new_empty!(FileFlags, fidl::encoding::DefaultFuchsiaResourceDialect)
9841                });
9842                fidl::decode!(
9843                    FileFlags,
9844                    fidl::encoding::DefaultFuchsiaResourceDialect,
9845                    val_ref,
9846                    decoder,
9847                    inner_offset,
9848                    inner_depth
9849                )?;
9850                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9851                {
9852                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9853                }
9854                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9855                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9856                }
9857            }
9858
9859            next_offset += envelope_size;
9860            _next_ordinal_to_read += 1;
9861            if next_offset >= end_offset {
9862                return Ok(());
9863            }
9864
9865            // Decode unknown envelopes for gaps in ordinals.
9866            while _next_ordinal_to_read < 4 {
9867                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9868                _next_ordinal_to_read += 1;
9869                next_offset += envelope_size;
9870            }
9871
9872            let next_out_of_line = decoder.next_out_of_line();
9873            let handles_before = decoder.remaining_handles();
9874            if let Some((inlined, num_bytes, num_handles)) =
9875                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9876            {
9877                let member_inline_size =
9878                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9879                if inlined != (member_inline_size <= 4) {
9880                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9881                }
9882                let inner_offset;
9883                let mut inner_depth = depth.clone();
9884                if inlined {
9885                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9886                    inner_offset = next_offset;
9887                } else {
9888                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9889                    inner_depth.increment()?;
9890                }
9891                let val_ref = self.fd.get_or_insert_with(|| {
9892                    fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect)
9893                });
9894                fidl::decode!(
9895                    i32,
9896                    fidl::encoding::DefaultFuchsiaResourceDialect,
9897                    val_ref,
9898                    decoder,
9899                    inner_offset,
9900                    inner_depth
9901                )?;
9902                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9903                {
9904                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9905                }
9906                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9907                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9908                }
9909            }
9910
9911            next_offset += envelope_size;
9912            _next_ordinal_to_read += 1;
9913            if next_offset >= end_offset {
9914                return Ok(());
9915            }
9916
9917            // Decode unknown envelopes for gaps in ordinals.
9918            while _next_ordinal_to_read < 5 {
9919                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9920                _next_ordinal_to_read += 1;
9921                next_offset += envelope_size;
9922            }
9923
9924            let next_out_of_line = decoder.next_out_of_line();
9925            let handles_before = decoder.remaining_handles();
9926            if let Some((inlined, num_bytes, num_handles)) =
9927                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9928            {
9929                let member_inline_size = <fidl::encoding::Vector<
9930                    fidl::encoding::HandleType<
9931                        fidl::NullableHandle,
9932                        { fidl::ObjectType::NONE.into_raw() },
9933                        2147483648,
9934                    >,
9935                    4,
9936                > as fidl::encoding::TypeMarker>::inline_size(
9937                    decoder.context
9938                );
9939                if inlined != (member_inline_size <= 4) {
9940                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9941                }
9942                let inner_offset;
9943                let mut inner_depth = depth.clone();
9944                if inlined {
9945                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9946                    inner_offset = next_offset;
9947                } else {
9948                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9949                    inner_depth.increment()?;
9950                }
9951                let val_ref = self.bag.get_or_insert_with(|| {
9952                    fidl::new_empty!(
9953                        fidl::encoding::Vector<
9954                            fidl::encoding::HandleType<
9955                                fidl::NullableHandle,
9956                                { fidl::ObjectType::NONE.into_raw() },
9957                                2147483648,
9958                            >,
9959                            4,
9960                        >,
9961                        fidl::encoding::DefaultFuchsiaResourceDialect
9962                    )
9963                });
9964                fidl::decode!(
9965                    fidl::encoding::Vector<
9966                        fidl::encoding::HandleType<
9967                            fidl::NullableHandle,
9968                            { fidl::ObjectType::NONE.into_raw() },
9969                            2147483648,
9970                        >,
9971                        4,
9972                    >,
9973                    fidl::encoding::DefaultFuchsiaResourceDialect,
9974                    val_ref,
9975                    decoder,
9976                    inner_offset,
9977                    inner_depth
9978                )?;
9979                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9980                {
9981                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9982                }
9983                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9984                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9985                }
9986            }
9987
9988            next_offset += envelope_size;
9989
9990            // Decode the remaining unknown envelopes.
9991            while next_offset < end_offset {
9992                _next_ordinal_to_read += 1;
9993                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9994                next_offset += envelope_size;
9995            }
9996
9997            Ok(())
9998        }
9999    }
10000
10001    impl FileRequest {
10002        #[inline(always)]
10003        fn max_ordinal_present(&self) -> u64 {
10004            if let Some(_) = self.add_requests {
10005                return 3;
10006            }
10007            if let Some(_) = self.get_requests {
10008                return 2;
10009            }
10010            if let Some(_) = self.close_requests {
10011                return 1;
10012            }
10013            0
10014        }
10015    }
10016
10017    impl fidl::encoding::ResourceTypeMarker for FileRequest {
10018        type Borrowed<'a> = &'a mut Self;
10019        fn take_or_borrow<'a>(
10020            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10021        ) -> Self::Borrowed<'a> {
10022            value
10023        }
10024    }
10025
10026    unsafe impl fidl::encoding::TypeMarker for FileRequest {
10027        type Owned = Self;
10028
10029        #[inline(always)]
10030        fn inline_align(_context: fidl::encoding::Context) -> usize {
10031            8
10032        }
10033
10034        #[inline(always)]
10035        fn inline_size(_context: fidl::encoding::Context) -> usize {
10036            16
10037        }
10038    }
10039
10040    unsafe impl fidl::encoding::Encode<FileRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
10041        for &mut FileRequest
10042    {
10043        unsafe fn encode(
10044            self,
10045            encoder: &mut fidl::encoding::Encoder<
10046                '_,
10047                fidl::encoding::DefaultFuchsiaResourceDialect,
10048            >,
10049            offset: usize,
10050            mut depth: fidl::encoding::Depth,
10051        ) -> fidl::Result<()> {
10052            encoder.debug_check_bounds::<FileRequest>(offset);
10053            // Vector header
10054            let max_ordinal: u64 = self.max_ordinal_present();
10055            encoder.write_num(max_ordinal, offset);
10056            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10057            // Calling encoder.out_of_line_offset(0) is not allowed.
10058            if max_ordinal == 0 {
10059                return Ok(());
10060            }
10061            depth.increment()?;
10062            let envelope_size = 8;
10063            let bytes_len = max_ordinal as usize * envelope_size;
10064            #[allow(unused_variables)]
10065            let offset = encoder.out_of_line_offset(bytes_len);
10066            let mut _prev_end_offset: usize = 0;
10067            if 1 > max_ordinal {
10068                return Ok(());
10069            }
10070
10071            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10072            // are envelope_size bytes.
10073            let cur_offset: usize = (1 - 1) * envelope_size;
10074
10075            // Zero reserved fields.
10076            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10077
10078            // Safety:
10079            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10080            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10081            //   envelope_size bytes, there is always sufficient room.
10082            fidl::encoding::encode_in_envelope_optional::<
10083                fidl::encoding::Vector<i32, 16>,
10084                fidl::encoding::DefaultFuchsiaResourceDialect,
10085            >(
10086                self.close_requests.as_ref().map(
10087                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::ValueTypeMarker>::borrow,
10088                ),
10089                encoder,
10090                offset + cur_offset,
10091                depth,
10092            )?;
10093
10094            _prev_end_offset = cur_offset + envelope_size;
10095            if 2 > max_ordinal {
10096                return Ok(());
10097            }
10098
10099            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10100            // are envelope_size bytes.
10101            let cur_offset: usize = (2 - 1) * envelope_size;
10102
10103            // Zero reserved fields.
10104            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10105
10106            // Safety:
10107            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10108            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10109            //   envelope_size bytes, there is always sufficient room.
10110            fidl::encoding::encode_in_envelope_optional::<
10111                fidl::encoding::Vector<i32, 16>,
10112                fidl::encoding::DefaultFuchsiaResourceDialect,
10113            >(
10114                self.get_requests.as_ref().map(
10115                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::ValueTypeMarker>::borrow,
10116                ),
10117                encoder,
10118                offset + cur_offset,
10119                depth,
10120            )?;
10121
10122            _prev_end_offset = cur_offset + envelope_size;
10123            if 3 > max_ordinal {
10124                return Ok(());
10125            }
10126
10127            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10128            // are envelope_size bytes.
10129            let cur_offset: usize = (3 - 1) * envelope_size;
10130
10131            // Zero reserved fields.
10132            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10133
10134            // Safety:
10135            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10136            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10137            //   envelope_size bytes, there is always sufficient room.
10138            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10139            self.add_requests.as_mut().map(<fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10140            encoder, offset + cur_offset, depth
10141        )?;
10142
10143            _prev_end_offset = cur_offset + envelope_size;
10144
10145            Ok(())
10146        }
10147    }
10148
10149    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FileRequest {
10150        #[inline(always)]
10151        fn new_empty() -> Self {
10152            Self::default()
10153        }
10154
10155        unsafe fn decode(
10156            &mut self,
10157            decoder: &mut fidl::encoding::Decoder<
10158                '_,
10159                fidl::encoding::DefaultFuchsiaResourceDialect,
10160            >,
10161            offset: usize,
10162            mut depth: fidl::encoding::Depth,
10163        ) -> fidl::Result<()> {
10164            decoder.debug_check_bounds::<Self>(offset);
10165            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10166                None => return Err(fidl::Error::NotNullable),
10167                Some(len) => len,
10168            };
10169            // Calling decoder.out_of_line_offset(0) is not allowed.
10170            if len == 0 {
10171                return Ok(());
10172            };
10173            depth.increment()?;
10174            let envelope_size = 8;
10175            let bytes_len = len * envelope_size;
10176            let offset = decoder.out_of_line_offset(bytes_len)?;
10177            // Decode the envelope for each type.
10178            let mut _next_ordinal_to_read = 0;
10179            let mut next_offset = offset;
10180            let end_offset = offset + bytes_len;
10181            _next_ordinal_to_read += 1;
10182            if next_offset >= end_offset {
10183                return Ok(());
10184            }
10185
10186            // Decode unknown envelopes for gaps in ordinals.
10187            while _next_ordinal_to_read < 1 {
10188                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10189                _next_ordinal_to_read += 1;
10190                next_offset += envelope_size;
10191            }
10192
10193            let next_out_of_line = decoder.next_out_of_line();
10194            let handles_before = decoder.remaining_handles();
10195            if let Some((inlined, num_bytes, num_handles)) =
10196                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10197            {
10198                let member_inline_size =
10199                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::TypeMarker>::inline_size(
10200                        decoder.context,
10201                    );
10202                if inlined != (member_inline_size <= 4) {
10203                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10204                }
10205                let inner_offset;
10206                let mut inner_depth = depth.clone();
10207                if inlined {
10208                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10209                    inner_offset = next_offset;
10210                } else {
10211                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10212                    inner_depth.increment()?;
10213                }
10214                let val_ref =
10215                self.close_requests.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect));
10216                fidl::decode!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10218                {
10219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10220                }
10221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10223                }
10224            }
10225
10226            next_offset += envelope_size;
10227            _next_ordinal_to_read += 1;
10228            if next_offset >= end_offset {
10229                return Ok(());
10230            }
10231
10232            // Decode unknown envelopes for gaps in ordinals.
10233            while _next_ordinal_to_read < 2 {
10234                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10235                _next_ordinal_to_read += 1;
10236                next_offset += envelope_size;
10237            }
10238
10239            let next_out_of_line = decoder.next_out_of_line();
10240            let handles_before = decoder.remaining_handles();
10241            if let Some((inlined, num_bytes, num_handles)) =
10242                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10243            {
10244                let member_inline_size =
10245                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::TypeMarker>::inline_size(
10246                        decoder.context,
10247                    );
10248                if inlined != (member_inline_size <= 4) {
10249                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10250                }
10251                let inner_offset;
10252                let mut inner_depth = depth.clone();
10253                if inlined {
10254                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10255                    inner_offset = next_offset;
10256                } else {
10257                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10258                    inner_depth.increment()?;
10259                }
10260                let val_ref =
10261                self.get_requests.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect));
10262                fidl::decode!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10263                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10264                {
10265                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10266                }
10267                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10268                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10269                }
10270            }
10271
10272            next_offset += envelope_size;
10273            _next_ordinal_to_read += 1;
10274            if next_offset >= end_offset {
10275                return Ok(());
10276            }
10277
10278            // Decode unknown envelopes for gaps in ordinals.
10279            while _next_ordinal_to_read < 3 {
10280                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10281                _next_ordinal_to_read += 1;
10282                next_offset += envelope_size;
10283            }
10284
10285            let next_out_of_line = decoder.next_out_of_line();
10286            let handles_before = decoder.remaining_handles();
10287            if let Some((inlined, num_bytes, num_handles)) =
10288                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10289            {
10290                let member_inline_size = <fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10291                if inlined != (member_inline_size <= 4) {
10292                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10293                }
10294                let inner_offset;
10295                let mut inner_depth = depth.clone();
10296                if inlined {
10297                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10298                    inner_offset = next_offset;
10299                } else {
10300                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10301                    inner_depth.increment()?;
10302                }
10303                let val_ref =
10304                self.add_requests.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect));
10305                fidl::decode!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10306                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10307                {
10308                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10309                }
10310                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10311                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10312                }
10313            }
10314
10315            next_offset += envelope_size;
10316
10317            // Decode the remaining unknown envelopes.
10318            while next_offset < end_offset {
10319                _next_ordinal_to_read += 1;
10320                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10321                next_offset += envelope_size;
10322            }
10323
10324            Ok(())
10325        }
10326    }
10327
10328    impl FileResponse {
10329        #[inline(always)]
10330        fn max_ordinal_present(&self) -> u64 {
10331            if let Some(_) = self.add_responses {
10332                return 3;
10333            }
10334            if let Some(_) = self.get_responses {
10335                return 2;
10336            }
10337            0
10338        }
10339    }
10340
10341    impl fidl::encoding::ResourceTypeMarker for FileResponse {
10342        type Borrowed<'a> = &'a mut Self;
10343        fn take_or_borrow<'a>(
10344            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10345        ) -> Self::Borrowed<'a> {
10346            value
10347        }
10348    }
10349
10350    unsafe impl fidl::encoding::TypeMarker for FileResponse {
10351        type Owned = Self;
10352
10353        #[inline(always)]
10354        fn inline_align(_context: fidl::encoding::Context) -> usize {
10355            8
10356        }
10357
10358        #[inline(always)]
10359        fn inline_size(_context: fidl::encoding::Context) -> usize {
10360            16
10361        }
10362    }
10363
10364    unsafe impl fidl::encoding::Encode<FileResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
10365        for &mut FileResponse
10366    {
10367        unsafe fn encode(
10368            self,
10369            encoder: &mut fidl::encoding::Encoder<
10370                '_,
10371                fidl::encoding::DefaultFuchsiaResourceDialect,
10372            >,
10373            offset: usize,
10374            mut depth: fidl::encoding::Depth,
10375        ) -> fidl::Result<()> {
10376            encoder.debug_check_bounds::<FileResponse>(offset);
10377            // Vector header
10378            let max_ordinal: u64 = self.max_ordinal_present();
10379            encoder.write_num(max_ordinal, offset);
10380            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10381            // Calling encoder.out_of_line_offset(0) is not allowed.
10382            if max_ordinal == 0 {
10383                return Ok(());
10384            }
10385            depth.increment()?;
10386            let envelope_size = 8;
10387            let bytes_len = max_ordinal as usize * envelope_size;
10388            #[allow(unused_variables)]
10389            let offset = encoder.out_of_line_offset(bytes_len);
10390            let mut _prev_end_offset: usize = 0;
10391            if 2 > max_ordinal {
10392                return Ok(());
10393            }
10394
10395            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10396            // are envelope_size bytes.
10397            let cur_offset: usize = (2 - 1) * envelope_size;
10398
10399            // Zero reserved fields.
10400            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10401
10402            // Safety:
10403            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10404            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10405            //   envelope_size bytes, there is always sufficient room.
10406            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10407            self.get_responses.as_mut().map(<fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10408            encoder, offset + cur_offset, depth
10409        )?;
10410
10411            _prev_end_offset = cur_offset + envelope_size;
10412            if 3 > max_ordinal {
10413                return Ok(());
10414            }
10415
10416            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10417            // are envelope_size bytes.
10418            let cur_offset: usize = (3 - 1) * envelope_size;
10419
10420            // Zero reserved fields.
10421            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10422
10423            // Safety:
10424            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10425            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10426            //   envelope_size bytes, there is always sufficient room.
10427            fidl::encoding::encode_in_envelope_optional::<
10428                fidl::encoding::Vector<i32, 16>,
10429                fidl::encoding::DefaultFuchsiaResourceDialect,
10430            >(
10431                self.add_responses.as_ref().map(
10432                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::ValueTypeMarker>::borrow,
10433                ),
10434                encoder,
10435                offset + cur_offset,
10436                depth,
10437            )?;
10438
10439            _prev_end_offset = cur_offset + envelope_size;
10440
10441            Ok(())
10442        }
10443    }
10444
10445    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FileResponse {
10446        #[inline(always)]
10447        fn new_empty() -> Self {
10448            Self::default()
10449        }
10450
10451        unsafe fn decode(
10452            &mut self,
10453            decoder: &mut fidl::encoding::Decoder<
10454                '_,
10455                fidl::encoding::DefaultFuchsiaResourceDialect,
10456            >,
10457            offset: usize,
10458            mut depth: fidl::encoding::Depth,
10459        ) -> fidl::Result<()> {
10460            decoder.debug_check_bounds::<Self>(offset);
10461            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10462                None => return Err(fidl::Error::NotNullable),
10463                Some(len) => len,
10464            };
10465            // Calling decoder.out_of_line_offset(0) is not allowed.
10466            if len == 0 {
10467                return Ok(());
10468            };
10469            depth.increment()?;
10470            let envelope_size = 8;
10471            let bytes_len = len * envelope_size;
10472            let offset = decoder.out_of_line_offset(bytes_len)?;
10473            // Decode the envelope for each type.
10474            let mut _next_ordinal_to_read = 0;
10475            let mut next_offset = offset;
10476            let end_offset = offset + bytes_len;
10477            _next_ordinal_to_read += 1;
10478            if next_offset >= end_offset {
10479                return Ok(());
10480            }
10481
10482            // Decode unknown envelopes for gaps in ordinals.
10483            while _next_ordinal_to_read < 2 {
10484                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10485                _next_ordinal_to_read += 1;
10486                next_offset += envelope_size;
10487            }
10488
10489            let next_out_of_line = decoder.next_out_of_line();
10490            let handles_before = decoder.remaining_handles();
10491            if let Some((inlined, num_bytes, num_handles)) =
10492                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10493            {
10494                let member_inline_size = <fidl::encoding::Vector<FileHandle, 16> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10495                if inlined != (member_inline_size <= 4) {
10496                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10497                }
10498                let inner_offset;
10499                let mut inner_depth = depth.clone();
10500                if inlined {
10501                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10502                    inner_offset = next_offset;
10503                } else {
10504                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10505                    inner_depth.increment()?;
10506                }
10507                let val_ref =
10508                self.get_responses.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect));
10509                fidl::decode!(fidl::encoding::Vector<FileHandle, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10510                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10511                {
10512                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10513                }
10514                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10515                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10516                }
10517            }
10518
10519            next_offset += envelope_size;
10520            _next_ordinal_to_read += 1;
10521            if next_offset >= end_offset {
10522                return Ok(());
10523            }
10524
10525            // Decode unknown envelopes for gaps in ordinals.
10526            while _next_ordinal_to_read < 3 {
10527                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10528                _next_ordinal_to_read += 1;
10529                next_offset += envelope_size;
10530            }
10531
10532            let next_out_of_line = decoder.next_out_of_line();
10533            let handles_before = decoder.remaining_handles();
10534            if let Some((inlined, num_bytes, num_handles)) =
10535                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10536            {
10537                let member_inline_size =
10538                    <fidl::encoding::Vector<i32, 16> as fidl::encoding::TypeMarker>::inline_size(
10539                        decoder.context,
10540                    );
10541                if inlined != (member_inline_size <= 4) {
10542                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10543                }
10544                let inner_offset;
10545                let mut inner_depth = depth.clone();
10546                if inlined {
10547                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10548                    inner_offset = next_offset;
10549                } else {
10550                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10551                    inner_depth.increment()?;
10552                }
10553                let val_ref =
10554                self.add_responses.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect));
10555                fidl::decode!(fidl::encoding::Vector<i32, 16>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10556                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10557                {
10558                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10559                }
10560                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10561                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10562                }
10563            }
10564
10565            next_offset += envelope_size;
10566
10567            // Decode the remaining unknown envelopes.
10568            while next_offset < end_offset {
10569                _next_ordinal_to_read += 1;
10570                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10571                next_offset += envelope_size;
10572            }
10573
10574            Ok(())
10575        }
10576    }
10577
10578    impl RemoteControllerStartRequest {
10579        #[inline(always)]
10580        fn max_ordinal_present(&self) -> u64 {
10581            if let Some(_) = self.container_power_controller {
10582                return 3;
10583            }
10584            if let Some(_) = self.lutex_controller {
10585                return 2;
10586            }
10587            if let Some(_) = self.dev_binder {
10588                return 1;
10589            }
10590            0
10591        }
10592    }
10593
10594    impl fidl::encoding::ResourceTypeMarker for RemoteControllerStartRequest {
10595        type Borrowed<'a> = &'a mut Self;
10596        fn take_or_borrow<'a>(
10597            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10598        ) -> Self::Borrowed<'a> {
10599            value
10600        }
10601    }
10602
10603    unsafe impl fidl::encoding::TypeMarker for RemoteControllerStartRequest {
10604        type Owned = Self;
10605
10606        #[inline(always)]
10607        fn inline_align(_context: fidl::encoding::Context) -> usize {
10608            8
10609        }
10610
10611        #[inline(always)]
10612        fn inline_size(_context: fidl::encoding::Context) -> usize {
10613            16
10614        }
10615    }
10616
10617    unsafe impl
10618        fidl::encoding::Encode<
10619            RemoteControllerStartRequest,
10620            fidl::encoding::DefaultFuchsiaResourceDialect,
10621        > for &mut RemoteControllerStartRequest
10622    {
10623        unsafe fn encode(
10624            self,
10625            encoder: &mut fidl::encoding::Encoder<
10626                '_,
10627                fidl::encoding::DefaultFuchsiaResourceDialect,
10628            >,
10629            offset: usize,
10630            mut depth: fidl::encoding::Depth,
10631        ) -> fidl::Result<()> {
10632            encoder.debug_check_bounds::<RemoteControllerStartRequest>(offset);
10633            // Vector header
10634            let max_ordinal: u64 = self.max_ordinal_present();
10635            encoder.write_num(max_ordinal, offset);
10636            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10637            // Calling encoder.out_of_line_offset(0) is not allowed.
10638            if max_ordinal == 0 {
10639                return Ok(());
10640            }
10641            depth.increment()?;
10642            let envelope_size = 8;
10643            let bytes_len = max_ordinal as usize * envelope_size;
10644            #[allow(unused_variables)]
10645            let offset = encoder.out_of_line_offset(bytes_len);
10646            let mut _prev_end_offset: usize = 0;
10647            if 1 > max_ordinal {
10648                return Ok(());
10649            }
10650
10651            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10652            // are envelope_size bytes.
10653            let cur_offset: usize = (1 - 1) * envelope_size;
10654
10655            // Zero reserved fields.
10656            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10657
10658            // Safety:
10659            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10660            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10661            //   envelope_size bytes, there is always sufficient room.
10662            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DevBinderMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10663            self.dev_binder.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DevBinderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10664            encoder, offset + cur_offset, depth
10665        )?;
10666
10667            _prev_end_offset = cur_offset + envelope_size;
10668            if 2 > max_ordinal {
10669                return Ok(());
10670            }
10671
10672            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10673            // are envelope_size bytes.
10674            let cur_offset: usize = (2 - 1) * envelope_size;
10675
10676            // Zero reserved fields.
10677            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10678
10679            // Safety:
10680            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10681            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10682            //   envelope_size bytes, there is always sufficient room.
10683            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LutexControllerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
10684            self.lutex_controller.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LutexControllerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
10685            encoder, offset + cur_offset, depth
10686        )?;
10687
10688            _prev_end_offset = cur_offset + envelope_size;
10689            if 3 > max_ordinal {
10690                return Ok(());
10691            }
10692
10693            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10694            // are envelope_size bytes.
10695            let cur_offset: usize = (3 - 1) * envelope_size;
10696
10697            // Zero reserved fields.
10698            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10699
10700            // Safety:
10701            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10702            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10703            //   envelope_size bytes, there is always sufficient room.
10704            fidl::encoding::encode_in_envelope_optional::<
10705                fidl::encoding::Endpoint<
10706                    fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>,
10707                >,
10708                fidl::encoding::DefaultFuchsiaResourceDialect,
10709            >(
10710                self.container_power_controller.as_mut().map(
10711                    <fidl::encoding::Endpoint<
10712                        fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>,
10713                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10714                ),
10715                encoder,
10716                offset + cur_offset,
10717                depth,
10718            )?;
10719
10720            _prev_end_offset = cur_offset + envelope_size;
10721
10722            Ok(())
10723        }
10724    }
10725
10726    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10727        for RemoteControllerStartRequest
10728    {
10729        #[inline(always)]
10730        fn new_empty() -> Self {
10731            Self::default()
10732        }
10733
10734        unsafe fn decode(
10735            &mut self,
10736            decoder: &mut fidl::encoding::Decoder<
10737                '_,
10738                fidl::encoding::DefaultFuchsiaResourceDialect,
10739            >,
10740            offset: usize,
10741            mut depth: fidl::encoding::Depth,
10742        ) -> fidl::Result<()> {
10743            decoder.debug_check_bounds::<Self>(offset);
10744            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10745                None => return Err(fidl::Error::NotNullable),
10746                Some(len) => len,
10747            };
10748            // Calling decoder.out_of_line_offset(0) is not allowed.
10749            if len == 0 {
10750                return Ok(());
10751            };
10752            depth.increment()?;
10753            let envelope_size = 8;
10754            let bytes_len = len * envelope_size;
10755            let offset = decoder.out_of_line_offset(bytes_len)?;
10756            // Decode the envelope for each type.
10757            let mut _next_ordinal_to_read = 0;
10758            let mut next_offset = offset;
10759            let end_offset = offset + bytes_len;
10760            _next_ordinal_to_read += 1;
10761            if next_offset >= end_offset {
10762                return Ok(());
10763            }
10764
10765            // Decode unknown envelopes for gaps in ordinals.
10766            while _next_ordinal_to_read < 1 {
10767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10768                _next_ordinal_to_read += 1;
10769                next_offset += envelope_size;
10770            }
10771
10772            let next_out_of_line = decoder.next_out_of_line();
10773            let handles_before = decoder.remaining_handles();
10774            if let Some((inlined, num_bytes, num_handles)) =
10775                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10776            {
10777                let member_inline_size = <fidl::encoding::Endpoint<
10778                    fidl::endpoints::ClientEnd<DevBinderMarker>,
10779                > as fidl::encoding::TypeMarker>::inline_size(
10780                    decoder.context
10781                );
10782                if inlined != (member_inline_size <= 4) {
10783                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10784                }
10785                let inner_offset;
10786                let mut inner_depth = depth.clone();
10787                if inlined {
10788                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10789                    inner_offset = next_offset;
10790                } else {
10791                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10792                    inner_depth.increment()?;
10793                }
10794                let val_ref = self.dev_binder.get_or_insert_with(|| {
10795                    fidl::new_empty!(
10796                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DevBinderMarker>>,
10797                        fidl::encoding::DefaultFuchsiaResourceDialect
10798                    )
10799                });
10800                fidl::decode!(
10801                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<DevBinderMarker>>,
10802                    fidl::encoding::DefaultFuchsiaResourceDialect,
10803                    val_ref,
10804                    decoder,
10805                    inner_offset,
10806                    inner_depth
10807                )?;
10808                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10809                {
10810                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10811                }
10812                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10813                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10814                }
10815            }
10816
10817            next_offset += envelope_size;
10818            _next_ordinal_to_read += 1;
10819            if next_offset >= end_offset {
10820                return Ok(());
10821            }
10822
10823            // Decode unknown envelopes for gaps in ordinals.
10824            while _next_ordinal_to_read < 2 {
10825                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10826                _next_ordinal_to_read += 1;
10827                next_offset += envelope_size;
10828            }
10829
10830            let next_out_of_line = decoder.next_out_of_line();
10831            let handles_before = decoder.remaining_handles();
10832            if let Some((inlined, num_bytes, num_handles)) =
10833                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10834            {
10835                let member_inline_size = <fidl::encoding::Endpoint<
10836                    fidl::endpoints::ClientEnd<LutexControllerMarker>,
10837                > as fidl::encoding::TypeMarker>::inline_size(
10838                    decoder.context
10839                );
10840                if inlined != (member_inline_size <= 4) {
10841                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10842                }
10843                let inner_offset;
10844                let mut inner_depth = depth.clone();
10845                if inlined {
10846                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10847                    inner_offset = next_offset;
10848                } else {
10849                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10850                    inner_depth.increment()?;
10851                }
10852                let val_ref = self.lutex_controller.get_or_insert_with(|| {
10853                    fidl::new_empty!(
10854                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LutexControllerMarker>>,
10855                        fidl::encoding::DefaultFuchsiaResourceDialect
10856                    )
10857                });
10858                fidl::decode!(
10859                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<LutexControllerMarker>>,
10860                    fidl::encoding::DefaultFuchsiaResourceDialect,
10861                    val_ref,
10862                    decoder,
10863                    inner_offset,
10864                    inner_depth
10865                )?;
10866                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10867                {
10868                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10869                }
10870                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10871                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10872                }
10873            }
10874
10875            next_offset += envelope_size;
10876            _next_ordinal_to_read += 1;
10877            if next_offset >= end_offset {
10878                return Ok(());
10879            }
10880
10881            // Decode unknown envelopes for gaps in ordinals.
10882            while _next_ordinal_to_read < 3 {
10883                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10884                _next_ordinal_to_read += 1;
10885                next_offset += envelope_size;
10886            }
10887
10888            let next_out_of_line = decoder.next_out_of_line();
10889            let handles_before = decoder.remaining_handles();
10890            if let Some((inlined, num_bytes, num_handles)) =
10891                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10892            {
10893                let member_inline_size = <fidl::encoding::Endpoint<
10894                    fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>,
10895                > as fidl::encoding::TypeMarker>::inline_size(
10896                    decoder.context
10897                );
10898                if inlined != (member_inline_size <= 4) {
10899                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10900                }
10901                let inner_offset;
10902                let mut inner_depth = depth.clone();
10903                if inlined {
10904                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10905                    inner_offset = next_offset;
10906                } else {
10907                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10908                    inner_depth.increment()?;
10909                }
10910                let val_ref = self.container_power_controller.get_or_insert_with(|| {
10911                    fidl::new_empty!(
10912                        fidl::encoding::Endpoint<
10913                            fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>,
10914                        >,
10915                        fidl::encoding::DefaultFuchsiaResourceDialect
10916                    )
10917                });
10918                fidl::decode!(
10919                    fidl::encoding::Endpoint<
10920                        fidl::endpoints::ClientEnd<ContainerPowerControllerMarker>,
10921                    >,
10922                    fidl::encoding::DefaultFuchsiaResourceDialect,
10923                    val_ref,
10924                    decoder,
10925                    inner_offset,
10926                    inner_depth
10927                )?;
10928                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10929                {
10930                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10931                }
10932                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10933                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10934                }
10935            }
10936
10937            next_offset += envelope_size;
10938
10939            // Decode the remaining unknown envelopes.
10940            while next_offset < end_offset {
10941                _next_ordinal_to_read += 1;
10942                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10943                next_offset += envelope_size;
10944            }
10945
10946            Ok(())
10947        }
10948    }
10949
10950    impl UnixDomainSocketWriteRequest {
10951        #[inline(always)]
10952        fn max_ordinal_present(&self) -> u64 {
10953            if let Some(_) = self.handles {
10954                return 2;
10955            }
10956            if let Some(_) = self.data {
10957                return 1;
10958            }
10959            0
10960        }
10961    }
10962
10963    impl fidl::encoding::ResourceTypeMarker for UnixDomainSocketWriteRequest {
10964        type Borrowed<'a> = &'a mut Self;
10965        fn take_or_borrow<'a>(
10966            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10967        ) -> Self::Borrowed<'a> {
10968            value
10969        }
10970    }
10971
10972    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketWriteRequest {
10973        type Owned = Self;
10974
10975        #[inline(always)]
10976        fn inline_align(_context: fidl::encoding::Context) -> usize {
10977            8
10978        }
10979
10980        #[inline(always)]
10981        fn inline_size(_context: fidl::encoding::Context) -> usize {
10982            16
10983        }
10984    }
10985
10986    unsafe impl
10987        fidl::encoding::Encode<
10988            UnixDomainSocketWriteRequest,
10989            fidl::encoding::DefaultFuchsiaResourceDialect,
10990        > for &mut UnixDomainSocketWriteRequest
10991    {
10992        unsafe fn encode(
10993            self,
10994            encoder: &mut fidl::encoding::Encoder<
10995                '_,
10996                fidl::encoding::DefaultFuchsiaResourceDialect,
10997            >,
10998            offset: usize,
10999            mut depth: fidl::encoding::Depth,
11000        ) -> fidl::Result<()> {
11001            encoder.debug_check_bounds::<UnixDomainSocketWriteRequest>(offset);
11002            // Vector header
11003            let max_ordinal: u64 = self.max_ordinal_present();
11004            encoder.write_num(max_ordinal, offset);
11005            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11006            // Calling encoder.out_of_line_offset(0) is not allowed.
11007            if max_ordinal == 0 {
11008                return Ok(());
11009            }
11010            depth.increment()?;
11011            let envelope_size = 8;
11012            let bytes_len = max_ordinal as usize * envelope_size;
11013            #[allow(unused_variables)]
11014            let offset = encoder.out_of_line_offset(bytes_len);
11015            let mut _prev_end_offset: usize = 0;
11016            if 1 > max_ordinal {
11017                return Ok(());
11018            }
11019
11020            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11021            // are envelope_size bytes.
11022            let cur_offset: usize = (1 - 1) * envelope_size;
11023
11024            // Zero reserved fields.
11025            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11026
11027            // Safety:
11028            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11029            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11030            //   envelope_size bytes, there is always sufficient room.
11031            fidl::encoding::encode_in_envelope_optional::<
11032                fidl::encoding::Vector<u8, 8192>,
11033                fidl::encoding::DefaultFuchsiaResourceDialect,
11034            >(
11035                self.data.as_ref().map(
11036                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow,
11037                ),
11038                encoder,
11039                offset + cur_offset,
11040                depth,
11041            )?;
11042
11043            _prev_end_offset = cur_offset + envelope_size;
11044            if 2 > max_ordinal {
11045                return Ok(());
11046            }
11047
11048            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11049            // are envelope_size bytes.
11050            let cur_offset: usize = (2 - 1) * envelope_size;
11051
11052            // Zero reserved fields.
11053            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11054
11055            // Safety:
11056            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11057            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11058            //   envelope_size bytes, there is always sufficient room.
11059            fidl::encoding::encode_in_envelope_optional::<
11060                fidl::encoding::Vector<
11061                    fidl::encoding::HandleType<
11062                        fidl::NullableHandle,
11063                        { fidl::ObjectType::NONE.into_raw() },
11064                        2147483648,
11065                    >,
11066                    4,
11067                >,
11068                fidl::encoding::DefaultFuchsiaResourceDialect,
11069            >(
11070                self.handles.as_mut().map(
11071                    <fidl::encoding::Vector<
11072                        fidl::encoding::HandleType<
11073                            fidl::NullableHandle,
11074                            { fidl::ObjectType::NONE.into_raw() },
11075                            2147483648,
11076                        >,
11077                        4,
11078                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11079                ),
11080                encoder,
11081                offset + cur_offset,
11082                depth,
11083            )?;
11084
11085            _prev_end_offset = cur_offset + envelope_size;
11086
11087            Ok(())
11088        }
11089    }
11090
11091    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11092        for UnixDomainSocketWriteRequest
11093    {
11094        #[inline(always)]
11095        fn new_empty() -> Self {
11096            Self::default()
11097        }
11098
11099        unsafe fn decode(
11100            &mut self,
11101            decoder: &mut fidl::encoding::Decoder<
11102                '_,
11103                fidl::encoding::DefaultFuchsiaResourceDialect,
11104            >,
11105            offset: usize,
11106            mut depth: fidl::encoding::Depth,
11107        ) -> fidl::Result<()> {
11108            decoder.debug_check_bounds::<Self>(offset);
11109            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11110                None => return Err(fidl::Error::NotNullable),
11111                Some(len) => len,
11112            };
11113            // Calling decoder.out_of_line_offset(0) is not allowed.
11114            if len == 0 {
11115                return Ok(());
11116            };
11117            depth.increment()?;
11118            let envelope_size = 8;
11119            let bytes_len = len * envelope_size;
11120            let offset = decoder.out_of_line_offset(bytes_len)?;
11121            // Decode the envelope for each type.
11122            let mut _next_ordinal_to_read = 0;
11123            let mut next_offset = offset;
11124            let end_offset = offset + bytes_len;
11125            _next_ordinal_to_read += 1;
11126            if next_offset >= end_offset {
11127                return Ok(());
11128            }
11129
11130            // Decode unknown envelopes for gaps in ordinals.
11131            while _next_ordinal_to_read < 1 {
11132                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11133                _next_ordinal_to_read += 1;
11134                next_offset += envelope_size;
11135            }
11136
11137            let next_out_of_line = decoder.next_out_of_line();
11138            let handles_before = decoder.remaining_handles();
11139            if let Some((inlined, num_bytes, num_handles)) =
11140                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11141            {
11142                let member_inline_size =
11143                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::TypeMarker>::inline_size(
11144                        decoder.context,
11145                    );
11146                if inlined != (member_inline_size <= 4) {
11147                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11148                }
11149                let inner_offset;
11150                let mut inner_depth = depth.clone();
11151                if inlined {
11152                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11153                    inner_offset = next_offset;
11154                } else {
11155                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11156                    inner_depth.increment()?;
11157                }
11158                let val_ref =
11159                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect));
11160                fidl::decode!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
11161                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11162                {
11163                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11164                }
11165                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11166                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11167                }
11168            }
11169
11170            next_offset += envelope_size;
11171            _next_ordinal_to_read += 1;
11172            if next_offset >= end_offset {
11173                return Ok(());
11174            }
11175
11176            // Decode unknown envelopes for gaps in ordinals.
11177            while _next_ordinal_to_read < 2 {
11178                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11179                _next_ordinal_to_read += 1;
11180                next_offset += envelope_size;
11181            }
11182
11183            let next_out_of_line = decoder.next_out_of_line();
11184            let handles_before = decoder.remaining_handles();
11185            if let Some((inlined, num_bytes, num_handles)) =
11186                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11187            {
11188                let member_inline_size = <fidl::encoding::Vector<
11189                    fidl::encoding::HandleType<
11190                        fidl::NullableHandle,
11191                        { fidl::ObjectType::NONE.into_raw() },
11192                        2147483648,
11193                    >,
11194                    4,
11195                > as fidl::encoding::TypeMarker>::inline_size(
11196                    decoder.context
11197                );
11198                if inlined != (member_inline_size <= 4) {
11199                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11200                }
11201                let inner_offset;
11202                let mut inner_depth = depth.clone();
11203                if inlined {
11204                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11205                    inner_offset = next_offset;
11206                } else {
11207                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11208                    inner_depth.increment()?;
11209                }
11210                let val_ref = self.handles.get_or_insert_with(|| {
11211                    fidl::new_empty!(
11212                        fidl::encoding::Vector<
11213                            fidl::encoding::HandleType<
11214                                fidl::NullableHandle,
11215                                { fidl::ObjectType::NONE.into_raw() },
11216                                2147483648,
11217                            >,
11218                            4,
11219                        >,
11220                        fidl::encoding::DefaultFuchsiaResourceDialect
11221                    )
11222                });
11223                fidl::decode!(
11224                    fidl::encoding::Vector<
11225                        fidl::encoding::HandleType<
11226                            fidl::NullableHandle,
11227                            { fidl::ObjectType::NONE.into_raw() },
11228                            2147483648,
11229                        >,
11230                        4,
11231                    >,
11232                    fidl::encoding::DefaultFuchsiaResourceDialect,
11233                    val_ref,
11234                    decoder,
11235                    inner_offset,
11236                    inner_depth
11237                )?;
11238                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11239                {
11240                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11241                }
11242                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11243                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11244                }
11245            }
11246
11247            next_offset += envelope_size;
11248
11249            // Decode the remaining unknown envelopes.
11250            while next_offset < end_offset {
11251                _next_ordinal_to_read += 1;
11252                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11253                next_offset += envelope_size;
11254            }
11255
11256            Ok(())
11257        }
11258    }
11259
11260    impl UnixDomainSocketGetEventResponse {
11261        #[inline(always)]
11262        fn max_ordinal_present(&self) -> u64 {
11263            if let Some(_) = self.event {
11264                return 1;
11265            }
11266            0
11267        }
11268    }
11269
11270    impl fidl::encoding::ResourceTypeMarker for UnixDomainSocketGetEventResponse {
11271        type Borrowed<'a> = &'a mut Self;
11272        fn take_or_borrow<'a>(
11273            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11274        ) -> Self::Borrowed<'a> {
11275            value
11276        }
11277    }
11278
11279    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketGetEventResponse {
11280        type Owned = Self;
11281
11282        #[inline(always)]
11283        fn inline_align(_context: fidl::encoding::Context) -> usize {
11284            8
11285        }
11286
11287        #[inline(always)]
11288        fn inline_size(_context: fidl::encoding::Context) -> usize {
11289            16
11290        }
11291    }
11292
11293    unsafe impl
11294        fidl::encoding::Encode<
11295            UnixDomainSocketGetEventResponse,
11296            fidl::encoding::DefaultFuchsiaResourceDialect,
11297        > for &mut UnixDomainSocketGetEventResponse
11298    {
11299        unsafe fn encode(
11300            self,
11301            encoder: &mut fidl::encoding::Encoder<
11302                '_,
11303                fidl::encoding::DefaultFuchsiaResourceDialect,
11304            >,
11305            offset: usize,
11306            mut depth: fidl::encoding::Depth,
11307        ) -> fidl::Result<()> {
11308            encoder.debug_check_bounds::<UnixDomainSocketGetEventResponse>(offset);
11309            // Vector header
11310            let max_ordinal: u64 = self.max_ordinal_present();
11311            encoder.write_num(max_ordinal, offset);
11312            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11313            // Calling encoder.out_of_line_offset(0) is not allowed.
11314            if max_ordinal == 0 {
11315                return Ok(());
11316            }
11317            depth.increment()?;
11318            let envelope_size = 8;
11319            let bytes_len = max_ordinal as usize * envelope_size;
11320            #[allow(unused_variables)]
11321            let offset = encoder.out_of_line_offset(bytes_len);
11322            let mut _prev_end_offset: usize = 0;
11323            if 1 > max_ordinal {
11324                return Ok(());
11325            }
11326
11327            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11328            // are envelope_size bytes.
11329            let cur_offset: usize = (1 - 1) * envelope_size;
11330
11331            // Zero reserved fields.
11332            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11333
11334            // Safety:
11335            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11336            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11337            //   envelope_size bytes, there is always sufficient room.
11338            fidl::encoding::encode_in_envelope_optional::<
11339                fidl::encoding::HandleType<
11340                    fidl::EventPair,
11341                    { fidl::ObjectType::EVENTPAIR.into_raw() },
11342                    20482,
11343                >,
11344                fidl::encoding::DefaultFuchsiaResourceDialect,
11345            >(
11346                self.event.as_mut().map(
11347                    <fidl::encoding::HandleType<
11348                        fidl::EventPair,
11349                        { fidl::ObjectType::EVENTPAIR.into_raw() },
11350                        20482,
11351                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11352                ),
11353                encoder,
11354                offset + cur_offset,
11355                depth,
11356            )?;
11357
11358            _prev_end_offset = cur_offset + envelope_size;
11359
11360            Ok(())
11361        }
11362    }
11363
11364    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11365        for UnixDomainSocketGetEventResponse
11366    {
11367        #[inline(always)]
11368        fn new_empty() -> Self {
11369            Self::default()
11370        }
11371
11372        unsafe fn decode(
11373            &mut self,
11374            decoder: &mut fidl::encoding::Decoder<
11375                '_,
11376                fidl::encoding::DefaultFuchsiaResourceDialect,
11377            >,
11378            offset: usize,
11379            mut depth: fidl::encoding::Depth,
11380        ) -> fidl::Result<()> {
11381            decoder.debug_check_bounds::<Self>(offset);
11382            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11383                None => return Err(fidl::Error::NotNullable),
11384                Some(len) => len,
11385            };
11386            // Calling decoder.out_of_line_offset(0) is not allowed.
11387            if len == 0 {
11388                return Ok(());
11389            };
11390            depth.increment()?;
11391            let envelope_size = 8;
11392            let bytes_len = len * envelope_size;
11393            let offset = decoder.out_of_line_offset(bytes_len)?;
11394            // Decode the envelope for each type.
11395            let mut _next_ordinal_to_read = 0;
11396            let mut next_offset = offset;
11397            let end_offset = offset + bytes_len;
11398            _next_ordinal_to_read += 1;
11399            if next_offset >= end_offset {
11400                return Ok(());
11401            }
11402
11403            // Decode unknown envelopes for gaps in ordinals.
11404            while _next_ordinal_to_read < 1 {
11405                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11406                _next_ordinal_to_read += 1;
11407                next_offset += envelope_size;
11408            }
11409
11410            let next_out_of_line = decoder.next_out_of_line();
11411            let handles_before = decoder.remaining_handles();
11412            if let Some((inlined, num_bytes, num_handles)) =
11413                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11414            {
11415                let member_inline_size = <fidl::encoding::HandleType<
11416                    fidl::EventPair,
11417                    { fidl::ObjectType::EVENTPAIR.into_raw() },
11418                    20482,
11419                > as fidl::encoding::TypeMarker>::inline_size(
11420                    decoder.context
11421                );
11422                if inlined != (member_inline_size <= 4) {
11423                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11424                }
11425                let inner_offset;
11426                let mut inner_depth = depth.clone();
11427                if inlined {
11428                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11429                    inner_offset = next_offset;
11430                } else {
11431                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11432                    inner_depth.increment()?;
11433                }
11434                let val_ref =
11435                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 20482>, fidl::encoding::DefaultFuchsiaResourceDialect));
11436                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 20482>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
11437                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11438                {
11439                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11440                }
11441                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11442                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11443                }
11444            }
11445
11446            next_offset += envelope_size;
11447
11448            // Decode the remaining unknown envelopes.
11449            while next_offset < end_offset {
11450                _next_ordinal_to_read += 1;
11451                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11452                next_offset += envelope_size;
11453            }
11454
11455            Ok(())
11456        }
11457    }
11458
11459    impl UnixDomainSocketReadResponse {
11460        #[inline(always)]
11461        fn max_ordinal_present(&self) -> u64 {
11462            if let Some(_) = self.handles {
11463                return 3;
11464            }
11465            if let Some(_) = self.data_original_length {
11466                return 2;
11467            }
11468            if let Some(_) = self.data {
11469                return 1;
11470            }
11471            0
11472        }
11473    }
11474
11475    impl fidl::encoding::ResourceTypeMarker for UnixDomainSocketReadResponse {
11476        type Borrowed<'a> = &'a mut Self;
11477        fn take_or_borrow<'a>(
11478            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11479        ) -> Self::Borrowed<'a> {
11480            value
11481        }
11482    }
11483
11484    unsafe impl fidl::encoding::TypeMarker for UnixDomainSocketReadResponse {
11485        type Owned = Self;
11486
11487        #[inline(always)]
11488        fn inline_align(_context: fidl::encoding::Context) -> usize {
11489            8
11490        }
11491
11492        #[inline(always)]
11493        fn inline_size(_context: fidl::encoding::Context) -> usize {
11494            16
11495        }
11496    }
11497
11498    unsafe impl
11499        fidl::encoding::Encode<
11500            UnixDomainSocketReadResponse,
11501            fidl::encoding::DefaultFuchsiaResourceDialect,
11502        > for &mut UnixDomainSocketReadResponse
11503    {
11504        unsafe fn encode(
11505            self,
11506            encoder: &mut fidl::encoding::Encoder<
11507                '_,
11508                fidl::encoding::DefaultFuchsiaResourceDialect,
11509            >,
11510            offset: usize,
11511            mut depth: fidl::encoding::Depth,
11512        ) -> fidl::Result<()> {
11513            encoder.debug_check_bounds::<UnixDomainSocketReadResponse>(offset);
11514            // Vector header
11515            let max_ordinal: u64 = self.max_ordinal_present();
11516            encoder.write_num(max_ordinal, offset);
11517            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11518            // Calling encoder.out_of_line_offset(0) is not allowed.
11519            if max_ordinal == 0 {
11520                return Ok(());
11521            }
11522            depth.increment()?;
11523            let envelope_size = 8;
11524            let bytes_len = max_ordinal as usize * envelope_size;
11525            #[allow(unused_variables)]
11526            let offset = encoder.out_of_line_offset(bytes_len);
11527            let mut _prev_end_offset: usize = 0;
11528            if 1 > max_ordinal {
11529                return Ok(());
11530            }
11531
11532            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11533            // are envelope_size bytes.
11534            let cur_offset: usize = (1 - 1) * envelope_size;
11535
11536            // Zero reserved fields.
11537            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11538
11539            // Safety:
11540            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11541            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11542            //   envelope_size bytes, there is always sufficient room.
11543            fidl::encoding::encode_in_envelope_optional::<
11544                fidl::encoding::Vector<u8, 8192>,
11545                fidl::encoding::DefaultFuchsiaResourceDialect,
11546            >(
11547                self.data.as_ref().map(
11548                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::ValueTypeMarker>::borrow,
11549                ),
11550                encoder,
11551                offset + cur_offset,
11552                depth,
11553            )?;
11554
11555            _prev_end_offset = cur_offset + envelope_size;
11556            if 2 > max_ordinal {
11557                return Ok(());
11558            }
11559
11560            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11561            // are envelope_size bytes.
11562            let cur_offset: usize = (2 - 1) * envelope_size;
11563
11564            // Zero reserved fields.
11565            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11566
11567            // Safety:
11568            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11569            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11570            //   envelope_size bytes, there is always sufficient room.
11571            fidl::encoding::encode_in_envelope_optional::<
11572                u64,
11573                fidl::encoding::DefaultFuchsiaResourceDialect,
11574            >(
11575                self.data_original_length
11576                    .as_ref()
11577                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11578                encoder,
11579                offset + cur_offset,
11580                depth,
11581            )?;
11582
11583            _prev_end_offset = cur_offset + envelope_size;
11584            if 3 > max_ordinal {
11585                return Ok(());
11586            }
11587
11588            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11589            // are envelope_size bytes.
11590            let cur_offset: usize = (3 - 1) * envelope_size;
11591
11592            // Zero reserved fields.
11593            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11594
11595            // Safety:
11596            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11597            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11598            //   envelope_size bytes, there is always sufficient room.
11599            fidl::encoding::encode_in_envelope_optional::<
11600                fidl::encoding::Vector<
11601                    fidl::encoding::HandleType<
11602                        fidl::NullableHandle,
11603                        { fidl::ObjectType::NONE.into_raw() },
11604                        2147483648,
11605                    >,
11606                    4,
11607                >,
11608                fidl::encoding::DefaultFuchsiaResourceDialect,
11609            >(
11610                self.handles.as_mut().map(
11611                    <fidl::encoding::Vector<
11612                        fidl::encoding::HandleType<
11613                            fidl::NullableHandle,
11614                            { fidl::ObjectType::NONE.into_raw() },
11615                            2147483648,
11616                        >,
11617                        4,
11618                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11619                ),
11620                encoder,
11621                offset + cur_offset,
11622                depth,
11623            )?;
11624
11625            _prev_end_offset = cur_offset + envelope_size;
11626
11627            Ok(())
11628        }
11629    }
11630
11631    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11632        for UnixDomainSocketReadResponse
11633    {
11634        #[inline(always)]
11635        fn new_empty() -> Self {
11636            Self::default()
11637        }
11638
11639        unsafe fn decode(
11640            &mut self,
11641            decoder: &mut fidl::encoding::Decoder<
11642                '_,
11643                fidl::encoding::DefaultFuchsiaResourceDialect,
11644            >,
11645            offset: usize,
11646            mut depth: fidl::encoding::Depth,
11647        ) -> fidl::Result<()> {
11648            decoder.debug_check_bounds::<Self>(offset);
11649            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11650                None => return Err(fidl::Error::NotNullable),
11651                Some(len) => len,
11652            };
11653            // Calling decoder.out_of_line_offset(0) is not allowed.
11654            if len == 0 {
11655                return Ok(());
11656            };
11657            depth.increment()?;
11658            let envelope_size = 8;
11659            let bytes_len = len * envelope_size;
11660            let offset = decoder.out_of_line_offset(bytes_len)?;
11661            // Decode the envelope for each type.
11662            let mut _next_ordinal_to_read = 0;
11663            let mut next_offset = offset;
11664            let end_offset = offset + bytes_len;
11665            _next_ordinal_to_read += 1;
11666            if next_offset >= end_offset {
11667                return Ok(());
11668            }
11669
11670            // Decode unknown envelopes for gaps in ordinals.
11671            while _next_ordinal_to_read < 1 {
11672                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11673                _next_ordinal_to_read += 1;
11674                next_offset += envelope_size;
11675            }
11676
11677            let next_out_of_line = decoder.next_out_of_line();
11678            let handles_before = decoder.remaining_handles();
11679            if let Some((inlined, num_bytes, num_handles)) =
11680                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11681            {
11682                let member_inline_size =
11683                    <fidl::encoding::Vector<u8, 8192> as fidl::encoding::TypeMarker>::inline_size(
11684                        decoder.context,
11685                    );
11686                if inlined != (member_inline_size <= 4) {
11687                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11688                }
11689                let inner_offset;
11690                let mut inner_depth = depth.clone();
11691                if inlined {
11692                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11693                    inner_offset = next_offset;
11694                } else {
11695                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11696                    inner_depth.increment()?;
11697                }
11698                let val_ref =
11699                self.data.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect));
11700                fidl::decode!(fidl::encoding::Vector<u8, 8192>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
11701                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11702                {
11703                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11704                }
11705                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11706                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11707                }
11708            }
11709
11710            next_offset += envelope_size;
11711            _next_ordinal_to_read += 1;
11712            if next_offset >= end_offset {
11713                return Ok(());
11714            }
11715
11716            // Decode unknown envelopes for gaps in ordinals.
11717            while _next_ordinal_to_read < 2 {
11718                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11719                _next_ordinal_to_read += 1;
11720                next_offset += envelope_size;
11721            }
11722
11723            let next_out_of_line = decoder.next_out_of_line();
11724            let handles_before = decoder.remaining_handles();
11725            if let Some((inlined, num_bytes, num_handles)) =
11726                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11727            {
11728                let member_inline_size =
11729                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11730                if inlined != (member_inline_size <= 4) {
11731                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11732                }
11733                let inner_offset;
11734                let mut inner_depth = depth.clone();
11735                if inlined {
11736                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11737                    inner_offset = next_offset;
11738                } else {
11739                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11740                    inner_depth.increment()?;
11741                }
11742                let val_ref = self.data_original_length.get_or_insert_with(|| {
11743                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
11744                });
11745                fidl::decode!(
11746                    u64,
11747                    fidl::encoding::DefaultFuchsiaResourceDialect,
11748                    val_ref,
11749                    decoder,
11750                    inner_offset,
11751                    inner_depth
11752                )?;
11753                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11754                {
11755                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11756                }
11757                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11758                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11759                }
11760            }
11761
11762            next_offset += envelope_size;
11763            _next_ordinal_to_read += 1;
11764            if next_offset >= end_offset {
11765                return Ok(());
11766            }
11767
11768            // Decode unknown envelopes for gaps in ordinals.
11769            while _next_ordinal_to_read < 3 {
11770                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11771                _next_ordinal_to_read += 1;
11772                next_offset += envelope_size;
11773            }
11774
11775            let next_out_of_line = decoder.next_out_of_line();
11776            let handles_before = decoder.remaining_handles();
11777            if let Some((inlined, num_bytes, num_handles)) =
11778                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11779            {
11780                let member_inline_size = <fidl::encoding::Vector<
11781                    fidl::encoding::HandleType<
11782                        fidl::NullableHandle,
11783                        { fidl::ObjectType::NONE.into_raw() },
11784                        2147483648,
11785                    >,
11786                    4,
11787                > as fidl::encoding::TypeMarker>::inline_size(
11788                    decoder.context
11789                );
11790                if inlined != (member_inline_size <= 4) {
11791                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11792                }
11793                let inner_offset;
11794                let mut inner_depth = depth.clone();
11795                if inlined {
11796                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11797                    inner_offset = next_offset;
11798                } else {
11799                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11800                    inner_depth.increment()?;
11801                }
11802                let val_ref = self.handles.get_or_insert_with(|| {
11803                    fidl::new_empty!(
11804                        fidl::encoding::Vector<
11805                            fidl::encoding::HandleType<
11806                                fidl::NullableHandle,
11807                                { fidl::ObjectType::NONE.into_raw() },
11808                                2147483648,
11809                            >,
11810                            4,
11811                        >,
11812                        fidl::encoding::DefaultFuchsiaResourceDialect
11813                    )
11814                });
11815                fidl::decode!(
11816                    fidl::encoding::Vector<
11817                        fidl::encoding::HandleType<
11818                            fidl::NullableHandle,
11819                            { fidl::ObjectType::NONE.into_raw() },
11820                            2147483648,
11821                        >,
11822                        4,
11823                    >,
11824                    fidl::encoding::DefaultFuchsiaResourceDialect,
11825                    val_ref,
11826                    decoder,
11827                    inner_offset,
11828                    inner_depth
11829                )?;
11830                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11831                {
11832                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11833                }
11834                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11835                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11836                }
11837            }
11838
11839            next_offset += envelope_size;
11840
11841            // Decode the remaining unknown envelopes.
11842            while next_offset < end_offset {
11843                _next_ordinal_to_read += 1;
11844                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11845                next_offset += envelope_size;
11846            }
11847
11848            Ok(())
11849        }
11850    }
11851
11852    impl WaitBitsetRequest {
11853        #[inline(always)]
11854        fn max_ordinal_present(&self) -> u64 {
11855            if let Some(_) = self.deadline {
11856                return 5;
11857            }
11858            if let Some(_) = self.mask {
11859                return 4;
11860            }
11861            if let Some(_) = self.value {
11862                return 3;
11863            }
11864            if let Some(_) = self.offset {
11865                return 2;
11866            }
11867            if let Some(_) = self.vmo {
11868                return 1;
11869            }
11870            0
11871        }
11872    }
11873
11874    impl fidl::encoding::ResourceTypeMarker for WaitBitsetRequest {
11875        type Borrowed<'a> = &'a mut Self;
11876        fn take_or_borrow<'a>(
11877            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11878        ) -> Self::Borrowed<'a> {
11879            value
11880        }
11881    }
11882
11883    unsafe impl fidl::encoding::TypeMarker for WaitBitsetRequest {
11884        type Owned = Self;
11885
11886        #[inline(always)]
11887        fn inline_align(_context: fidl::encoding::Context) -> usize {
11888            8
11889        }
11890
11891        #[inline(always)]
11892        fn inline_size(_context: fidl::encoding::Context) -> usize {
11893            16
11894        }
11895    }
11896
11897    unsafe impl
11898        fidl::encoding::Encode<WaitBitsetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
11899        for &mut WaitBitsetRequest
11900    {
11901        unsafe fn encode(
11902            self,
11903            encoder: &mut fidl::encoding::Encoder<
11904                '_,
11905                fidl::encoding::DefaultFuchsiaResourceDialect,
11906            >,
11907            offset: usize,
11908            mut depth: fidl::encoding::Depth,
11909        ) -> fidl::Result<()> {
11910            encoder.debug_check_bounds::<WaitBitsetRequest>(offset);
11911            // Vector header
11912            let max_ordinal: u64 = self.max_ordinal_present();
11913            encoder.write_num(max_ordinal, offset);
11914            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11915            // Calling encoder.out_of_line_offset(0) is not allowed.
11916            if max_ordinal == 0 {
11917                return Ok(());
11918            }
11919            depth.increment()?;
11920            let envelope_size = 8;
11921            let bytes_len = max_ordinal as usize * envelope_size;
11922            #[allow(unused_variables)]
11923            let offset = encoder.out_of_line_offset(bytes_len);
11924            let mut _prev_end_offset: usize = 0;
11925            if 1 > max_ordinal {
11926                return Ok(());
11927            }
11928
11929            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11930            // are envelope_size bytes.
11931            let cur_offset: usize = (1 - 1) * envelope_size;
11932
11933            // Zero reserved fields.
11934            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11935
11936            // Safety:
11937            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11938            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11939            //   envelope_size bytes, there is always sufficient room.
11940            fidl::encoding::encode_in_envelope_optional::<
11941                fidl::encoding::HandleType<
11942                    fidl::Vmo,
11943                    { fidl::ObjectType::VMO.into_raw() },
11944                    2147483648,
11945                >,
11946                fidl::encoding::DefaultFuchsiaResourceDialect,
11947            >(
11948                self.vmo.as_mut().map(
11949                    <fidl::encoding::HandleType<
11950                        fidl::Vmo,
11951                        { fidl::ObjectType::VMO.into_raw() },
11952                        2147483648,
11953                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11954                ),
11955                encoder,
11956                offset + cur_offset,
11957                depth,
11958            )?;
11959
11960            _prev_end_offset = cur_offset + envelope_size;
11961            if 2 > max_ordinal {
11962                return Ok(());
11963            }
11964
11965            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11966            // are envelope_size bytes.
11967            let cur_offset: usize = (2 - 1) * envelope_size;
11968
11969            // Zero reserved fields.
11970            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11971
11972            // Safety:
11973            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11974            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11975            //   envelope_size bytes, there is always sufficient room.
11976            fidl::encoding::encode_in_envelope_optional::<
11977                u64,
11978                fidl::encoding::DefaultFuchsiaResourceDialect,
11979            >(
11980                self.offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
11981                encoder,
11982                offset + cur_offset,
11983                depth,
11984            )?;
11985
11986            _prev_end_offset = cur_offset + envelope_size;
11987            if 3 > max_ordinal {
11988                return Ok(());
11989            }
11990
11991            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11992            // are envelope_size bytes.
11993            let cur_offset: usize = (3 - 1) * envelope_size;
11994
11995            // Zero reserved fields.
11996            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11997
11998            // Safety:
11999            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12000            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12001            //   envelope_size bytes, there is always sufficient room.
12002            fidl::encoding::encode_in_envelope_optional::<
12003                u32,
12004                fidl::encoding::DefaultFuchsiaResourceDialect,
12005            >(
12006                self.value.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12007                encoder,
12008                offset + cur_offset,
12009                depth,
12010            )?;
12011
12012            _prev_end_offset = cur_offset + envelope_size;
12013            if 4 > max_ordinal {
12014                return Ok(());
12015            }
12016
12017            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12018            // are envelope_size bytes.
12019            let cur_offset: usize = (4 - 1) * envelope_size;
12020
12021            // Zero reserved fields.
12022            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12023
12024            // Safety:
12025            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12026            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12027            //   envelope_size bytes, there is always sufficient room.
12028            fidl::encoding::encode_in_envelope_optional::<
12029                u32,
12030                fidl::encoding::DefaultFuchsiaResourceDialect,
12031            >(
12032                self.mask.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12033                encoder,
12034                offset + cur_offset,
12035                depth,
12036            )?;
12037
12038            _prev_end_offset = cur_offset + envelope_size;
12039            if 5 > max_ordinal {
12040                return Ok(());
12041            }
12042
12043            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12044            // are envelope_size bytes.
12045            let cur_offset: usize = (5 - 1) * envelope_size;
12046
12047            // Zero reserved fields.
12048            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12049
12050            // Safety:
12051            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12052            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12053            //   envelope_size bytes, there is always sufficient room.
12054            fidl::encoding::encode_in_envelope_optional::<
12055                i64,
12056                fidl::encoding::DefaultFuchsiaResourceDialect,
12057            >(
12058                self.deadline.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
12059                encoder,
12060                offset + cur_offset,
12061                depth,
12062            )?;
12063
12064            _prev_end_offset = cur_offset + envelope_size;
12065
12066            Ok(())
12067        }
12068    }
12069
12070    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12071        for WaitBitsetRequest
12072    {
12073        #[inline(always)]
12074        fn new_empty() -> Self {
12075            Self::default()
12076        }
12077
12078        unsafe fn decode(
12079            &mut self,
12080            decoder: &mut fidl::encoding::Decoder<
12081                '_,
12082                fidl::encoding::DefaultFuchsiaResourceDialect,
12083            >,
12084            offset: usize,
12085            mut depth: fidl::encoding::Depth,
12086        ) -> fidl::Result<()> {
12087            decoder.debug_check_bounds::<Self>(offset);
12088            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12089                None => return Err(fidl::Error::NotNullable),
12090                Some(len) => len,
12091            };
12092            // Calling decoder.out_of_line_offset(0) is not allowed.
12093            if len == 0 {
12094                return Ok(());
12095            };
12096            depth.increment()?;
12097            let envelope_size = 8;
12098            let bytes_len = len * envelope_size;
12099            let offset = decoder.out_of_line_offset(bytes_len)?;
12100            // Decode the envelope for each type.
12101            let mut _next_ordinal_to_read = 0;
12102            let mut next_offset = offset;
12103            let end_offset = offset + bytes_len;
12104            _next_ordinal_to_read += 1;
12105            if next_offset >= end_offset {
12106                return Ok(());
12107            }
12108
12109            // Decode unknown envelopes for gaps in ordinals.
12110            while _next_ordinal_to_read < 1 {
12111                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12112                _next_ordinal_to_read += 1;
12113                next_offset += envelope_size;
12114            }
12115
12116            let next_out_of_line = decoder.next_out_of_line();
12117            let handles_before = decoder.remaining_handles();
12118            if let Some((inlined, num_bytes, num_handles)) =
12119                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12120            {
12121                let member_inline_size = <fidl::encoding::HandleType<
12122                    fidl::Vmo,
12123                    { fidl::ObjectType::VMO.into_raw() },
12124                    2147483648,
12125                > as fidl::encoding::TypeMarker>::inline_size(
12126                    decoder.context
12127                );
12128                if inlined != (member_inline_size <= 4) {
12129                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12130                }
12131                let inner_offset;
12132                let mut inner_depth = depth.clone();
12133                if inlined {
12134                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12135                    inner_offset = next_offset;
12136                } else {
12137                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12138                    inner_depth.increment()?;
12139                }
12140                let val_ref =
12141                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
12142                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12143                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12144                {
12145                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12146                }
12147                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12148                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12149                }
12150            }
12151
12152            next_offset += envelope_size;
12153            _next_ordinal_to_read += 1;
12154            if next_offset >= end_offset {
12155                return Ok(());
12156            }
12157
12158            // Decode unknown envelopes for gaps in ordinals.
12159            while _next_ordinal_to_read < 2 {
12160                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12161                _next_ordinal_to_read += 1;
12162                next_offset += envelope_size;
12163            }
12164
12165            let next_out_of_line = decoder.next_out_of_line();
12166            let handles_before = decoder.remaining_handles();
12167            if let Some((inlined, num_bytes, num_handles)) =
12168                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12169            {
12170                let member_inline_size =
12171                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12172                if inlined != (member_inline_size <= 4) {
12173                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12174                }
12175                let inner_offset;
12176                let mut inner_depth = depth.clone();
12177                if inlined {
12178                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12179                    inner_offset = next_offset;
12180                } else {
12181                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12182                    inner_depth.increment()?;
12183                }
12184                let val_ref = self.offset.get_or_insert_with(|| {
12185                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12186                });
12187                fidl::decode!(
12188                    u64,
12189                    fidl::encoding::DefaultFuchsiaResourceDialect,
12190                    val_ref,
12191                    decoder,
12192                    inner_offset,
12193                    inner_depth
12194                )?;
12195                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12196                {
12197                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12198                }
12199                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12200                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12201                }
12202            }
12203
12204            next_offset += envelope_size;
12205            _next_ordinal_to_read += 1;
12206            if next_offset >= end_offset {
12207                return Ok(());
12208            }
12209
12210            // Decode unknown envelopes for gaps in ordinals.
12211            while _next_ordinal_to_read < 3 {
12212                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12213                _next_ordinal_to_read += 1;
12214                next_offset += envelope_size;
12215            }
12216
12217            let next_out_of_line = decoder.next_out_of_line();
12218            let handles_before = decoder.remaining_handles();
12219            if let Some((inlined, num_bytes, num_handles)) =
12220                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12221            {
12222                let member_inline_size =
12223                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12224                if inlined != (member_inline_size <= 4) {
12225                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12226                }
12227                let inner_offset;
12228                let mut inner_depth = depth.clone();
12229                if inlined {
12230                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12231                    inner_offset = next_offset;
12232                } else {
12233                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12234                    inner_depth.increment()?;
12235                }
12236                let val_ref = self.value.get_or_insert_with(|| {
12237                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12238                });
12239                fidl::decode!(
12240                    u32,
12241                    fidl::encoding::DefaultFuchsiaResourceDialect,
12242                    val_ref,
12243                    decoder,
12244                    inner_offset,
12245                    inner_depth
12246                )?;
12247                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12248                {
12249                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12250                }
12251                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12252                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12253                }
12254            }
12255
12256            next_offset += envelope_size;
12257            _next_ordinal_to_read += 1;
12258            if next_offset >= end_offset {
12259                return Ok(());
12260            }
12261
12262            // Decode unknown envelopes for gaps in ordinals.
12263            while _next_ordinal_to_read < 4 {
12264                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12265                _next_ordinal_to_read += 1;
12266                next_offset += envelope_size;
12267            }
12268
12269            let next_out_of_line = decoder.next_out_of_line();
12270            let handles_before = decoder.remaining_handles();
12271            if let Some((inlined, num_bytes, num_handles)) =
12272                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12273            {
12274                let member_inline_size =
12275                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12276                if inlined != (member_inline_size <= 4) {
12277                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12278                }
12279                let inner_offset;
12280                let mut inner_depth = depth.clone();
12281                if inlined {
12282                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12283                    inner_offset = next_offset;
12284                } else {
12285                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12286                    inner_depth.increment()?;
12287                }
12288                let val_ref = self.mask.get_or_insert_with(|| {
12289                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12290                });
12291                fidl::decode!(
12292                    u32,
12293                    fidl::encoding::DefaultFuchsiaResourceDialect,
12294                    val_ref,
12295                    decoder,
12296                    inner_offset,
12297                    inner_depth
12298                )?;
12299                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12300                {
12301                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12302                }
12303                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12304                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12305                }
12306            }
12307
12308            next_offset += envelope_size;
12309            _next_ordinal_to_read += 1;
12310            if next_offset >= end_offset {
12311                return Ok(());
12312            }
12313
12314            // Decode unknown envelopes for gaps in ordinals.
12315            while _next_ordinal_to_read < 5 {
12316                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12317                _next_ordinal_to_read += 1;
12318                next_offset += envelope_size;
12319            }
12320
12321            let next_out_of_line = decoder.next_out_of_line();
12322            let handles_before = decoder.remaining_handles();
12323            if let Some((inlined, num_bytes, num_handles)) =
12324                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12325            {
12326                let member_inline_size =
12327                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12328                if inlined != (member_inline_size <= 4) {
12329                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12330                }
12331                let inner_offset;
12332                let mut inner_depth = depth.clone();
12333                if inlined {
12334                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12335                    inner_offset = next_offset;
12336                } else {
12337                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12338                    inner_depth.increment()?;
12339                }
12340                let val_ref = self.deadline.get_or_insert_with(|| {
12341                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
12342                });
12343                fidl::decode!(
12344                    i64,
12345                    fidl::encoding::DefaultFuchsiaResourceDialect,
12346                    val_ref,
12347                    decoder,
12348                    inner_offset,
12349                    inner_depth
12350                )?;
12351                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12352                {
12353                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12354                }
12355                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12356                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12357                }
12358            }
12359
12360            next_offset += envelope_size;
12361
12362            // Decode the remaining unknown envelopes.
12363            while next_offset < end_offset {
12364                _next_ordinal_to_read += 1;
12365                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12366                next_offset += envelope_size;
12367            }
12368
12369            Ok(())
12370        }
12371    }
12372
12373    impl WakeBitsetRequest {
12374        #[inline(always)]
12375        fn max_ordinal_present(&self) -> u64 {
12376            if let Some(_) = self.mask {
12377                return 4;
12378            }
12379            if let Some(_) = self.count {
12380                return 3;
12381            }
12382            if let Some(_) = self.offset {
12383                return 2;
12384            }
12385            if let Some(_) = self.vmo {
12386                return 1;
12387            }
12388            0
12389        }
12390    }
12391
12392    impl fidl::encoding::ResourceTypeMarker for WakeBitsetRequest {
12393        type Borrowed<'a> = &'a mut Self;
12394        fn take_or_borrow<'a>(
12395            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12396        ) -> Self::Borrowed<'a> {
12397            value
12398        }
12399    }
12400
12401    unsafe impl fidl::encoding::TypeMarker for WakeBitsetRequest {
12402        type Owned = Self;
12403
12404        #[inline(always)]
12405        fn inline_align(_context: fidl::encoding::Context) -> usize {
12406            8
12407        }
12408
12409        #[inline(always)]
12410        fn inline_size(_context: fidl::encoding::Context) -> usize {
12411            16
12412        }
12413    }
12414
12415    unsafe impl
12416        fidl::encoding::Encode<WakeBitsetRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12417        for &mut WakeBitsetRequest
12418    {
12419        unsafe fn encode(
12420            self,
12421            encoder: &mut fidl::encoding::Encoder<
12422                '_,
12423                fidl::encoding::DefaultFuchsiaResourceDialect,
12424            >,
12425            offset: usize,
12426            mut depth: fidl::encoding::Depth,
12427        ) -> fidl::Result<()> {
12428            encoder.debug_check_bounds::<WakeBitsetRequest>(offset);
12429            // Vector header
12430            let max_ordinal: u64 = self.max_ordinal_present();
12431            encoder.write_num(max_ordinal, offset);
12432            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12433            // Calling encoder.out_of_line_offset(0) is not allowed.
12434            if max_ordinal == 0 {
12435                return Ok(());
12436            }
12437            depth.increment()?;
12438            let envelope_size = 8;
12439            let bytes_len = max_ordinal as usize * envelope_size;
12440            #[allow(unused_variables)]
12441            let offset = encoder.out_of_line_offset(bytes_len);
12442            let mut _prev_end_offset: usize = 0;
12443            if 1 > max_ordinal {
12444                return Ok(());
12445            }
12446
12447            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12448            // are envelope_size bytes.
12449            let cur_offset: usize = (1 - 1) * envelope_size;
12450
12451            // Zero reserved fields.
12452            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12453
12454            // Safety:
12455            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12456            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12457            //   envelope_size bytes, there is always sufficient room.
12458            fidl::encoding::encode_in_envelope_optional::<
12459                fidl::encoding::HandleType<
12460                    fidl::Vmo,
12461                    { fidl::ObjectType::VMO.into_raw() },
12462                    2147483648,
12463                >,
12464                fidl::encoding::DefaultFuchsiaResourceDialect,
12465            >(
12466                self.vmo.as_mut().map(
12467                    <fidl::encoding::HandleType<
12468                        fidl::Vmo,
12469                        { fidl::ObjectType::VMO.into_raw() },
12470                        2147483648,
12471                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12472                ),
12473                encoder,
12474                offset + cur_offset,
12475                depth,
12476            )?;
12477
12478            _prev_end_offset = cur_offset + envelope_size;
12479            if 2 > max_ordinal {
12480                return Ok(());
12481            }
12482
12483            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12484            // are envelope_size bytes.
12485            let cur_offset: usize = (2 - 1) * envelope_size;
12486
12487            // Zero reserved fields.
12488            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12489
12490            // Safety:
12491            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12492            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12493            //   envelope_size bytes, there is always sufficient room.
12494            fidl::encoding::encode_in_envelope_optional::<
12495                u64,
12496                fidl::encoding::DefaultFuchsiaResourceDialect,
12497            >(
12498                self.offset.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
12499                encoder,
12500                offset + cur_offset,
12501                depth,
12502            )?;
12503
12504            _prev_end_offset = cur_offset + envelope_size;
12505            if 3 > max_ordinal {
12506                return Ok(());
12507            }
12508
12509            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12510            // are envelope_size bytes.
12511            let cur_offset: usize = (3 - 1) * envelope_size;
12512
12513            // Zero reserved fields.
12514            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12515
12516            // Safety:
12517            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12518            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12519            //   envelope_size bytes, there is always sufficient room.
12520            fidl::encoding::encode_in_envelope_optional::<
12521                u32,
12522                fidl::encoding::DefaultFuchsiaResourceDialect,
12523            >(
12524                self.count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12525                encoder,
12526                offset + cur_offset,
12527                depth,
12528            )?;
12529
12530            _prev_end_offset = cur_offset + envelope_size;
12531            if 4 > max_ordinal {
12532                return Ok(());
12533            }
12534
12535            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12536            // are envelope_size bytes.
12537            let cur_offset: usize = (4 - 1) * envelope_size;
12538
12539            // Zero reserved fields.
12540            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12541
12542            // Safety:
12543            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12544            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12545            //   envelope_size bytes, there is always sufficient room.
12546            fidl::encoding::encode_in_envelope_optional::<
12547                u32,
12548                fidl::encoding::DefaultFuchsiaResourceDialect,
12549            >(
12550                self.mask.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
12551                encoder,
12552                offset + cur_offset,
12553                depth,
12554            )?;
12555
12556            _prev_end_offset = cur_offset + envelope_size;
12557
12558            Ok(())
12559        }
12560    }
12561
12562    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12563        for WakeBitsetRequest
12564    {
12565        #[inline(always)]
12566        fn new_empty() -> Self {
12567            Self::default()
12568        }
12569
12570        unsafe fn decode(
12571            &mut self,
12572            decoder: &mut fidl::encoding::Decoder<
12573                '_,
12574                fidl::encoding::DefaultFuchsiaResourceDialect,
12575            >,
12576            offset: usize,
12577            mut depth: fidl::encoding::Depth,
12578        ) -> fidl::Result<()> {
12579            decoder.debug_check_bounds::<Self>(offset);
12580            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12581                None => return Err(fidl::Error::NotNullable),
12582                Some(len) => len,
12583            };
12584            // Calling decoder.out_of_line_offset(0) is not allowed.
12585            if len == 0 {
12586                return Ok(());
12587            };
12588            depth.increment()?;
12589            let envelope_size = 8;
12590            let bytes_len = len * envelope_size;
12591            let offset = decoder.out_of_line_offset(bytes_len)?;
12592            // Decode the envelope for each type.
12593            let mut _next_ordinal_to_read = 0;
12594            let mut next_offset = offset;
12595            let end_offset = offset + bytes_len;
12596            _next_ordinal_to_read += 1;
12597            if next_offset >= end_offset {
12598                return Ok(());
12599            }
12600
12601            // Decode unknown envelopes for gaps in ordinals.
12602            while _next_ordinal_to_read < 1 {
12603                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12604                _next_ordinal_to_read += 1;
12605                next_offset += envelope_size;
12606            }
12607
12608            let next_out_of_line = decoder.next_out_of_line();
12609            let handles_before = decoder.remaining_handles();
12610            if let Some((inlined, num_bytes, num_handles)) =
12611                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12612            {
12613                let member_inline_size = <fidl::encoding::HandleType<
12614                    fidl::Vmo,
12615                    { fidl::ObjectType::VMO.into_raw() },
12616                    2147483648,
12617                > as fidl::encoding::TypeMarker>::inline_size(
12618                    decoder.context
12619                );
12620                if inlined != (member_inline_size <= 4) {
12621                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12622                }
12623                let inner_offset;
12624                let mut inner_depth = depth.clone();
12625                if inlined {
12626                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12627                    inner_offset = next_offset;
12628                } else {
12629                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12630                    inner_depth.increment()?;
12631                }
12632                let val_ref =
12633                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
12634                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12635                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12636                {
12637                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12638                }
12639                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12640                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12641                }
12642            }
12643
12644            next_offset += envelope_size;
12645            _next_ordinal_to_read += 1;
12646            if next_offset >= end_offset {
12647                return Ok(());
12648            }
12649
12650            // Decode unknown envelopes for gaps in ordinals.
12651            while _next_ordinal_to_read < 2 {
12652                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12653                _next_ordinal_to_read += 1;
12654                next_offset += envelope_size;
12655            }
12656
12657            let next_out_of_line = decoder.next_out_of_line();
12658            let handles_before = decoder.remaining_handles();
12659            if let Some((inlined, num_bytes, num_handles)) =
12660                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12661            {
12662                let member_inline_size =
12663                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12664                if inlined != (member_inline_size <= 4) {
12665                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12666                }
12667                let inner_offset;
12668                let mut inner_depth = depth.clone();
12669                if inlined {
12670                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12671                    inner_offset = next_offset;
12672                } else {
12673                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12674                    inner_depth.increment()?;
12675                }
12676                let val_ref = self.offset.get_or_insert_with(|| {
12677                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12678                });
12679                fidl::decode!(
12680                    u64,
12681                    fidl::encoding::DefaultFuchsiaResourceDialect,
12682                    val_ref,
12683                    decoder,
12684                    inner_offset,
12685                    inner_depth
12686                )?;
12687                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12688                {
12689                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12690                }
12691                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12692                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12693                }
12694            }
12695
12696            next_offset += envelope_size;
12697            _next_ordinal_to_read += 1;
12698            if next_offset >= end_offset {
12699                return Ok(());
12700            }
12701
12702            // Decode unknown envelopes for gaps in ordinals.
12703            while _next_ordinal_to_read < 3 {
12704                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12705                _next_ordinal_to_read += 1;
12706                next_offset += envelope_size;
12707            }
12708
12709            let next_out_of_line = decoder.next_out_of_line();
12710            let handles_before = decoder.remaining_handles();
12711            if let Some((inlined, num_bytes, num_handles)) =
12712                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12713            {
12714                let member_inline_size =
12715                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12716                if inlined != (member_inline_size <= 4) {
12717                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12718                }
12719                let inner_offset;
12720                let mut inner_depth = depth.clone();
12721                if inlined {
12722                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12723                    inner_offset = next_offset;
12724                } else {
12725                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12726                    inner_depth.increment()?;
12727                }
12728                let val_ref = self.count.get_or_insert_with(|| {
12729                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12730                });
12731                fidl::decode!(
12732                    u32,
12733                    fidl::encoding::DefaultFuchsiaResourceDialect,
12734                    val_ref,
12735                    decoder,
12736                    inner_offset,
12737                    inner_depth
12738                )?;
12739                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12740                {
12741                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12742                }
12743                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12744                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12745                }
12746            }
12747
12748            next_offset += envelope_size;
12749            _next_ordinal_to_read += 1;
12750            if next_offset >= end_offset {
12751                return Ok(());
12752            }
12753
12754            // Decode unknown envelopes for gaps in ordinals.
12755            while _next_ordinal_to_read < 4 {
12756                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12757                _next_ordinal_to_read += 1;
12758                next_offset += envelope_size;
12759            }
12760
12761            let next_out_of_line = decoder.next_out_of_line();
12762            let handles_before = decoder.remaining_handles();
12763            if let Some((inlined, num_bytes, num_handles)) =
12764                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12765            {
12766                let member_inline_size =
12767                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12768                if inlined != (member_inline_size <= 4) {
12769                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12770                }
12771                let inner_offset;
12772                let mut inner_depth = depth.clone();
12773                if inlined {
12774                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12775                    inner_offset = next_offset;
12776                } else {
12777                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12778                    inner_depth.increment()?;
12779                }
12780                let val_ref = self.mask.get_or_insert_with(|| {
12781                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
12782                });
12783                fidl::decode!(
12784                    u32,
12785                    fidl::encoding::DefaultFuchsiaResourceDialect,
12786                    val_ref,
12787                    decoder,
12788                    inner_offset,
12789                    inner_depth
12790                )?;
12791                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12792                {
12793                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12794                }
12795                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12796                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12797                }
12798            }
12799
12800            next_offset += envelope_size;
12801
12802            // Decode the remaining unknown envelopes.
12803            while next_offset < end_offset {
12804                _next_ordinal_to_read += 1;
12805                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12806                next_offset += envelope_size;
12807            }
12808
12809            Ok(())
12810        }
12811    }
12812
12813    impl WakeResponse {
12814        #[inline(always)]
12815        fn max_ordinal_present(&self) -> u64 {
12816            if let Some(_) = self.count {
12817                return 1;
12818            }
12819            0
12820        }
12821    }
12822
12823    impl fidl::encoding::ResourceTypeMarker for WakeResponse {
12824        type Borrowed<'a> = &'a mut Self;
12825        fn take_or_borrow<'a>(
12826            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12827        ) -> Self::Borrowed<'a> {
12828            value
12829        }
12830    }
12831
12832    unsafe impl fidl::encoding::TypeMarker for WakeResponse {
12833        type Owned = Self;
12834
12835        #[inline(always)]
12836        fn inline_align(_context: fidl::encoding::Context) -> usize {
12837            8
12838        }
12839
12840        #[inline(always)]
12841        fn inline_size(_context: fidl::encoding::Context) -> usize {
12842            16
12843        }
12844    }
12845
12846    unsafe impl fidl::encoding::Encode<WakeResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
12847        for &mut WakeResponse
12848    {
12849        unsafe fn encode(
12850            self,
12851            encoder: &mut fidl::encoding::Encoder<
12852                '_,
12853                fidl::encoding::DefaultFuchsiaResourceDialect,
12854            >,
12855            offset: usize,
12856            mut depth: fidl::encoding::Depth,
12857        ) -> fidl::Result<()> {
12858            encoder.debug_check_bounds::<WakeResponse>(offset);
12859            // Vector header
12860            let max_ordinal: u64 = self.max_ordinal_present();
12861            encoder.write_num(max_ordinal, offset);
12862            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12863            // Calling encoder.out_of_line_offset(0) is not allowed.
12864            if max_ordinal == 0 {
12865                return Ok(());
12866            }
12867            depth.increment()?;
12868            let envelope_size = 8;
12869            let bytes_len = max_ordinal as usize * envelope_size;
12870            #[allow(unused_variables)]
12871            let offset = encoder.out_of_line_offset(bytes_len);
12872            let mut _prev_end_offset: usize = 0;
12873            if 1 > max_ordinal {
12874                return Ok(());
12875            }
12876
12877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12878            // are envelope_size bytes.
12879            let cur_offset: usize = (1 - 1) * envelope_size;
12880
12881            // Zero reserved fields.
12882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12883
12884            // Safety:
12885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12887            //   envelope_size bytes, there is always sufficient room.
12888            fidl::encoding::encode_in_envelope_optional::<
12889                u64,
12890                fidl::encoding::DefaultFuchsiaResourceDialect,
12891            >(
12892                self.count.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
12893                encoder,
12894                offset + cur_offset,
12895                depth,
12896            )?;
12897
12898            _prev_end_offset = cur_offset + envelope_size;
12899
12900            Ok(())
12901        }
12902    }
12903
12904    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WakeResponse {
12905        #[inline(always)]
12906        fn new_empty() -> Self {
12907            Self::default()
12908        }
12909
12910        unsafe fn decode(
12911            &mut self,
12912            decoder: &mut fidl::encoding::Decoder<
12913                '_,
12914                fidl::encoding::DefaultFuchsiaResourceDialect,
12915            >,
12916            offset: usize,
12917            mut depth: fidl::encoding::Depth,
12918        ) -> fidl::Result<()> {
12919            decoder.debug_check_bounds::<Self>(offset);
12920            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12921                None => return Err(fidl::Error::NotNullable),
12922                Some(len) => len,
12923            };
12924            // Calling decoder.out_of_line_offset(0) is not allowed.
12925            if len == 0 {
12926                return Ok(());
12927            };
12928            depth.increment()?;
12929            let envelope_size = 8;
12930            let bytes_len = len * envelope_size;
12931            let offset = decoder.out_of_line_offset(bytes_len)?;
12932            // Decode the envelope for each type.
12933            let mut _next_ordinal_to_read = 0;
12934            let mut next_offset = offset;
12935            let end_offset = offset + bytes_len;
12936            _next_ordinal_to_read += 1;
12937            if next_offset >= end_offset {
12938                return Ok(());
12939            }
12940
12941            // Decode unknown envelopes for gaps in ordinals.
12942            while _next_ordinal_to_read < 1 {
12943                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12944                _next_ordinal_to_read += 1;
12945                next_offset += envelope_size;
12946            }
12947
12948            let next_out_of_line = decoder.next_out_of_line();
12949            let handles_before = decoder.remaining_handles();
12950            if let Some((inlined, num_bytes, num_handles)) =
12951                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12952            {
12953                let member_inline_size =
12954                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12955                if inlined != (member_inline_size <= 4) {
12956                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12957                }
12958                let inner_offset;
12959                let mut inner_depth = depth.clone();
12960                if inlined {
12961                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12962                    inner_offset = next_offset;
12963                } else {
12964                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12965                    inner_depth.increment()?;
12966                }
12967                let val_ref = self.count.get_or_insert_with(|| {
12968                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
12969                });
12970                fidl::decode!(
12971                    u64,
12972                    fidl::encoding::DefaultFuchsiaResourceDialect,
12973                    val_ref,
12974                    decoder,
12975                    inner_offset,
12976                    inner_depth
12977                )?;
12978                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12979                {
12980                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12981                }
12982                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12983                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12984                }
12985            }
12986
12987            next_offset += envelope_size;
12988
12989            // Decode the remaining unknown envelopes.
12990            while next_offset < end_offset {
12991                _next_ordinal_to_read += 1;
12992                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12993                next_offset += envelope_size;
12994            }
12995
12996            Ok(())
12997        }
12998    }
12999}