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