Skip to main content

fidl_fuchsia_hardware_usb_request_common/
fidl_fuchsia_hardware_usb_request_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
11pub type VmoId = u64;
12
13/// Limit on the max transfer size of Requests by embedding data (see Buffer::data).
14/// Set to 1024 to accommodate typical SuperSpeed USB packet payloads.
15pub const MAX_TRANSFER_SIZE: u32 = 1024;
16
17/// Bulk Request Information
18#[derive(Clone, Debug, Default, PartialEq)]
19pub struct BulkRequestInfo {
20    #[doc(hidden)]
21    pub __source_breaking: fidl::marker::SourceBreaking,
22}
23
24impl fidl::Persistable for BulkRequestInfo {}
25
26/// Control Request Information
27#[derive(Clone, Debug, Default, PartialEq)]
28pub struct ControlRequestInfo {
29    /// Control Transfer required Setup packet
30    pub setup: Option<fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup>,
31    #[doc(hidden)]
32    pub __source_breaking: fidl::marker::SourceBreaking,
33}
34
35impl fidl::Persistable for ControlRequestInfo {}
36
37/// Interrupt Request Information
38#[derive(Clone, Debug, Default, PartialEq)]
39pub struct InterruptRequestInfo {
40    #[doc(hidden)]
41    pub __source_breaking: fidl::marker::SourceBreaking,
42}
43
44impl fidl::Persistable for InterruptRequestInfo {}
45
46/// Isochronous Request Information.
47#[derive(Clone, Debug, Default, PartialEq)]
48pub struct IsochronousRequestInfo {
49    /// Frame ID
50    pub frame_id: Option<u64>,
51    #[doc(hidden)]
52    pub __source_breaking: fidl::marker::SourceBreaking,
53}
54
55impl fidl::Persistable for IsochronousRequestInfo {}
56
57/// Extra information needed for different types of Requests.
58#[derive(Clone, Debug)]
59pub enum RequestInfo {
60    /// Control Request Information
61    Control(ControlRequestInfo),
62    /// Bulk Request Information
63    Bulk(BulkRequestInfo),
64    /// Isochronous Request Information
65    Isochronous(IsochronousRequestInfo),
66    /// Interrupt Request Information
67    Interrupt(InterruptRequestInfo),
68    #[doc(hidden)]
69    __SourceBreaking { unknown_ordinal: u64 },
70}
71
72/// Pattern that matches an unknown `RequestInfo` member.
73#[macro_export]
74macro_rules! RequestInfoUnknown {
75    () => {
76        _
77    };
78}
79
80// Custom PartialEq so that unknown variants are not equal to themselves.
81impl PartialEq for RequestInfo {
82    fn eq(&self, other: &Self) -> bool {
83        match (self, other) {
84            (Self::Control(x), Self::Control(y)) => *x == *y,
85            (Self::Bulk(x), Self::Bulk(y)) => *x == *y,
86            (Self::Isochronous(x), Self::Isochronous(y)) => *x == *y,
87            (Self::Interrupt(x), Self::Interrupt(y)) => *x == *y,
88            _ => false,
89        }
90    }
91}
92
93impl RequestInfo {
94    #[inline]
95    pub fn ordinal(&self) -> u64 {
96        match *self {
97            Self::Control(_) => 1,
98            Self::Bulk(_) => 2,
99            Self::Isochronous(_) => 3,
100            Self::Interrupt(_) => 4,
101            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
102        }
103    }
104
105    #[inline]
106    pub fn unknown_variant_for_testing() -> Self {
107        Self::__SourceBreaking { unknown_ordinal: 0 }
108    }
109
110    #[inline]
111    pub fn is_unknown(&self) -> bool {
112        match self {
113            Self::__SourceBreaking { .. } => true,
114            _ => false,
115        }
116    }
117}
118
119impl fidl::Persistable for RequestInfo {}
120
121mod internal {
122    use super::*;
123
124    impl BulkRequestInfo {
125        #[inline(always)]
126        fn max_ordinal_present(&self) -> u64 {
127            0
128        }
129    }
130
131    impl fidl::encoding::ValueTypeMarker for BulkRequestInfo {
132        type Borrowed<'a> = &'a Self;
133        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
134            value
135        }
136    }
137
138    unsafe impl fidl::encoding::TypeMarker for BulkRequestInfo {
139        type Owned = Self;
140
141        #[inline(always)]
142        fn inline_align(_context: fidl::encoding::Context) -> usize {
143            8
144        }
145
146        #[inline(always)]
147        fn inline_size(_context: fidl::encoding::Context) -> usize {
148            16
149        }
150    }
151
152    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<BulkRequestInfo, D>
153        for &BulkRequestInfo
154    {
155        unsafe fn encode(
156            self,
157            encoder: &mut fidl::encoding::Encoder<'_, D>,
158            offset: usize,
159            mut depth: fidl::encoding::Depth,
160        ) -> fidl::Result<()> {
161            encoder.debug_check_bounds::<BulkRequestInfo>(offset);
162            // Vector header
163            let max_ordinal: u64 = self.max_ordinal_present();
164            encoder.write_num(max_ordinal, offset);
165            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
166            // Calling encoder.out_of_line_offset(0) is not allowed.
167            if max_ordinal == 0 {
168                return Ok(());
169            }
170            depth.increment()?;
171            let envelope_size = 8;
172            let bytes_len = max_ordinal as usize * envelope_size;
173            #[allow(unused_variables)]
174            let offset = encoder.out_of_line_offset(bytes_len);
175            let mut _prev_end_offset: usize = 0;
176
177            Ok(())
178        }
179    }
180
181    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BulkRequestInfo {
182        #[inline(always)]
183        fn new_empty() -> Self {
184            Self::default()
185        }
186
187        unsafe fn decode(
188            &mut self,
189            decoder: &mut fidl::encoding::Decoder<'_, D>,
190            offset: usize,
191            mut depth: fidl::encoding::Depth,
192        ) -> fidl::Result<()> {
193            decoder.debug_check_bounds::<Self>(offset);
194            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
195                None => return Err(fidl::Error::NotNullable),
196                Some(len) => len,
197            };
198            // Calling decoder.out_of_line_offset(0) is not allowed.
199            if len == 0 {
200                return Ok(());
201            };
202            depth.increment()?;
203            let envelope_size = 8;
204            let bytes_len = len * envelope_size;
205            let offset = decoder.out_of_line_offset(bytes_len)?;
206            // Decode the envelope for each type.
207            let mut _next_ordinal_to_read = 0;
208            let mut next_offset = offset;
209            let end_offset = offset + bytes_len;
210
211            // Decode the remaining unknown envelopes.
212            while next_offset < end_offset {
213                _next_ordinal_to_read += 1;
214                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
215                next_offset += envelope_size;
216            }
217
218            Ok(())
219        }
220    }
221
222    impl ControlRequestInfo {
223        #[inline(always)]
224        fn max_ordinal_present(&self) -> u64 {
225            if let Some(_) = self.setup {
226                return 1;
227            }
228            0
229        }
230    }
231
232    impl fidl::encoding::ValueTypeMarker for ControlRequestInfo {
233        type Borrowed<'a> = &'a Self;
234        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
235            value
236        }
237    }
238
239    unsafe impl fidl::encoding::TypeMarker for ControlRequestInfo {
240        type Owned = Self;
241
242        #[inline(always)]
243        fn inline_align(_context: fidl::encoding::Context) -> usize {
244            8
245        }
246
247        #[inline(always)]
248        fn inline_size(_context: fidl::encoding::Context) -> usize {
249            16
250        }
251    }
252
253    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ControlRequestInfo, D>
254        for &ControlRequestInfo
255    {
256        unsafe fn encode(
257            self,
258            encoder: &mut fidl::encoding::Encoder<'_, D>,
259            offset: usize,
260            mut depth: fidl::encoding::Depth,
261        ) -> fidl::Result<()> {
262            encoder.debug_check_bounds::<ControlRequestInfo>(offset);
263            // Vector header
264            let max_ordinal: u64 = self.max_ordinal_present();
265            encoder.write_num(max_ordinal, offset);
266            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
267            // Calling encoder.out_of_line_offset(0) is not allowed.
268            if max_ordinal == 0 {
269                return Ok(());
270            }
271            depth.increment()?;
272            let envelope_size = 8;
273            let bytes_len = max_ordinal as usize * envelope_size;
274            #[allow(unused_variables)]
275            let offset = encoder.out_of_line_offset(bytes_len);
276            let mut _prev_end_offset: usize = 0;
277            if 1 > max_ordinal {
278                return Ok(());
279            }
280
281            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
282            // are envelope_size bytes.
283            let cur_offset: usize = (1 - 1) * envelope_size;
284
285            // Zero reserved fields.
286            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
287
288            // Safety:
289            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
290            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
291            //   envelope_size bytes, there is always sufficient room.
292            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup, D>(
293            self.setup.as_ref().map(<fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup as fidl::encoding::ValueTypeMarker>::borrow),
294            encoder, offset + cur_offset, depth
295        )?;
296
297            _prev_end_offset = cur_offset + envelope_size;
298
299            Ok(())
300        }
301    }
302
303    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ControlRequestInfo {
304        #[inline(always)]
305        fn new_empty() -> Self {
306            Self::default()
307        }
308
309        unsafe fn decode(
310            &mut self,
311            decoder: &mut fidl::encoding::Decoder<'_, D>,
312            offset: usize,
313            mut depth: fidl::encoding::Depth,
314        ) -> fidl::Result<()> {
315            decoder.debug_check_bounds::<Self>(offset);
316            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
317                None => return Err(fidl::Error::NotNullable),
318                Some(len) => len,
319            };
320            // Calling decoder.out_of_line_offset(0) is not allowed.
321            if len == 0 {
322                return Ok(());
323            };
324            depth.increment()?;
325            let envelope_size = 8;
326            let bytes_len = len * envelope_size;
327            let offset = decoder.out_of_line_offset(bytes_len)?;
328            // Decode the envelope for each type.
329            let mut _next_ordinal_to_read = 0;
330            let mut next_offset = offset;
331            let end_offset = offset + bytes_len;
332            _next_ordinal_to_read += 1;
333            if next_offset >= end_offset {
334                return Ok(());
335            }
336
337            // Decode unknown envelopes for gaps in ordinals.
338            while _next_ordinal_to_read < 1 {
339                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
340                _next_ordinal_to_read += 1;
341                next_offset += envelope_size;
342            }
343
344            let next_out_of_line = decoder.next_out_of_line();
345            let handles_before = decoder.remaining_handles();
346            if let Some((inlined, num_bytes, num_handles)) =
347                fidl::encoding::decode_envelope_header(decoder, next_offset)?
348            {
349                let member_inline_size = <fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup as fidl::encoding::TypeMarker>::inline_size(decoder.context);
350                if inlined != (member_inline_size <= 4) {
351                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
352                }
353                let inner_offset;
354                let mut inner_depth = depth.clone();
355                if inlined {
356                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
357                    inner_offset = next_offset;
358                } else {
359                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
360                    inner_depth.increment()?;
361                }
362                let val_ref = self.setup.get_or_insert_with(|| {
363                    fidl::new_empty!(fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup, D)
364                });
365                fidl::decode!(
366                    fidl_fuchsia_hardware_usb_descriptor_common::UsbSetup,
367                    D,
368                    val_ref,
369                    decoder,
370                    inner_offset,
371                    inner_depth
372                )?;
373                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
374                {
375                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
376                }
377                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
378                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
379                }
380            }
381
382            next_offset += envelope_size;
383
384            // Decode the remaining unknown envelopes.
385            while next_offset < end_offset {
386                _next_ordinal_to_read += 1;
387                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
388                next_offset += envelope_size;
389            }
390
391            Ok(())
392        }
393    }
394
395    impl InterruptRequestInfo {
396        #[inline(always)]
397        fn max_ordinal_present(&self) -> u64 {
398            0
399        }
400    }
401
402    impl fidl::encoding::ValueTypeMarker for InterruptRequestInfo {
403        type Borrowed<'a> = &'a Self;
404        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
405            value
406        }
407    }
408
409    unsafe impl fidl::encoding::TypeMarker for InterruptRequestInfo {
410        type Owned = Self;
411
412        #[inline(always)]
413        fn inline_align(_context: fidl::encoding::Context) -> usize {
414            8
415        }
416
417        #[inline(always)]
418        fn inline_size(_context: fidl::encoding::Context) -> usize {
419            16
420        }
421    }
422
423    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InterruptRequestInfo, D>
424        for &InterruptRequestInfo
425    {
426        unsafe fn encode(
427            self,
428            encoder: &mut fidl::encoding::Encoder<'_, D>,
429            offset: usize,
430            mut depth: fidl::encoding::Depth,
431        ) -> fidl::Result<()> {
432            encoder.debug_check_bounds::<InterruptRequestInfo>(offset);
433            // Vector header
434            let max_ordinal: u64 = self.max_ordinal_present();
435            encoder.write_num(max_ordinal, offset);
436            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
437            // Calling encoder.out_of_line_offset(0) is not allowed.
438            if max_ordinal == 0 {
439                return Ok(());
440            }
441            depth.increment()?;
442            let envelope_size = 8;
443            let bytes_len = max_ordinal as usize * envelope_size;
444            #[allow(unused_variables)]
445            let offset = encoder.out_of_line_offset(bytes_len);
446            let mut _prev_end_offset: usize = 0;
447
448            Ok(())
449        }
450    }
451
452    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterruptRequestInfo {
453        #[inline(always)]
454        fn new_empty() -> Self {
455            Self::default()
456        }
457
458        unsafe fn decode(
459            &mut self,
460            decoder: &mut fidl::encoding::Decoder<'_, D>,
461            offset: usize,
462            mut depth: fidl::encoding::Depth,
463        ) -> fidl::Result<()> {
464            decoder.debug_check_bounds::<Self>(offset);
465            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
466                None => return Err(fidl::Error::NotNullable),
467                Some(len) => len,
468            };
469            // Calling decoder.out_of_line_offset(0) is not allowed.
470            if len == 0 {
471                return Ok(());
472            };
473            depth.increment()?;
474            let envelope_size = 8;
475            let bytes_len = len * envelope_size;
476            let offset = decoder.out_of_line_offset(bytes_len)?;
477            // Decode the envelope for each type.
478            let mut _next_ordinal_to_read = 0;
479            let mut next_offset = offset;
480            let end_offset = offset + bytes_len;
481
482            // Decode the remaining unknown envelopes.
483            while next_offset < end_offset {
484                _next_ordinal_to_read += 1;
485                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
486                next_offset += envelope_size;
487            }
488
489            Ok(())
490        }
491    }
492
493    impl IsochronousRequestInfo {
494        #[inline(always)]
495        fn max_ordinal_present(&self) -> u64 {
496            if let Some(_) = self.frame_id {
497                return 1;
498            }
499            0
500        }
501    }
502
503    impl fidl::encoding::ValueTypeMarker for IsochronousRequestInfo {
504        type Borrowed<'a> = &'a Self;
505        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
506            value
507        }
508    }
509
510    unsafe impl fidl::encoding::TypeMarker for IsochronousRequestInfo {
511        type Owned = Self;
512
513        #[inline(always)]
514        fn inline_align(_context: fidl::encoding::Context) -> usize {
515            8
516        }
517
518        #[inline(always)]
519        fn inline_size(_context: fidl::encoding::Context) -> usize {
520            16
521        }
522    }
523
524    unsafe impl<D: fidl::encoding::ResourceDialect>
525        fidl::encoding::Encode<IsochronousRequestInfo, D> for &IsochronousRequestInfo
526    {
527        unsafe fn encode(
528            self,
529            encoder: &mut fidl::encoding::Encoder<'_, D>,
530            offset: usize,
531            mut depth: fidl::encoding::Depth,
532        ) -> fidl::Result<()> {
533            encoder.debug_check_bounds::<IsochronousRequestInfo>(offset);
534            // Vector header
535            let max_ordinal: u64 = self.max_ordinal_present();
536            encoder.write_num(max_ordinal, offset);
537            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
538            // Calling encoder.out_of_line_offset(0) is not allowed.
539            if max_ordinal == 0 {
540                return Ok(());
541            }
542            depth.increment()?;
543            let envelope_size = 8;
544            let bytes_len = max_ordinal as usize * envelope_size;
545            #[allow(unused_variables)]
546            let offset = encoder.out_of_line_offset(bytes_len);
547            let mut _prev_end_offset: usize = 0;
548            if 1 > max_ordinal {
549                return Ok(());
550            }
551
552            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
553            // are envelope_size bytes.
554            let cur_offset: usize = (1 - 1) * envelope_size;
555
556            // Zero reserved fields.
557            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
558
559            // Safety:
560            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
561            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
562            //   envelope_size bytes, there is always sufficient room.
563            fidl::encoding::encode_in_envelope_optional::<u64, D>(
564                self.frame_id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
565                encoder,
566                offset + cur_offset,
567                depth,
568            )?;
569
570            _prev_end_offset = cur_offset + envelope_size;
571
572            Ok(())
573        }
574    }
575
576    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
577        for IsochronousRequestInfo
578    {
579        #[inline(always)]
580        fn new_empty() -> Self {
581            Self::default()
582        }
583
584        unsafe fn decode(
585            &mut self,
586            decoder: &mut fidl::encoding::Decoder<'_, D>,
587            offset: usize,
588            mut depth: fidl::encoding::Depth,
589        ) -> fidl::Result<()> {
590            decoder.debug_check_bounds::<Self>(offset);
591            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
592                None => return Err(fidl::Error::NotNullable),
593                Some(len) => len,
594            };
595            // Calling decoder.out_of_line_offset(0) is not allowed.
596            if len == 0 {
597                return Ok(());
598            };
599            depth.increment()?;
600            let envelope_size = 8;
601            let bytes_len = len * envelope_size;
602            let offset = decoder.out_of_line_offset(bytes_len)?;
603            // Decode the envelope for each type.
604            let mut _next_ordinal_to_read = 0;
605            let mut next_offset = offset;
606            let end_offset = offset + bytes_len;
607            _next_ordinal_to_read += 1;
608            if next_offset >= end_offset {
609                return Ok(());
610            }
611
612            // Decode unknown envelopes for gaps in ordinals.
613            while _next_ordinal_to_read < 1 {
614                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
615                _next_ordinal_to_read += 1;
616                next_offset += envelope_size;
617            }
618
619            let next_out_of_line = decoder.next_out_of_line();
620            let handles_before = decoder.remaining_handles();
621            if let Some((inlined, num_bytes, num_handles)) =
622                fidl::encoding::decode_envelope_header(decoder, next_offset)?
623            {
624                let member_inline_size =
625                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
626                if inlined != (member_inline_size <= 4) {
627                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
628                }
629                let inner_offset;
630                let mut inner_depth = depth.clone();
631                if inlined {
632                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
633                    inner_offset = next_offset;
634                } else {
635                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
636                    inner_depth.increment()?;
637                }
638                let val_ref = self.frame_id.get_or_insert_with(|| fidl::new_empty!(u64, D));
639                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
640                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
641                {
642                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
643                }
644                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
645                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
646                }
647            }
648
649            next_offset += envelope_size;
650
651            // Decode the remaining unknown envelopes.
652            while next_offset < end_offset {
653                _next_ordinal_to_read += 1;
654                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
655                next_offset += envelope_size;
656            }
657
658            Ok(())
659        }
660    }
661
662    impl fidl::encoding::ValueTypeMarker for RequestInfo {
663        type Borrowed<'a> = &'a Self;
664        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
665            value
666        }
667    }
668
669    unsafe impl fidl::encoding::TypeMarker for RequestInfo {
670        type Owned = Self;
671
672        #[inline(always)]
673        fn inline_align(_context: fidl::encoding::Context) -> usize {
674            8
675        }
676
677        #[inline(always)]
678        fn inline_size(_context: fidl::encoding::Context) -> usize {
679            16
680        }
681    }
682
683    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RequestInfo, D>
684        for &RequestInfo
685    {
686        #[inline]
687        unsafe fn encode(
688            self,
689            encoder: &mut fidl::encoding::Encoder<'_, D>,
690            offset: usize,
691            _depth: fidl::encoding::Depth,
692        ) -> fidl::Result<()> {
693            encoder.debug_check_bounds::<RequestInfo>(offset);
694            encoder.write_num::<u64>(self.ordinal(), offset);
695            match self {
696                RequestInfo::Control(ref val) => {
697                    fidl::encoding::encode_in_envelope::<ControlRequestInfo, D>(
698                        <ControlRequestInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
699                        encoder,
700                        offset + 8,
701                        _depth,
702                    )
703                }
704                RequestInfo::Bulk(ref val) => {
705                    fidl::encoding::encode_in_envelope::<BulkRequestInfo, D>(
706                        <BulkRequestInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
707                        encoder,
708                        offset + 8,
709                        _depth,
710                    )
711                }
712                RequestInfo::Isochronous(ref val) => {
713                    fidl::encoding::encode_in_envelope::<IsochronousRequestInfo, D>(
714                        <IsochronousRequestInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
715                        encoder,
716                        offset + 8,
717                        _depth,
718                    )
719                }
720                RequestInfo::Interrupt(ref val) => {
721                    fidl::encoding::encode_in_envelope::<InterruptRequestInfo, D>(
722                        <InterruptRequestInfo as fidl::encoding::ValueTypeMarker>::borrow(val),
723                        encoder,
724                        offset + 8,
725                        _depth,
726                    )
727                }
728                RequestInfo::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
729            }
730        }
731    }
732
733    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RequestInfo {
734        #[inline(always)]
735        fn new_empty() -> Self {
736            Self::__SourceBreaking { unknown_ordinal: 0 }
737        }
738
739        #[inline]
740        unsafe fn decode(
741            &mut self,
742            decoder: &mut fidl::encoding::Decoder<'_, D>,
743            offset: usize,
744            mut depth: fidl::encoding::Depth,
745        ) -> fidl::Result<()> {
746            decoder.debug_check_bounds::<Self>(offset);
747            #[allow(unused_variables)]
748            let next_out_of_line = decoder.next_out_of_line();
749            let handles_before = decoder.remaining_handles();
750            let (ordinal, inlined, num_bytes, num_handles) =
751                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
752
753            let member_inline_size = match ordinal {
754                1 => {
755                    <ControlRequestInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context)
756                }
757                2 => <BulkRequestInfo as fidl::encoding::TypeMarker>::inline_size(decoder.context),
758                3 => <IsochronousRequestInfo as fidl::encoding::TypeMarker>::inline_size(
759                    decoder.context,
760                ),
761                4 => <InterruptRequestInfo as fidl::encoding::TypeMarker>::inline_size(
762                    decoder.context,
763                ),
764                0 => return Err(fidl::Error::UnknownUnionTag),
765                _ => num_bytes as usize,
766            };
767
768            if inlined != (member_inline_size <= 4) {
769                return Err(fidl::Error::InvalidInlineBitInEnvelope);
770            }
771            let _inner_offset;
772            if inlined {
773                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
774                _inner_offset = offset + 8;
775            } else {
776                depth.increment()?;
777                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
778            }
779            match ordinal {
780                1 => {
781                    #[allow(irrefutable_let_patterns)]
782                    if let RequestInfo::Control(_) = self {
783                        // Do nothing, read the value into the object
784                    } else {
785                        // Initialize `self` to the right variant
786                        *self = RequestInfo::Control(fidl::new_empty!(ControlRequestInfo, D));
787                    }
788                    #[allow(irrefutable_let_patterns)]
789                    if let RequestInfo::Control(ref mut val) = self {
790                        fidl::decode!(ControlRequestInfo, D, val, decoder, _inner_offset, depth)?;
791                    } else {
792                        unreachable!()
793                    }
794                }
795                2 => {
796                    #[allow(irrefutable_let_patterns)]
797                    if let RequestInfo::Bulk(_) = self {
798                        // Do nothing, read the value into the object
799                    } else {
800                        // Initialize `self` to the right variant
801                        *self = RequestInfo::Bulk(fidl::new_empty!(BulkRequestInfo, D));
802                    }
803                    #[allow(irrefutable_let_patterns)]
804                    if let RequestInfo::Bulk(ref mut val) = self {
805                        fidl::decode!(BulkRequestInfo, D, val, decoder, _inner_offset, depth)?;
806                    } else {
807                        unreachable!()
808                    }
809                }
810                3 => {
811                    #[allow(irrefutable_let_patterns)]
812                    if let RequestInfo::Isochronous(_) = self {
813                        // Do nothing, read the value into the object
814                    } else {
815                        // Initialize `self` to the right variant
816                        *self =
817                            RequestInfo::Isochronous(fidl::new_empty!(IsochronousRequestInfo, D));
818                    }
819                    #[allow(irrefutable_let_patterns)]
820                    if let RequestInfo::Isochronous(ref mut val) = self {
821                        fidl::decode!(
822                            IsochronousRequestInfo,
823                            D,
824                            val,
825                            decoder,
826                            _inner_offset,
827                            depth
828                        )?;
829                    } else {
830                        unreachable!()
831                    }
832                }
833                4 => {
834                    #[allow(irrefutable_let_patterns)]
835                    if let RequestInfo::Interrupt(_) = self {
836                        // Do nothing, read the value into the object
837                    } else {
838                        // Initialize `self` to the right variant
839                        *self = RequestInfo::Interrupt(fidl::new_empty!(InterruptRequestInfo, D));
840                    }
841                    #[allow(irrefutable_let_patterns)]
842                    if let RequestInfo::Interrupt(ref mut val) = self {
843                        fidl::decode!(InterruptRequestInfo, D, val, decoder, _inner_offset, depth)?;
844                    } else {
845                        unreachable!()
846                    }
847                }
848                #[allow(deprecated)]
849                ordinal => {
850                    for _ in 0..num_handles {
851                        decoder.drop_next_handle()?;
852                    }
853                    *self = RequestInfo::__SourceBreaking { unknown_ordinal: ordinal };
854                }
855            }
856            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
857                return Err(fidl::Error::InvalidNumBytesInEnvelope);
858            }
859            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
860                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
861            }
862            Ok(())
863        }
864    }
865}