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