Skip to main content

fidl_fuchsia_hardware_usb_endpoint_common/
fidl_fuchsia_hardware_usb_endpoint_common.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::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Limit on the number of completions delivered in a single `OnCompletion` event to avoid
12/// exceeding the Zircon channel message size limit (`ZX_CHANNEL_MAX_MSG_BYTES` = 64KB) even with
13/// scatter-gather buffer chaining.
14pub const MAX_COMPLETIONS_PER_EVENT: u32 = 64;
15
16/// Limit on the number of Requests in one call to `QueueRequests()`.
17pub const REQUEST_MAX: u32 = 64;
18
19/// Limit on the number of VMOs in one call to `RegisterVmos()` or `UnregisterVmos()`.
20/// Bounded by the Zircon channel handle limit (`ZX_CHANNEL_MAX_MSG_HANDLES` = 64) since
21/// `RegisterVmos()` returns a vector of VMO handles.
22pub const VMO_VECTOR_MAX: u32 = 64;
23
24#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct EndpointUnregisterVmosRequest {
26    pub vmo_ids: Vec<u64>,
27}
28
29impl fidl::Persistable for EndpointUnregisterVmosRequest {}
30
31#[derive(Clone, Debug, PartialEq)]
32pub struct EndpointGetInfoResponse {
33    pub info: EndpointInfo,
34}
35
36impl fidl::Persistable for EndpointGetInfoResponse {}
37
38/// Bulk Endpoint Information
39#[derive(Clone, Debug, Default, PartialEq)]
40pub struct BulkEndpointInfo {
41    /// True if the endpoint controller supports multi-page / multi-TRB scatter-gather chaining.
42    /// If false, each request must consist of a single VMO that resides entirely within a single
43    /// physically contiguous range of memory (i.e. cannot span non-contiguous physical pages or
44    /// multiple buffer regions).
45    pub supports_scatter_gather: Option<bool>,
46    #[doc(hidden)]
47    pub __source_breaking: fidl::marker::SourceBreaking,
48}
49
50impl fidl::Persistable for BulkEndpointInfo {}
51
52/// Control Endpoint Information
53#[derive(Clone, Debug, Default, PartialEq)]
54pub struct ControlEndpointInfo {
55    #[doc(hidden)]
56    pub __source_breaking: fidl::marker::SourceBreaking,
57}
58
59impl fidl::Persistable for ControlEndpointInfo {}
60
61/// Interrupt Endpoint Information
62#[derive(Clone, Debug, Default, PartialEq)]
63pub struct InterruptEndpointInfo {
64    /// True if the endpoint controller supports multi-page / multi-TRB scatter-gather chaining.
65    /// If false, each request must consist of a single VMO that resides entirely within a single
66    /// physically contiguous range of memory (i.e. cannot span non-contiguous physical pages or
67    /// multiple buffer regions).
68    pub supports_scatter_gather: Option<bool>,
69    #[doc(hidden)]
70    pub __source_breaking: fidl::marker::SourceBreaking,
71}
72
73impl fidl::Persistable for InterruptEndpointInfo {}
74
75/// Isochronous Endpoint Information
76#[derive(Clone, Debug, Default, PartialEq)]
77pub struct IsochronousEndpointInfo {
78    /// Lead time described in number of transfers.
79    pub lead_time: Option<u64>,
80    /// True if the endpoint controller supports multi-page / multi-TRB scatter-gather chaining.
81    /// If false, each request must consist of a single VMO that resides entirely within a single
82    /// physically contiguous range of memory (i.e. cannot span non-contiguous physical pages or
83    /// multiple buffer regions).
84    pub supports_scatter_gather: Option<bool>,
85    #[doc(hidden)]
86    pub __source_breaking: fidl::marker::SourceBreaking,
87}
88
89impl fidl::Persistable for IsochronousEndpointInfo {}
90
91/// VMO information for registering VMOs. Only used for `RegisterVmos()` to convey the ID to register
92/// a VMO to and its size.
93#[derive(Clone, Debug, Default, PartialEq)]
94pub struct VmoInfo {
95    /// ID corresponding to the VMO to be registered.
96    pub id: Option<u64>,
97    /// Size of VMO to register.
98    pub size: Option<u64>,
99    #[doc(hidden)]
100    pub __source_breaking: fidl::marker::SourceBreaking,
101}
102
103impl fidl::Persistable for VmoInfo {}
104
105/// Endpoint Information
106#[derive(Clone, Debug)]
107pub enum EndpointInfo {
108    /// Bulk endpoint information
109    Bulk(BulkEndpointInfo),
110    /// Control endpoint information
111    Control(ControlEndpointInfo),
112    /// Isochronous endpoint information
113    Isochronous(IsochronousEndpointInfo),
114    /// Interrupt endpoint information
115    Interrupt(InterruptEndpointInfo),
116    #[doc(hidden)]
117    __SourceBreaking { unknown_ordinal: u64 },
118}
119
120/// Pattern that matches an unknown `EndpointInfo` member.
121#[macro_export]
122macro_rules! EndpointInfoUnknown {
123    () => {
124        _
125    };
126}
127
128// Custom PartialEq so that unknown variants are not equal to themselves.
129impl PartialEq for EndpointInfo {
130    fn eq(&self, other: &Self) -> bool {
131        match (self, other) {
132            (Self::Bulk(x), Self::Bulk(y)) => *x == *y,
133            (Self::Control(x), Self::Control(y)) => *x == *y,
134            (Self::Isochronous(x), Self::Isochronous(y)) => *x == *y,
135            (Self::Interrupt(x), Self::Interrupt(y)) => *x == *y,
136            _ => false,
137        }
138    }
139}
140
141impl EndpointInfo {
142    #[inline]
143    pub fn ordinal(&self) -> u64 {
144        match *self {
145            Self::Bulk(_) => 1,
146            Self::Control(_) => 2,
147            Self::Isochronous(_) => 3,
148            Self::Interrupt(_) => 4,
149            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
150        }
151    }
152
153    #[inline]
154    pub fn unknown_variant_for_testing() -> Self {
155        Self::__SourceBreaking { unknown_ordinal: 0 }
156    }
157
158    #[inline]
159    pub fn is_unknown(&self) -> bool {
160        match self {
161            Self::__SourceBreaking { .. } => true,
162            _ => false,
163        }
164    }
165}
166
167impl fidl::Persistable for EndpointInfo {}
168
169pub mod endpoint_ordinals {
170    pub const GET_INFO: u64 = 0x1fba84f171a95023;
171    pub const REGISTER_VMOS: u64 = 0x1dea601921185c7b;
172    pub const UNREGISTER_VMOS: u64 = 0x34719ede1c99c10;
173    pub const QUEUE_REQUESTS: u64 = 0x431e4170793e38a6;
174    pub const ON_COMPLETION: u64 = 0x2d6471306c049771;
175    pub const CANCEL_ALL: u64 = 0x233854c776cda1cc;
176}
177
178mod internal {
179    use super::*;
180
181    impl fidl::encoding::ValueTypeMarker for EndpointUnregisterVmosRequest {
182        type Borrowed<'a> = &'a Self;
183        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
184            value
185        }
186    }
187
188    unsafe impl fidl::encoding::TypeMarker for EndpointUnregisterVmosRequest {
189        type Owned = Self;
190
191        #[inline(always)]
192        fn inline_align(_context: fidl::encoding::Context) -> usize {
193            8
194        }
195
196        #[inline(always)]
197        fn inline_size(_context: fidl::encoding::Context) -> usize {
198            16
199        }
200    }
201
202    unsafe impl<D: fidl::encoding::ResourceDialect>
203        fidl::encoding::Encode<EndpointUnregisterVmosRequest, D>
204        for &EndpointUnregisterVmosRequest
205    {
206        #[inline]
207        unsafe fn encode(
208            self,
209            encoder: &mut fidl::encoding::Encoder<'_, D>,
210            offset: usize,
211            _depth: fidl::encoding::Depth,
212        ) -> fidl::Result<()> {
213            encoder.debug_check_bounds::<EndpointUnregisterVmosRequest>(offset);
214            // Delegate to tuple encoding.
215            fidl::encoding::Encode::<EndpointUnregisterVmosRequest, D>::encode(
216                (<fidl::encoding::Vector<u64, 64> as fidl::encoding::ValueTypeMarker>::borrow(
217                    &self.vmo_ids,
218                ),),
219                encoder,
220                offset,
221                _depth,
222            )
223        }
224    }
225    unsafe impl<
226        D: fidl::encoding::ResourceDialect,
227        T0: fidl::encoding::Encode<fidl::encoding::Vector<u64, 64>, D>,
228    > fidl::encoding::Encode<EndpointUnregisterVmosRequest, D> for (T0,)
229    {
230        #[inline]
231        unsafe fn encode(
232            self,
233            encoder: &mut fidl::encoding::Encoder<'_, D>,
234            offset: usize,
235            depth: fidl::encoding::Depth,
236        ) -> fidl::Result<()> {
237            encoder.debug_check_bounds::<EndpointUnregisterVmosRequest>(offset);
238            // Zero out padding regions. There's no need to apply masks
239            // because the unmasked parts will be overwritten by fields.
240            // Write the fields.
241            self.0.encode(encoder, offset + 0, depth)?;
242            Ok(())
243        }
244    }
245
246    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
247        for EndpointUnregisterVmosRequest
248    {
249        #[inline(always)]
250        fn new_empty() -> Self {
251            Self { vmo_ids: fidl::new_empty!(fidl::encoding::Vector<u64, 64>, D) }
252        }
253
254        #[inline]
255        unsafe fn decode(
256            &mut self,
257            decoder: &mut fidl::encoding::Decoder<'_, D>,
258            offset: usize,
259            _depth: fidl::encoding::Depth,
260        ) -> fidl::Result<()> {
261            decoder.debug_check_bounds::<Self>(offset);
262            // Verify that padding bytes are zero.
263            fidl::decode!(fidl::encoding::Vector<u64, 64>, D, &mut self.vmo_ids, decoder, offset + 0, _depth)?;
264            Ok(())
265        }
266    }
267
268    impl fidl::encoding::ValueTypeMarker for EndpointGetInfoResponse {
269        type Borrowed<'a> = &'a Self;
270        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
271            value
272        }
273    }
274
275    unsafe impl fidl::encoding::TypeMarker for EndpointGetInfoResponse {
276        type Owned = Self;
277
278        #[inline(always)]
279        fn inline_align(_context: fidl::encoding::Context) -> usize {
280            8
281        }
282
283        #[inline(always)]
284        fn inline_size(_context: fidl::encoding::Context) -> usize {
285            16
286        }
287    }
288
289    unsafe impl<D: fidl::encoding::ResourceDialect>
290        fidl::encoding::Encode<EndpointGetInfoResponse, D> for &EndpointGetInfoResponse
291    {
292        #[inline]
293        unsafe fn encode(
294            self,
295            encoder: &mut fidl::encoding::Encoder<'_, D>,
296            offset: usize,
297            _depth: fidl::encoding::Depth,
298        ) -> fidl::Result<()> {
299            encoder.debug_check_bounds::<EndpointGetInfoResponse>(offset);
300            // Delegate to tuple encoding.
301            fidl::encoding::Encode::<EndpointGetInfoResponse, D>::encode(
302                (<EndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
303                encoder,
304                offset,
305                _depth,
306            )
307        }
308    }
309    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<EndpointInfo, D>>
310        fidl::encoding::Encode<EndpointGetInfoResponse, D> for (T0,)
311    {
312        #[inline]
313        unsafe fn encode(
314            self,
315            encoder: &mut fidl::encoding::Encoder<'_, D>,
316            offset: usize,
317            depth: fidl::encoding::Depth,
318        ) -> fidl::Result<()> {
319            encoder.debug_check_bounds::<EndpointGetInfoResponse>(offset);
320            // Zero out padding regions. There's no need to apply masks
321            // because the unmasked parts will be overwritten by fields.
322            // Write the fields.
323            self.0.encode(encoder, offset + 0, depth)?;
324            Ok(())
325        }
326    }
327
328    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
329        for EndpointGetInfoResponse
330    {
331        #[inline(always)]
332        fn new_empty() -> Self {
333            Self { info: fidl::new_empty!(EndpointInfo, D) }
334        }
335
336        #[inline]
337        unsafe fn decode(
338            &mut self,
339            decoder: &mut fidl::encoding::Decoder<'_, D>,
340            offset: usize,
341            _depth: fidl::encoding::Depth,
342        ) -> fidl::Result<()> {
343            decoder.debug_check_bounds::<Self>(offset);
344            // Verify that padding bytes are zero.
345            fidl::decode!(EndpointInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
346            Ok(())
347        }
348    }
349
350    impl BulkEndpointInfo {
351        #[inline(always)]
352        fn max_ordinal_present(&self) -> u64 {
353            if let Some(_) = self.supports_scatter_gather {
354                return 1;
355            }
356            0
357        }
358    }
359
360    impl fidl::encoding::ValueTypeMarker for BulkEndpointInfo {
361        type Borrowed<'a> = &'a Self;
362        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
363            value
364        }
365    }
366
367    unsafe impl fidl::encoding::TypeMarker for BulkEndpointInfo {
368        type Owned = Self;
369
370        #[inline(always)]
371        fn inline_align(_context: fidl::encoding::Context) -> usize {
372            8
373        }
374
375        #[inline(always)]
376        fn inline_size(_context: fidl::encoding::Context) -> usize {
377            16
378        }
379    }
380
381    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BulkEndpointInfo, D>
382        for &BulkEndpointInfo
383    {
384        unsafe fn encode(
385            self,
386            encoder: &mut fidl::encoding::Encoder<'_, D>,
387            offset: usize,
388            mut depth: fidl::encoding::Depth,
389        ) -> fidl::Result<()> {
390            encoder.debug_check_bounds::<BulkEndpointInfo>(offset);
391            // Vector header
392            let max_ordinal: u64 = self.max_ordinal_present();
393            encoder.write_num(max_ordinal, offset);
394            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
395            // Calling encoder.out_of_line_offset(0) is not allowed.
396            if max_ordinal == 0 {
397                return Ok(());
398            }
399            depth.increment()?;
400            let envelope_size = 8;
401            let bytes_len = max_ordinal as usize * envelope_size;
402            #[allow(unused_variables)]
403            let offset = encoder.out_of_line_offset(bytes_len);
404            let mut _prev_end_offset: usize = 0;
405            if 1 > max_ordinal {
406                return Ok(());
407            }
408
409            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
410            // are envelope_size bytes.
411            let cur_offset: usize = (1 - 1) * envelope_size;
412
413            // Zero reserved fields.
414            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
415
416            // Safety:
417            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
418            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
419            //   envelope_size bytes, there is always sufficient room.
420            fidl::encoding::encode_in_envelope_optional::<bool, D>(
421                self.supports_scatter_gather
422                    .as_ref()
423                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
424                encoder,
425                offset + cur_offset,
426                depth,
427            )?;
428
429            _prev_end_offset = cur_offset + envelope_size;
430
431            Ok(())
432        }
433    }
434
435    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BulkEndpointInfo {
436        #[inline(always)]
437        fn new_empty() -> Self {
438            Self::default()
439        }
440
441        unsafe fn decode(
442            &mut self,
443            decoder: &mut fidl::encoding::Decoder<'_, D>,
444            offset: usize,
445            mut depth: fidl::encoding::Depth,
446        ) -> fidl::Result<()> {
447            decoder.debug_check_bounds::<Self>(offset);
448            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
449                None => return Err(fidl::Error::NotNullable),
450                Some(len) => len,
451            };
452            // Calling decoder.out_of_line_offset(0) is not allowed.
453            if len == 0 {
454                return Ok(());
455            };
456            depth.increment()?;
457            let envelope_size = 8;
458            let bytes_len = len * envelope_size;
459            let offset = decoder.out_of_line_offset(bytes_len)?;
460            // Decode the envelope for each type.
461            let mut _next_ordinal_to_read = 0;
462            let mut next_offset = offset;
463            let end_offset = offset + bytes_len;
464            _next_ordinal_to_read += 1;
465            if next_offset >= end_offset {
466                return Ok(());
467            }
468
469            // Decode unknown envelopes for gaps in ordinals.
470            while _next_ordinal_to_read < 1 {
471                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
472                _next_ordinal_to_read += 1;
473                next_offset += envelope_size;
474            }
475
476            let next_out_of_line = decoder.next_out_of_line();
477            let handles_before = decoder.remaining_handles();
478            if let Some((inlined, num_bytes, num_handles)) =
479                fidl::encoding::decode_envelope_header(decoder, next_offset)?
480            {
481                let member_inline_size =
482                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
483                if inlined != (member_inline_size <= 4) {
484                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
485                }
486                let inner_offset;
487                let mut inner_depth = depth.clone();
488                if inlined {
489                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
490                    inner_offset = next_offset;
491                } else {
492                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
493                    inner_depth.increment()?;
494                }
495                let val_ref =
496                    self.supports_scatter_gather.get_or_insert_with(|| fidl::new_empty!(bool, D));
497                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
498                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
499                {
500                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
501                }
502                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
503                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
504                }
505            }
506
507            next_offset += envelope_size;
508
509            // Decode the remaining unknown envelopes.
510            while next_offset < end_offset {
511                _next_ordinal_to_read += 1;
512                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
513                next_offset += envelope_size;
514            }
515
516            Ok(())
517        }
518    }
519
520    impl ControlEndpointInfo {
521        #[inline(always)]
522        fn max_ordinal_present(&self) -> u64 {
523            0
524        }
525    }
526
527    impl fidl::encoding::ValueTypeMarker for ControlEndpointInfo {
528        type Borrowed<'a> = &'a Self;
529        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
530            value
531        }
532    }
533
534    unsafe impl fidl::encoding::TypeMarker for ControlEndpointInfo {
535        type Owned = Self;
536
537        #[inline(always)]
538        fn inline_align(_context: fidl::encoding::Context) -> usize {
539            8
540        }
541
542        #[inline(always)]
543        fn inline_size(_context: fidl::encoding::Context) -> usize {
544            16
545        }
546    }
547
548    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ControlEndpointInfo, D>
549        for &ControlEndpointInfo
550    {
551        unsafe fn encode(
552            self,
553            encoder: &mut fidl::encoding::Encoder<'_, D>,
554            offset: usize,
555            mut depth: fidl::encoding::Depth,
556        ) -> fidl::Result<()> {
557            encoder.debug_check_bounds::<ControlEndpointInfo>(offset);
558            // Vector header
559            let max_ordinal: u64 = self.max_ordinal_present();
560            encoder.write_num(max_ordinal, offset);
561            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
562            // Calling encoder.out_of_line_offset(0) is not allowed.
563            if max_ordinal == 0 {
564                return Ok(());
565            }
566            depth.increment()?;
567            let envelope_size = 8;
568            let bytes_len = max_ordinal as usize * envelope_size;
569            #[allow(unused_variables)]
570            let offset = encoder.out_of_line_offset(bytes_len);
571            let mut _prev_end_offset: usize = 0;
572
573            Ok(())
574        }
575    }
576
577    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ControlEndpointInfo {
578        #[inline(always)]
579        fn new_empty() -> Self {
580            Self::default()
581        }
582
583        unsafe fn decode(
584            &mut self,
585            decoder: &mut fidl::encoding::Decoder<'_, D>,
586            offset: usize,
587            mut depth: fidl::encoding::Depth,
588        ) -> fidl::Result<()> {
589            decoder.debug_check_bounds::<Self>(offset);
590            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
591                None => return Err(fidl::Error::NotNullable),
592                Some(len) => len,
593            };
594            // Calling decoder.out_of_line_offset(0) is not allowed.
595            if len == 0 {
596                return Ok(());
597            };
598            depth.increment()?;
599            let envelope_size = 8;
600            let bytes_len = len * envelope_size;
601            let offset = decoder.out_of_line_offset(bytes_len)?;
602            // Decode the envelope for each type.
603            let mut _next_ordinal_to_read = 0;
604            let mut next_offset = offset;
605            let end_offset = offset + bytes_len;
606
607            // Decode the remaining unknown envelopes.
608            while next_offset < end_offset {
609                _next_ordinal_to_read += 1;
610                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
611                next_offset += envelope_size;
612            }
613
614            Ok(())
615        }
616    }
617
618    impl InterruptEndpointInfo {
619        #[inline(always)]
620        fn max_ordinal_present(&self) -> u64 {
621            if let Some(_) = self.supports_scatter_gather {
622                return 1;
623            }
624            0
625        }
626    }
627
628    impl fidl::encoding::ValueTypeMarker for InterruptEndpointInfo {
629        type Borrowed<'a> = &'a Self;
630        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
631            value
632        }
633    }
634
635    unsafe impl fidl::encoding::TypeMarker for InterruptEndpointInfo {
636        type Owned = Self;
637
638        #[inline(always)]
639        fn inline_align(_context: fidl::encoding::Context) -> usize {
640            8
641        }
642
643        #[inline(always)]
644        fn inline_size(_context: fidl::encoding::Context) -> usize {
645            16
646        }
647    }
648
649    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InterruptEndpointInfo, D>
650        for &InterruptEndpointInfo
651    {
652        unsafe fn encode(
653            self,
654            encoder: &mut fidl::encoding::Encoder<'_, D>,
655            offset: usize,
656            mut depth: fidl::encoding::Depth,
657        ) -> fidl::Result<()> {
658            encoder.debug_check_bounds::<InterruptEndpointInfo>(offset);
659            // Vector header
660            let max_ordinal: u64 = self.max_ordinal_present();
661            encoder.write_num(max_ordinal, offset);
662            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
663            // Calling encoder.out_of_line_offset(0) is not allowed.
664            if max_ordinal == 0 {
665                return Ok(());
666            }
667            depth.increment()?;
668            let envelope_size = 8;
669            let bytes_len = max_ordinal as usize * envelope_size;
670            #[allow(unused_variables)]
671            let offset = encoder.out_of_line_offset(bytes_len);
672            let mut _prev_end_offset: usize = 0;
673            if 1 > max_ordinal {
674                return Ok(());
675            }
676
677            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
678            // are envelope_size bytes.
679            let cur_offset: usize = (1 - 1) * envelope_size;
680
681            // Zero reserved fields.
682            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
683
684            // Safety:
685            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
686            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
687            //   envelope_size bytes, there is always sufficient room.
688            fidl::encoding::encode_in_envelope_optional::<bool, D>(
689                self.supports_scatter_gather
690                    .as_ref()
691                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
692                encoder,
693                offset + cur_offset,
694                depth,
695            )?;
696
697            _prev_end_offset = cur_offset + envelope_size;
698
699            Ok(())
700        }
701    }
702
703    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterruptEndpointInfo {
704        #[inline(always)]
705        fn new_empty() -> Self {
706            Self::default()
707        }
708
709        unsafe fn decode(
710            &mut self,
711            decoder: &mut fidl::encoding::Decoder<'_, D>,
712            offset: usize,
713            mut depth: fidl::encoding::Depth,
714        ) -> fidl::Result<()> {
715            decoder.debug_check_bounds::<Self>(offset);
716            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
717                None => return Err(fidl::Error::NotNullable),
718                Some(len) => len,
719            };
720            // Calling decoder.out_of_line_offset(0) is not allowed.
721            if len == 0 {
722                return Ok(());
723            };
724            depth.increment()?;
725            let envelope_size = 8;
726            let bytes_len = len * envelope_size;
727            let offset = decoder.out_of_line_offset(bytes_len)?;
728            // Decode the envelope for each type.
729            let mut _next_ordinal_to_read = 0;
730            let mut next_offset = offset;
731            let end_offset = offset + bytes_len;
732            _next_ordinal_to_read += 1;
733            if next_offset >= end_offset {
734                return Ok(());
735            }
736
737            // Decode unknown envelopes for gaps in ordinals.
738            while _next_ordinal_to_read < 1 {
739                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
740                _next_ordinal_to_read += 1;
741                next_offset += envelope_size;
742            }
743
744            let next_out_of_line = decoder.next_out_of_line();
745            let handles_before = decoder.remaining_handles();
746            if let Some((inlined, num_bytes, num_handles)) =
747                fidl::encoding::decode_envelope_header(decoder, next_offset)?
748            {
749                let member_inline_size =
750                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
751                if inlined != (member_inline_size <= 4) {
752                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
753                }
754                let inner_offset;
755                let mut inner_depth = depth.clone();
756                if inlined {
757                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
758                    inner_offset = next_offset;
759                } else {
760                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
761                    inner_depth.increment()?;
762                }
763                let val_ref =
764                    self.supports_scatter_gather.get_or_insert_with(|| fidl::new_empty!(bool, D));
765                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
766                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
767                {
768                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
769                }
770                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
771                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
772                }
773            }
774
775            next_offset += envelope_size;
776
777            // Decode the remaining unknown envelopes.
778            while next_offset < end_offset {
779                _next_ordinal_to_read += 1;
780                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
781                next_offset += envelope_size;
782            }
783
784            Ok(())
785        }
786    }
787
788    impl IsochronousEndpointInfo {
789        #[inline(always)]
790        fn max_ordinal_present(&self) -> u64 {
791            if let Some(_) = self.supports_scatter_gather {
792                return 2;
793            }
794            if let Some(_) = self.lead_time {
795                return 1;
796            }
797            0
798        }
799    }
800
801    impl fidl::encoding::ValueTypeMarker for IsochronousEndpointInfo {
802        type Borrowed<'a> = &'a Self;
803        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
804            value
805        }
806    }
807
808    unsafe impl fidl::encoding::TypeMarker for IsochronousEndpointInfo {
809        type Owned = Self;
810
811        #[inline(always)]
812        fn inline_align(_context: fidl::encoding::Context) -> usize {
813            8
814        }
815
816        #[inline(always)]
817        fn inline_size(_context: fidl::encoding::Context) -> usize {
818            16
819        }
820    }
821
822    unsafe impl<D: fidl::encoding::ResourceDialect>
823        fidl::encoding::Encode<IsochronousEndpointInfo, D> for &IsochronousEndpointInfo
824    {
825        unsafe fn encode(
826            self,
827            encoder: &mut fidl::encoding::Encoder<'_, D>,
828            offset: usize,
829            mut depth: fidl::encoding::Depth,
830        ) -> fidl::Result<()> {
831            encoder.debug_check_bounds::<IsochronousEndpointInfo>(offset);
832            // Vector header
833            let max_ordinal: u64 = self.max_ordinal_present();
834            encoder.write_num(max_ordinal, offset);
835            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
836            // Calling encoder.out_of_line_offset(0) is not allowed.
837            if max_ordinal == 0 {
838                return Ok(());
839            }
840            depth.increment()?;
841            let envelope_size = 8;
842            let bytes_len = max_ordinal as usize * envelope_size;
843            #[allow(unused_variables)]
844            let offset = encoder.out_of_line_offset(bytes_len);
845            let mut _prev_end_offset: usize = 0;
846            if 1 > max_ordinal {
847                return Ok(());
848            }
849
850            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
851            // are envelope_size bytes.
852            let cur_offset: usize = (1 - 1) * envelope_size;
853
854            // Zero reserved fields.
855            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
856
857            // Safety:
858            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
859            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
860            //   envelope_size bytes, there is always sufficient room.
861            fidl::encoding::encode_in_envelope_optional::<u64, D>(
862                self.lead_time.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
863                encoder,
864                offset + cur_offset,
865                depth,
866            )?;
867
868            _prev_end_offset = cur_offset + envelope_size;
869            if 2 > max_ordinal {
870                return Ok(());
871            }
872
873            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
874            // are envelope_size bytes.
875            let cur_offset: usize = (2 - 1) * envelope_size;
876
877            // Zero reserved fields.
878            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
879
880            // Safety:
881            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
882            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
883            //   envelope_size bytes, there is always sufficient room.
884            fidl::encoding::encode_in_envelope_optional::<bool, D>(
885                self.supports_scatter_gather
886                    .as_ref()
887                    .map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
888                encoder,
889                offset + cur_offset,
890                depth,
891            )?;
892
893            _prev_end_offset = cur_offset + envelope_size;
894
895            Ok(())
896        }
897    }
898
899    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
900        for IsochronousEndpointInfo
901    {
902        #[inline(always)]
903        fn new_empty() -> Self {
904            Self::default()
905        }
906
907        unsafe fn decode(
908            &mut self,
909            decoder: &mut fidl::encoding::Decoder<'_, D>,
910            offset: usize,
911            mut depth: fidl::encoding::Depth,
912        ) -> fidl::Result<()> {
913            decoder.debug_check_bounds::<Self>(offset);
914            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
915                None => return Err(fidl::Error::NotNullable),
916                Some(len) => len,
917            };
918            // Calling decoder.out_of_line_offset(0) is not allowed.
919            if len == 0 {
920                return Ok(());
921            };
922            depth.increment()?;
923            let envelope_size = 8;
924            let bytes_len = len * envelope_size;
925            let offset = decoder.out_of_line_offset(bytes_len)?;
926            // Decode the envelope for each type.
927            let mut _next_ordinal_to_read = 0;
928            let mut next_offset = offset;
929            let end_offset = offset + bytes_len;
930            _next_ordinal_to_read += 1;
931            if next_offset >= end_offset {
932                return Ok(());
933            }
934
935            // Decode unknown envelopes for gaps in ordinals.
936            while _next_ordinal_to_read < 1 {
937                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
938                _next_ordinal_to_read += 1;
939                next_offset += envelope_size;
940            }
941
942            let next_out_of_line = decoder.next_out_of_line();
943            let handles_before = decoder.remaining_handles();
944            if let Some((inlined, num_bytes, num_handles)) =
945                fidl::encoding::decode_envelope_header(decoder, next_offset)?
946            {
947                let member_inline_size =
948                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
949                if inlined != (member_inline_size <= 4) {
950                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
951                }
952                let inner_offset;
953                let mut inner_depth = depth.clone();
954                if inlined {
955                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
956                    inner_offset = next_offset;
957                } else {
958                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
959                    inner_depth.increment()?;
960                }
961                let val_ref = self.lead_time.get_or_insert_with(|| fidl::new_empty!(u64, D));
962                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
963                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
964                {
965                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
966                }
967                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
968                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
969                }
970            }
971
972            next_offset += envelope_size;
973            _next_ordinal_to_read += 1;
974            if next_offset >= end_offset {
975                return Ok(());
976            }
977
978            // Decode unknown envelopes for gaps in ordinals.
979            while _next_ordinal_to_read < 2 {
980                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
981                _next_ordinal_to_read += 1;
982                next_offset += envelope_size;
983            }
984
985            let next_out_of_line = decoder.next_out_of_line();
986            let handles_before = decoder.remaining_handles();
987            if let Some((inlined, num_bytes, num_handles)) =
988                fidl::encoding::decode_envelope_header(decoder, next_offset)?
989            {
990                let member_inline_size =
991                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
992                if inlined != (member_inline_size <= 4) {
993                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
994                }
995                let inner_offset;
996                let mut inner_depth = depth.clone();
997                if inlined {
998                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
999                    inner_offset = next_offset;
1000                } else {
1001                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1002                    inner_depth.increment()?;
1003                }
1004                let val_ref =
1005                    self.supports_scatter_gather.get_or_insert_with(|| fidl::new_empty!(bool, D));
1006                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1007                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1008                {
1009                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1010                }
1011                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1012                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1013                }
1014            }
1015
1016            next_offset += envelope_size;
1017
1018            // Decode the remaining unknown envelopes.
1019            while next_offset < end_offset {
1020                _next_ordinal_to_read += 1;
1021                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1022                next_offset += envelope_size;
1023            }
1024
1025            Ok(())
1026        }
1027    }
1028
1029    impl VmoInfo {
1030        #[inline(always)]
1031        fn max_ordinal_present(&self) -> u64 {
1032            if let Some(_) = self.size {
1033                return 2;
1034            }
1035            if let Some(_) = self.id {
1036                return 1;
1037            }
1038            0
1039        }
1040    }
1041
1042    impl fidl::encoding::ValueTypeMarker for VmoInfo {
1043        type Borrowed<'a> = &'a Self;
1044        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1045            value
1046        }
1047    }
1048
1049    unsafe impl fidl::encoding::TypeMarker for VmoInfo {
1050        type Owned = Self;
1051
1052        #[inline(always)]
1053        fn inline_align(_context: fidl::encoding::Context) -> usize {
1054            8
1055        }
1056
1057        #[inline(always)]
1058        fn inline_size(_context: fidl::encoding::Context) -> usize {
1059            16
1060        }
1061    }
1062
1063    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VmoInfo, D> for &VmoInfo {
1064        unsafe fn encode(
1065            self,
1066            encoder: &mut fidl::encoding::Encoder<'_, D>,
1067            offset: usize,
1068            mut depth: fidl::encoding::Depth,
1069        ) -> fidl::Result<()> {
1070            encoder.debug_check_bounds::<VmoInfo>(offset);
1071            // Vector header
1072            let max_ordinal: u64 = self.max_ordinal_present();
1073            encoder.write_num(max_ordinal, offset);
1074            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1075            // Calling encoder.out_of_line_offset(0) is not allowed.
1076            if max_ordinal == 0 {
1077                return Ok(());
1078            }
1079            depth.increment()?;
1080            let envelope_size = 8;
1081            let bytes_len = max_ordinal as usize * envelope_size;
1082            #[allow(unused_variables)]
1083            let offset = encoder.out_of_line_offset(bytes_len);
1084            let mut _prev_end_offset: usize = 0;
1085            if 1 > max_ordinal {
1086                return Ok(());
1087            }
1088
1089            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1090            // are envelope_size bytes.
1091            let cur_offset: usize = (1 - 1) * envelope_size;
1092
1093            // Zero reserved fields.
1094            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1095
1096            // Safety:
1097            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1098            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1099            //   envelope_size bytes, there is always sufficient room.
1100            fidl::encoding::encode_in_envelope_optional::<u64, D>(
1101                self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1102                encoder,
1103                offset + cur_offset,
1104                depth,
1105            )?;
1106
1107            _prev_end_offset = cur_offset + envelope_size;
1108            if 2 > max_ordinal {
1109                return Ok(());
1110            }
1111
1112            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1113            // are envelope_size bytes.
1114            let cur_offset: usize = (2 - 1) * envelope_size;
1115
1116            // Zero reserved fields.
1117            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1118
1119            // Safety:
1120            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1121            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1122            //   envelope_size bytes, there is always sufficient room.
1123            fidl::encoding::encode_in_envelope_optional::<u64, D>(
1124                self.size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1125                encoder,
1126                offset + cur_offset,
1127                depth,
1128            )?;
1129
1130            _prev_end_offset = cur_offset + envelope_size;
1131
1132            Ok(())
1133        }
1134    }
1135
1136    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VmoInfo {
1137        #[inline(always)]
1138        fn new_empty() -> Self {
1139            Self::default()
1140        }
1141
1142        unsafe fn decode(
1143            &mut self,
1144            decoder: &mut fidl::encoding::Decoder<'_, D>,
1145            offset: usize,
1146            mut depth: fidl::encoding::Depth,
1147        ) -> fidl::Result<()> {
1148            decoder.debug_check_bounds::<Self>(offset);
1149            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1150                None => return Err(fidl::Error::NotNullable),
1151                Some(len) => len,
1152            };
1153            // Calling decoder.out_of_line_offset(0) is not allowed.
1154            if len == 0 {
1155                return Ok(());
1156            };
1157            depth.increment()?;
1158            let envelope_size = 8;
1159            let bytes_len = len * envelope_size;
1160            let offset = decoder.out_of_line_offset(bytes_len)?;
1161            // Decode the envelope for each type.
1162            let mut _next_ordinal_to_read = 0;
1163            let mut next_offset = offset;
1164            let end_offset = offset + bytes_len;
1165            _next_ordinal_to_read += 1;
1166            if next_offset >= end_offset {
1167                return Ok(());
1168            }
1169
1170            // Decode unknown envelopes for gaps in ordinals.
1171            while _next_ordinal_to_read < 1 {
1172                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1173                _next_ordinal_to_read += 1;
1174                next_offset += envelope_size;
1175            }
1176
1177            let next_out_of_line = decoder.next_out_of_line();
1178            let handles_before = decoder.remaining_handles();
1179            if let Some((inlined, num_bytes, num_handles)) =
1180                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1181            {
1182                let member_inline_size =
1183                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1184                if inlined != (member_inline_size <= 4) {
1185                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1186                }
1187                let inner_offset;
1188                let mut inner_depth = depth.clone();
1189                if inlined {
1190                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1191                    inner_offset = next_offset;
1192                } else {
1193                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1194                    inner_depth.increment()?;
1195                }
1196                let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
1197                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1198                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1199                {
1200                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1201                }
1202                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1203                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1204                }
1205            }
1206
1207            next_offset += envelope_size;
1208            _next_ordinal_to_read += 1;
1209            if next_offset >= end_offset {
1210                return Ok(());
1211            }
1212
1213            // Decode unknown envelopes for gaps in ordinals.
1214            while _next_ordinal_to_read < 2 {
1215                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1216                _next_ordinal_to_read += 1;
1217                next_offset += envelope_size;
1218            }
1219
1220            let next_out_of_line = decoder.next_out_of_line();
1221            let handles_before = decoder.remaining_handles();
1222            if let Some((inlined, num_bytes, num_handles)) =
1223                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1224            {
1225                let member_inline_size =
1226                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1227                if inlined != (member_inline_size <= 4) {
1228                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1229                }
1230                let inner_offset;
1231                let mut inner_depth = depth.clone();
1232                if inlined {
1233                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1234                    inner_offset = next_offset;
1235                } else {
1236                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1237                    inner_depth.increment()?;
1238                }
1239                let val_ref = self.size.get_or_insert_with(|| fidl::new_empty!(u64, D));
1240                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1241                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1242                {
1243                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1244                }
1245                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1246                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1247                }
1248            }
1249
1250            next_offset += envelope_size;
1251
1252            // Decode the remaining unknown envelopes.
1253            while next_offset < end_offset {
1254                _next_ordinal_to_read += 1;
1255                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1256                next_offset += envelope_size;
1257            }
1258
1259            Ok(())
1260        }
1261    }
1262
1263    impl fidl::encoding::ValueTypeMarker for EndpointInfo {
1264        type Borrowed<'a> = &'a Self;
1265        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1266            value
1267        }
1268    }
1269
1270    unsafe impl fidl::encoding::TypeMarker for EndpointInfo {
1271        type Owned = Self;
1272
1273        #[inline(always)]
1274        fn inline_align(_context: fidl::encoding::Context) -> usize {
1275            8
1276        }
1277
1278        #[inline(always)]
1279        fn inline_size(_context: fidl::encoding::Context) -> usize {
1280            16
1281        }
1282    }
1283
1284    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<EndpointInfo, D>
1285        for &EndpointInfo
1286    {
1287        #[inline]
1288        unsafe fn encode(
1289            self,
1290            encoder: &mut fidl::encoding::Encoder<'_, D>,
1291            offset: usize,
1292            _depth: fidl::encoding::Depth,
1293        ) -> fidl::Result<()> {
1294            encoder.debug_check_bounds::<EndpointInfo>(offset);
1295            encoder.write_num::<u64>(self.ordinal(), offset);
1296            match self {
1297                EndpointInfo::Bulk(ref val) => {
1298                    fidl::encoding::encode_in_envelope::<BulkEndpointInfo, D>(
1299                        <BulkEndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
1300                        encoder,
1301                        offset + 8,
1302                        _depth,
1303                    )
1304                }
1305                EndpointInfo::Control(ref val) => {
1306                    fidl::encoding::encode_in_envelope::<ControlEndpointInfo, D>(
1307                        <ControlEndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
1308                        encoder,
1309                        offset + 8,
1310                        _depth,
1311                    )
1312                }
1313                EndpointInfo::Isochronous(ref val) => {
1314                    fidl::encoding::encode_in_envelope::<IsochronousEndpointInfo, D>(
1315                        <IsochronousEndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
1316                        encoder,
1317                        offset + 8,
1318                        _depth,
1319                    )
1320                }
1321                EndpointInfo::Interrupt(ref val) => {
1322                    fidl::encoding::encode_in_envelope::<InterruptEndpointInfo, D>(
1323                        <InterruptEndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
1324                        encoder,
1325                        offset + 8,
1326                        _depth,
1327                    )
1328                }
1329                EndpointInfo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1330            }
1331        }
1332    }
1333
1334    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for EndpointInfo {
1335        #[inline(always)]
1336        fn new_empty() -> Self {
1337            Self::__SourceBreaking { unknown_ordinal: 0 }
1338        }
1339
1340        #[inline]
1341        unsafe fn decode(
1342            &mut self,
1343            decoder: &mut fidl::encoding::Decoder<'_, D>,
1344            offset: usize,
1345            mut depth: fidl::encoding::Depth,
1346        ) -> fidl::Result<()> {
1347            decoder.debug_check_bounds::<Self>(offset);
1348            #[allow(unused_variables)]
1349            let next_out_of_line = decoder.next_out_of_line();
1350            let handles_before = decoder.remaining_handles();
1351            let (ordinal, inlined, num_bytes, num_handles) =
1352                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1353
1354            let member_inline_size = match ordinal {
1355                1 => <BulkEndpointInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1356                2 => <ControlEndpointInfo as fidl::encoding::TypeMarker>::inline_size(
1357                    decoder.context,
1358                ),
1359                3 => <IsochronousEndpointInfo as fidl::encoding::TypeMarker>::inline_size(
1360                    decoder.context,
1361                ),
1362                4 => <InterruptEndpointInfo as fidl::encoding::TypeMarker>::inline_size(
1363                    decoder.context,
1364                ),
1365                0 => return Err(fidl::Error::UnknownUnionTag),
1366                _ => num_bytes as usize,
1367            };
1368
1369            if inlined != (member_inline_size <= 4) {
1370                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1371            }
1372            let _inner_offset;
1373            if inlined {
1374                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1375                _inner_offset = offset + 8;
1376            } else {
1377                depth.increment()?;
1378                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1379            }
1380            match ordinal {
1381                1 => {
1382                    #[allow(irrefutable_let_patterns)]
1383                    if let EndpointInfo::Bulk(_) = self {
1384                        // Do nothing, read the value into the object
1385                    } else {
1386                        // Initialize `self` to the right variant
1387                        *self = EndpointInfo::Bulk(fidl::new_empty!(BulkEndpointInfo, D));
1388                    }
1389                    #[allow(irrefutable_let_patterns)]
1390                    if let EndpointInfo::Bulk(ref mut val) = self {
1391                        fidl::decode!(BulkEndpointInfo, D, val, decoder, _inner_offset, depth)?;
1392                    } else {
1393                        unreachable!()
1394                    }
1395                }
1396                2 => {
1397                    #[allow(irrefutable_let_patterns)]
1398                    if let EndpointInfo::Control(_) = self {
1399                        // Do nothing, read the value into the object
1400                    } else {
1401                        // Initialize `self` to the right variant
1402                        *self = EndpointInfo::Control(fidl::new_empty!(ControlEndpointInfo, D));
1403                    }
1404                    #[allow(irrefutable_let_patterns)]
1405                    if let EndpointInfo::Control(ref mut val) = self {
1406                        fidl::decode!(ControlEndpointInfo, D, val, decoder, _inner_offset, depth)?;
1407                    } else {
1408                        unreachable!()
1409                    }
1410                }
1411                3 => {
1412                    #[allow(irrefutable_let_patterns)]
1413                    if let EndpointInfo::Isochronous(_) = self {
1414                        // Do nothing, read the value into the object
1415                    } else {
1416                        // Initialize `self` to the right variant
1417                        *self =
1418                            EndpointInfo::Isochronous(fidl::new_empty!(IsochronousEndpointInfo, D));
1419                    }
1420                    #[allow(irrefutable_let_patterns)]
1421                    if let EndpointInfo::Isochronous(ref mut val) = self {
1422                        fidl::decode!(
1423                            IsochronousEndpointInfo,
1424                            D,
1425                            val,
1426                            decoder,
1427                            _inner_offset,
1428                            depth
1429                        )?;
1430                    } else {
1431                        unreachable!()
1432                    }
1433                }
1434                4 => {
1435                    #[allow(irrefutable_let_patterns)]
1436                    if let EndpointInfo::Interrupt(_) = self {
1437                        // Do nothing, read the value into the object
1438                    } else {
1439                        // Initialize `self` to the right variant
1440                        *self = EndpointInfo::Interrupt(fidl::new_empty!(InterruptEndpointInfo, D));
1441                    }
1442                    #[allow(irrefutable_let_patterns)]
1443                    if let EndpointInfo::Interrupt(ref mut val) = self {
1444                        fidl::decode!(
1445                            InterruptEndpointInfo,
1446                            D,
1447                            val,
1448                            decoder,
1449                            _inner_offset,
1450                            depth
1451                        )?;
1452                    } else {
1453                        unreachable!()
1454                    }
1455                }
1456                #[allow(deprecated)]
1457                ordinal => {
1458                    for _ in 0..num_handles {
1459                        decoder.drop_next_handle()?;
1460                    }
1461                    *self = EndpointInfo::__SourceBreaking { unknown_ordinal: ordinal };
1462                }
1463            }
1464            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1465                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1466            }
1467            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1468                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1469            }
1470            Ok(())
1471        }
1472    }
1473}