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 EndpointControlHandle {
883    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
884        self.inner.shutdown_with_epitaph(status.into())
885    }
886}
887
888impl fidl::endpoints::ControlHandle for EndpointControlHandle {
889    fn shutdown(&self) {
890        self.inner.shutdown()
891    }
892
893    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
894        self.inner.shutdown_with_epitaph(status)
895    }
896
897    fn is_closed(&self) -> bool {
898        self.inner.channel().is_closed()
899    }
900    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
901        self.inner.channel().on_closed()
902    }
903
904    #[cfg(target_os = "fuchsia")]
905    fn signal_peer(
906        &self,
907        clear_mask: zx::Signals,
908        set_mask: zx::Signals,
909    ) -> Result<(), zx_status::Status> {
910        use fidl::Peered;
911        self.inner.channel().signal_peer(clear_mask, set_mask)
912    }
913}
914
915impl EndpointControlHandle {
916    pub fn send_on_completion(&self, mut completion: Vec<Completion>) -> Result<(), fidl::Error> {
917        self.inner.send::<EndpointOnCompletionRequest>(
918            (completion.as_mut(),),
919            0,
920            0x2d6471306c049771,
921            fidl::encoding::DynamicFlags::empty(),
922        )
923    }
924}
925
926#[must_use = "FIDL methods require a response to be sent"]
927#[derive(Debug)]
928pub struct EndpointGetInfoResponder {
929    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
930    tx_id: u32,
931}
932
933/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
934/// if the responder is dropped without sending a response, so that the client
935/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
936impl std::ops::Drop for EndpointGetInfoResponder {
937    fn drop(&mut self) {
938        self.control_handle.shutdown();
939        // Safety: drops once, never accessed again
940        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
941    }
942}
943
944impl fidl::endpoints::Responder for EndpointGetInfoResponder {
945    type ControlHandle = EndpointControlHandle;
946
947    fn control_handle(&self) -> &EndpointControlHandle {
948        &self.control_handle
949    }
950
951    fn drop_without_shutdown(mut self) {
952        // Safety: drops once, never accessed again due to mem::forget
953        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
954        // Prevent Drop from running (which would shut down the channel)
955        std::mem::forget(self);
956    }
957}
958
959impl EndpointGetInfoResponder {
960    /// Sends a response to the FIDL transaction.
961    ///
962    /// Sets the channel to shutdown if an error occurs.
963    pub fn send(self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
964        let _result = self.send_raw(result);
965        if _result.is_err() {
966            self.control_handle.shutdown();
967        }
968        self.drop_without_shutdown();
969        _result
970    }
971
972    /// Similar to "send" but does not shutdown the channel if an error occurs.
973    pub fn send_no_shutdown_on_err(
974        self,
975        mut result: Result<&EndpointInfo, i32>,
976    ) -> Result<(), fidl::Error> {
977        let _result = self.send_raw(result);
978        self.drop_without_shutdown();
979        _result
980    }
981
982    fn send_raw(&self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
983        self.control_handle.inner.send::<fidl::encoding::ResultType<EndpointGetInfoResponse, i32>>(
984            result.map(|info| (info,)),
985            self.tx_id,
986            0x1fba84f171a95023,
987            fidl::encoding::DynamicFlags::empty(),
988        )
989    }
990}
991
992#[must_use = "FIDL methods require a response to be sent"]
993#[derive(Debug)]
994pub struct EndpointRegisterVmosResponder {
995    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
996    tx_id: u32,
997}
998
999/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1000/// if the responder is dropped without sending a response, so that the client
1001/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1002impl std::ops::Drop for EndpointRegisterVmosResponder {
1003    fn drop(&mut self) {
1004        self.control_handle.shutdown();
1005        // Safety: drops once, never accessed again
1006        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1007    }
1008}
1009
1010impl fidl::endpoints::Responder for EndpointRegisterVmosResponder {
1011    type ControlHandle = EndpointControlHandle;
1012
1013    fn control_handle(&self) -> &EndpointControlHandle {
1014        &self.control_handle
1015    }
1016
1017    fn drop_without_shutdown(mut self) {
1018        // Safety: drops once, never accessed again due to mem::forget
1019        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1020        // Prevent Drop from running (which would shut down the channel)
1021        std::mem::forget(self);
1022    }
1023}
1024
1025impl EndpointRegisterVmosResponder {
1026    /// Sends a response to the FIDL transaction.
1027    ///
1028    /// Sets the channel to shutdown if an error occurs.
1029    pub fn send(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1030        let _result = self.send_raw(vmos);
1031        if _result.is_err() {
1032            self.control_handle.shutdown();
1033        }
1034        self.drop_without_shutdown();
1035        _result
1036    }
1037
1038    /// Similar to "send" but does not shutdown the channel if an error occurs.
1039    pub fn send_no_shutdown_on_err(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1040        let _result = self.send_raw(vmos);
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    fn send_raw(&self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1046        self.control_handle.inner.send::<EndpointRegisterVmosResponse>(
1047            (vmos.as_mut(),),
1048            self.tx_id,
1049            0x1dea601921185c7b,
1050            fidl::encoding::DynamicFlags::empty(),
1051        )
1052    }
1053}
1054
1055#[must_use = "FIDL methods require a response to be sent"]
1056#[derive(Debug)]
1057pub struct EndpointUnregisterVmosResponder {
1058    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1059    tx_id: u32,
1060}
1061
1062/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1063/// if the responder is dropped without sending a response, so that the client
1064/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1065impl std::ops::Drop for EndpointUnregisterVmosResponder {
1066    fn drop(&mut self) {
1067        self.control_handle.shutdown();
1068        // Safety: drops once, never accessed again
1069        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1070    }
1071}
1072
1073impl fidl::endpoints::Responder for EndpointUnregisterVmosResponder {
1074    type ControlHandle = EndpointControlHandle;
1075
1076    fn control_handle(&self) -> &EndpointControlHandle {
1077        &self.control_handle
1078    }
1079
1080    fn drop_without_shutdown(mut self) {
1081        // Safety: drops once, never accessed again due to mem::forget
1082        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1083        // Prevent Drop from running (which would shut down the channel)
1084        std::mem::forget(self);
1085    }
1086}
1087
1088impl EndpointUnregisterVmosResponder {
1089    /// Sends a response to the FIDL transaction.
1090    ///
1091    /// Sets the channel to shutdown if an error occurs.
1092    pub fn send(self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1093        let _result = self.send_raw(failed_vmo_ids, errors);
1094        if _result.is_err() {
1095            self.control_handle.shutdown();
1096        }
1097        self.drop_without_shutdown();
1098        _result
1099    }
1100
1101    /// Similar to "send" but does not shutdown the channel if an error occurs.
1102    pub fn send_no_shutdown_on_err(
1103        self,
1104        mut failed_vmo_ids: &[u64],
1105        mut errors: &[i32],
1106    ) -> Result<(), fidl::Error> {
1107        let _result = self.send_raw(failed_vmo_ids, errors);
1108        self.drop_without_shutdown();
1109        _result
1110    }
1111
1112    fn send_raw(&self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1113        self.control_handle.inner.send::<EndpointUnregisterVmosResponse>(
1114            (failed_vmo_ids, errors),
1115            self.tx_id,
1116            0x34719ede1c99c10,
1117            fidl::encoding::DynamicFlags::empty(),
1118        )
1119    }
1120}
1121
1122#[must_use = "FIDL methods require a response to be sent"]
1123#[derive(Debug)]
1124pub struct EndpointCancelAllResponder {
1125    control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1126    tx_id: u32,
1127}
1128
1129/// Set the the channel to be shutdown (see [`EndpointControlHandle::shutdown`])
1130/// if the responder is dropped without sending a response, so that the client
1131/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1132impl std::ops::Drop for EndpointCancelAllResponder {
1133    fn drop(&mut self) {
1134        self.control_handle.shutdown();
1135        // Safety: drops once, never accessed again
1136        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1137    }
1138}
1139
1140impl fidl::endpoints::Responder for EndpointCancelAllResponder {
1141    type ControlHandle = EndpointControlHandle;
1142
1143    fn control_handle(&self) -> &EndpointControlHandle {
1144        &self.control_handle
1145    }
1146
1147    fn drop_without_shutdown(mut self) {
1148        // Safety: drops once, never accessed again due to mem::forget
1149        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1150        // Prevent Drop from running (which would shut down the channel)
1151        std::mem::forget(self);
1152    }
1153}
1154
1155impl EndpointCancelAllResponder {
1156    /// Sends a response to the FIDL transaction.
1157    ///
1158    /// Sets the channel to shutdown if an error occurs.
1159    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1160        let _result = self.send_raw(result);
1161        if _result.is_err() {
1162            self.control_handle.shutdown();
1163        }
1164        self.drop_without_shutdown();
1165        _result
1166    }
1167
1168    /// Similar to "send" but does not shutdown the channel if an error occurs.
1169    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1170        let _result = self.send_raw(result);
1171        self.drop_without_shutdown();
1172        _result
1173    }
1174
1175    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1176        self.control_handle
1177            .inner
1178            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1179                result,
1180                self.tx_id,
1181                0x233854c776cda1cc,
1182                fidl::encoding::DynamicFlags::empty(),
1183            )
1184    }
1185}
1186
1187mod internal {
1188    use super::*;
1189
1190    impl fidl::encoding::ResourceTypeMarker for EndpointOnCompletionRequest {
1191        type Borrowed<'a> = &'a mut Self;
1192        fn take_or_borrow<'a>(
1193            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1194        ) -> Self::Borrowed<'a> {
1195            value
1196        }
1197    }
1198
1199    unsafe impl fidl::encoding::TypeMarker for EndpointOnCompletionRequest {
1200        type Owned = Self;
1201
1202        #[inline(always)]
1203        fn inline_align(_context: fidl::encoding::Context) -> usize {
1204            8
1205        }
1206
1207        #[inline(always)]
1208        fn inline_size(_context: fidl::encoding::Context) -> usize {
1209            16
1210        }
1211    }
1212
1213    unsafe impl
1214        fidl::encoding::Encode<
1215            EndpointOnCompletionRequest,
1216            fidl::encoding::DefaultFuchsiaResourceDialect,
1217        > for &mut EndpointOnCompletionRequest
1218    {
1219        #[inline]
1220        unsafe fn encode(
1221            self,
1222            encoder: &mut fidl::encoding::Encoder<
1223                '_,
1224                fidl::encoding::DefaultFuchsiaResourceDialect,
1225            >,
1226            offset: usize,
1227            _depth: fidl::encoding::Depth,
1228        ) -> fidl::Result<()> {
1229            encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1230            // Delegate to tuple encoding.
1231            fidl::encoding::Encode::<EndpointOnCompletionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1232                (
1233                    <fidl::encoding::Vector<Completion, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.completion),
1234                ),
1235                encoder, offset, _depth
1236            )
1237        }
1238    }
1239    unsafe impl<
1240        T0: fidl::encoding::Encode<
1241                fidl::encoding::Vector<Completion, 300>,
1242                fidl::encoding::DefaultFuchsiaResourceDialect,
1243            >,
1244    >
1245        fidl::encoding::Encode<
1246            EndpointOnCompletionRequest,
1247            fidl::encoding::DefaultFuchsiaResourceDialect,
1248        > for (T0,)
1249    {
1250        #[inline]
1251        unsafe fn encode(
1252            self,
1253            encoder: &mut fidl::encoding::Encoder<
1254                '_,
1255                fidl::encoding::DefaultFuchsiaResourceDialect,
1256            >,
1257            offset: usize,
1258            depth: fidl::encoding::Depth,
1259        ) -> fidl::Result<()> {
1260            encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1261            // Zero out padding regions. There's no need to apply masks
1262            // because the unmasked parts will be overwritten by fields.
1263            // Write the fields.
1264            self.0.encode(encoder, offset + 0, depth)?;
1265            Ok(())
1266        }
1267    }
1268
1269    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1270        for EndpointOnCompletionRequest
1271    {
1272        #[inline(always)]
1273        fn new_empty() -> Self {
1274            Self {
1275                completion: fidl::new_empty!(fidl::encoding::Vector<Completion, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1276            }
1277        }
1278
1279        #[inline]
1280        unsafe fn decode(
1281            &mut self,
1282            decoder: &mut fidl::encoding::Decoder<
1283                '_,
1284                fidl::encoding::DefaultFuchsiaResourceDialect,
1285            >,
1286            offset: usize,
1287            _depth: fidl::encoding::Depth,
1288        ) -> fidl::Result<()> {
1289            decoder.debug_check_bounds::<Self>(offset);
1290            // Verify that padding bytes are zero.
1291            fidl::decode!(fidl::encoding::Vector<Completion, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.completion, decoder, offset + 0, _depth)?;
1292            Ok(())
1293        }
1294    }
1295
1296    impl fidl::encoding::ResourceTypeMarker for EndpointQueueRequestsRequest {
1297        type Borrowed<'a> = &'a mut Self;
1298        fn take_or_borrow<'a>(
1299            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1300        ) -> Self::Borrowed<'a> {
1301            value
1302        }
1303    }
1304
1305    unsafe impl fidl::encoding::TypeMarker for EndpointQueueRequestsRequest {
1306        type Owned = Self;
1307
1308        #[inline(always)]
1309        fn inline_align(_context: fidl::encoding::Context) -> usize {
1310            8
1311        }
1312
1313        #[inline(always)]
1314        fn inline_size(_context: fidl::encoding::Context) -> usize {
1315            16
1316        }
1317    }
1318
1319    unsafe impl
1320        fidl::encoding::Encode<
1321            EndpointQueueRequestsRequest,
1322            fidl::encoding::DefaultFuchsiaResourceDialect,
1323        > for &mut EndpointQueueRequestsRequest
1324    {
1325        #[inline]
1326        unsafe fn encode(
1327            self,
1328            encoder: &mut fidl::encoding::Encoder<
1329                '_,
1330                fidl::encoding::DefaultFuchsiaResourceDialect,
1331            >,
1332            offset: usize,
1333            _depth: fidl::encoding::Depth,
1334        ) -> fidl::Result<()> {
1335            encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1336            // Delegate to tuple encoding.
1337            fidl::encoding::Encode::<EndpointQueueRequestsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1338                (
1339                    <fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1340                ),
1341                encoder, offset, _depth
1342            )
1343        }
1344    }
1345    unsafe impl<
1346        T0: fidl::encoding::Encode<
1347                fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>,
1348                fidl::encoding::DefaultFuchsiaResourceDialect,
1349            >,
1350    >
1351        fidl::encoding::Encode<
1352            EndpointQueueRequestsRequest,
1353            fidl::encoding::DefaultFuchsiaResourceDialect,
1354        > for (T0,)
1355    {
1356        #[inline]
1357        unsafe fn encode(
1358            self,
1359            encoder: &mut fidl::encoding::Encoder<
1360                '_,
1361                fidl::encoding::DefaultFuchsiaResourceDialect,
1362            >,
1363            offset: usize,
1364            depth: fidl::encoding::Depth,
1365        ) -> fidl::Result<()> {
1366            encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1367            // Zero out padding regions. There's no need to apply masks
1368            // because the unmasked parts will be overwritten by fields.
1369            // Write the fields.
1370            self.0.encode(encoder, offset + 0, depth)?;
1371            Ok(())
1372        }
1373    }
1374
1375    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1376        for EndpointQueueRequestsRequest
1377    {
1378        #[inline(always)]
1379        fn new_empty() -> Self {
1380            Self {
1381                req: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1382            }
1383        }
1384
1385        #[inline]
1386        unsafe fn decode(
1387            &mut self,
1388            decoder: &mut fidl::encoding::Decoder<
1389                '_,
1390                fidl::encoding::DefaultFuchsiaResourceDialect,
1391            >,
1392            offset: usize,
1393            _depth: fidl::encoding::Depth,
1394        ) -> fidl::Result<()> {
1395            decoder.debug_check_bounds::<Self>(offset);
1396            // Verify that padding bytes are zero.
1397            fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.req, decoder, offset + 0, _depth)?;
1398            Ok(())
1399        }
1400    }
1401
1402    impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosRequest {
1403        type Borrowed<'a> = &'a mut Self;
1404        fn take_or_borrow<'a>(
1405            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1406        ) -> Self::Borrowed<'a> {
1407            value
1408        }
1409    }
1410
1411    unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosRequest {
1412        type Owned = Self;
1413
1414        #[inline(always)]
1415        fn inline_align(_context: fidl::encoding::Context) -> usize {
1416            8
1417        }
1418
1419        #[inline(always)]
1420        fn inline_size(_context: fidl::encoding::Context) -> usize {
1421            16
1422        }
1423    }
1424
1425    unsafe impl
1426        fidl::encoding::Encode<
1427            EndpointRegisterVmosRequest,
1428            fidl::encoding::DefaultFuchsiaResourceDialect,
1429        > for &mut EndpointRegisterVmosRequest
1430    {
1431        #[inline]
1432        unsafe fn encode(
1433            self,
1434            encoder: &mut fidl::encoding::Encoder<
1435                '_,
1436                fidl::encoding::DefaultFuchsiaResourceDialect,
1437            >,
1438            offset: usize,
1439            _depth: fidl::encoding::Depth,
1440        ) -> fidl::Result<()> {
1441            encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1442            // Delegate to tuple encoding.
1443            fidl::encoding::Encode::<EndpointRegisterVmosRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1444                (
1445                    <fidl::encoding::Vector<VmoInfo, 300> as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_ids),
1446                ),
1447                encoder, offset, _depth
1448            )
1449        }
1450    }
1451    unsafe impl<
1452        T0: fidl::encoding::Encode<
1453                fidl::encoding::Vector<VmoInfo, 300>,
1454                fidl::encoding::DefaultFuchsiaResourceDialect,
1455            >,
1456    >
1457        fidl::encoding::Encode<
1458            EndpointRegisterVmosRequest,
1459            fidl::encoding::DefaultFuchsiaResourceDialect,
1460        > for (T0,)
1461    {
1462        #[inline]
1463        unsafe fn encode(
1464            self,
1465            encoder: &mut fidl::encoding::Encoder<
1466                '_,
1467                fidl::encoding::DefaultFuchsiaResourceDialect,
1468            >,
1469            offset: usize,
1470            depth: fidl::encoding::Depth,
1471        ) -> fidl::Result<()> {
1472            encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1473            // Zero out padding regions. There's no need to apply masks
1474            // because the unmasked parts will be overwritten by fields.
1475            // Write the fields.
1476            self.0.encode(encoder, offset + 0, depth)?;
1477            Ok(())
1478        }
1479    }
1480
1481    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1482        for EndpointRegisterVmosRequest
1483    {
1484        #[inline(always)]
1485        fn new_empty() -> Self {
1486            Self {
1487                vmo_ids: fidl::new_empty!(fidl::encoding::Vector<VmoInfo, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1488            }
1489        }
1490
1491        #[inline]
1492        unsafe fn decode(
1493            &mut self,
1494            decoder: &mut fidl::encoding::Decoder<
1495                '_,
1496                fidl::encoding::DefaultFuchsiaResourceDialect,
1497            >,
1498            offset: usize,
1499            _depth: fidl::encoding::Depth,
1500        ) -> fidl::Result<()> {
1501            decoder.debug_check_bounds::<Self>(offset);
1502            // Verify that padding bytes are zero.
1503            fidl::decode!(fidl::encoding::Vector<VmoInfo, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo_ids, decoder, offset + 0, _depth)?;
1504            Ok(())
1505        }
1506    }
1507
1508    impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosResponse {
1509        type Borrowed<'a> = &'a mut Self;
1510        fn take_or_borrow<'a>(
1511            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1512        ) -> Self::Borrowed<'a> {
1513            value
1514        }
1515    }
1516
1517    unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosResponse {
1518        type Owned = Self;
1519
1520        #[inline(always)]
1521        fn inline_align(_context: fidl::encoding::Context) -> usize {
1522            8
1523        }
1524
1525        #[inline(always)]
1526        fn inline_size(_context: fidl::encoding::Context) -> usize {
1527            16
1528        }
1529    }
1530
1531    unsafe impl
1532        fidl::encoding::Encode<
1533            EndpointRegisterVmosResponse,
1534            fidl::encoding::DefaultFuchsiaResourceDialect,
1535        > for &mut EndpointRegisterVmosResponse
1536    {
1537        #[inline]
1538        unsafe fn encode(
1539            self,
1540            encoder: &mut fidl::encoding::Encoder<
1541                '_,
1542                fidl::encoding::DefaultFuchsiaResourceDialect,
1543            >,
1544            offset: usize,
1545            _depth: fidl::encoding::Depth,
1546        ) -> fidl::Result<()> {
1547            encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1548            // Delegate to tuple encoding.
1549            fidl::encoding::Encode::<EndpointRegisterVmosResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1550                (
1551                    <fidl::encoding::Vector<VmoHandle, 300> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmos),
1552                ),
1553                encoder, offset, _depth
1554            )
1555        }
1556    }
1557    unsafe impl<
1558        T0: fidl::encoding::Encode<
1559                fidl::encoding::Vector<VmoHandle, 300>,
1560                fidl::encoding::DefaultFuchsiaResourceDialect,
1561            >,
1562    >
1563        fidl::encoding::Encode<
1564            EndpointRegisterVmosResponse,
1565            fidl::encoding::DefaultFuchsiaResourceDialect,
1566        > for (T0,)
1567    {
1568        #[inline]
1569        unsafe fn encode(
1570            self,
1571            encoder: &mut fidl::encoding::Encoder<
1572                '_,
1573                fidl::encoding::DefaultFuchsiaResourceDialect,
1574            >,
1575            offset: usize,
1576            depth: fidl::encoding::Depth,
1577        ) -> fidl::Result<()> {
1578            encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1579            // Zero out padding regions. There's no need to apply masks
1580            // because the unmasked parts will be overwritten by fields.
1581            // Write the fields.
1582            self.0.encode(encoder, offset + 0, depth)?;
1583            Ok(())
1584        }
1585    }
1586
1587    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1588        for EndpointRegisterVmosResponse
1589    {
1590        #[inline(always)]
1591        fn new_empty() -> Self {
1592            Self {
1593                vmos: fidl::new_empty!(fidl::encoding::Vector<VmoHandle, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1594            }
1595        }
1596
1597        #[inline]
1598        unsafe fn decode(
1599            &mut self,
1600            decoder: &mut fidl::encoding::Decoder<
1601                '_,
1602                fidl::encoding::DefaultFuchsiaResourceDialect,
1603            >,
1604            offset: usize,
1605            _depth: fidl::encoding::Depth,
1606        ) -> fidl::Result<()> {
1607            decoder.debug_check_bounds::<Self>(offset);
1608            // Verify that padding bytes are zero.
1609            fidl::decode!(fidl::encoding::Vector<VmoHandle, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
1610            Ok(())
1611        }
1612    }
1613
1614    impl fidl::encoding::ResourceTypeMarker for EndpointUnregisterVmosResponse {
1615        type Borrowed<'a> = &'a mut Self;
1616        fn take_or_borrow<'a>(
1617            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1618        ) -> Self::Borrowed<'a> {
1619            value
1620        }
1621    }
1622
1623    unsafe impl fidl::encoding::TypeMarker for EndpointUnregisterVmosResponse {
1624        type Owned = Self;
1625
1626        #[inline(always)]
1627        fn inline_align(_context: fidl::encoding::Context) -> usize {
1628            8
1629        }
1630
1631        #[inline(always)]
1632        fn inline_size(_context: fidl::encoding::Context) -> usize {
1633            32
1634        }
1635    }
1636
1637    unsafe impl
1638        fidl::encoding::Encode<
1639            EndpointUnregisterVmosResponse,
1640            fidl::encoding::DefaultFuchsiaResourceDialect,
1641        > for &mut EndpointUnregisterVmosResponse
1642    {
1643        #[inline]
1644        unsafe fn encode(
1645            self,
1646            encoder: &mut fidl::encoding::Encoder<
1647                '_,
1648                fidl::encoding::DefaultFuchsiaResourceDialect,
1649            >,
1650            offset: usize,
1651            _depth: fidl::encoding::Depth,
1652        ) -> fidl::Result<()> {
1653            encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1654            // Delegate to tuple encoding.
1655            fidl::encoding::Encode::<
1656                EndpointUnregisterVmosResponse,
1657                fidl::encoding::DefaultFuchsiaResourceDialect,
1658            >::encode(
1659                (
1660                    <fidl::encoding::Vector<u64, 300> as fidl::encoding::ValueTypeMarker>::borrow(
1661                        &self.failed_vmo_ids,
1662                    ),
1663                    <fidl::encoding::Vector<i32, 300> as fidl::encoding::ValueTypeMarker>::borrow(
1664                        &self.errors,
1665                    ),
1666                ),
1667                encoder,
1668                offset,
1669                _depth,
1670            )
1671        }
1672    }
1673    unsafe impl<
1674        T0: fidl::encoding::Encode<
1675                fidl::encoding::Vector<u64, 300>,
1676                fidl::encoding::DefaultFuchsiaResourceDialect,
1677            >,
1678        T1: fidl::encoding::Encode<
1679                fidl::encoding::Vector<i32, 300>,
1680                fidl::encoding::DefaultFuchsiaResourceDialect,
1681            >,
1682    >
1683        fidl::encoding::Encode<
1684            EndpointUnregisterVmosResponse,
1685            fidl::encoding::DefaultFuchsiaResourceDialect,
1686        > for (T0, T1)
1687    {
1688        #[inline]
1689        unsafe fn encode(
1690            self,
1691            encoder: &mut fidl::encoding::Encoder<
1692                '_,
1693                fidl::encoding::DefaultFuchsiaResourceDialect,
1694            >,
1695            offset: usize,
1696            depth: fidl::encoding::Depth,
1697        ) -> fidl::Result<()> {
1698            encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1699            // Zero out padding regions. There's no need to apply masks
1700            // because the unmasked parts will be overwritten by fields.
1701            // Write the fields.
1702            self.0.encode(encoder, offset + 0, depth)?;
1703            self.1.encode(encoder, offset + 16, depth)?;
1704            Ok(())
1705        }
1706    }
1707
1708    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1709        for EndpointUnregisterVmosResponse
1710    {
1711        #[inline(always)]
1712        fn new_empty() -> Self {
1713            Self {
1714                failed_vmo_ids: fidl::new_empty!(fidl::encoding::Vector<u64, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1715                errors: fidl::new_empty!(fidl::encoding::Vector<i32, 300>, fidl::encoding::DefaultFuchsiaResourceDialect),
1716            }
1717        }
1718
1719        #[inline]
1720        unsafe fn decode(
1721            &mut self,
1722            decoder: &mut fidl::encoding::Decoder<
1723                '_,
1724                fidl::encoding::DefaultFuchsiaResourceDialect,
1725            >,
1726            offset: usize,
1727            _depth: fidl::encoding::Depth,
1728        ) -> fidl::Result<()> {
1729            decoder.debug_check_bounds::<Self>(offset);
1730            // Verify that padding bytes are zero.
1731            fidl::decode!(fidl::encoding::Vector<u64, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.failed_vmo_ids, decoder, offset + 0, _depth)?;
1732            fidl::decode!(fidl::encoding::Vector<i32, 300>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.errors, decoder, offset + 16, _depth)?;
1733            Ok(())
1734        }
1735    }
1736
1737    impl Completion {
1738        #[inline(always)]
1739        fn max_ordinal_present(&self) -> u64 {
1740            if let Some(_) = self.wake_lease {
1741                return 4;
1742            }
1743            if let Some(_) = self.transfer_size {
1744                return 3;
1745            }
1746            if let Some(_) = self.status {
1747                return 2;
1748            }
1749            if let Some(_) = self.request {
1750                return 1;
1751            }
1752            0
1753        }
1754    }
1755
1756    impl fidl::encoding::ResourceTypeMarker for Completion {
1757        type Borrowed<'a> = &'a mut Self;
1758        fn take_or_borrow<'a>(
1759            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1760        ) -> Self::Borrowed<'a> {
1761            value
1762        }
1763    }
1764
1765    unsafe impl fidl::encoding::TypeMarker for Completion {
1766        type Owned = Self;
1767
1768        #[inline(always)]
1769        fn inline_align(_context: fidl::encoding::Context) -> usize {
1770            8
1771        }
1772
1773        #[inline(always)]
1774        fn inline_size(_context: fidl::encoding::Context) -> usize {
1775            16
1776        }
1777    }
1778
1779    unsafe impl fidl::encoding::Encode<Completion, fidl::encoding::DefaultFuchsiaResourceDialect>
1780        for &mut Completion
1781    {
1782        unsafe fn encode(
1783            self,
1784            encoder: &mut fidl::encoding::Encoder<
1785                '_,
1786                fidl::encoding::DefaultFuchsiaResourceDialect,
1787            >,
1788            offset: usize,
1789            mut depth: fidl::encoding::Depth,
1790        ) -> fidl::Result<()> {
1791            encoder.debug_check_bounds::<Completion>(offset);
1792            // Vector header
1793            let max_ordinal: u64 = self.max_ordinal_present();
1794            encoder.write_num(max_ordinal, offset);
1795            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1796            // Calling encoder.out_of_line_offset(0) is not allowed.
1797            if max_ordinal == 0 {
1798                return Ok(());
1799            }
1800            depth.increment()?;
1801            let envelope_size = 8;
1802            let bytes_len = max_ordinal as usize * envelope_size;
1803            #[allow(unused_variables)]
1804            let offset = encoder.out_of_line_offset(bytes_len);
1805            let mut _prev_end_offset: usize = 0;
1806            if 1 > max_ordinal {
1807                return Ok(());
1808            }
1809
1810            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1811            // are envelope_size bytes.
1812            let cur_offset: usize = (1 - 1) * envelope_size;
1813
1814            // Zero reserved fields.
1815            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1816
1817            // Safety:
1818            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1819            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1820            //   envelope_size bytes, there is always sufficient room.
1821            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_usb_request::Request, fidl::encoding::DefaultFuchsiaResourceDialect>(
1822            self.request.as_mut().map(<fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1823            encoder, offset + cur_offset, depth
1824        )?;
1825
1826            _prev_end_offset = cur_offset + envelope_size;
1827            if 2 > max_ordinal {
1828                return Ok(());
1829            }
1830
1831            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1832            // are envelope_size bytes.
1833            let cur_offset: usize = (2 - 1) * envelope_size;
1834
1835            // Zero reserved fields.
1836            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1837
1838            // Safety:
1839            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1840            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1841            //   envelope_size bytes, there is always sufficient room.
1842            fidl::encoding::encode_in_envelope_optional::<
1843                i32,
1844                fidl::encoding::DefaultFuchsiaResourceDialect,
1845            >(
1846                self.status.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1847                encoder,
1848                offset + cur_offset,
1849                depth,
1850            )?;
1851
1852            _prev_end_offset = cur_offset + envelope_size;
1853            if 3 > max_ordinal {
1854                return Ok(());
1855            }
1856
1857            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1858            // are envelope_size bytes.
1859            let cur_offset: usize = (3 - 1) * envelope_size;
1860
1861            // Zero reserved fields.
1862            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1863
1864            // Safety:
1865            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1866            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1867            //   envelope_size bytes, there is always sufficient room.
1868            fidl::encoding::encode_in_envelope_optional::<
1869                u64,
1870                fidl::encoding::DefaultFuchsiaResourceDialect,
1871            >(
1872                self.transfer_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1873                encoder,
1874                offset + cur_offset,
1875                depth,
1876            )?;
1877
1878            _prev_end_offset = cur_offset + envelope_size;
1879            if 4 > max_ordinal {
1880                return Ok(());
1881            }
1882
1883            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1884            // are envelope_size bytes.
1885            let cur_offset: usize = (4 - 1) * envelope_size;
1886
1887            // Zero reserved fields.
1888            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1889
1890            // Safety:
1891            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1892            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1893            //   envelope_size bytes, there is always sufficient room.
1894            fidl::encoding::encode_in_envelope_optional::<
1895                fidl::encoding::HandleType<
1896                    fidl::EventPair,
1897                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1898                    2147483648,
1899                >,
1900                fidl::encoding::DefaultFuchsiaResourceDialect,
1901            >(
1902                self.wake_lease.as_mut().map(
1903                    <fidl::encoding::HandleType<
1904                        fidl::EventPair,
1905                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1906                        2147483648,
1907                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1908                ),
1909                encoder,
1910                offset + cur_offset,
1911                depth,
1912            )?;
1913
1914            _prev_end_offset = cur_offset + envelope_size;
1915
1916            Ok(())
1917        }
1918    }
1919
1920    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Completion {
1921        #[inline(always)]
1922        fn new_empty() -> Self {
1923            Self::default()
1924        }
1925
1926        unsafe fn decode(
1927            &mut self,
1928            decoder: &mut fidl::encoding::Decoder<
1929                '_,
1930                fidl::encoding::DefaultFuchsiaResourceDialect,
1931            >,
1932            offset: usize,
1933            mut depth: fidl::encoding::Depth,
1934        ) -> fidl::Result<()> {
1935            decoder.debug_check_bounds::<Self>(offset);
1936            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1937                None => return Err(fidl::Error::NotNullable),
1938                Some(len) => len,
1939            };
1940            // Calling decoder.out_of_line_offset(0) is not allowed.
1941            if len == 0 {
1942                return Ok(());
1943            };
1944            depth.increment()?;
1945            let envelope_size = 8;
1946            let bytes_len = len * envelope_size;
1947            let offset = decoder.out_of_line_offset(bytes_len)?;
1948            // Decode the envelope for each type.
1949            let mut _next_ordinal_to_read = 0;
1950            let mut next_offset = offset;
1951            let end_offset = offset + bytes_len;
1952            _next_ordinal_to_read += 1;
1953            if next_offset >= end_offset {
1954                return Ok(());
1955            }
1956
1957            // Decode unknown envelopes for gaps in ordinals.
1958            while _next_ordinal_to_read < 1 {
1959                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1960                _next_ordinal_to_read += 1;
1961                next_offset += envelope_size;
1962            }
1963
1964            let next_out_of_line = decoder.next_out_of_line();
1965            let handles_before = decoder.remaining_handles();
1966            if let Some((inlined, num_bytes, num_handles)) =
1967                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1968            {
1969                let member_inline_size = <fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1970                if inlined != (member_inline_size <= 4) {
1971                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1972                }
1973                let inner_offset;
1974                let mut inner_depth = depth.clone();
1975                if inlined {
1976                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1977                    inner_offset = next_offset;
1978                } else {
1979                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1980                    inner_depth.increment()?;
1981                }
1982                let val_ref = self.request.get_or_insert_with(|| {
1983                    fidl::new_empty!(
1984                        fidl_fuchsia_hardware_usb_request::Request,
1985                        fidl::encoding::DefaultFuchsiaResourceDialect
1986                    )
1987                });
1988                fidl::decode!(
1989                    fidl_fuchsia_hardware_usb_request::Request,
1990                    fidl::encoding::DefaultFuchsiaResourceDialect,
1991                    val_ref,
1992                    decoder,
1993                    inner_offset,
1994                    inner_depth
1995                )?;
1996                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1997                {
1998                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1999                }
2000                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2001                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2002                }
2003            }
2004
2005            next_offset += envelope_size;
2006            _next_ordinal_to_read += 1;
2007            if next_offset >= end_offset {
2008                return Ok(());
2009            }
2010
2011            // Decode unknown envelopes for gaps in ordinals.
2012            while _next_ordinal_to_read < 2 {
2013                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2014                _next_ordinal_to_read += 1;
2015                next_offset += envelope_size;
2016            }
2017
2018            let next_out_of_line = decoder.next_out_of_line();
2019            let handles_before = decoder.remaining_handles();
2020            if let Some((inlined, num_bytes, num_handles)) =
2021                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2022            {
2023                let member_inline_size =
2024                    <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2025                if inlined != (member_inline_size <= 4) {
2026                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2027                }
2028                let inner_offset;
2029                let mut inner_depth = depth.clone();
2030                if inlined {
2031                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2032                    inner_offset = next_offset;
2033                } else {
2034                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2035                    inner_depth.increment()?;
2036                }
2037                let val_ref = self.status.get_or_insert_with(|| {
2038                    fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect)
2039                });
2040                fidl::decode!(
2041                    i32,
2042                    fidl::encoding::DefaultFuchsiaResourceDialect,
2043                    val_ref,
2044                    decoder,
2045                    inner_offset,
2046                    inner_depth
2047                )?;
2048                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2049                {
2050                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2051                }
2052                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2053                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2054                }
2055            }
2056
2057            next_offset += envelope_size;
2058            _next_ordinal_to_read += 1;
2059            if next_offset >= end_offset {
2060                return Ok(());
2061            }
2062
2063            // Decode unknown envelopes for gaps in ordinals.
2064            while _next_ordinal_to_read < 3 {
2065                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2066                _next_ordinal_to_read += 1;
2067                next_offset += envelope_size;
2068            }
2069
2070            let next_out_of_line = decoder.next_out_of_line();
2071            let handles_before = decoder.remaining_handles();
2072            if let Some((inlined, num_bytes, num_handles)) =
2073                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2074            {
2075                let member_inline_size =
2076                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2077                if inlined != (member_inline_size <= 4) {
2078                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2079                }
2080                let inner_offset;
2081                let mut inner_depth = depth.clone();
2082                if inlined {
2083                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2084                    inner_offset = next_offset;
2085                } else {
2086                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2087                    inner_depth.increment()?;
2088                }
2089                let val_ref = self.transfer_size.get_or_insert_with(|| {
2090                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2091                });
2092                fidl::decode!(
2093                    u64,
2094                    fidl::encoding::DefaultFuchsiaResourceDialect,
2095                    val_ref,
2096                    decoder,
2097                    inner_offset,
2098                    inner_depth
2099                )?;
2100                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2101                {
2102                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2103                }
2104                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2105                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2106                }
2107            }
2108
2109            next_offset += envelope_size;
2110            _next_ordinal_to_read += 1;
2111            if next_offset >= end_offset {
2112                return Ok(());
2113            }
2114
2115            // Decode unknown envelopes for gaps in ordinals.
2116            while _next_ordinal_to_read < 4 {
2117                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2118                _next_ordinal_to_read += 1;
2119                next_offset += envelope_size;
2120            }
2121
2122            let next_out_of_line = decoder.next_out_of_line();
2123            let handles_before = decoder.remaining_handles();
2124            if let Some((inlined, num_bytes, num_handles)) =
2125                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2126            {
2127                let member_inline_size = <fidl::encoding::HandleType<
2128                    fidl::EventPair,
2129                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2130                    2147483648,
2131                > as fidl::encoding::TypeMarker>::inline_size(
2132                    decoder.context
2133                );
2134                if inlined != (member_inline_size <= 4) {
2135                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2136                }
2137                let inner_offset;
2138                let mut inner_depth = depth.clone();
2139                if inlined {
2140                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2141                    inner_offset = next_offset;
2142                } else {
2143                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2144                    inner_depth.increment()?;
2145                }
2146                let val_ref =
2147                self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2148                fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2149                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2150                {
2151                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2152                }
2153                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2154                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2155                }
2156            }
2157
2158            next_offset += envelope_size;
2159
2160            // Decode the remaining unknown envelopes.
2161            while next_offset < end_offset {
2162                _next_ordinal_to_read += 1;
2163                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2164                next_offset += envelope_size;
2165            }
2166
2167            Ok(())
2168        }
2169    }
2170
2171    impl VmoHandle {
2172        #[inline(always)]
2173        fn max_ordinal_present(&self) -> u64 {
2174            if let Some(_) = self.vmo {
2175                return 2;
2176            }
2177            if let Some(_) = self.id {
2178                return 1;
2179            }
2180            0
2181        }
2182    }
2183
2184    impl fidl::encoding::ResourceTypeMarker for VmoHandle {
2185        type Borrowed<'a> = &'a mut Self;
2186        fn take_or_borrow<'a>(
2187            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2188        ) -> Self::Borrowed<'a> {
2189            value
2190        }
2191    }
2192
2193    unsafe impl fidl::encoding::TypeMarker for VmoHandle {
2194        type Owned = Self;
2195
2196        #[inline(always)]
2197        fn inline_align(_context: fidl::encoding::Context) -> usize {
2198            8
2199        }
2200
2201        #[inline(always)]
2202        fn inline_size(_context: fidl::encoding::Context) -> usize {
2203            16
2204        }
2205    }
2206
2207    unsafe impl fidl::encoding::Encode<VmoHandle, fidl::encoding::DefaultFuchsiaResourceDialect>
2208        for &mut VmoHandle
2209    {
2210        unsafe fn encode(
2211            self,
2212            encoder: &mut fidl::encoding::Encoder<
2213                '_,
2214                fidl::encoding::DefaultFuchsiaResourceDialect,
2215            >,
2216            offset: usize,
2217            mut depth: fidl::encoding::Depth,
2218        ) -> fidl::Result<()> {
2219            encoder.debug_check_bounds::<VmoHandle>(offset);
2220            // Vector header
2221            let max_ordinal: u64 = self.max_ordinal_present();
2222            encoder.write_num(max_ordinal, offset);
2223            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2224            // Calling encoder.out_of_line_offset(0) is not allowed.
2225            if max_ordinal == 0 {
2226                return Ok(());
2227            }
2228            depth.increment()?;
2229            let envelope_size = 8;
2230            let bytes_len = max_ordinal as usize * envelope_size;
2231            #[allow(unused_variables)]
2232            let offset = encoder.out_of_line_offset(bytes_len);
2233            let mut _prev_end_offset: usize = 0;
2234            if 1 > max_ordinal {
2235                return Ok(());
2236            }
2237
2238            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2239            // are envelope_size bytes.
2240            let cur_offset: usize = (1 - 1) * envelope_size;
2241
2242            // Zero reserved fields.
2243            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2244
2245            // Safety:
2246            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2247            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2248            //   envelope_size bytes, there is always sufficient room.
2249            fidl::encoding::encode_in_envelope_optional::<
2250                u64,
2251                fidl::encoding::DefaultFuchsiaResourceDialect,
2252            >(
2253                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2254                encoder,
2255                offset + cur_offset,
2256                depth,
2257            )?;
2258
2259            _prev_end_offset = cur_offset + envelope_size;
2260            if 2 > max_ordinal {
2261                return Ok(());
2262            }
2263
2264            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2265            // are envelope_size bytes.
2266            let cur_offset: usize = (2 - 1) * envelope_size;
2267
2268            // Zero reserved fields.
2269            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2270
2271            // Safety:
2272            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2273            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2274            //   envelope_size bytes, there is always sufficient room.
2275            fidl::encoding::encode_in_envelope_optional::<
2276                fidl::encoding::HandleType<
2277                    fidl::Vmo,
2278                    { fidl::ObjectType::VMO.into_raw() },
2279                    2147483648,
2280                >,
2281                fidl::encoding::DefaultFuchsiaResourceDialect,
2282            >(
2283                self.vmo.as_mut().map(
2284                    <fidl::encoding::HandleType<
2285                        fidl::Vmo,
2286                        { fidl::ObjectType::VMO.into_raw() },
2287                        2147483648,
2288                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2289                ),
2290                encoder,
2291                offset + cur_offset,
2292                depth,
2293            )?;
2294
2295            _prev_end_offset = cur_offset + envelope_size;
2296
2297            Ok(())
2298        }
2299    }
2300
2301    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoHandle {
2302        #[inline(always)]
2303        fn new_empty() -> Self {
2304            Self::default()
2305        }
2306
2307        unsafe fn decode(
2308            &mut self,
2309            decoder: &mut fidl::encoding::Decoder<
2310                '_,
2311                fidl::encoding::DefaultFuchsiaResourceDialect,
2312            >,
2313            offset: usize,
2314            mut depth: fidl::encoding::Depth,
2315        ) -> fidl::Result<()> {
2316            decoder.debug_check_bounds::<Self>(offset);
2317            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2318                None => return Err(fidl::Error::NotNullable),
2319                Some(len) => len,
2320            };
2321            // Calling decoder.out_of_line_offset(0) is not allowed.
2322            if len == 0 {
2323                return Ok(());
2324            };
2325            depth.increment()?;
2326            let envelope_size = 8;
2327            let bytes_len = len * envelope_size;
2328            let offset = decoder.out_of_line_offset(bytes_len)?;
2329            // Decode the envelope for each type.
2330            let mut _next_ordinal_to_read = 0;
2331            let mut next_offset = offset;
2332            let end_offset = offset + bytes_len;
2333            _next_ordinal_to_read += 1;
2334            if next_offset >= end_offset {
2335                return Ok(());
2336            }
2337
2338            // Decode unknown envelopes for gaps in ordinals.
2339            while _next_ordinal_to_read < 1 {
2340                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2341                _next_ordinal_to_read += 1;
2342                next_offset += envelope_size;
2343            }
2344
2345            let next_out_of_line = decoder.next_out_of_line();
2346            let handles_before = decoder.remaining_handles();
2347            if let Some((inlined, num_bytes, num_handles)) =
2348                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2349            {
2350                let member_inline_size =
2351                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2352                if inlined != (member_inline_size <= 4) {
2353                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2354                }
2355                let inner_offset;
2356                let mut inner_depth = depth.clone();
2357                if inlined {
2358                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2359                    inner_offset = next_offset;
2360                } else {
2361                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2362                    inner_depth.increment()?;
2363                }
2364                let val_ref = self.id.get_or_insert_with(|| {
2365                    fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2366                });
2367                fidl::decode!(
2368                    u64,
2369                    fidl::encoding::DefaultFuchsiaResourceDialect,
2370                    val_ref,
2371                    decoder,
2372                    inner_offset,
2373                    inner_depth
2374                )?;
2375                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2376                {
2377                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2378                }
2379                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2380                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2381                }
2382            }
2383
2384            next_offset += envelope_size;
2385            _next_ordinal_to_read += 1;
2386            if next_offset >= end_offset {
2387                return Ok(());
2388            }
2389
2390            // Decode unknown envelopes for gaps in ordinals.
2391            while _next_ordinal_to_read < 2 {
2392                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2393                _next_ordinal_to_read += 1;
2394                next_offset += envelope_size;
2395            }
2396
2397            let next_out_of_line = decoder.next_out_of_line();
2398            let handles_before = decoder.remaining_handles();
2399            if let Some((inlined, num_bytes, num_handles)) =
2400                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2401            {
2402                let member_inline_size = <fidl::encoding::HandleType<
2403                    fidl::Vmo,
2404                    { fidl::ObjectType::VMO.into_raw() },
2405                    2147483648,
2406                > as fidl::encoding::TypeMarker>::inline_size(
2407                    decoder.context
2408                );
2409                if inlined != (member_inline_size <= 4) {
2410                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2411                }
2412                let inner_offset;
2413                let mut inner_depth = depth.clone();
2414                if inlined {
2415                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2416                    inner_offset = next_offset;
2417                } else {
2418                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2419                    inner_depth.increment()?;
2420                }
2421                let val_ref =
2422                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2423                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2424                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2425                {
2426                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2427                }
2428                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2429                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2430                }
2431            }
2432
2433            next_offset += envelope_size;
2434
2435            // Decode the remaining unknown envelopes.
2436            while next_offset < end_offset {
2437                _next_ordinal_to_read += 1;
2438                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2439                next_offset += envelope_size;
2440            }
2441
2442            Ok(())
2443        }
2444    }
2445}