Skip to main content

fidl_fuchsia_hardware_usb_endpoint/
fidl_fuchsia_hardware_usb_endpoint.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_hardware_usb_endpoint_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct EndpointOnCompletionRequest {
16    pub completion: Vec<Completion>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for EndpointOnCompletionRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct EndpointQueueRequestsRequest {
26    pub req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for EndpointQueueRequestsRequest
31{
32}
33
34#[derive(Debug, PartialEq)]
35pub struct EndpointRegisterVmosRequest {
36    pub vmo_ids: Vec<VmoInfo>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40    for EndpointRegisterVmosRequest
41{
42}
43
44#[derive(Debug, PartialEq)]
45pub struct EndpointRegisterVmosResponse {
46    pub vmos: Vec<VmoHandle>,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
50    for EndpointRegisterVmosResponse
51{
52}
53
54#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub struct EndpointUnregisterVmosResponse {
56    pub failed_vmo_ids: Vec<u64>,
57    pub errors: Vec<i32>,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61    for EndpointUnregisterVmosResponse
62{
63}
64
65/// Completion
66#[derive(Debug, Default, PartialEq)]
67pub struct Completion {
68    /// Request completed.
69    pub request: Option<fidl_fuchsia_hardware_usb_request::Request>,
70    /// Completion status.
71    pub status: Option<i32>,
72    /// Bytes successfully transferred.
73    pub transfer_size: Option<u64>,
74    /// Wake lease if this completion took the system out of suspend.
75    pub wake_lease: Option<fidl::EventPair>,
76    #[doc(hidden)]
77    pub __source_breaking: fidl::marker::SourceBreaking,
78}
79
80impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Completion {}
81
82/// VMO handle returned for registered VMOs. Only used as a return value for `UnregisterVmos()` to
83/// associate a VMO handle with the VmoId it was registered to.
84#[derive(Debug, Default, PartialEq)]
85pub struct VmoHandle {
86    /// ID corresponding to the registered VMO as passed in by `RegisterVmos()` through `VmoInfo`.
87    pub id: Option<u64>,
88    /// Handle to VMO.
89    pub vmo: Option<fidl::Vmo>,
90    #[doc(hidden)]
91    pub __source_breaking: fidl::marker::SourceBreaking,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VmoHandle {}
95
96#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
97pub struct EndpointMarker;
98
99impl fidl::endpoints::ProtocolMarker for EndpointMarker {
100    type Proxy = EndpointProxy;
101    type RequestStream = EndpointRequestStream;
102    #[cfg(target_os = "fuchsia")]
103    type SynchronousProxy = EndpointSynchronousProxy;
104
105    const DEBUG_NAME: &'static str = "fuchsia.hardware.usb.endpoint.Endpoint";
106}
107impl fidl::endpoints::DiscoverableProtocolMarker for EndpointMarker {}
108pub type EndpointGetInfoResult = Result<EndpointInfo, i32>;
109pub type EndpointCancelAllResult = Result<(), i32>;
110
111pub trait EndpointProxyInterface: Send + Sync {
112    type GetInfoResponseFut: std::future::Future<Output = Result<EndpointGetInfoResult, fidl::Error>>
113        + Send;
114    fn r#get_info(&self) -> Self::GetInfoResponseFut;
115    type RegisterVmosResponseFut: std::future::Future<Output = Result<Vec<VmoHandle>, fidl::Error>>
116        + Send;
117    fn r#register_vmos(&self, vmo_ids: &[VmoInfo]) -> Self::RegisterVmosResponseFut;
118    type UnregisterVmosResponseFut: std::future::Future<Output = Result<(Vec<u64>, Vec<i32>), fidl::Error>>
119        + Send;
120    fn r#unregister_vmos(&self, vmo_ids: &[u64]) -> Self::UnregisterVmosResponseFut;
121    fn r#queue_requests(
122        &self,
123        req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
124    ) -> Result<(), fidl::Error>;
125    type CancelAllResponseFut: std::future::Future<Output = Result<EndpointCancelAllResult, fidl::Error>>
126        + Send;
127    fn r#cancel_all(&self) -> Self::CancelAllResponseFut;
128}
129#[derive(Debug)]
130#[cfg(target_os = "fuchsia")]
131pub struct EndpointSynchronousProxy {
132    client: fidl::client::sync::Client,
133}
134
135#[cfg(target_os = "fuchsia")]
136impl fidl::endpoints::SynchronousProxy for EndpointSynchronousProxy {
137    type Proxy = EndpointProxy;
138    type Protocol = EndpointMarker;
139
140    fn from_channel(inner: fidl::Channel) -> Self {
141        Self::new(inner)
142    }
143
144    fn into_channel(self) -> fidl::Channel {
145        self.client.into_channel()
146    }
147
148    fn as_channel(&self) -> &fidl::Channel {
149        self.client.as_channel()
150    }
151}
152
153#[cfg(target_os = "fuchsia")]
154impl EndpointSynchronousProxy {
155    pub fn new(channel: fidl::Channel) -> Self {
156        Self { client: fidl::client::sync::Client::new(channel) }
157    }
158
159    pub fn into_channel(self) -> fidl::Channel {
160        self.client.into_channel()
161    }
162
163    /// Waits until an event arrives and returns it. It is safe for other
164    /// threads to make concurrent requests while waiting for an event.
165    pub fn wait_for_event(
166        &self,
167        deadline: zx::MonotonicInstant,
168    ) -> Result<EndpointEvent, fidl::Error> {
169        EndpointEvent::decode(self.client.wait_for_event::<EndpointMarker>(deadline)?)
170    }
171
172    /// Gets endpoint information
173    pub fn r#get_info(
174        &self,
175        ___deadline: zx::MonotonicInstant,
176    ) -> Result<EndpointGetInfoResult, fidl::Error> {
177        let _response = self.client.send_query::<
178            fidl::encoding::EmptyPayload,
179            fidl::encoding::ResultType<EndpointGetInfoResponse, i32>,
180            EndpointMarker,
181        >(
182            (),
183            0x1fba84f171a95023,
184            fidl::encoding::DynamicFlags::empty(),
185            ___deadline,
186        )?;
187        Ok(_response.map(|x| x.info))
188    }
189
190    /// Registers and pins VMOs to the vmo_ids. Returns
191    ///  * vmo: Handles to successfully registered vmo_ids.
192    /// VMO IDs that are already are registered to will fail.
193    pub fn r#register_vmos(
194        &self,
195        mut vmo_ids: &[VmoInfo],
196        ___deadline: zx::MonotonicInstant,
197    ) -> Result<Vec<VmoHandle>, fidl::Error> {
198        let _response = self.client.send_query::<
199            EndpointRegisterVmosRequest,
200            EndpointRegisterVmosResponse,
201            EndpointMarker,
202        >(
203            (vmo_ids,),
204            0x1dea601921185c7b,
205            fidl::encoding::DynamicFlags::empty(),
206            ___deadline,
207        )?;
208        Ok(_response.vmos)
209    }
210
211    /// Unregisters the VMOs corresponding to the vmo_ids. Returns
212    ///  * failed_vmo_ids: vmo_ids that failed to unregister.
213    ///  * errors: Error values that correspond 1:1 to failed_vmo_ids above.
214    pub fn r#unregister_vmos(
215        &self,
216        mut vmo_ids: &[u64],
217        ___deadline: zx::MonotonicInstant,
218    ) -> Result<(Vec<u64>, Vec<i32>), fidl::Error> {
219        let _response = self.client.send_query::<
220            EndpointUnregisterVmosRequest,
221            EndpointUnregisterVmosResponse,
222            EndpointMarker,
223        >(
224            (vmo_ids,),
225            0x34719ede1c99c10,
226            fidl::encoding::DynamicFlags::empty(),
227            ___deadline,
228        )?;
229        Ok((_response.failed_vmo_ids, _response.errors))
230    }
231
232    /// Submit Requests to queue. Processed starting with the 0th Request. Submitting a vector of
233    /// Requests allows for pre-buffering.
234    ///
235    /// Clients are responsible for cache management and ensuring cache coherency. The explanation
236    /// to follow concerns VMOs that have been previously registered via RegisterVmos. The following
237    /// rules must be followed:
238    ///
239    /// 1. After writing to VMO-backed buffers, the caller must call zx_cache_flush with
240    ///    ZX_CACHE_FLUSH_DATA before invoking QueueRequests, causing the hardware to DMA-process
241    ///    the buffer. This avoids both stale buffer data being DMA-read, and a concurrent race
242    ///    between the hardware and CPU to update the same addresses.
243    ///
244    /// 2. Before reading from VMO-backed buffers, the caller must call zx_cache_flush with
245    ///    ZX_CACHE_FLUSH_DATA | ZX_CACHE_FLUSH_INVALIDATE after the buffer contents have been
246    ///    DMA-written by the hardware. This implies a non-dirty cache (see #1 above) and ensures
247    ///    any subsequent CPU-reads fetch the previously DMA-written data from RAM.
248    ///
249    /// Failing to adhere to these rules will result in the exchange of corrupted and/or stale data.
250    /// If the VMO is not virtually mapped (uncommon), zx_vmo_op_range should be used in lieu of
251    /// zx_cache_flush. If the usb::FidlRequest types are in use, they contain helpers for these
252    /// operations.
253    ///
254    /// Requests may be pre-buffered. In other words, requests may be queued for data that is not
255    /// present/ready in the buffer yet. The USB Endpoint Server consuming requests does not care
256    /// if the data in the buffer is ready or not and will always process requests on schedule. It
257    /// is the responsibility of the USB Endpoint Client that submits requests to ensure that data
258    /// is ready on schedule (taking into consideration cache management above).
259    ///  * Definition of "on schedule" varies for different endpoints and controllers. In general,
260    ///    this will be communicated by the `lead_time` parameter returned by `GetInfo`.
261    pub fn r#queue_requests(
262        &self,
263        mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
264    ) -> Result<(), fidl::Error> {
265        self.client.send::<EndpointQueueRequestsRequest>(
266            (req.as_mut(),),
267            0x431e4170793e38a6,
268            fidl::encoding::DynamicFlags::empty(),
269        )
270    }
271
272    /// Cancels all requests. Returns
273    ///  * ZX_ERR_IO_NOT_PRESENT: If device is not running, disconnected, or inactive.
274    ///  * ZX_ERR_IO: If cancel failed due to an unsuccessful request.
275    pub fn r#cancel_all(
276        &self,
277        ___deadline: zx::MonotonicInstant,
278    ) -> Result<EndpointCancelAllResult, fidl::Error> {
279        let _response = self.client.send_query::<
280            fidl::encoding::EmptyPayload,
281            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
282            EndpointMarker,
283        >(
284            (),
285            0x233854c776cda1cc,
286            fidl::encoding::DynamicFlags::empty(),
287            ___deadline,
288        )?;
289        Ok(_response.map(|x| x))
290    }
291}
292
293#[cfg(target_os = "fuchsia")]
294impl From<EndpointSynchronousProxy> for zx::NullableHandle {
295    fn from(value: EndpointSynchronousProxy) -> Self {
296        value.into_channel().into()
297    }
298}
299
300#[cfg(target_os = "fuchsia")]
301impl From<fidl::Channel> for EndpointSynchronousProxy {
302    fn from(value: fidl::Channel) -> Self {
303        Self::new(value)
304    }
305}
306
307#[cfg(target_os = "fuchsia")]
308impl fidl::endpoints::FromClient for EndpointSynchronousProxy {
309    type Protocol = EndpointMarker;
310
311    fn from_client(value: fidl::endpoints::ClientEnd<EndpointMarker>) -> Self {
312        Self::new(value.into_channel())
313    }
314}
315
316#[derive(Debug, Clone)]
317pub struct EndpointProxy {
318    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
319}
320
321impl fidl::endpoints::Proxy for EndpointProxy {
322    type Protocol = EndpointMarker;
323
324    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
325        Self::new(inner)
326    }
327
328    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
329        self.client.into_channel().map_err(|client| Self { client })
330    }
331
332    fn as_channel(&self) -> &::fidl::AsyncChannel {
333        self.client.as_channel()
334    }
335}
336
337impl EndpointProxy {
338    /// Create a new Proxy for fuchsia.hardware.usb.endpoint/Endpoint.
339    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
340        let protocol_name = <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
341        Self { client: fidl::client::Client::new(channel, protocol_name) }
342    }
343
344    /// Get a Stream of events from the remote end of the protocol.
345    ///
346    /// # Panics
347    ///
348    /// Panics if the event stream was already taken.
349    pub fn take_event_stream(&self) -> EndpointEventStream {
350        EndpointEventStream { event_receiver: self.client.take_event_receiver() }
351    }
352
353    /// Gets endpoint information
354    pub fn r#get_info(
355        &self,
356    ) -> fidl::client::QueryResponseFut<
357        EndpointGetInfoResult,
358        fidl::encoding::DefaultFuchsiaResourceDialect,
359    > {
360        EndpointProxyInterface::r#get_info(self)
361    }
362
363    /// Registers and pins VMOs to the vmo_ids. Returns
364    ///  * vmo: Handles to successfully registered vmo_ids.
365    /// VMO IDs that are already are registered to will fail.
366    pub fn r#register_vmos(
367        &self,
368        mut vmo_ids: &[VmoInfo],
369    ) -> fidl::client::QueryResponseFut<Vec<VmoHandle>, fidl::encoding::DefaultFuchsiaResourceDialect>
370    {
371        EndpointProxyInterface::r#register_vmos(self, vmo_ids)
372    }
373
374    /// Unregisters the VMOs corresponding to the vmo_ids. Returns
375    ///  * failed_vmo_ids: vmo_ids that failed to unregister.
376    ///  * errors: Error values that correspond 1:1 to failed_vmo_ids above.
377    pub fn r#unregister_vmos(
378        &self,
379        mut vmo_ids: &[u64],
380    ) -> fidl::client::QueryResponseFut<
381        (Vec<u64>, Vec<i32>),
382        fidl::encoding::DefaultFuchsiaResourceDialect,
383    > {
384        EndpointProxyInterface::r#unregister_vmos(self, vmo_ids)
385    }
386
387    /// Submit Requests to queue. Processed starting with the 0th Request. Submitting a vector of
388    /// Requests allows for pre-buffering.
389    ///
390    /// Clients are responsible for cache management and ensuring cache coherency. The explanation
391    /// to follow concerns VMOs that have been previously registered via RegisterVmos. The following
392    /// rules must be followed:
393    ///
394    /// 1. After writing to VMO-backed buffers, the caller must call zx_cache_flush with
395    ///    ZX_CACHE_FLUSH_DATA before invoking QueueRequests, causing the hardware to DMA-process
396    ///    the buffer. This avoids both stale buffer data being DMA-read, and a concurrent race
397    ///    between the hardware and CPU to update the same addresses.
398    ///
399    /// 2. Before reading from VMO-backed buffers, the caller must call zx_cache_flush with
400    ///    ZX_CACHE_FLUSH_DATA | ZX_CACHE_FLUSH_INVALIDATE after the buffer contents have been
401    ///    DMA-written by the hardware. This implies a non-dirty cache (see #1 above) and ensures
402    ///    any subsequent CPU-reads fetch the previously DMA-written data from RAM.
403    ///
404    /// Failing to adhere to these rules will result in the exchange of corrupted and/or stale data.
405    /// If the VMO is not virtually mapped (uncommon), zx_vmo_op_range should be used in lieu of
406    /// zx_cache_flush. If the usb::FidlRequest types are in use, they contain helpers for these
407    /// operations.
408    ///
409    /// Requests may be pre-buffered. In other words, requests may be queued for data that is not
410    /// present/ready in the buffer yet. The USB Endpoint Server consuming requests does not care
411    /// if the data in the buffer is ready or not and will always process requests on schedule. It
412    /// is the responsibility of the USB Endpoint Client that submits requests to ensure that data
413    /// is ready on schedule (taking into consideration cache management above).
414    ///  * Definition of "on schedule" varies for different endpoints and controllers. In general,
415    ///    this will be communicated by the `lead_time` parameter returned by `GetInfo`.
416    pub fn r#queue_requests(
417        &self,
418        mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
419    ) -> Result<(), fidl::Error> {
420        EndpointProxyInterface::r#queue_requests(self, req)
421    }
422
423    /// Cancels all requests. Returns
424    ///  * ZX_ERR_IO_NOT_PRESENT: If device is not running, disconnected, or inactive.
425    ///  * ZX_ERR_IO: If cancel failed due to an unsuccessful request.
426    pub fn r#cancel_all(
427        &self,
428    ) -> fidl::client::QueryResponseFut<
429        EndpointCancelAllResult,
430        fidl::encoding::DefaultFuchsiaResourceDialect,
431    > {
432        EndpointProxyInterface::r#cancel_all(self)
433    }
434}
435
436impl EndpointProxyInterface for EndpointProxy {
437    type GetInfoResponseFut = fidl::client::QueryResponseFut<
438        EndpointGetInfoResult,
439        fidl::encoding::DefaultFuchsiaResourceDialect,
440    >;
441    fn r#get_info(&self) -> Self::GetInfoResponseFut {
442        fn _decode(
443            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
444        ) -> Result<EndpointGetInfoResult, fidl::Error> {
445            let _response = fidl::client::decode_transaction_body::<
446                fidl::encoding::ResultType<EndpointGetInfoResponse, i32>,
447                fidl::encoding::DefaultFuchsiaResourceDialect,
448                0x1fba84f171a95023,
449            >(_buf?)?;
450            Ok(_response.map(|x| x.info))
451        }
452        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, EndpointGetInfoResult>(
453            (),
454            0x1fba84f171a95023,
455            fidl::encoding::DynamicFlags::empty(),
456            _decode,
457        )
458    }
459
460    type RegisterVmosResponseFut = fidl::client::QueryResponseFut<
461        Vec<VmoHandle>,
462        fidl::encoding::DefaultFuchsiaResourceDialect,
463    >;
464    fn r#register_vmos(&self, mut vmo_ids: &[VmoInfo]) -> Self::RegisterVmosResponseFut {
465        fn _decode(
466            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
467        ) -> Result<Vec<VmoHandle>, fidl::Error> {
468            let _response = fidl::client::decode_transaction_body::<
469                EndpointRegisterVmosResponse,
470                fidl::encoding::DefaultFuchsiaResourceDialect,
471                0x1dea601921185c7b,
472            >(_buf?)?;
473            Ok(_response.vmos)
474        }
475        self.client.send_query_and_decode::<EndpointRegisterVmosRequest, Vec<VmoHandle>>(
476            (vmo_ids,),
477            0x1dea601921185c7b,
478            fidl::encoding::DynamicFlags::empty(),
479            _decode,
480        )
481    }
482
483    type UnregisterVmosResponseFut = fidl::client::QueryResponseFut<
484        (Vec<u64>, Vec<i32>),
485        fidl::encoding::DefaultFuchsiaResourceDialect,
486    >;
487    fn r#unregister_vmos(&self, mut vmo_ids: &[u64]) -> Self::UnregisterVmosResponseFut {
488        fn _decode(
489            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
490        ) -> Result<(Vec<u64>, Vec<i32>), fidl::Error> {
491            let _response = fidl::client::decode_transaction_body::<
492                EndpointUnregisterVmosResponse,
493                fidl::encoding::DefaultFuchsiaResourceDialect,
494                0x34719ede1c99c10,
495            >(_buf?)?;
496            Ok((_response.failed_vmo_ids, _response.errors))
497        }
498        self.client.send_query_and_decode::<EndpointUnregisterVmosRequest, (Vec<u64>, Vec<i32>)>(
499            (vmo_ids,),
500            0x34719ede1c99c10,
501            fidl::encoding::DynamicFlags::empty(),
502            _decode,
503        )
504    }
505
506    fn r#queue_requests(
507        &self,
508        mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
509    ) -> Result<(), fidl::Error> {
510        self.client.send::<EndpointQueueRequestsRequest>(
511            (req.as_mut(),),
512            0x431e4170793e38a6,
513            fidl::encoding::DynamicFlags::empty(),
514        )
515    }
516
517    type CancelAllResponseFut = fidl::client::QueryResponseFut<
518        EndpointCancelAllResult,
519        fidl::encoding::DefaultFuchsiaResourceDialect,
520    >;
521    fn r#cancel_all(&self) -> Self::CancelAllResponseFut {
522        fn _decode(
523            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
524        ) -> Result<EndpointCancelAllResult, fidl::Error> {
525            let _response = fidl::client::decode_transaction_body::<
526                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
527                fidl::encoding::DefaultFuchsiaResourceDialect,
528                0x233854c776cda1cc,
529            >(_buf?)?;
530            Ok(_response.map(|x| x))
531        }
532        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, EndpointCancelAllResult>(
533            (),
534            0x233854c776cda1cc,
535            fidl::encoding::DynamicFlags::empty(),
536            _decode,
537        )
538    }
539}
540
541pub struct EndpointEventStream {
542    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
543}
544
545impl std::marker::Unpin for EndpointEventStream {}
546
547impl futures::stream::FusedStream for EndpointEventStream {
548    fn is_terminated(&self) -> bool {
549        self.event_receiver.is_terminated()
550    }
551}
552
553impl futures::Stream for EndpointEventStream {
554    type Item = Result<EndpointEvent, fidl::Error>;
555
556    fn poll_next(
557        mut self: std::pin::Pin<&mut Self>,
558        cx: &mut std::task::Context<'_>,
559    ) -> std::task::Poll<Option<Self::Item>> {
560        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
561            &mut self.event_receiver,
562            cx
563        )?) {
564            Some(buf) => std::task::Poll::Ready(Some(EndpointEvent::decode(buf))),
565            None => std::task::Poll::Ready(None),
566        }
567    }
568}
569
570#[derive(Debug)]
571pub enum EndpointEvent {
572    OnCompletion { completion: Vec<Completion> },
573}
574
575impl EndpointEvent {
576    #[allow(irrefutable_let_patterns)]
577    pub fn into_on_completion(self) -> Option<Vec<Completion>> {
578        if let EndpointEvent::OnCompletion { completion } = self {
579            Some((completion))
580        } else {
581            None
582        }
583    }
584
585    /// Decodes a message buffer as a [`EndpointEvent`].
586    fn decode(
587        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
588    ) -> Result<EndpointEvent, fidl::Error> {
589        let (bytes, _handles) = buf.split_mut();
590        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
591        debug_assert_eq!(tx_header.tx_id, 0);
592        match tx_header.ordinal {
593            0x2d6471306c049771 => {
594                let mut out = fidl::new_empty!(
595                    EndpointOnCompletionRequest,
596                    fidl::encoding::DefaultFuchsiaResourceDialect
597                );
598                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointOnCompletionRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
599                Ok((EndpointEvent::OnCompletion { completion: out.completion }))
600            }
601            _ => Err(fidl::Error::UnknownOrdinal {
602                ordinal: tx_header.ordinal,
603                protocol_name: <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
604            }),
605        }
606    }
607}
608
609/// A Stream of incoming requests for fuchsia.hardware.usb.endpoint/Endpoint.
610pub struct EndpointRequestStream {
611    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
612    is_terminated: bool,
613}
614
615impl std::marker::Unpin for EndpointRequestStream {}
616
617impl futures::stream::FusedStream for EndpointRequestStream {
618    fn is_terminated(&self) -> bool {
619        self.is_terminated
620    }
621}
622
623impl fidl::endpoints::RequestStream for EndpointRequestStream {
624    type Protocol = EndpointMarker;
625    type ControlHandle = EndpointControlHandle;
626
627    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
628        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
629    }
630
631    fn control_handle(&self) -> Self::ControlHandle {
632        EndpointControlHandle { inner: self.inner.clone() }
633    }
634
635    fn into_inner(
636        self,
637    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
638    {
639        (self.inner, self.is_terminated)
640    }
641
642    fn from_inner(
643        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
644        is_terminated: bool,
645    ) -> Self {
646        Self { inner, is_terminated }
647    }
648}
649
650impl futures::Stream for EndpointRequestStream {
651    type Item = Result<EndpointRequest, fidl::Error>;
652
653    fn poll_next(
654        mut self: std::pin::Pin<&mut Self>,
655        cx: &mut std::task::Context<'_>,
656    ) -> std::task::Poll<Option<Self::Item>> {
657        let this = &mut *self;
658        if this.inner.check_shutdown(cx) {
659            this.is_terminated = true;
660            return std::task::Poll::Ready(None);
661        }
662        if this.is_terminated {
663            panic!("polled EndpointRequestStream after completion");
664        }
665        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
666            |bytes, handles| {
667                match this.inner.channel().read_etc(cx, bytes, handles) {
668                    std::task::Poll::Ready(Ok(())) => {}
669                    std::task::Poll::Pending => return std::task::Poll::Pending,
670                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
671                        this.is_terminated = true;
672                        return std::task::Poll::Ready(None);
673                    }
674                    std::task::Poll::Ready(Err(e)) => {
675                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
676                            e.into(),
677                        ))));
678                    }
679                }
680
681                // A message has been received from the channel
682                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
683
684                std::task::Poll::Ready(Some(match header.ordinal {
685                    0x1fba84f171a95023 => {
686                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
687                        let mut req = fidl::new_empty!(
688                            fidl::encoding::EmptyPayload,
689                            fidl::encoding::DefaultFuchsiaResourceDialect
690                        );
691                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
692                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
693                        Ok(EndpointRequest::GetInfo {
694                            responder: EndpointGetInfoResponder {
695                                control_handle: std::mem::ManuallyDrop::new(control_handle),
696                                tx_id: header.tx_id,
697                            },
698                        })
699                    }
700                    0x1dea601921185c7b => {
701                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
702                        let mut req = fidl::new_empty!(
703                            EndpointRegisterVmosRequest,
704                            fidl::encoding::DefaultFuchsiaResourceDialect
705                        );
706                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointRegisterVmosRequest>(&header, _body_bytes, handles, &mut req)?;
707                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
708                        Ok(EndpointRequest::RegisterVmos {
709                            vmo_ids: req.vmo_ids,
710
711                            responder: EndpointRegisterVmosResponder {
712                                control_handle: std::mem::ManuallyDrop::new(control_handle),
713                                tx_id: header.tx_id,
714                            },
715                        })
716                    }
717                    0x34719ede1c99c10 => {
718                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
719                        let mut req = fidl::new_empty!(
720                            EndpointUnregisterVmosRequest,
721                            fidl::encoding::DefaultFuchsiaResourceDialect
722                        );
723                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointUnregisterVmosRequest>(&header, _body_bytes, handles, &mut req)?;
724                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
725                        Ok(EndpointRequest::UnregisterVmos {
726                            vmo_ids: req.vmo_ids,
727
728                            responder: EndpointUnregisterVmosResponder {
729                                control_handle: std::mem::ManuallyDrop::new(control_handle),
730                                tx_id: header.tx_id,
731                            },
732                        })
733                    }
734                    0x431e4170793e38a6 => {
735                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
736                        let mut req = fidl::new_empty!(
737                            EndpointQueueRequestsRequest,
738                            fidl::encoding::DefaultFuchsiaResourceDialect
739                        );
740                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointQueueRequestsRequest>(&header, _body_bytes, handles, &mut req)?;
741                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
742                        Ok(EndpointRequest::QueueRequests { req: req.req, control_handle })
743                    }
744                    0x233854c776cda1cc => {
745                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
746                        let mut req = fidl::new_empty!(
747                            fidl::encoding::EmptyPayload,
748                            fidl::encoding::DefaultFuchsiaResourceDialect
749                        );
750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
751                        let control_handle = EndpointControlHandle { inner: this.inner.clone() };
752                        Ok(EndpointRequest::CancelAll {
753                            responder: EndpointCancelAllResponder {
754                                control_handle: std::mem::ManuallyDrop::new(control_handle),
755                                tx_id: header.tx_id,
756                            },
757                        })
758                    }
759                    _ => Err(fidl::Error::UnknownOrdinal {
760                        ordinal: header.ordinal,
761                        protocol_name:
762                            <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
763                    }),
764                }))
765            },
766        )
767    }
768}
769
770/// Endpoint Interface.
771/// Pre-registered VMOs associated with the Endpoint are tied to the lifetime of the Endpoint. When
772/// the Endpoint is closed, all outstanding registered VMOs are unregistered, references to their
773/// handles dropped and any necessary actions for DisableEndpoint will be called.
774#[derive(Debug)]
775pub enum EndpointRequest {
776    /// Gets endpoint information
777    GetInfo { responder: EndpointGetInfoResponder },
778    /// Registers and pins VMOs to the vmo_ids. Returns
779    ///  * vmo: Handles to successfully registered vmo_ids.
780    /// VMO IDs that are already are registered to will fail.
781    RegisterVmos { vmo_ids: Vec<VmoInfo>, responder: EndpointRegisterVmosResponder },
782    /// Unregisters the VMOs corresponding to the vmo_ids. Returns
783    ///  * failed_vmo_ids: vmo_ids that failed to unregister.
784    ///  * errors: Error values that correspond 1:1 to failed_vmo_ids above.
785    UnregisterVmos { vmo_ids: Vec<u64>, responder: EndpointUnregisterVmosResponder },
786    /// Submit Requests to queue. Processed starting with the 0th Request. Submitting a vector of
787    /// Requests allows for pre-buffering.
788    ///
789    /// Clients are responsible for cache management and ensuring cache coherency. The explanation
790    /// to follow concerns VMOs that have been previously registered via RegisterVmos. The following
791    /// rules must be followed:
792    ///
793    /// 1. After writing to VMO-backed buffers, the caller must call zx_cache_flush with
794    ///    ZX_CACHE_FLUSH_DATA before invoking QueueRequests, causing the hardware to DMA-process
795    ///    the buffer. This avoids both stale buffer data being DMA-read, and a concurrent race
796    ///    between the hardware and CPU to update the same addresses.
797    ///
798    /// 2. Before reading from VMO-backed buffers, the caller must call zx_cache_flush with
799    ///    ZX_CACHE_FLUSH_DATA | ZX_CACHE_FLUSH_INVALIDATE after the buffer contents have been
800    ///    DMA-written by the hardware. This implies a non-dirty cache (see #1 above) and ensures
801    ///    any subsequent CPU-reads fetch the previously DMA-written data from RAM.
802    ///
803    /// Failing to adhere to these rules will result in the exchange of corrupted and/or stale data.
804    /// If the VMO is not virtually mapped (uncommon), zx_vmo_op_range should be used in lieu of
805    /// zx_cache_flush. If the usb::FidlRequest types are in use, they contain helpers for these
806    /// operations.
807    ///
808    /// Requests may be pre-buffered. In other words, requests may be queued for data that is not
809    /// present/ready in the buffer yet. The USB Endpoint Server consuming requests does not care
810    /// if the data in the buffer is ready or not and will always process requests on schedule. It
811    /// is the responsibility of the USB Endpoint Client that submits requests to ensure that data
812    /// is ready on schedule (taking into consideration cache management above).
813    ///  * Definition of "on schedule" varies for different endpoints and controllers. In general,
814    ///    this will be communicated by the `lead_time` parameter returned by `GetInfo`.
815    QueueRequests {
816        req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
817        control_handle: EndpointControlHandle,
818    },
819    /// Cancels all requests. Returns
820    ///  * ZX_ERR_IO_NOT_PRESENT: If device is not running, disconnected, or inactive.
821    ///  * ZX_ERR_IO: If cancel failed due to an unsuccessful request.
822    CancelAll { responder: EndpointCancelAllResponder },
823}
824
825impl EndpointRequest {
826    #[allow(irrefutable_let_patterns)]
827    pub fn into_get_info(self) -> Option<(EndpointGetInfoResponder)> {
828        if let EndpointRequest::GetInfo { responder } = self { Some((responder)) } else { None }
829    }
830
831    #[allow(irrefutable_let_patterns)]
832    pub fn into_register_vmos(self) -> Option<(Vec<VmoInfo>, EndpointRegisterVmosResponder)> {
833        if let EndpointRequest::RegisterVmos { vmo_ids, responder } = self {
834            Some((vmo_ids, responder))
835        } else {
836            None
837        }
838    }
839
840    #[allow(irrefutable_let_patterns)]
841    pub fn into_unregister_vmos(self) -> Option<(Vec<u64>, EndpointUnregisterVmosResponder)> {
842        if let EndpointRequest::UnregisterVmos { vmo_ids, responder } = self {
843            Some((vmo_ids, responder))
844        } else {
845            None
846        }
847    }
848
849    #[allow(irrefutable_let_patterns)]
850    pub fn into_queue_requests(
851        self,
852    ) -> Option<(Vec<fidl_fuchsia_hardware_usb_request::Request>, EndpointControlHandle)> {
853        if let EndpointRequest::QueueRequests { req, control_handle } = self {
854            Some((req, control_handle))
855        } else {
856            None
857        }
858    }
859
860    #[allow(irrefutable_let_patterns)]
861    pub fn into_cancel_all(self) -> Option<(EndpointCancelAllResponder)> {
862        if let EndpointRequest::CancelAll { responder } = self { Some((responder)) } else { None }
863    }
864
865    /// Name of the method defined in FIDL
866    pub fn method_name(&self) -> &'static str {
867        match *self {
868            EndpointRequest::GetInfo { .. } => "get_info",
869            EndpointRequest::RegisterVmos { .. } => "register_vmos",
870            EndpointRequest::UnregisterVmos { .. } => "unregister_vmos",
871            EndpointRequest::QueueRequests { .. } => "queue_requests",
872            EndpointRequest::CancelAll { .. } => "cancel_all",
873        }
874    }
875}
876
877#[derive(Debug, Clone)]
878pub struct EndpointControlHandle {
879    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
880}
881
882impl fidl::endpoints::ControlHandle for EndpointControlHandle {
883    fn shutdown(&self) {
884        self.inner.shutdown()
885    }
886
887    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
888        self.inner.shutdown_with_epitaph(status)
889    }
890
891    fn is_closed(&self) -> bool {
892        self.inner.channel().is_closed()
893    }
894    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
895        self.inner.channel().on_closed()
896    }
897
898    #[cfg(target_os = "fuchsia")]
899    fn signal_peer(
900        &self,
901        clear_mask: zx::Signals,
902        set_mask: zx::Signals,
903    ) -> Result<(), zx_status::Status> {
904        use fidl::Peered;
905        self.inner.channel().signal_peer(clear_mask, set_mask)
906    }
907}
908
909impl EndpointControlHandle {
910    pub fn send_on_completion(&self, mut completion: Vec<Completion>) -> Result<(), fidl::Error> {
911        self.inner.send::<EndpointOnCompletionRequest>(
912            (completion.as_mut(),),
913            0,
914            0x2d6471306c049771,
915            fidl::encoding::DynamicFlags::empty(),
916        )
917    }
918}
919
920#[must_use = "FIDL methods require a response to be sent"]
921#[derive(Debug)]
922pub struct EndpointGetInfoResponder {
923    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
924    tx_id: u32,
925}
926
927/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
928/// if the responder is dropped without sending a response, so that the client
929/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
930impl std::ops::Drop for EndpointGetInfoResponder {
931    fn drop(&mut self) {
932        self.control_handle.shutdown();
933        // Safety: drops once, never accessed again
934        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
935    }
936}
937
938impl fidl::endpoints::Responder for EndpointGetInfoResponder {
939    type ControlHandle = EndpointControlHandle;
940
941    fn control_handle(&self) -> &EndpointControlHandle {
942        &self.control_handle
943    }
944
945    fn drop_without_shutdown(mut self) {
946        // Safety: drops once, never accessed again due to mem::forget
947        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
948        // Prevent Drop from running (which would shut down the channel)
949        std::mem::forget(self);
950    }
951}
952
953impl EndpointGetInfoResponder {
954    /// Sends a response to the FIDL transaction.
955    ///
956    /// Sets the channel to shutdown if an error occurs.
957    pub fn send(self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
958        let _result = self.send_raw(result);
959        if _result.is_err() {
960            self.control_handle.shutdown();
961        }
962        self.drop_without_shutdown();
963        _result
964    }
965
966    /// Similar to "send" but does not shutdown the channel if an error occurs.
967    pub fn send_no_shutdown_on_err(
968        self,
969        mut result: Result<&EndpointInfo, i32>,
970    ) -> Result<(), fidl::Error> {
971        let _result = self.send_raw(result);
972        self.drop_without_shutdown();
973        _result
974    }
975
976    fn send_raw(&self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
977        self.control_handle.inner.send::<fidl::encoding::ResultType<EndpointGetInfoResponse, i32>>(
978            result.map(|info| (info,)),
979            self.tx_id,
980            0x1fba84f171a95023,
981            fidl::encoding::DynamicFlags::empty(),
982        )
983    }
984}
985
986#[must_use = "FIDL methods require a response to be sent"]
987#[derive(Debug)]
988pub struct EndpointRegisterVmosResponder {
989    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
990    tx_id: u32,
991}
992
993/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
994/// if the responder is dropped without sending a response, so that the client
995/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
996impl std::ops::Drop for EndpointRegisterVmosResponder {
997    fn drop(&mut self) {
998        self.control_handle.shutdown();
999        // Safety: drops once, never accessed again
1000        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1001    }
1002}
1003
1004impl fidl::endpoints::Responder for EndpointRegisterVmosResponder {
1005    type ControlHandle = EndpointControlHandle;
1006
1007    fn control_handle(&self) -> &EndpointControlHandle {
1008        &self.control_handle
1009    }
1010
1011    fn drop_without_shutdown(mut self) {
1012        // Safety: drops once, never accessed again due to mem::forget
1013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1014        // Prevent Drop from running (which would shut down the channel)
1015        std::mem::forget(self);
1016    }
1017}
1018
1019impl EndpointRegisterVmosResponder {
1020    /// Sends a response to the FIDL transaction.
1021    ///
1022    /// Sets the channel to shutdown if an error occurs.
1023    pub fn send(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1024        let _result = self.send_raw(vmos);
1025        if _result.is_err() {
1026            self.control_handle.shutdown();
1027        }
1028        self.drop_without_shutdown();
1029        _result
1030    }
1031
1032    /// Similar to "send" but does not shutdown the channel if an error occurs.
1033    pub fn send_no_shutdown_on_err(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1034        let _result = self.send_raw(vmos);
1035        self.drop_without_shutdown();
1036        _result
1037    }
1038
1039    fn send_raw(&self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1040        self.control_handle.inner.send::<EndpointRegisterVmosResponse>(
1041            (vmos.as_mut(),),
1042            self.tx_id,
1043            0x1dea601921185c7b,
1044            fidl::encoding::DynamicFlags::empty(),
1045        )
1046    }
1047}
1048
1049#[must_use = "FIDL methods require a response to be sent"]
1050#[derive(Debug)]
1051pub struct EndpointUnregisterVmosResponder {
1052    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1053    tx_id: u32,
1054}
1055
1056/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1057/// if the responder is dropped without sending a response, so that the client
1058/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1059impl std::ops::Drop for EndpointUnregisterVmosResponder {
1060    fn drop(&mut self) {
1061        self.control_handle.shutdown();
1062        // Safety: drops once, never accessed again
1063        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1064    }
1065}
1066
1067impl fidl::endpoints::Responder for EndpointUnregisterVmosResponder {
1068    type ControlHandle = EndpointControlHandle;
1069
1070    fn control_handle(&self) -> &EndpointControlHandle {
1071        &self.control_handle
1072    }
1073
1074    fn drop_without_shutdown(mut self) {
1075        // Safety: drops once, never accessed again due to mem::forget
1076        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1077        // Prevent Drop from running (which would shut down the channel)
1078        std::mem::forget(self);
1079    }
1080}
1081
1082impl EndpointUnregisterVmosResponder {
1083    /// Sends a response to the FIDL transaction.
1084    ///
1085    /// Sets the channel to shutdown if an error occurs.
1086    pub fn send(self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1087        let _result = self.send_raw(failed_vmo_ids, errors);
1088        if _result.is_err() {
1089            self.control_handle.shutdown();
1090        }
1091        self.drop_without_shutdown();
1092        _result
1093    }
1094
1095    /// Similar to "send" but does not shutdown the channel if an error occurs.
1096    pub fn send_no_shutdown_on_err(
1097        self,
1098        mut failed_vmo_ids: &[u64],
1099        mut errors: &[i32],
1100    ) -> Result<(), fidl::Error> {
1101        let _result = self.send_raw(failed_vmo_ids, errors);
1102        self.drop_without_shutdown();
1103        _result
1104    }
1105
1106    fn send_raw(&self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1107        self.control_handle.inner.send::<EndpointUnregisterVmosResponse>(
1108            (failed_vmo_ids, errors),
1109            self.tx_id,
1110            0x34719ede1c99c10,
1111            fidl::encoding::DynamicFlags::empty(),
1112        )
1113    }
1114}
1115
1116#[must_use = "FIDL methods require a response to be sent"]
1117#[derive(Debug)]
1118pub struct EndpointCancelAllResponder {
1119    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1120    tx_id: u32,
1121}
1122
1123/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1124/// if the responder is dropped without sending a response, so that the client
1125/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1126impl std::ops::Drop for EndpointCancelAllResponder {
1127    fn drop(&mut self) {
1128        self.control_handle.shutdown();
1129        // Safety: drops once, never accessed again
1130        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1131    }
1132}
1133
1134impl fidl::endpoints::Responder for EndpointCancelAllResponder {
1135    type ControlHandle = EndpointControlHandle;
1136
1137    fn control_handle(&self) -> &EndpointControlHandle {
1138        &self.control_handle
1139    }
1140
1141    fn drop_without_shutdown(mut self) {
1142        // Safety: drops once, never accessed again due to mem::forget
1143        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1144        // Prevent Drop from running (which would shut down the channel)
1145        std::mem::forget(self);
1146    }
1147}
1148
1149impl EndpointCancelAllResponder {
1150    /// Sends a response to the FIDL transaction.
1151    ///
1152    /// Sets the channel to shutdown if an error occurs.
1153    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1154        let _result = self.send_raw(result);
1155        if _result.is_err() {
1156            self.control_handle.shutdown();
1157        }
1158        self.drop_without_shutdown();
1159        _result
1160    }
1161
1162    /// Similar to "send" but does not shutdown the channel if an error occurs.
1163    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1164        let _result = self.send_raw(result);
1165        self.drop_without_shutdown();
1166        _result
1167    }
1168
1169    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1170        self.control_handle
1171            .inner
1172            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1173                result,
1174                self.tx_id,
1175                0x233854c776cda1cc,
1176                fidl::encoding::DynamicFlags::empty(),
1177            )
1178    }
1179}
1180
1181mod internal {
1182    use super::*;
1183
1184    impl fidl::encoding::ResourceTypeMarker for EndpointOnCompletionRequest {
1185        type Borrowed<'a> = &'a mut Self;
1186        fn take_or_borrow<'a>(
1187            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1188        ) -> Self::Borrowed<'a> {
1189            value
1190        }
1191    }
1192
1193    unsafe impl fidl::encoding::TypeMarker for EndpointOnCompletionRequest {
1194        type Owned = Self;
1195
1196        #[inline(always)]
1197        fn inline_align(_context: fidl::encoding::Context) -> usize {
1198            8
1199        }
1200
1201        #[inline(always)]
1202        fn inline_size(_context: fidl::encoding::Context) -> usize {
1203            16
1204        }
1205    }
1206
1207    unsafe impl
1208        fidl::encoding::Encode<
1209            EndpointOnCompletionRequest,
1210            fidl::encoding::DefaultFuchsiaResourceDialect,
1211        > for &mut EndpointOnCompletionRequest
1212    {
1213        #[inline]
1214        unsafe fn encode(
1215            self,
1216            encoder: &mut fidl::encoding::Encoder<
1217                '_,
1218                fidl::encoding::DefaultFuchsiaResourceDialect,
1219            >,
1220            offset: usize,
1221            _depth: fidl::encoding::Depth,
1222        ) -> fidl::Result<()> {
1223            encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1224            // Delegate to tuple encoding.
1225            fidl::encoding::Encode::<EndpointOnCompletionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1226                (
1227                    <fidl::encoding::Vector<Completion, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.completion),
1228                ),
1229                encoder, offset, _depth
1230            )
1231        }
1232    }
1233    unsafe impl<
1234        T0: fidl::encoding::Encode<
1235                fidl::encoding::Vector<Completion, 300>,
1236                fidl::encoding::DefaultFuchsiaResourceDialect,
1237            >,
1238    >
1239        fidl::encoding::Encode<
1240            EndpointOnCompletionRequest,
1241            fidl::encoding::DefaultFuchsiaResourceDialect,
1242        > for (T0,)
1243    {
1244        #[inline]
1245        unsafe fn encode(
1246            self,
1247            encoder: &mut fidl::encoding::Encoder<
1248                '_,
1249                fidl::encoding::DefaultFuchsiaResourceDialect,
1250            >,
1251            offset: usize,
1252            depth: fidl::encoding::Depth,
1253        ) -> fidl::Result<()> {
1254            encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1255            // Zero out padding regions. There's no need to apply masks
1256            // because the unmasked parts will be overwritten by fields.
1257            // Write the fields.
1258            self.0.encode(encoder, offset + 0, depth)?;
1259            Ok(())
1260        }
1261    }
1262
1263    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1264        for EndpointOnCompletionRequest
1265    {
1266        #[inline(always)]
1267        fn new_empty() -> Self {
1268            Self {
1269                completion: fidl::new_empty!(fidl::encoding::Vector<Completion, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1270            }
1271        }
1272
1273        #[inline]
1274        unsafe fn decode(
1275            &mut self,
1276            decoder: &mut fidl::encoding::Decoder<
1277                '_,
1278                fidl::encoding::DefaultFuchsiaResourceDialect,
1279            >,
1280            offset: usize,
1281            _depth: fidl::encoding::Depth,
1282        ) -> fidl::Result<()> {
1283            decoder.debug_check_bounds::<Self>(offset);
1284            // Verify that padding bytes are zero.
1285            fidl::decode!(fidl::encoding::Vector<Completion, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.completion, decoder, offset + 0, _depth)?;
1286            Ok(())
1287        }
1288    }
1289
1290    impl fidl::encoding::ResourceTypeMarker for EndpointQueueRequestsRequest {
1291        type Borrowed<'a> = &'a mut Self;
1292        fn take_or_borrow<'a>(
1293            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1294        ) -> Self::Borrowed<'a> {
1295            value
1296        }
1297    }
1298
1299    unsafe impl fidl::encoding::TypeMarker for EndpointQueueRequestsRequest {
1300        type Owned = Self;
1301
1302        #[inline(always)]
1303        fn inline_align(_context: fidl::encoding::Context) -> usize {
1304            8
1305        }
1306
1307        #[inline(always)]
1308        fn inline_size(_context: fidl::encoding::Context) -> usize {
1309            16
1310        }
1311    }
1312
1313    unsafe impl
1314        fidl::encoding::Encode<
1315            EndpointQueueRequestsRequest,
1316            fidl::encoding::DefaultFuchsiaResourceDialect,
1317        > for &mut EndpointQueueRequestsRequest
1318    {
1319        #[inline]
1320        unsafe fn encode(
1321            self,
1322            encoder: &mut fidl::encoding::Encoder<
1323                '_,
1324                fidl::encoding::DefaultFuchsiaResourceDialect,
1325            >,
1326            offset: usize,
1327            _depth: fidl::encoding::Depth,
1328        ) -> fidl::Result<()> {
1329            encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1330            // Delegate to tuple encoding.
1331            fidl::encoding::Encode::<EndpointQueueRequestsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1332                (
1333                    <fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1334                ),
1335                encoder, offset, _depth
1336            )
1337        }
1338    }
1339    unsafe impl<
1340        T0: fidl::encoding::Encode<
1341                fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>,
1342                fidl::encoding::DefaultFuchsiaResourceDialect,
1343            >,
1344    >
1345        fidl::encoding::Encode<
1346            EndpointQueueRequestsRequest,
1347            fidl::encoding::DefaultFuchsiaResourceDialect,
1348        > for (T0,)
1349    {
1350        #[inline]
1351        unsafe fn encode(
1352            self,
1353            encoder: &mut fidl::encoding::Encoder<
1354                '_,
1355                fidl::encoding::DefaultFuchsiaResourceDialect,
1356            >,
1357            offset: usize,
1358            depth: fidl::encoding::Depth,
1359        ) -> fidl::Result<()> {
1360            encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1361            // Zero out padding regions. There's no need to apply masks
1362            // because the unmasked parts will be overwritten by fields.
1363            // Write the fields.
1364            self.0.encode(encoder, offset + 0, depth)?;
1365            Ok(())
1366        }
1367    }
1368
1369    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1370        for EndpointQueueRequestsRequest
1371    {
1372        #[inline(always)]
1373        fn new_empty() -> Self {
1374            Self {
1375                req: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1376            }
1377        }
1378
1379        #[inline]
1380        unsafe fn decode(
1381            &mut self,
1382            decoder: &mut fidl::encoding::Decoder<
1383                '_,
1384                fidl::encoding::DefaultFuchsiaResourceDialect,
1385            >,
1386            offset: usize,
1387            _depth: fidl::encoding::Depth,
1388        ) -> fidl::Result<()> {
1389            decoder.debug_check_bounds::<Self>(offset);
1390            // Verify that padding bytes are zero.
1391            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.req, decoder, offset + 0, _depth)?;
1392            Ok(())
1393        }
1394    }
1395
1396    impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosRequest {
1397        type Borrowed<'a> = &'a mut Self;
1398        fn take_or_borrow<'a>(
1399            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1400        ) -> Self::Borrowed<'a> {
1401            value
1402        }
1403    }
1404
1405    unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosRequest {
1406        type Owned = Self;
1407
1408        #[inline(always)]
1409        fn inline_align(_context: fidl::encoding::Context) -> usize {
1410            8
1411        }
1412
1413        #[inline(always)]
1414        fn inline_size(_context: fidl::encoding::Context) -> usize {
1415            16
1416        }
1417    }
1418
1419    unsafe impl
1420        fidl::encoding::Encode<
1421            EndpointRegisterVmosRequest,
1422            fidl::encoding::DefaultFuchsiaResourceDialect,
1423        > for &mut EndpointRegisterVmosRequest
1424    {
1425        #[inline]
1426        unsafe fn encode(
1427            self,
1428            encoder: &mut fidl::encoding::Encoder<
1429                '_,
1430                fidl::encoding::DefaultFuchsiaResourceDialect,
1431            >,
1432            offset: usize,
1433            _depth: fidl::encoding::Depth,
1434        ) -> fidl::Result<()> {
1435            encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1436            // Delegate to tuple encoding.
1437            fidl::encoding::Encode::<EndpointRegisterVmosRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1438                (
1439                    <fidl::encoding::Vector<VmoInfo, 300> as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_ids),
1440                ),
1441                encoder, offset, _depth
1442            )
1443        }
1444    }
1445    unsafe impl<
1446        T0: fidl::encoding::Encode<
1447                fidl::encoding::Vector<VmoInfo, 300>,
1448                fidl::encoding::DefaultFuchsiaResourceDialect,
1449            >,
1450    >
1451        fidl::encoding::Encode<
1452            EndpointRegisterVmosRequest,
1453            fidl::encoding::DefaultFuchsiaResourceDialect,
1454        > for (T0,)
1455    {
1456        #[inline]
1457        unsafe fn encode(
1458            self,
1459            encoder: &mut fidl::encoding::Encoder<
1460                '_,
1461                fidl::encoding::DefaultFuchsiaResourceDialect,
1462            >,
1463            offset: usize,
1464            depth: fidl::encoding::Depth,
1465        ) -> fidl::Result<()> {
1466            encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1467            // Zero out padding regions. There's no need to apply masks
1468            // because the unmasked parts will be overwritten by fields.
1469            // Write the fields.
1470            self.0.encode(encoder, offset + 0, depth)?;
1471            Ok(())
1472        }
1473    }
1474
1475    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1476        for EndpointRegisterVmosRequest
1477    {
1478        #[inline(always)]
1479        fn new_empty() -> Self {
1480            Self {
1481                vmo_ids: fidl::new_empty!(fidl::encoding::Vector<VmoInfo, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1482            }
1483        }
1484
1485        #[inline]
1486        unsafe fn decode(
1487            &mut self,
1488            decoder: &mut fidl::encoding::Decoder<
1489                '_,
1490                fidl::encoding::DefaultFuchsiaResourceDialect,
1491            >,
1492            offset: usize,
1493            _depth: fidl::encoding::Depth,
1494        ) -> fidl::Result<()> {
1495            decoder.debug_check_bounds::<Self>(offset);
1496            // Verify that padding bytes are zero.
1497            fidl::decode!(fidl::encoding::Vector<VmoInfo, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo_ids, decoder, offset + 0, _depth)?;
1498            Ok(())
1499        }
1500    }
1501
1502    impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosResponse {
1503        type Borrowed<'a> = &'a mut Self;
1504        fn take_or_borrow<'a>(
1505            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1506        ) -> Self::Borrowed<'a> {
1507            value
1508        }
1509    }
1510
1511    unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosResponse {
1512        type Owned = Self;
1513
1514        #[inline(always)]
1515        fn inline_align(_context: fidl::encoding::Context) -> usize {
1516            8
1517        }
1518
1519        #[inline(always)]
1520        fn inline_size(_context: fidl::encoding::Context) -> usize {
1521            16
1522        }
1523    }
1524
1525    unsafe impl
1526        fidl::encoding::Encode<
1527            EndpointRegisterVmosResponse,
1528            fidl::encoding::DefaultFuchsiaResourceDialect,
1529        > for &mut EndpointRegisterVmosResponse
1530    {
1531        #[inline]
1532        unsafe fn encode(
1533            self,
1534            encoder: &mut fidl::encoding::Encoder<
1535                '_,
1536                fidl::encoding::DefaultFuchsiaResourceDialect,
1537            >,
1538            offset: usize,
1539            _depth: fidl::encoding::Depth,
1540        ) -> fidl::Result<()> {
1541            encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1542            // Delegate to tuple encoding.
1543            fidl::encoding::Encode::<EndpointRegisterVmosResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1544                (
1545                    <fidl::encoding::Vector<VmoHandle, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmos),
1546                ),
1547                encoder, offset, _depth
1548            )
1549        }
1550    }
1551    unsafe impl<
1552        T0: fidl::encoding::Encode<
1553                fidl::encoding::Vector<VmoHandle, 300>,
1554                fidl::encoding::DefaultFuchsiaResourceDialect,
1555            >,
1556    >
1557        fidl::encoding::Encode<
1558            EndpointRegisterVmosResponse,
1559            fidl::encoding::DefaultFuchsiaResourceDialect,
1560        > for (T0,)
1561    {
1562        #[inline]
1563        unsafe fn encode(
1564            self,
1565            encoder: &mut fidl::encoding::Encoder<
1566                '_,
1567                fidl::encoding::DefaultFuchsiaResourceDialect,
1568            >,
1569            offset: usize,
1570            depth: fidl::encoding::Depth,
1571        ) -> fidl::Result<()> {
1572            encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1573            // Zero out padding regions. There's no need to apply masks
1574            // because the unmasked parts will be overwritten by fields.
1575            // Write the fields.
1576            self.0.encode(encoder, offset + 0, depth)?;
1577            Ok(())
1578        }
1579    }
1580
1581    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1582        for EndpointRegisterVmosResponse
1583    {
1584        #[inline(always)]
1585        fn new_empty() -> Self {
1586            Self {
1587                vmos: fidl::new_empty!(fidl::encoding::Vector<VmoHandle, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1588            }
1589        }
1590
1591        #[inline]
1592        unsafe fn decode(
1593            &mut self,
1594            decoder: &mut fidl::encoding::Decoder<
1595                '_,
1596                fidl::encoding::DefaultFuchsiaResourceDialect,
1597            >,
1598            offset: usize,
1599            _depth: fidl::encoding::Depth,
1600        ) -> fidl::Result<()> {
1601            decoder.debug_check_bounds::<Self>(offset);
1602            // Verify that padding bytes are zero.
1603            fidl::decode!(fidl::encoding::Vector<VmoHandle, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
1604            Ok(())
1605        }
1606    }
1607
1608    impl fidl::encoding::ResourceTypeMarker for EndpointUnregisterVmosResponse {
1609        type Borrowed<'a> = &'a mut Self;
1610        fn take_or_borrow<'a>(
1611            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1612        ) -> Self::Borrowed<'a> {
1613            value
1614        }
1615    }
1616
1617    unsafe impl fidl::encoding::TypeMarker for EndpointUnregisterVmosResponse {
1618        type Owned = Self;
1619
1620        #[inline(always)]
1621        fn inline_align(_context: fidl::encoding::Context) -> usize {
1622            8
1623        }
1624
1625        #[inline(always)]
1626        fn inline_size(_context: fidl::encoding::Context) -> usize {
1627            32
1628        }
1629    }
1630
1631    unsafe impl
1632        fidl::encoding::Encode<
1633            EndpointUnregisterVmosResponse,
1634            fidl::encoding::DefaultFuchsiaResourceDialect,
1635        > for &mut EndpointUnregisterVmosResponse
1636    {
1637        #[inline]
1638        unsafe fn encode(
1639            self,
1640            encoder: &mut fidl::encoding::Encoder<
1641                '_,
1642                fidl::encoding::DefaultFuchsiaResourceDialect,
1643            >,
1644            offset: usize,
1645            _depth: fidl::encoding::Depth,
1646        ) -> fidl::Result<()> {
1647            encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1648            // Delegate to tuple encoding.
1649            fidl::encoding::Encode::<
1650                EndpointUnregisterVmosResponse,
1651                fidl::encoding::DefaultFuchsiaResourceDialect,
1652            >::encode(
1653                (
1654                    <fidl::encoding::Vector<u64, 300> as fidl::encoding::ValueTypeMarker>::borrow(
1655                        &self.failed_vmo_ids,
1656                    ),
1657                    <fidl::encoding::Vector<i32, 300> as fidl::encoding::ValueTypeMarker>::borrow(
1658                        &self.errors,
1659                    ),
1660                ),
1661                encoder,
1662                offset,
1663                _depth,
1664            )
1665        }
1666    }
1667    unsafe impl<
1668        T0: fidl::encoding::Encode<
1669                fidl::encoding::Vector<u64, 300>,
1670                fidl::encoding::DefaultFuchsiaResourceDialect,
1671            >,
1672        T1: fidl::encoding::Encode<
1673                fidl::encoding::Vector<i32, 300>,
1674                fidl::encoding::DefaultFuchsiaResourceDialect,
1675            >,
1676    >
1677        fidl::encoding::Encode<
1678            EndpointUnregisterVmosResponse,
1679            fidl::encoding::DefaultFuchsiaResourceDialect,
1680        > for (T0, T1)
1681    {
1682        #[inline]
1683        unsafe fn encode(
1684            self,
1685            encoder: &mut fidl::encoding::Encoder<
1686                '_,
1687                fidl::encoding::DefaultFuchsiaResourceDialect,
1688            >,
1689            offset: usize,
1690            depth: fidl::encoding::Depth,
1691        ) -> fidl::Result<()> {
1692            encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1693            // Zero out padding regions. There's no need to apply masks
1694            // because the unmasked parts will be overwritten by fields.
1695            // Write the fields.
1696            self.0.encode(encoder, offset + 0, depth)?;
1697            self.1.encode(encoder, offset + 16, depth)?;
1698            Ok(())
1699        }
1700    }
1701
1702    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1703        for EndpointUnregisterVmosResponse
1704    {
1705        #[inline(always)]
1706        fn new_empty() -> Self {
1707            Self {
1708                failed_vmo_ids: fidl::new_empty!(fidl::encoding::Vector<u64, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1709                errors: fidl::new_empty!(fidl::encoding::Vector<i32, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1710            }
1711        }
1712
1713        #[inline]
1714        unsafe fn decode(
1715            &mut self,
1716            decoder: &mut fidl::encoding::Decoder<
1717                '_,
1718                fidl::encoding::DefaultFuchsiaResourceDialect,
1719            >,
1720            offset: usize,
1721            _depth: fidl::encoding::Depth,
1722        ) -> fidl::Result<()> {
1723            decoder.debug_check_bounds::<Self>(offset);
1724            // Verify that padding bytes are zero.
1725            fidl::decode!(fidl::encoding::Vector<u64, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.failed_vmo_ids, decoder, offset + 0, _depth)?;
1726            fidl::decode!(fidl::encoding::Vector<i32, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.errors, decoder, offset + 16, _depth)?;
1727            Ok(())
1728        }
1729    }
1730
1731    impl Completion {
1732        #[inline(always)]
1733        fn max_ordinal_present(&self) -> u64 {
1734            if let Some(_) = self.wake_lease {
1735                return 4;
1736            }
1737            if let Some(_) = self.transfer_size {
1738                return 3;
1739            }
1740            if let Some(_) = self.status {
1741                return 2;
1742            }
1743            if let Some(_) = self.request {
1744                return 1;
1745            }
1746            0
1747        }
1748    }
1749
1750    impl fidl::encoding::ResourceTypeMarker for Completion {
1751        type Borrowed<'a> = &'a mut Self;
1752        fn take_or_borrow<'a>(
1753            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1754        ) -> Self::Borrowed<'a> {
1755            value
1756        }
1757    }
1758
1759    unsafe impl fidl::encoding::TypeMarker for Completion {
1760        type Owned = Self;
1761
1762        #[inline(always)]
1763        fn inline_align(_context: fidl::encoding::Context) -> usize {
1764            8
1765        }
1766
1767        #[inline(always)]
1768        fn inline_size(_context: fidl::encoding::Context) -> usize {
1769            16
1770        }
1771    }
1772
1773    unsafe impl fidl::encoding::Encode<Completion, fidl::encoding::DefaultFuchsiaResourceDialect>
1774        for &mut Completion
1775    {
1776        unsafe fn encode(
1777            self,
1778            encoder: &mut fidl::encoding::Encoder<
1779                '_,
1780                fidl::encoding::DefaultFuchsiaResourceDialect,
1781            >,
1782            offset: usize,
1783            mut depth: fidl::encoding::Depth,
1784        ) -> fidl::Result<()> {
1785            encoder.debug_check_bounds::<Completion>(offset);
1786            // Vector header
1787            let max_ordinal: u64 = self.max_ordinal_present();
1788            encoder.write_num(max_ordinal, offset);
1789            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1790            // Calling encoder.out_of_line_offset(0) is not allowed.
1791            if max_ordinal == 0 {
1792                return Ok(());
1793            }
1794            depth.increment()?;
1795            let envelope_size = 8;
1796            let bytes_len = max_ordinal as usize * envelope_size;
1797            #[allow(unused_variables)]
1798            let offset = encoder.out_of_line_offset(bytes_len);
1799            let mut _prev_end_offset: usize = 0;
1800            if 1 > max_ordinal {
1801                return Ok(());
1802            }
1803
1804            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1805            // are envelope_size bytes.
1806            let cur_offset: usize = (1 - 1) * envelope_size;
1807
1808            // Zero reserved fields.
1809            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1810
1811            // Safety:
1812            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1813            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1814            //   envelope_size bytes, there is always sufficient room.
1815            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_usb_request::Request, fidl::encoding::DefaultFuchsiaResourceDialect>(
1816            self.request.as_mut().map(<fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1817            encoder, offset + cur_offset, depth
1818        )?;
1819
1820            _prev_end_offset = cur_offset + envelope_size;
1821            if 2 > max_ordinal {
1822                return Ok(());
1823            }
1824
1825            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1826            // are envelope_size bytes.
1827            let cur_offset: usize = (2 - 1) * envelope_size;
1828
1829            // Zero reserved fields.
1830            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1831
1832            // Safety:
1833            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1834            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1835            //   envelope_size bytes, there is always sufficient room.
1836            fidl::encoding::encode_in_envelope_optional::<
1837                i32,
1838                fidl::encoding::DefaultFuchsiaResourceDialect,
1839            >(
1840                self.status.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1841                encoder,
1842                offset + cur_offset,
1843                depth,
1844            )?;
1845
1846            _prev_end_offset = cur_offset + envelope_size;
1847            if 3 > max_ordinal {
1848                return Ok(());
1849            }
1850
1851            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1852            // are envelope_size bytes.
1853            let cur_offset: usize = (3 - 1) * envelope_size;
1854
1855            // Zero reserved fields.
1856            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1857
1858            // Safety:
1859            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1860            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1861            //   envelope_size bytes, there is always sufficient room.
1862            fidl::encoding::encode_in_envelope_optional::<
1863                u64,
1864                fidl::encoding::DefaultFuchsiaResourceDialect,
1865            >(
1866                self.transfer_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1867                encoder,
1868                offset + cur_offset,
1869                depth,
1870            )?;
1871
1872            _prev_end_offset = cur_offset + envelope_size;
1873            if 4 > max_ordinal {
1874                return Ok(());
1875            }
1876
1877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1878            // are envelope_size bytes.
1879            let cur_offset: usize = (4 - 1) * envelope_size;
1880
1881            // Zero reserved fields.
1882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1883
1884            // Safety:
1885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1887            //   envelope_size bytes, there is always sufficient room.
1888            fidl::encoding::encode_in_envelope_optional::<
1889                fidl::encoding::HandleType<
1890                    fidl::EventPair,
1891                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1892                    2147483648,
1893                >,
1894                fidl::encoding::DefaultFuchsiaResourceDialect,
1895            >(
1896                self.wake_lease.as_mut().map(
1897                    <fidl::encoding::HandleType<
1898                        fidl::EventPair,
1899                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1900                        2147483648,
1901                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1902                ),
1903                encoder,
1904                offset + cur_offset,
1905                depth,
1906            )?;
1907
1908            _prev_end_offset = cur_offset + envelope_size;
1909
1910            Ok(())
1911        }
1912    }
1913
1914    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Completion {
1915        #[inline(always)]
1916        fn new_empty() -> Self {
1917            Self::default()
1918        }
1919
1920        unsafe fn decode(
1921            &mut self,
1922            decoder: &mut fidl::encoding::Decoder<
1923                '_,
1924                fidl::encoding::DefaultFuchsiaResourceDialect,
1925            >,
1926            offset: usize,
1927            mut depth: fidl::encoding::Depth,
1928        ) -> fidl::Result<()> {
1929            decoder.debug_check_bounds::<Self>(offset);
1930            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1931                None => return Err(fidl::Error::NotNullable),
1932                Some(len) => len,
1933            };
1934            // Calling decoder.out_of_line_offset(0) is not allowed.
1935            if len == 0 {
1936                return Ok(());
1937            };
1938            depth.increment()?;
1939            let envelope_size = 8;
1940            let bytes_len = len * envelope_size;
1941            let offset = decoder.out_of_line_offset(bytes_len)?;
1942            // Decode the envelope for each type.
1943            let mut _next_ordinal_to_read = 0;
1944            let mut next_offset = offset;
1945            let end_offset = offset + bytes_len;
1946            _next_ordinal_to_read += 1;
1947            if next_offset >= end_offset {
1948                return Ok(());
1949            }
1950
1951            // Decode unknown envelopes for gaps in ordinals.
1952            while _next_ordinal_to_read < 1 {
1953                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1954                _next_ordinal_to_read += 1;
1955                next_offset += envelope_size;
1956            }
1957
1958            let next_out_of_line = decoder.next_out_of_line();
1959            let handles_before = decoder.remaining_handles();
1960            if let Some((inlined, num_bytes, num_handles)) =
1961                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1962            {
1963                let member_inline_size = <fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1964                if inlined != (member_inline_size <= 4) {
1965                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1966                }
1967                let inner_offset;
1968                let mut inner_depth = depth.clone();
1969                if inlined {
1970                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1971                    inner_offset = next_offset;
1972                } else {
1973                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1974                    inner_depth.increment()?;
1975                }
1976                let val_ref = self.request.get_or_insert_with(|| {
1977                    fidl::new_empty!(
1978                        fidl_fuchsia_hardware_usb_request::Request,
1979                        fidl::encoding::DefaultFuchsiaResourceDialect
1980                    )
1981                });
1982                fidl::decode!(
1983                    fidl_fuchsia_hardware_usb_request::Request,
1984                    fidl::encoding::DefaultFuchsiaResourceDialect,
1985                    val_ref,
1986                    decoder,
1987                    inner_offset,
1988                    inner_depth
1989                )?;
1990                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1991                {
1992                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1993                }
1994                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1995                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1996                }
1997            }
1998
1999            next_offset += envelope_size;
2000            _next_ordinal_to_read += 1;
2001            if next_offset >= end_offset {
2002                return Ok(());
2003            }
2004
2005            // Decode unknown envelopes for gaps in ordinals.
2006            while _next_ordinal_to_read < 2 {
2007                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2008                _next_ordinal_to_read += 1;
2009                next_offset += envelope_size;
2010            }
2011
2012            let next_out_of_line = decoder.next_out_of_line();
2013            let handles_before = decoder.remaining_handles();
2014            if let Some((inlined, num_bytes, num_handles)) =
2015                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2016            {
2017                let member_inline_size =
2018                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2019                if inlined != (member_inline_size <= 4) {
2020                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2021                }
2022                let inner_offset;
2023                let mut inner_depth = depth.clone();
2024                if inlined {
2025                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2026                    inner_offset = next_offset;
2027                } else {
2028                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2029                    inner_depth.increment()?;
2030                }
2031                let val_ref = self.status.get_or_insert_with(|| {
2032                    fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect)
2033                });
2034                fidl::decode!(
2035                    i32,
2036                    fidl::encoding::DefaultFuchsiaResourceDialect,
2037                    val_ref,
2038                    decoder,
2039                    inner_offset,
2040                    inner_depth
2041                )?;
2042                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2043                {
2044                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2045                }
2046                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2047                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2048                }
2049            }
2050
2051            next_offset += envelope_size;
2052            _next_ordinal_to_read += 1;
2053            if next_offset >= end_offset {
2054                return Ok(());
2055            }
2056
2057            // Decode unknown envelopes for gaps in ordinals.
2058            while _next_ordinal_to_read < 3 {
2059                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2060                _next_ordinal_to_read += 1;
2061                next_offset += envelope_size;
2062            }
2063
2064            let next_out_of_line = decoder.next_out_of_line();
2065            let handles_before = decoder.remaining_handles();
2066            if let Some((inlined, num_bytes, num_handles)) =
2067                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2068            {
2069                let member_inline_size =
2070                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2071                if inlined != (member_inline_size <= 4) {
2072                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2073                }
2074                let inner_offset;
2075                let mut inner_depth = depth.clone();
2076                if inlined {
2077                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2078                    inner_offset = next_offset;
2079                } else {
2080                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2081                    inner_depth.increment()?;
2082                }
2083                let val_ref = self.transfer_size.get_or_insert_with(|| {
2084                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2085                });
2086                fidl::decode!(
2087                    u64,
2088                    fidl::encoding::DefaultFuchsiaResourceDialect,
2089                    val_ref,
2090                    decoder,
2091                    inner_offset,
2092                    inner_depth
2093                )?;
2094                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2095                {
2096                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2097                }
2098                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2099                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2100                }
2101            }
2102
2103            next_offset += envelope_size;
2104            _next_ordinal_to_read += 1;
2105            if next_offset >= end_offset {
2106                return Ok(());
2107            }
2108
2109            // Decode unknown envelopes for gaps in ordinals.
2110            while _next_ordinal_to_read < 4 {
2111                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2112                _next_ordinal_to_read += 1;
2113                next_offset += envelope_size;
2114            }
2115
2116            let next_out_of_line = decoder.next_out_of_line();
2117            let handles_before = decoder.remaining_handles();
2118            if let Some((inlined, num_bytes, num_handles)) =
2119                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2120            {
2121                let member_inline_size = <fidl::encoding::HandleType<
2122                    fidl::EventPair,
2123                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2124                    2147483648,
2125                > as fidl::encoding::TypeMarker>::inline_size(
2126                    decoder.context
2127                );
2128                if inlined != (member_inline_size <= 4) {
2129                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2130                }
2131                let inner_offset;
2132                let mut inner_depth = depth.clone();
2133                if inlined {
2134                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2135                    inner_offset = next_offset;
2136                } else {
2137                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2138                    inner_depth.increment()?;
2139                }
2140                let val_ref =
2141                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2142                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2143                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2144                {
2145                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2146                }
2147                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2148                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2149                }
2150            }
2151
2152            next_offset += envelope_size;
2153
2154            // Decode the remaining unknown envelopes.
2155            while next_offset < end_offset {
2156                _next_ordinal_to_read += 1;
2157                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2158                next_offset += envelope_size;
2159            }
2160
2161            Ok(())
2162        }
2163    }
2164
2165    impl VmoHandle {
2166        #[inline(always)]
2167        fn max_ordinal_present(&self) -> u64 {
2168            if let Some(_) = self.vmo {
2169                return 2;
2170            }
2171            if let Some(_) = self.id {
2172                return 1;
2173            }
2174            0
2175        }
2176    }
2177
2178    impl fidl::encoding::ResourceTypeMarker for VmoHandle {
2179        type Borrowed<'a> = &'a mut Self;
2180        fn take_or_borrow<'a>(
2181            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2182        ) -> Self::Borrowed<'a> {
2183            value
2184        }
2185    }
2186
2187    unsafe impl fidl::encoding::TypeMarker for VmoHandle {
2188        type Owned = Self;
2189
2190        #[inline(always)]
2191        fn inline_align(_context: fidl::encoding::Context) -> usize {
2192            8
2193        }
2194
2195        #[inline(always)]
2196        fn inline_size(_context: fidl::encoding::Context) -> usize {
2197            16
2198        }
2199    }
2200
2201    unsafe impl fidl::encoding::Encode<VmoHandle, fidl::encoding::DefaultFuchsiaResourceDialect>
2202        for &mut VmoHandle
2203    {
2204        unsafe fn encode(
2205            self,
2206            encoder: &mut fidl::encoding::Encoder<
2207                '_,
2208                fidl::encoding::DefaultFuchsiaResourceDialect,
2209            >,
2210            offset: usize,
2211            mut depth: fidl::encoding::Depth,
2212        ) -> fidl::Result<()> {
2213            encoder.debug_check_bounds::<VmoHandle>(offset);
2214            // Vector header
2215            let max_ordinal: u64 = self.max_ordinal_present();
2216            encoder.write_num(max_ordinal, offset);
2217            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2218            // Calling encoder.out_of_line_offset(0) is not allowed.
2219            if max_ordinal == 0 {
2220                return Ok(());
2221            }
2222            depth.increment()?;
2223            let envelope_size = 8;
2224            let bytes_len = max_ordinal as usize * envelope_size;
2225            #[allow(unused_variables)]
2226            let offset = encoder.out_of_line_offset(bytes_len);
2227            let mut _prev_end_offset: usize = 0;
2228            if 1 > max_ordinal {
2229                return Ok(());
2230            }
2231
2232            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2233            // are envelope_size bytes.
2234            let cur_offset: usize = (1 - 1) * envelope_size;
2235
2236            // Zero reserved fields.
2237            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2238
2239            // Safety:
2240            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2241            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2242            //   envelope_size bytes, there is always sufficient room.
2243            fidl::encoding::encode_in_envelope_optional::<
2244                u64,
2245                fidl::encoding::DefaultFuchsiaResourceDialect,
2246            >(
2247                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2248                encoder,
2249                offset + cur_offset,
2250                depth,
2251            )?;
2252
2253            _prev_end_offset = cur_offset + envelope_size;
2254            if 2 > max_ordinal {
2255                return Ok(());
2256            }
2257
2258            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2259            // are envelope_size bytes.
2260            let cur_offset: usize = (2 - 1) * envelope_size;
2261
2262            // Zero reserved fields.
2263            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2264
2265            // Safety:
2266            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2267            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2268            //   envelope_size bytes, there is always sufficient room.
2269            fidl::encoding::encode_in_envelope_optional::<
2270                fidl::encoding::HandleType<
2271                    fidl::Vmo,
2272                    { fidl::ObjectType::VMO.into_raw() },
2273                    2147483648,
2274                >,
2275                fidl::encoding::DefaultFuchsiaResourceDialect,
2276            >(
2277                self.vmo.as_mut().map(
2278                    <fidl::encoding::HandleType<
2279                        fidl::Vmo,
2280                        { fidl::ObjectType::VMO.into_raw() },
2281                        2147483648,
2282                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2283                ),
2284                encoder,
2285                offset + cur_offset,
2286                depth,
2287            )?;
2288
2289            _prev_end_offset = cur_offset + envelope_size;
2290
2291            Ok(())
2292        }
2293    }
2294
2295    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoHandle {
2296        #[inline(always)]
2297        fn new_empty() -> Self {
2298            Self::default()
2299        }
2300
2301        unsafe fn decode(
2302            &mut self,
2303            decoder: &mut fidl::encoding::Decoder<
2304                '_,
2305                fidl::encoding::DefaultFuchsiaResourceDialect,
2306            >,
2307            offset: usize,
2308            mut depth: fidl::encoding::Depth,
2309        ) -> fidl::Result<()> {
2310            decoder.debug_check_bounds::<Self>(offset);
2311            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2312                None => return Err(fidl::Error::NotNullable),
2313                Some(len) => len,
2314            };
2315            // Calling decoder.out_of_line_offset(0) is not allowed.
2316            if len == 0 {
2317                return Ok(());
2318            };
2319            depth.increment()?;
2320            let envelope_size = 8;
2321            let bytes_len = len * envelope_size;
2322            let offset = decoder.out_of_line_offset(bytes_len)?;
2323            // Decode the envelope for each type.
2324            let mut _next_ordinal_to_read = 0;
2325            let mut next_offset = offset;
2326            let end_offset = offset + bytes_len;
2327            _next_ordinal_to_read += 1;
2328            if next_offset >= end_offset {
2329                return Ok(());
2330            }
2331
2332            // Decode unknown envelopes for gaps in ordinals.
2333            while _next_ordinal_to_read < 1 {
2334                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2335                _next_ordinal_to_read += 1;
2336                next_offset += envelope_size;
2337            }
2338
2339            let next_out_of_line = decoder.next_out_of_line();
2340            let handles_before = decoder.remaining_handles();
2341            if let Some((inlined, num_bytes, num_handles)) =
2342                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2343            {
2344                let member_inline_size =
2345                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2346                if inlined != (member_inline_size <= 4) {
2347                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2348                }
2349                let inner_offset;
2350                let mut inner_depth = depth.clone();
2351                if inlined {
2352                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2353                    inner_offset = next_offset;
2354                } else {
2355                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2356                    inner_depth.increment()?;
2357                }
2358                let val_ref = self.id.get_or_insert_with(|| {
2359                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2360                });
2361                fidl::decode!(
2362                    u64,
2363                    fidl::encoding::DefaultFuchsiaResourceDialect,
2364                    val_ref,
2365                    decoder,
2366                    inner_offset,
2367                    inner_depth
2368                )?;
2369                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2370                {
2371                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2372                }
2373                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2374                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2375                }
2376            }
2377
2378            next_offset += envelope_size;
2379            _next_ordinal_to_read += 1;
2380            if next_offset >= end_offset {
2381                return Ok(());
2382            }
2383
2384            // Decode unknown envelopes for gaps in ordinals.
2385            while _next_ordinal_to_read < 2 {
2386                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2387                _next_ordinal_to_read += 1;
2388                next_offset += envelope_size;
2389            }
2390
2391            let next_out_of_line = decoder.next_out_of_line();
2392            let handles_before = decoder.remaining_handles();
2393            if let Some((inlined, num_bytes, num_handles)) =
2394                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2395            {
2396                let member_inline_size = <fidl::encoding::HandleType<
2397                    fidl::Vmo,
2398                    { fidl::ObjectType::VMO.into_raw() },
2399                    2147483648,
2400                > as fidl::encoding::TypeMarker>::inline_size(
2401                    decoder.context
2402                );
2403                if inlined != (member_inline_size <= 4) {
2404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2405                }
2406                let inner_offset;
2407                let mut inner_depth = depth.clone();
2408                if inlined {
2409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2410                    inner_offset = next_offset;
2411                } else {
2412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2413                    inner_depth.increment()?;
2414                }
2415                let val_ref =
2416                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2417                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2419                {
2420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2421                }
2422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2424                }
2425            }
2426
2427            next_offset += envelope_size;
2428
2429            // Decode the remaining unknown envelopes.
2430            while next_offset < end_offset {
2431                _next_ordinal_to_read += 1;
2432                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2433                next_offset += envelope_size;
2434            }
2435
2436            Ok(())
2437        }
2438    }
2439}