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