fidl_fuchsia_cpu_profiler__common/
fidl_fuchsia_cpu_profiler__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Various approaches to obtaining a backtrace
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum CallgraphStrategy {
14    /// Don't try to get a callgraph
15    None,
16    /// Copy out stack memory and attempt to parse the DWARF info.
17    /// This is the slowest and most memory intensive of the approaches, but
18    /// gives the most accurate callgraphs. Parsing dwarf allows the callgraph
19    /// to trace inlined and leaf functions which other approaches do not
20    /// support.
21    Dwarf,
22    /// Intel CPUs support a hardware feature called Last Branch Records (LBR)s
23    /// which record up to the last 32 calls made depending on hardware version.
24    /// On supported CPUs, this is a low overhead approach to finding the
25    /// callgraph with the caveat that stacks that exceed 32 calls in depth will
26    /// overflow the hardware buffer.
27    LastBranchRecord,
28    /// arm and riscv support shadow call stacks which are an efficient way for us
29    /// to find and copy out the call stack. However, leaf functions and code
30    /// compiled without shadow callstack support, such as the vdso will not
31    /// appear in the returned callgraph.
32    ShadowCallStack,
33    /// A general approach of parsing the frame pointers of the callstack. Frame
34    /// pointers are supported across architectures and are slightly more
35    /// expensive than the lbrs or shadow call stacks, but much cheaper than
36    /// parsing dwarf. Code compiled with omitted frame pointers and inlined
37    /// functions will not appear in the resulting stacks.
38    FramePointer,
39    #[doc(hidden)]
40    __SourceBreaking { unknown_ordinal: u8 },
41}
42
43/// Pattern that matches an unknown `CallgraphStrategy` member.
44#[macro_export]
45macro_rules! CallgraphStrategyUnknown {
46    () => {
47        _
48    };
49}
50
51impl CallgraphStrategy {
52    #[inline]
53    pub fn from_primitive(prim: u8) -> Option<Self> {
54        match prim {
55            0 => Some(Self::None),
56            1 => Some(Self::Dwarf),
57            2 => Some(Self::LastBranchRecord),
58            3 => Some(Self::ShadowCallStack),
59            4 => Some(Self::FramePointer),
60            _ => None,
61        }
62    }
63
64    #[inline]
65    pub fn from_primitive_allow_unknown(prim: u8) -> Self {
66        match prim {
67            0 => Self::None,
68            1 => Self::Dwarf,
69            2 => Self::LastBranchRecord,
70            3 => Self::ShadowCallStack,
71            4 => Self::FramePointer,
72            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
73        }
74    }
75
76    #[inline]
77    pub fn unknown() -> Self {
78        Self::__SourceBreaking { unknown_ordinal: 0xff }
79    }
80
81    #[inline]
82    pub const fn into_primitive(self) -> u8 {
83        match self {
84            Self::None => 0,
85            Self::Dwarf => 1,
86            Self::LastBranchRecord => 2,
87            Self::ShadowCallStack => 3,
88            Self::FramePointer => 4,
89            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
90        }
91    }
92
93    #[inline]
94    pub fn is_unknown(&self) -> bool {
95        match self {
96            Self::__SourceBreaking { unknown_ordinal: _ } => true,
97            _ => false,
98        }
99    }
100}
101
102/// Curated set of platform independent IDs
103#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
104pub enum CounterId {
105    /// A counter increments each nanosecond
106    Nanoseconds,
107    /// A counter increments each cpu cycle
108    Cycles,
109    /// A counter increments on each instruction retired
110    InstructionsRetired,
111    /// A counter increments on each branch correctly predicted
112    BranchesPredicted,
113    /// A counter increments on each branch mispredicted
114    BranchesMispredidcted,
115    #[doc(hidden)]
116    __SourceBreaking { unknown_ordinal: u8 },
117}
118
119/// Pattern that matches an unknown `CounterId` member.
120#[macro_export]
121macro_rules! CounterIdUnknown {
122    () => {
123        _
124    };
125}
126
127impl CounterId {
128    #[inline]
129    pub fn from_primitive(prim: u8) -> Option<Self> {
130        match prim {
131            0 => Some(Self::Nanoseconds),
132            1 => Some(Self::Cycles),
133            2 => Some(Self::InstructionsRetired),
134            3 => Some(Self::BranchesPredicted),
135            4 => Some(Self::BranchesMispredidcted),
136            _ => None,
137        }
138    }
139
140    #[inline]
141    pub fn from_primitive_allow_unknown(prim: u8) -> Self {
142        match prim {
143            0 => Self::Nanoseconds,
144            1 => Self::Cycles,
145            2 => Self::InstructionsRetired,
146            3 => Self::BranchesPredicted,
147            4 => Self::BranchesMispredidcted,
148            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
149        }
150    }
151
152    #[inline]
153    pub fn unknown() -> Self {
154        Self::__SourceBreaking { unknown_ordinal: 0xff }
155    }
156
157    #[inline]
158    pub const fn into_primitive(self) -> u8 {
159        match self {
160            Self::Nanoseconds => 0,
161            Self::Cycles => 1,
162            Self::InstructionsRetired => 2,
163            Self::BranchesPredicted => 3,
164            Self::BranchesMispredidcted => 4,
165            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
166        }
167    }
168
169    #[inline]
170    pub fn is_unknown(&self) -> bool {
171        match self {
172            Self::__SourceBreaking { unknown_ordinal: _ } => true,
173            _ => false,
174        }
175    }
176}
177
178#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
179pub enum SessionConfigureError {
180    BadSocket,
181    BadState,
182    InvalidConfiguration,
183    MissingSampleConfigs,
184    MissingTargetConfigs,
185    MissingComponentUrl,
186    #[doc(hidden)]
187    __SourceBreaking {
188        unknown_ordinal: u32,
189    },
190}
191
192/// Pattern that matches an unknown `SessionConfigureError` member.
193#[macro_export]
194macro_rules! SessionConfigureErrorUnknown {
195    () => {
196        _
197    };
198}
199
200impl SessionConfigureError {
201    #[inline]
202    pub fn from_primitive(prim: u32) -> Option<Self> {
203        match prim {
204            1 => Some(Self::BadSocket),
205            2 => Some(Self::BadState),
206            3 => Some(Self::InvalidConfiguration),
207            4 => Some(Self::MissingSampleConfigs),
208            5 => Some(Self::MissingTargetConfigs),
209            6 => Some(Self::MissingComponentUrl),
210            _ => None,
211        }
212    }
213
214    #[inline]
215    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
216        match prim {
217            1 => Self::BadSocket,
218            2 => Self::BadState,
219            3 => Self::InvalidConfiguration,
220            4 => Self::MissingSampleConfigs,
221            5 => Self::MissingTargetConfigs,
222            6 => Self::MissingComponentUrl,
223            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
224        }
225    }
226
227    #[inline]
228    pub fn unknown() -> Self {
229        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
230    }
231
232    #[inline]
233    pub const fn into_primitive(self) -> u32 {
234        match self {
235            Self::BadSocket => 1,
236            Self::BadState => 2,
237            Self::InvalidConfiguration => 3,
238            Self::MissingSampleConfigs => 4,
239            Self::MissingTargetConfigs => 5,
240            Self::MissingComponentUrl => 6,
241            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
242        }
243    }
244
245    #[inline]
246    pub fn is_unknown(&self) -> bool {
247        match self {
248            Self::__SourceBreaking { unknown_ordinal: _ } => true,
249            _ => false,
250        }
251    }
252}
253
254#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
255pub enum SessionStartError {
256    BadState,
257    #[doc(hidden)]
258    __SourceBreaking {
259        unknown_ordinal: u32,
260    },
261}
262
263/// Pattern that matches an unknown `SessionStartError` member.
264#[macro_export]
265macro_rules! SessionStartErrorUnknown {
266    () => {
267        _
268    };
269}
270
271impl SessionStartError {
272    #[inline]
273    pub fn from_primitive(prim: u32) -> Option<Self> {
274        match prim {
275            1 => Some(Self::BadState),
276            _ => None,
277        }
278    }
279
280    #[inline]
281    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
282        match prim {
283            1 => Self::BadState,
284            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
285        }
286    }
287
288    #[inline]
289    pub fn unknown() -> Self {
290        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
291    }
292
293    #[inline]
294    pub const fn into_primitive(self) -> u32 {
295        match self {
296            Self::BadState => 1,
297            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
298        }
299    }
300
301    #[inline]
302    pub fn is_unknown(&self) -> bool {
303        match self {
304            Self::__SourceBreaking { unknown_ordinal: _ } => true,
305            _ => false,
306        }
307    }
308}
309
310#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
311pub struct SystemWide;
312
313impl fidl::Persistable for SystemWide {}
314
315#[derive(Clone, Debug, Default, PartialEq)]
316pub struct CallgraphConfig {
317    pub strategy: Option<CallgraphStrategy>,
318    #[doc(hidden)]
319    pub __source_breaking: fidl::marker::SourceBreaking,
320}
321
322impl fidl::Persistable for CallgraphConfig {}
323
324#[derive(Clone, Debug, Default, PartialEq)]
325pub struct LaunchComponent {
326    /// The url of the component to launch (required)
327    pub url: Option<String>,
328    /// The location to launch the component. If not specified, a default
329    /// location will be used.
330    pub moniker: Option<String>,
331    #[doc(hidden)]
332    pub __source_breaking: fidl::marker::SourceBreaking,
333}
334
335impl fidl::Persistable for LaunchComponent {}
336
337#[derive(Clone, Debug, Default, PartialEq)]
338pub struct Sample {
339    /// Whether the profiler should include callgraph information and if so,
340    /// what strategy it should use.
341    pub callgraph: Option<CallgraphConfig>,
342    /// The value of a counter since the last sample
343    pub counters: Option<Vec<Counter>>,
344    #[doc(hidden)]
345    pub __source_breaking: fidl::marker::SourceBreaking,
346}
347
348impl fidl::Persistable for Sample {}
349
350/// Profiling information about the profile itself
351#[derive(Clone, Debug, Default, PartialEq)]
352pub struct SamplingConfig {
353    /// How many ticks of the counter should occur between each sample
354    pub period: Option<u64>,
355    /// The counter to the rate on
356    pub timebase: Option<Counter>,
357    /// What information the profiler will write when it takes
358    /// a sample.
359    pub sample: Option<Sample>,
360    #[doc(hidden)]
361    pub __source_breaking: fidl::marker::SourceBreaking,
362}
363
364impl fidl::Persistable for SamplingConfig {}
365
366#[derive(Clone, Debug, Default, PartialEq)]
367pub struct SessionStartRequest {
368    /// If true, delays writing data to the output socket until the profiling
369    /// session ends. This reduces overhead, but also caps the maximum output
370    /// size to the requested buffer size.
371    pub buffer_size_mb: Option<u64>,
372    pub buffer_results: Option<bool>,
373    #[doc(hidden)]
374    pub __source_breaking: fidl::marker::SourceBreaking,
375}
376
377impl fidl::Persistable for SessionStartRequest {}
378
379#[derive(Clone, Debug, Default, PartialEq)]
380pub struct SessionStopResponse {
381    pub samples_collected: Option<u64>,
382    pub mean_sample_time: Option<u64>,
383    pub median_sample_time: Option<u64>,
384    pub min_sample_time: Option<u64>,
385    pub max_sample_time: Option<u64>,
386    pub missing_process_mappings: Option<Vec<u64>>,
387    #[doc(hidden)]
388    pub __source_breaking: fidl::marker::SourceBreaking,
389}
390
391impl fidl::Persistable for SessionStopResponse {}
392
393#[derive(Clone, Debug)]
394pub enum Counter {
395    /// Curated set of platform independent ids that get converted into the
396    /// appropriate hardware specific counter id.
397    PlatformIndependent(CounterId),
398    /// In the case a counter is not widely supported across
399    /// platform or not included in the curated set, one can
400    /// specify a platform dependent id that will not get
401    /// converted.
402    PlatformDependent(u32),
403    #[doc(hidden)]
404    __SourceBreaking { unknown_ordinal: u64 },
405}
406
407/// Pattern that matches an unknown `Counter` member.
408#[macro_export]
409macro_rules! CounterUnknown {
410    () => {
411        _
412    };
413}
414
415// Custom PartialEq so that unknown variants are not equal to themselves.
416impl PartialEq for Counter {
417    fn eq(&self, other: &Self) -> bool {
418        match (self, other) {
419            (Self::PlatformIndependent(x), Self::PlatformIndependent(y)) => *x == *y,
420            (Self::PlatformDependent(x), Self::PlatformDependent(y)) => *x == *y,
421            _ => false,
422        }
423    }
424}
425
426impl Counter {
427    #[inline]
428    pub fn ordinal(&self) -> u64 {
429        match *self {
430            Self::PlatformIndependent(_) => 1,
431            Self::PlatformDependent(_) => 2,
432            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
433        }
434    }
435
436    #[inline]
437    pub fn unknown_variant_for_testing() -> Self {
438        Self::__SourceBreaking { unknown_ordinal: 0 }
439    }
440
441    #[inline]
442    pub fn is_unknown(&self) -> bool {
443        match self {
444            Self::__SourceBreaking { .. } => true,
445            _ => false,
446        }
447    }
448}
449
450impl fidl::Persistable for Counter {}
451
452/// An adhoc set of running tasks to attach to.
453#[derive(Clone, Debug)]
454pub enum Task {
455    /// Profile a process and all threads associated with it.
456    Process(u64),
457    /// Profile a single thread.
458    Thread(u64),
459    /// Profile a job and all processes and threads associated with it.
460    Job(u64),
461    /// Profile everything running on the system.
462    ///
463    /// Equivalent to finding root job's koid and passing it as a Task::job.
464    SystemWide(SystemWide),
465    #[doc(hidden)]
466    __SourceBreaking { unknown_ordinal: u64 },
467}
468
469/// Pattern that matches an unknown `Task` member.
470#[macro_export]
471macro_rules! TaskUnknown {
472    () => {
473        _
474    };
475}
476
477// Custom PartialEq so that unknown variants are not equal to themselves.
478impl PartialEq for Task {
479    fn eq(&self, other: &Self) -> bool {
480        match (self, other) {
481            (Self::Process(x), Self::Process(y)) => *x == *y,
482            (Self::Thread(x), Self::Thread(y)) => *x == *y,
483            (Self::Job(x), Self::Job(y)) => *x == *y,
484            (Self::SystemWide(x), Self::SystemWide(y)) => *x == *y,
485            _ => false,
486        }
487    }
488}
489
490impl Task {
491    #[inline]
492    pub fn ordinal(&self) -> u64 {
493        match *self {
494            Self::Process(_) => 1,
495            Self::Thread(_) => 2,
496            Self::Job(_) => 3,
497            Self::SystemWide(_) => 4,
498            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
499        }
500    }
501
502    #[inline]
503    pub fn unknown_variant_for_testing() -> Self {
504        Self::__SourceBreaking { unknown_ordinal: 0 }
505    }
506
507    #[inline]
508    pub fn is_unknown(&self) -> bool {
509        match self {
510            Self::__SourceBreaking { .. } => true,
511            _ => false,
512        }
513    }
514}
515
516impl fidl::Persistable for Task {}
517
518pub mod session_ordinals {
519    pub const CONFIGURE: u64 = 0x67e7e28a9b959ce8;
520    pub const START: u64 = 0x4e82f9133a968ad5;
521    pub const STOP: u64 = 0x76aa8dd59cb61e89;
522    pub const RESET: u64 = 0x5f522fde537356fa;
523}
524
525mod internal {
526    use super::*;
527    unsafe impl fidl::encoding::TypeMarker for CallgraphStrategy {
528        type Owned = Self;
529
530        #[inline(always)]
531        fn inline_align(_context: fidl::encoding::Context) -> usize {
532            std::mem::align_of::<u8>()
533        }
534
535        #[inline(always)]
536        fn inline_size(_context: fidl::encoding::Context) -> usize {
537            std::mem::size_of::<u8>()
538        }
539
540        #[inline(always)]
541        fn encode_is_copy() -> bool {
542            false
543        }
544
545        #[inline(always)]
546        fn decode_is_copy() -> bool {
547            false
548        }
549    }
550
551    impl fidl::encoding::ValueTypeMarker for CallgraphStrategy {
552        type Borrowed<'a> = Self;
553        #[inline(always)]
554        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
555            *value
556        }
557    }
558
559    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
560        for CallgraphStrategy
561    {
562        #[inline]
563        unsafe fn encode(
564            self,
565            encoder: &mut fidl::encoding::Encoder<'_, D>,
566            offset: usize,
567            _depth: fidl::encoding::Depth,
568        ) -> fidl::Result<()> {
569            encoder.debug_check_bounds::<Self>(offset);
570            encoder.write_num(self.into_primitive(), offset);
571            Ok(())
572        }
573    }
574
575    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CallgraphStrategy {
576        #[inline(always)]
577        fn new_empty() -> Self {
578            Self::unknown()
579        }
580
581        #[inline]
582        unsafe fn decode(
583            &mut self,
584            decoder: &mut fidl::encoding::Decoder<'_, D>,
585            offset: usize,
586            _depth: fidl::encoding::Depth,
587        ) -> fidl::Result<()> {
588            decoder.debug_check_bounds::<Self>(offset);
589            let prim = decoder.read_num::<u8>(offset);
590
591            *self = Self::from_primitive_allow_unknown(prim);
592            Ok(())
593        }
594    }
595    unsafe impl fidl::encoding::TypeMarker for CounterId {
596        type Owned = Self;
597
598        #[inline(always)]
599        fn inline_align(_context: fidl::encoding::Context) -> usize {
600            std::mem::align_of::<u8>()
601        }
602
603        #[inline(always)]
604        fn inline_size(_context: fidl::encoding::Context) -> usize {
605            std::mem::size_of::<u8>()
606        }
607
608        #[inline(always)]
609        fn encode_is_copy() -> bool {
610            false
611        }
612
613        #[inline(always)]
614        fn decode_is_copy() -> bool {
615            false
616        }
617    }
618
619    impl fidl::encoding::ValueTypeMarker for CounterId {
620        type Borrowed<'a> = Self;
621        #[inline(always)]
622        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
623            *value
624        }
625    }
626
627    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for CounterId {
628        #[inline]
629        unsafe fn encode(
630            self,
631            encoder: &mut fidl::encoding::Encoder<'_, D>,
632            offset: usize,
633            _depth: fidl::encoding::Depth,
634        ) -> fidl::Result<()> {
635            encoder.debug_check_bounds::<Self>(offset);
636            encoder.write_num(self.into_primitive(), offset);
637            Ok(())
638        }
639    }
640
641    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CounterId {
642        #[inline(always)]
643        fn new_empty() -> Self {
644            Self::unknown()
645        }
646
647        #[inline]
648        unsafe fn decode(
649            &mut self,
650            decoder: &mut fidl::encoding::Decoder<'_, D>,
651            offset: usize,
652            _depth: fidl::encoding::Depth,
653        ) -> fidl::Result<()> {
654            decoder.debug_check_bounds::<Self>(offset);
655            let prim = decoder.read_num::<u8>(offset);
656
657            *self = Self::from_primitive_allow_unknown(prim);
658            Ok(())
659        }
660    }
661    unsafe impl fidl::encoding::TypeMarker for SessionConfigureError {
662        type Owned = Self;
663
664        #[inline(always)]
665        fn inline_align(_context: fidl::encoding::Context) -> usize {
666            std::mem::align_of::<u32>()
667        }
668
669        #[inline(always)]
670        fn inline_size(_context: fidl::encoding::Context) -> usize {
671            std::mem::size_of::<u32>()
672        }
673
674        #[inline(always)]
675        fn encode_is_copy() -> bool {
676            false
677        }
678
679        #[inline(always)]
680        fn decode_is_copy() -> bool {
681            false
682        }
683    }
684
685    impl fidl::encoding::ValueTypeMarker for SessionConfigureError {
686        type Borrowed<'a> = Self;
687        #[inline(always)]
688        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
689            *value
690        }
691    }
692
693    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
694        for SessionConfigureError
695    {
696        #[inline]
697        unsafe fn encode(
698            self,
699            encoder: &mut fidl::encoding::Encoder<'_, D>,
700            offset: usize,
701            _depth: fidl::encoding::Depth,
702        ) -> fidl::Result<()> {
703            encoder.debug_check_bounds::<Self>(offset);
704            encoder.write_num(self.into_primitive(), offset);
705            Ok(())
706        }
707    }
708
709    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SessionConfigureError {
710        #[inline(always)]
711        fn new_empty() -> Self {
712            Self::unknown()
713        }
714
715        #[inline]
716        unsafe fn decode(
717            &mut self,
718            decoder: &mut fidl::encoding::Decoder<'_, D>,
719            offset: usize,
720            _depth: fidl::encoding::Depth,
721        ) -> fidl::Result<()> {
722            decoder.debug_check_bounds::<Self>(offset);
723            let prim = decoder.read_num::<u32>(offset);
724
725            *self = Self::from_primitive_allow_unknown(prim);
726            Ok(())
727        }
728    }
729    unsafe impl fidl::encoding::TypeMarker for SessionStartError {
730        type Owned = Self;
731
732        #[inline(always)]
733        fn inline_align(_context: fidl::encoding::Context) -> usize {
734            std::mem::align_of::<u32>()
735        }
736
737        #[inline(always)]
738        fn inline_size(_context: fidl::encoding::Context) -> usize {
739            std::mem::size_of::<u32>()
740        }
741
742        #[inline(always)]
743        fn encode_is_copy() -> bool {
744            false
745        }
746
747        #[inline(always)]
748        fn decode_is_copy() -> bool {
749            false
750        }
751    }
752
753    impl fidl::encoding::ValueTypeMarker for SessionStartError {
754        type Borrowed<'a> = Self;
755        #[inline(always)]
756        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
757            *value
758        }
759    }
760
761    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
762        for SessionStartError
763    {
764        #[inline]
765        unsafe fn encode(
766            self,
767            encoder: &mut fidl::encoding::Encoder<'_, D>,
768            offset: usize,
769            _depth: fidl::encoding::Depth,
770        ) -> fidl::Result<()> {
771            encoder.debug_check_bounds::<Self>(offset);
772            encoder.write_num(self.into_primitive(), offset);
773            Ok(())
774        }
775    }
776
777    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SessionStartError {
778        #[inline(always)]
779        fn new_empty() -> Self {
780            Self::unknown()
781        }
782
783        #[inline]
784        unsafe fn decode(
785            &mut self,
786            decoder: &mut fidl::encoding::Decoder<'_, D>,
787            offset: usize,
788            _depth: fidl::encoding::Depth,
789        ) -> fidl::Result<()> {
790            decoder.debug_check_bounds::<Self>(offset);
791            let prim = decoder.read_num::<u32>(offset);
792
793            *self = Self::from_primitive_allow_unknown(prim);
794            Ok(())
795        }
796    }
797
798    impl fidl::encoding::ValueTypeMarker for SystemWide {
799        type Borrowed<'a> = &'a Self;
800        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
801            value
802        }
803    }
804
805    unsafe impl fidl::encoding::TypeMarker for SystemWide {
806        type Owned = Self;
807
808        #[inline(always)]
809        fn inline_align(_context: fidl::encoding::Context) -> usize {
810            1
811        }
812
813        #[inline(always)]
814        fn inline_size(_context: fidl::encoding::Context) -> usize {
815            1
816        }
817    }
818
819    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SystemWide, D>
820        for &SystemWide
821    {
822        #[inline]
823        unsafe fn encode(
824            self,
825            encoder: &mut fidl::encoding::Encoder<'_, D>,
826            offset: usize,
827            _depth: fidl::encoding::Depth,
828        ) -> fidl::Result<()> {
829            encoder.debug_check_bounds::<SystemWide>(offset);
830            encoder.write_num(0u8, offset);
831            Ok(())
832        }
833    }
834
835    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SystemWide {
836        #[inline(always)]
837        fn new_empty() -> Self {
838            Self
839        }
840
841        #[inline]
842        unsafe fn decode(
843            &mut self,
844            decoder: &mut fidl::encoding::Decoder<'_, D>,
845            offset: usize,
846            _depth: fidl::encoding::Depth,
847        ) -> fidl::Result<()> {
848            decoder.debug_check_bounds::<Self>(offset);
849            match decoder.read_num::<u8>(offset) {
850                0 => Ok(()),
851                _ => Err(fidl::Error::Invalid),
852            }
853        }
854    }
855
856    impl CallgraphConfig {
857        #[inline(always)]
858        fn max_ordinal_present(&self) -> u64 {
859            if let Some(_) = self.strategy {
860                return 1;
861            }
862            0
863        }
864    }
865
866    impl fidl::encoding::ValueTypeMarker for CallgraphConfig {
867        type Borrowed<'a> = &'a Self;
868        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
869            value
870        }
871    }
872
873    unsafe impl fidl::encoding::TypeMarker for CallgraphConfig {
874        type Owned = Self;
875
876        #[inline(always)]
877        fn inline_align(_context: fidl::encoding::Context) -> usize {
878            8
879        }
880
881        #[inline(always)]
882        fn inline_size(_context: fidl::encoding::Context) -> usize {
883            16
884        }
885    }
886
887    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CallgraphConfig, D>
888        for &CallgraphConfig
889    {
890        unsafe fn encode(
891            self,
892            encoder: &mut fidl::encoding::Encoder<'_, D>,
893            offset: usize,
894            mut depth: fidl::encoding::Depth,
895        ) -> fidl::Result<()> {
896            encoder.debug_check_bounds::<CallgraphConfig>(offset);
897            // Vector header
898            let max_ordinal: u64 = self.max_ordinal_present();
899            encoder.write_num(max_ordinal, offset);
900            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
901            // Calling encoder.out_of_line_offset(0) is not allowed.
902            if max_ordinal == 0 {
903                return Ok(());
904            }
905            depth.increment()?;
906            let envelope_size = 8;
907            let bytes_len = max_ordinal as usize * envelope_size;
908            #[allow(unused_variables)]
909            let offset = encoder.out_of_line_offset(bytes_len);
910            let mut _prev_end_offset: usize = 0;
911            if 1 > max_ordinal {
912                return Ok(());
913            }
914
915            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
916            // are envelope_size bytes.
917            let cur_offset: usize = (1 - 1) * envelope_size;
918
919            // Zero reserved fields.
920            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
921
922            // Safety:
923            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
924            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
925            //   envelope_size bytes, there is always sufficient room.
926            fidl::encoding::encode_in_envelope_optional::<CallgraphStrategy, D>(
927                self.strategy
928                    .as_ref()
929                    .map(<CallgraphStrategy as fidl::encoding::ValueTypeMarker>::borrow),
930                encoder,
931                offset + cur_offset,
932                depth,
933            )?;
934
935            _prev_end_offset = cur_offset + envelope_size;
936
937            Ok(())
938        }
939    }
940
941    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CallgraphConfig {
942        #[inline(always)]
943        fn new_empty() -> Self {
944            Self::default()
945        }
946
947        unsafe fn decode(
948            &mut self,
949            decoder: &mut fidl::encoding::Decoder<'_, D>,
950            offset: usize,
951            mut depth: fidl::encoding::Depth,
952        ) -> fidl::Result<()> {
953            decoder.debug_check_bounds::<Self>(offset);
954            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
955                None => return Err(fidl::Error::NotNullable),
956                Some(len) => len,
957            };
958            // Calling decoder.out_of_line_offset(0) is not allowed.
959            if len == 0 {
960                return Ok(());
961            };
962            depth.increment()?;
963            let envelope_size = 8;
964            let bytes_len = len * envelope_size;
965            let offset = decoder.out_of_line_offset(bytes_len)?;
966            // Decode the envelope for each type.
967            let mut _next_ordinal_to_read = 0;
968            let mut next_offset = offset;
969            let end_offset = offset + bytes_len;
970            _next_ordinal_to_read += 1;
971            if next_offset >= end_offset {
972                return Ok(());
973            }
974
975            // Decode unknown envelopes for gaps in ordinals.
976            while _next_ordinal_to_read < 1 {
977                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
978                _next_ordinal_to_read += 1;
979                next_offset += envelope_size;
980            }
981
982            let next_out_of_line = decoder.next_out_of_line();
983            let handles_before = decoder.remaining_handles();
984            if let Some((inlined, num_bytes, num_handles)) =
985                fidl::encoding::decode_envelope_header(decoder, next_offset)?
986            {
987                let member_inline_size =
988                    <CallgraphStrategy as fidl::encoding::TypeMarker>::inline_size(decoder.context);
989                if inlined != (member_inline_size <= 4) {
990                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
991                }
992                let inner_offset;
993                let mut inner_depth = depth.clone();
994                if inlined {
995                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
996                    inner_offset = next_offset;
997                } else {
998                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
999                    inner_depth.increment()?;
1000                }
1001                let val_ref =
1002                    self.strategy.get_or_insert_with(|| fidl::new_empty!(CallgraphStrategy, D));
1003                fidl::decode!(CallgraphStrategy, D, val_ref, decoder, inner_offset, inner_depth)?;
1004                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1005                {
1006                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1007                }
1008                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1009                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1010                }
1011            }
1012
1013            next_offset += envelope_size;
1014
1015            // Decode the remaining unknown envelopes.
1016            while next_offset < end_offset {
1017                _next_ordinal_to_read += 1;
1018                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1019                next_offset += envelope_size;
1020            }
1021
1022            Ok(())
1023        }
1024    }
1025
1026    impl LaunchComponent {
1027        #[inline(always)]
1028        fn max_ordinal_present(&self) -> u64 {
1029            if let Some(_) = self.moniker {
1030                return 2;
1031            }
1032            if let Some(_) = self.url {
1033                return 1;
1034            }
1035            0
1036        }
1037    }
1038
1039    impl fidl::encoding::ValueTypeMarker for LaunchComponent {
1040        type Borrowed<'a> = &'a Self;
1041        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1042            value
1043        }
1044    }
1045
1046    unsafe impl fidl::encoding::TypeMarker for LaunchComponent {
1047        type Owned = Self;
1048
1049        #[inline(always)]
1050        fn inline_align(_context: fidl::encoding::Context) -> usize {
1051            8
1052        }
1053
1054        #[inline(always)]
1055        fn inline_size(_context: fidl::encoding::Context) -> usize {
1056            16
1057        }
1058    }
1059
1060    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<LaunchComponent, D>
1061        for &LaunchComponent
1062    {
1063        unsafe fn encode(
1064            self,
1065            encoder: &mut fidl::encoding::Encoder<'_, D>,
1066            offset: usize,
1067            mut depth: fidl::encoding::Depth,
1068        ) -> fidl::Result<()> {
1069            encoder.debug_check_bounds::<LaunchComponent>(offset);
1070            // Vector header
1071            let max_ordinal: u64 = self.max_ordinal_present();
1072            encoder.write_num(max_ordinal, offset);
1073            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1074            // Calling encoder.out_of_line_offset(0) is not allowed.
1075            if max_ordinal == 0 {
1076                return Ok(());
1077            }
1078            depth.increment()?;
1079            let envelope_size = 8;
1080            let bytes_len = max_ordinal as usize * envelope_size;
1081            #[allow(unused_variables)]
1082            let offset = encoder.out_of_line_offset(bytes_len);
1083            let mut _prev_end_offset: usize = 0;
1084            if 1 > max_ordinal {
1085                return Ok(());
1086            }
1087
1088            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1089            // are envelope_size bytes.
1090            let cur_offset: usize = (1 - 1) * envelope_size;
1091
1092            // Zero reserved fields.
1093            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1094
1095            // Safety:
1096            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1097            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1098            //   envelope_size bytes, there is always sufficient room.
1099            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
1100            self.url.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
1101            encoder, offset + cur_offset, depth
1102        )?;
1103
1104            _prev_end_offset = cur_offset + envelope_size;
1105            if 2 > max_ordinal {
1106                return Ok(());
1107            }
1108
1109            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1110            // are envelope_size bytes.
1111            let cur_offset: usize = (2 - 1) * envelope_size;
1112
1113            // Zero reserved fields.
1114            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1115
1116            // Safety:
1117            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1118            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1119            //   envelope_size bytes, there is always sufficient room.
1120            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<4096>, D>(
1121            self.moniker.as_ref().map(<fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow),
1122            encoder, offset + cur_offset, depth
1123        )?;
1124
1125            _prev_end_offset = cur_offset + envelope_size;
1126
1127            Ok(())
1128        }
1129    }
1130
1131    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LaunchComponent {
1132        #[inline(always)]
1133        fn new_empty() -> Self {
1134            Self::default()
1135        }
1136
1137        unsafe fn decode(
1138            &mut self,
1139            decoder: &mut fidl::encoding::Decoder<'_, D>,
1140            offset: usize,
1141            mut depth: fidl::encoding::Depth,
1142        ) -> fidl::Result<()> {
1143            decoder.debug_check_bounds::<Self>(offset);
1144            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1145                None => return Err(fidl::Error::NotNullable),
1146                Some(len) => len,
1147            };
1148            // Calling decoder.out_of_line_offset(0) is not allowed.
1149            if len == 0 {
1150                return Ok(());
1151            };
1152            depth.increment()?;
1153            let envelope_size = 8;
1154            let bytes_len = len * envelope_size;
1155            let offset = decoder.out_of_line_offset(bytes_len)?;
1156            // Decode the envelope for each type.
1157            let mut _next_ordinal_to_read = 0;
1158            let mut next_offset = offset;
1159            let end_offset = offset + bytes_len;
1160            _next_ordinal_to_read += 1;
1161            if next_offset >= end_offset {
1162                return Ok(());
1163            }
1164
1165            // Decode unknown envelopes for gaps in ordinals.
1166            while _next_ordinal_to_read < 1 {
1167                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1168                _next_ordinal_to_read += 1;
1169                next_offset += envelope_size;
1170            }
1171
1172            let next_out_of_line = decoder.next_out_of_line();
1173            let handles_before = decoder.remaining_handles();
1174            if let Some((inlined, num_bytes, num_handles)) =
1175                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1176            {
1177                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1178                if inlined != (member_inline_size <= 4) {
1179                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1180                }
1181                let inner_offset;
1182                let mut inner_depth = depth.clone();
1183                if inlined {
1184                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1185                    inner_offset = next_offset;
1186                } else {
1187                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1188                    inner_depth.increment()?;
1189                }
1190                let val_ref = self.url.get_or_insert_with(|| {
1191                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
1192                });
1193                fidl::decode!(
1194                    fidl::encoding::BoundedString<4096>,
1195                    D,
1196                    val_ref,
1197                    decoder,
1198                    inner_offset,
1199                    inner_depth
1200                )?;
1201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1202                {
1203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1204                }
1205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1207                }
1208            }
1209
1210            next_offset += envelope_size;
1211            _next_ordinal_to_read += 1;
1212            if next_offset >= end_offset {
1213                return Ok(());
1214            }
1215
1216            // Decode unknown envelopes for gaps in ordinals.
1217            while _next_ordinal_to_read < 2 {
1218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1219                _next_ordinal_to_read += 1;
1220                next_offset += envelope_size;
1221            }
1222
1223            let next_out_of_line = decoder.next_out_of_line();
1224            let handles_before = decoder.remaining_handles();
1225            if let Some((inlined, num_bytes, num_handles)) =
1226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1227            {
1228                let member_inline_size = <fidl::encoding::BoundedString<4096> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1229                if inlined != (member_inline_size <= 4) {
1230                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1231                }
1232                let inner_offset;
1233                let mut inner_depth = depth.clone();
1234                if inlined {
1235                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1236                    inner_offset = next_offset;
1237                } else {
1238                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1239                    inner_depth.increment()?;
1240                }
1241                let val_ref = self.moniker.get_or_insert_with(|| {
1242                    fidl::new_empty!(fidl::encoding::BoundedString<4096>, D)
1243                });
1244                fidl::decode!(
1245                    fidl::encoding::BoundedString<4096>,
1246                    D,
1247                    val_ref,
1248                    decoder,
1249                    inner_offset,
1250                    inner_depth
1251                )?;
1252                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1253                {
1254                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1255                }
1256                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1257                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1258                }
1259            }
1260
1261            next_offset += envelope_size;
1262
1263            // Decode the remaining unknown envelopes.
1264            while next_offset < end_offset {
1265                _next_ordinal_to_read += 1;
1266                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1267                next_offset += envelope_size;
1268            }
1269
1270            Ok(())
1271        }
1272    }
1273
1274    impl Sample {
1275        #[inline(always)]
1276        fn max_ordinal_present(&self) -> u64 {
1277            if let Some(_) = self.counters {
1278                return 2;
1279            }
1280            if let Some(_) = self.callgraph {
1281                return 1;
1282            }
1283            0
1284        }
1285    }
1286
1287    impl fidl::encoding::ValueTypeMarker for Sample {
1288        type Borrowed<'a> = &'a Self;
1289        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1290            value
1291        }
1292    }
1293
1294    unsafe impl fidl::encoding::TypeMarker for Sample {
1295        type Owned = Self;
1296
1297        #[inline(always)]
1298        fn inline_align(_context: fidl::encoding::Context) -> usize {
1299            8
1300        }
1301
1302        #[inline(always)]
1303        fn inline_size(_context: fidl::encoding::Context) -> usize {
1304            16
1305        }
1306    }
1307
1308    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Sample, D> for &Sample {
1309        unsafe fn encode(
1310            self,
1311            encoder: &mut fidl::encoding::Encoder<'_, D>,
1312            offset: usize,
1313            mut depth: fidl::encoding::Depth,
1314        ) -> fidl::Result<()> {
1315            encoder.debug_check_bounds::<Sample>(offset);
1316            // Vector header
1317            let max_ordinal: u64 = self.max_ordinal_present();
1318            encoder.write_num(max_ordinal, offset);
1319            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1320            // Calling encoder.out_of_line_offset(0) is not allowed.
1321            if max_ordinal == 0 {
1322                return Ok(());
1323            }
1324            depth.increment()?;
1325            let envelope_size = 8;
1326            let bytes_len = max_ordinal as usize * envelope_size;
1327            #[allow(unused_variables)]
1328            let offset = encoder.out_of_line_offset(bytes_len);
1329            let mut _prev_end_offset: usize = 0;
1330            if 1 > max_ordinal {
1331                return Ok(());
1332            }
1333
1334            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1335            // are envelope_size bytes.
1336            let cur_offset: usize = (1 - 1) * envelope_size;
1337
1338            // Zero reserved fields.
1339            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1340
1341            // Safety:
1342            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1343            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1344            //   envelope_size bytes, there is always sufficient room.
1345            fidl::encoding::encode_in_envelope_optional::<CallgraphConfig, D>(
1346                self.callgraph
1347                    .as_ref()
1348                    .map(<CallgraphConfig as fidl::encoding::ValueTypeMarker>::borrow),
1349                encoder,
1350                offset + cur_offset,
1351                depth,
1352            )?;
1353
1354            _prev_end_offset = cur_offset + envelope_size;
1355            if 2 > max_ordinal {
1356                return Ok(());
1357            }
1358
1359            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1360            // are envelope_size bytes.
1361            let cur_offset: usize = (2 - 1) * envelope_size;
1362
1363            // Zero reserved fields.
1364            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1365
1366            // Safety:
1367            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1368            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1369            //   envelope_size bytes, there is always sufficient room.
1370            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Counter, 64>, D>(
1371            self.counters.as_ref().map(<fidl::encoding::Vector<Counter, 64> as fidl::encoding::ValueTypeMarker>::borrow),
1372            encoder, offset + cur_offset, depth
1373        )?;
1374
1375            _prev_end_offset = cur_offset + envelope_size;
1376
1377            Ok(())
1378        }
1379    }
1380
1381    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Sample {
1382        #[inline(always)]
1383        fn new_empty() -> Self {
1384            Self::default()
1385        }
1386
1387        unsafe fn decode(
1388            &mut self,
1389            decoder: &mut fidl::encoding::Decoder<'_, D>,
1390            offset: usize,
1391            mut depth: fidl::encoding::Depth,
1392        ) -> fidl::Result<()> {
1393            decoder.debug_check_bounds::<Self>(offset);
1394            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1395                None => return Err(fidl::Error::NotNullable),
1396                Some(len) => len,
1397            };
1398            // Calling decoder.out_of_line_offset(0) is not allowed.
1399            if len == 0 {
1400                return Ok(());
1401            };
1402            depth.increment()?;
1403            let envelope_size = 8;
1404            let bytes_len = len * envelope_size;
1405            let offset = decoder.out_of_line_offset(bytes_len)?;
1406            // Decode the envelope for each type.
1407            let mut _next_ordinal_to_read = 0;
1408            let mut next_offset = offset;
1409            let end_offset = offset + bytes_len;
1410            _next_ordinal_to_read += 1;
1411            if next_offset >= end_offset {
1412                return Ok(());
1413            }
1414
1415            // Decode unknown envelopes for gaps in ordinals.
1416            while _next_ordinal_to_read < 1 {
1417                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1418                _next_ordinal_to_read += 1;
1419                next_offset += envelope_size;
1420            }
1421
1422            let next_out_of_line = decoder.next_out_of_line();
1423            let handles_before = decoder.remaining_handles();
1424            if let Some((inlined, num_bytes, num_handles)) =
1425                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1426            {
1427                let member_inline_size =
1428                    <CallgraphConfig as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1429                if inlined != (member_inline_size <= 4) {
1430                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1431                }
1432                let inner_offset;
1433                let mut inner_depth = depth.clone();
1434                if inlined {
1435                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1436                    inner_offset = next_offset;
1437                } else {
1438                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1439                    inner_depth.increment()?;
1440                }
1441                let val_ref =
1442                    self.callgraph.get_or_insert_with(|| fidl::new_empty!(CallgraphConfig, D));
1443                fidl::decode!(CallgraphConfig, D, val_ref, decoder, inner_offset, inner_depth)?;
1444                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1445                {
1446                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1447                }
1448                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1449                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1450                }
1451            }
1452
1453            next_offset += envelope_size;
1454            _next_ordinal_to_read += 1;
1455            if next_offset >= end_offset {
1456                return Ok(());
1457            }
1458
1459            // Decode unknown envelopes for gaps in ordinals.
1460            while _next_ordinal_to_read < 2 {
1461                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1462                _next_ordinal_to_read += 1;
1463                next_offset += envelope_size;
1464            }
1465
1466            let next_out_of_line = decoder.next_out_of_line();
1467            let handles_before = decoder.remaining_handles();
1468            if let Some((inlined, num_bytes, num_handles)) =
1469                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1470            {
1471                let member_inline_size = <fidl::encoding::Vector<Counter, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1472                if inlined != (member_inline_size <= 4) {
1473                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1474                }
1475                let inner_offset;
1476                let mut inner_depth = depth.clone();
1477                if inlined {
1478                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1479                    inner_offset = next_offset;
1480                } else {
1481                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1482                    inner_depth.increment()?;
1483                }
1484                let val_ref = self.counters.get_or_insert_with(
1485                    || fidl::new_empty!(fidl::encoding::Vector<Counter, 64>, D),
1486                );
1487                fidl::decode!(fidl::encoding::Vector<Counter, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
1488                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1489                {
1490                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1491                }
1492                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1493                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1494                }
1495            }
1496
1497            next_offset += envelope_size;
1498
1499            // Decode the remaining unknown envelopes.
1500            while next_offset < end_offset {
1501                _next_ordinal_to_read += 1;
1502                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1503                next_offset += envelope_size;
1504            }
1505
1506            Ok(())
1507        }
1508    }
1509
1510    impl SamplingConfig {
1511        #[inline(always)]
1512        fn max_ordinal_present(&self) -> u64 {
1513            if let Some(_) = self.sample {
1514                return 3;
1515            }
1516            if let Some(_) = self.timebase {
1517                return 2;
1518            }
1519            if let Some(_) = self.period {
1520                return 1;
1521            }
1522            0
1523        }
1524    }
1525
1526    impl fidl::encoding::ValueTypeMarker for SamplingConfig {
1527        type Borrowed<'a> = &'a Self;
1528        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1529            value
1530        }
1531    }
1532
1533    unsafe impl fidl::encoding::TypeMarker for SamplingConfig {
1534        type Owned = Self;
1535
1536        #[inline(always)]
1537        fn inline_align(_context: fidl::encoding::Context) -> usize {
1538            8
1539        }
1540
1541        #[inline(always)]
1542        fn inline_size(_context: fidl::encoding::Context) -> usize {
1543            16
1544        }
1545    }
1546
1547    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SamplingConfig, D>
1548        for &SamplingConfig
1549    {
1550        unsafe fn encode(
1551            self,
1552            encoder: &mut fidl::encoding::Encoder<'_, D>,
1553            offset: usize,
1554            mut depth: fidl::encoding::Depth,
1555        ) -> fidl::Result<()> {
1556            encoder.debug_check_bounds::<SamplingConfig>(offset);
1557            // Vector header
1558            let max_ordinal: u64 = self.max_ordinal_present();
1559            encoder.write_num(max_ordinal, offset);
1560            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1561            // Calling encoder.out_of_line_offset(0) is not allowed.
1562            if max_ordinal == 0 {
1563                return Ok(());
1564            }
1565            depth.increment()?;
1566            let envelope_size = 8;
1567            let bytes_len = max_ordinal as usize * envelope_size;
1568            #[allow(unused_variables)]
1569            let offset = encoder.out_of_line_offset(bytes_len);
1570            let mut _prev_end_offset: usize = 0;
1571            if 1 > max_ordinal {
1572                return Ok(());
1573            }
1574
1575            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1576            // are envelope_size bytes.
1577            let cur_offset: usize = (1 - 1) * envelope_size;
1578
1579            // Zero reserved fields.
1580            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1581
1582            // Safety:
1583            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1584            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1585            //   envelope_size bytes, there is always sufficient room.
1586            fidl::encoding::encode_in_envelope_optional::<u64, D>(
1587                self.period.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1588                encoder,
1589                offset + cur_offset,
1590                depth,
1591            )?;
1592
1593            _prev_end_offset = cur_offset + envelope_size;
1594            if 2 > max_ordinal {
1595                return Ok(());
1596            }
1597
1598            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1599            // are envelope_size bytes.
1600            let cur_offset: usize = (2 - 1) * envelope_size;
1601
1602            // Zero reserved fields.
1603            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1604
1605            // Safety:
1606            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1607            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1608            //   envelope_size bytes, there is always sufficient room.
1609            fidl::encoding::encode_in_envelope_optional::<Counter, D>(
1610                self.timebase.as_ref().map(<Counter as fidl::encoding::ValueTypeMarker>::borrow),
1611                encoder,
1612                offset + cur_offset,
1613                depth,
1614            )?;
1615
1616            _prev_end_offset = cur_offset + envelope_size;
1617            if 3 > max_ordinal {
1618                return Ok(());
1619            }
1620
1621            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1622            // are envelope_size bytes.
1623            let cur_offset: usize = (3 - 1) * envelope_size;
1624
1625            // Zero reserved fields.
1626            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1627
1628            // Safety:
1629            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1630            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1631            //   envelope_size bytes, there is always sufficient room.
1632            fidl::encoding::encode_in_envelope_optional::<Sample, D>(
1633                self.sample.as_ref().map(<Sample as fidl::encoding::ValueTypeMarker>::borrow),
1634                encoder,
1635                offset + cur_offset,
1636                depth,
1637            )?;
1638
1639            _prev_end_offset = cur_offset + envelope_size;
1640
1641            Ok(())
1642        }
1643    }
1644
1645    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SamplingConfig {
1646        #[inline(always)]
1647        fn new_empty() -> Self {
1648            Self::default()
1649        }
1650
1651        unsafe fn decode(
1652            &mut self,
1653            decoder: &mut fidl::encoding::Decoder<'_, D>,
1654            offset: usize,
1655            mut depth: fidl::encoding::Depth,
1656        ) -> fidl::Result<()> {
1657            decoder.debug_check_bounds::<Self>(offset);
1658            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1659                None => return Err(fidl::Error::NotNullable),
1660                Some(len) => len,
1661            };
1662            // Calling decoder.out_of_line_offset(0) is not allowed.
1663            if len == 0 {
1664                return Ok(());
1665            };
1666            depth.increment()?;
1667            let envelope_size = 8;
1668            let bytes_len = len * envelope_size;
1669            let offset = decoder.out_of_line_offset(bytes_len)?;
1670            // Decode the envelope for each type.
1671            let mut _next_ordinal_to_read = 0;
1672            let mut next_offset = offset;
1673            let end_offset = offset + bytes_len;
1674            _next_ordinal_to_read += 1;
1675            if next_offset >= end_offset {
1676                return Ok(());
1677            }
1678
1679            // Decode unknown envelopes for gaps in ordinals.
1680            while _next_ordinal_to_read < 1 {
1681                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1682                _next_ordinal_to_read += 1;
1683                next_offset += envelope_size;
1684            }
1685
1686            let next_out_of_line = decoder.next_out_of_line();
1687            let handles_before = decoder.remaining_handles();
1688            if let Some((inlined, num_bytes, num_handles)) =
1689                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1690            {
1691                let member_inline_size =
1692                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1693                if inlined != (member_inline_size <= 4) {
1694                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1695                }
1696                let inner_offset;
1697                let mut inner_depth = depth.clone();
1698                if inlined {
1699                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1700                    inner_offset = next_offset;
1701                } else {
1702                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1703                    inner_depth.increment()?;
1704                }
1705                let val_ref = self.period.get_or_insert_with(|| fidl::new_empty!(u64, D));
1706                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1707                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1708                {
1709                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1710                }
1711                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1712                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1713                }
1714            }
1715
1716            next_offset += envelope_size;
1717            _next_ordinal_to_read += 1;
1718            if next_offset >= end_offset {
1719                return Ok(());
1720            }
1721
1722            // Decode unknown envelopes for gaps in ordinals.
1723            while _next_ordinal_to_read < 2 {
1724                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1725                _next_ordinal_to_read += 1;
1726                next_offset += envelope_size;
1727            }
1728
1729            let next_out_of_line = decoder.next_out_of_line();
1730            let handles_before = decoder.remaining_handles();
1731            if let Some((inlined, num_bytes, num_handles)) =
1732                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1733            {
1734                let member_inline_size =
1735                    <Counter as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1736                if inlined != (member_inline_size <= 4) {
1737                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1738                }
1739                let inner_offset;
1740                let mut inner_depth = depth.clone();
1741                if inlined {
1742                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1743                    inner_offset = next_offset;
1744                } else {
1745                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1746                    inner_depth.increment()?;
1747                }
1748                let val_ref = self.timebase.get_or_insert_with(|| fidl::new_empty!(Counter, D));
1749                fidl::decode!(Counter, D, val_ref, decoder, inner_offset, inner_depth)?;
1750                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1751                {
1752                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1753                }
1754                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1755                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1756                }
1757            }
1758
1759            next_offset += envelope_size;
1760            _next_ordinal_to_read += 1;
1761            if next_offset >= end_offset {
1762                return Ok(());
1763            }
1764
1765            // Decode unknown envelopes for gaps in ordinals.
1766            while _next_ordinal_to_read < 3 {
1767                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1768                _next_ordinal_to_read += 1;
1769                next_offset += envelope_size;
1770            }
1771
1772            let next_out_of_line = decoder.next_out_of_line();
1773            let handles_before = decoder.remaining_handles();
1774            if let Some((inlined, num_bytes, num_handles)) =
1775                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1776            {
1777                let member_inline_size =
1778                    <Sample as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1779                if inlined != (member_inline_size <= 4) {
1780                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1781                }
1782                let inner_offset;
1783                let mut inner_depth = depth.clone();
1784                if inlined {
1785                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1786                    inner_offset = next_offset;
1787                } else {
1788                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1789                    inner_depth.increment()?;
1790                }
1791                let val_ref = self.sample.get_or_insert_with(|| fidl::new_empty!(Sample, D));
1792                fidl::decode!(Sample, D, val_ref, decoder, inner_offset, inner_depth)?;
1793                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1794                {
1795                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1796                }
1797                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1798                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1799                }
1800            }
1801
1802            next_offset += envelope_size;
1803
1804            // Decode the remaining unknown envelopes.
1805            while next_offset < end_offset {
1806                _next_ordinal_to_read += 1;
1807                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1808                next_offset += envelope_size;
1809            }
1810
1811            Ok(())
1812        }
1813    }
1814
1815    impl SessionStartRequest {
1816        #[inline(always)]
1817        fn max_ordinal_present(&self) -> u64 {
1818            if let Some(_) = self.buffer_results {
1819                return 2;
1820            }
1821            if let Some(_) = self.buffer_size_mb {
1822                return 1;
1823            }
1824            0
1825        }
1826    }
1827
1828    impl fidl::encoding::ValueTypeMarker for SessionStartRequest {
1829        type Borrowed<'a> = &'a Self;
1830        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1831            value
1832        }
1833    }
1834
1835    unsafe impl fidl::encoding::TypeMarker for SessionStartRequest {
1836        type Owned = Self;
1837
1838        #[inline(always)]
1839        fn inline_align(_context: fidl::encoding::Context) -> usize {
1840            8
1841        }
1842
1843        #[inline(always)]
1844        fn inline_size(_context: fidl::encoding::Context) -> usize {
1845            16
1846        }
1847    }
1848
1849    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SessionStartRequest, D>
1850        for &SessionStartRequest
1851    {
1852        unsafe fn encode(
1853            self,
1854            encoder: &mut fidl::encoding::Encoder<'_, D>,
1855            offset: usize,
1856            mut depth: fidl::encoding::Depth,
1857        ) -> fidl::Result<()> {
1858            encoder.debug_check_bounds::<SessionStartRequest>(offset);
1859            // Vector header
1860            let max_ordinal: u64 = self.max_ordinal_present();
1861            encoder.write_num(max_ordinal, offset);
1862            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1863            // Calling encoder.out_of_line_offset(0) is not allowed.
1864            if max_ordinal == 0 {
1865                return Ok(());
1866            }
1867            depth.increment()?;
1868            let envelope_size = 8;
1869            let bytes_len = max_ordinal as usize * envelope_size;
1870            #[allow(unused_variables)]
1871            let offset = encoder.out_of_line_offset(bytes_len);
1872            let mut _prev_end_offset: usize = 0;
1873            if 1 > max_ordinal {
1874                return Ok(());
1875            }
1876
1877            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1878            // are envelope_size bytes.
1879            let cur_offset: usize = (1 - 1) * envelope_size;
1880
1881            // Zero reserved fields.
1882            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1883
1884            // Safety:
1885            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1886            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1887            //   envelope_size bytes, there is always sufficient room.
1888            fidl::encoding::encode_in_envelope_optional::<u64, D>(
1889                self.buffer_size_mb.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1890                encoder,
1891                offset + cur_offset,
1892                depth,
1893            )?;
1894
1895            _prev_end_offset = cur_offset + envelope_size;
1896            if 2 > max_ordinal {
1897                return Ok(());
1898            }
1899
1900            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1901            // are envelope_size bytes.
1902            let cur_offset: usize = (2 - 1) * envelope_size;
1903
1904            // Zero reserved fields.
1905            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1906
1907            // Safety:
1908            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1909            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1910            //   envelope_size bytes, there is always sufficient room.
1911            fidl::encoding::encode_in_envelope_optional::<bool, D>(
1912                self.buffer_results.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1913                encoder,
1914                offset + cur_offset,
1915                depth,
1916            )?;
1917
1918            _prev_end_offset = cur_offset + envelope_size;
1919
1920            Ok(())
1921        }
1922    }
1923
1924    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SessionStartRequest {
1925        #[inline(always)]
1926        fn new_empty() -> Self {
1927            Self::default()
1928        }
1929
1930        unsafe fn decode(
1931            &mut self,
1932            decoder: &mut fidl::encoding::Decoder<'_, D>,
1933            offset: usize,
1934            mut depth: fidl::encoding::Depth,
1935        ) -> fidl::Result<()> {
1936            decoder.debug_check_bounds::<Self>(offset);
1937            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1938                None => return Err(fidl::Error::NotNullable),
1939                Some(len) => len,
1940            };
1941            // Calling decoder.out_of_line_offset(0) is not allowed.
1942            if len == 0 {
1943                return Ok(());
1944            };
1945            depth.increment()?;
1946            let envelope_size = 8;
1947            let bytes_len = len * envelope_size;
1948            let offset = decoder.out_of_line_offset(bytes_len)?;
1949            // Decode the envelope for each type.
1950            let mut _next_ordinal_to_read = 0;
1951            let mut next_offset = offset;
1952            let end_offset = offset + bytes_len;
1953            _next_ordinal_to_read += 1;
1954            if next_offset >= end_offset {
1955                return Ok(());
1956            }
1957
1958            // Decode unknown envelopes for gaps in ordinals.
1959            while _next_ordinal_to_read < 1 {
1960                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1961                _next_ordinal_to_read += 1;
1962                next_offset += envelope_size;
1963            }
1964
1965            let next_out_of_line = decoder.next_out_of_line();
1966            let handles_before = decoder.remaining_handles();
1967            if let Some((inlined, num_bytes, num_handles)) =
1968                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1969            {
1970                let member_inline_size =
1971                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1972                if inlined != (member_inline_size <= 4) {
1973                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1974                }
1975                let inner_offset;
1976                let mut inner_depth = depth.clone();
1977                if inlined {
1978                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1979                    inner_offset = next_offset;
1980                } else {
1981                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1982                    inner_depth.increment()?;
1983                }
1984                let val_ref = self.buffer_size_mb.get_or_insert_with(|| fidl::new_empty!(u64, D));
1985                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1986                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1987                {
1988                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1989                }
1990                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1991                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1992                }
1993            }
1994
1995            next_offset += envelope_size;
1996            _next_ordinal_to_read += 1;
1997            if next_offset >= end_offset {
1998                return Ok(());
1999            }
2000
2001            // Decode unknown envelopes for gaps in ordinals.
2002            while _next_ordinal_to_read < 2 {
2003                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2004                _next_ordinal_to_read += 1;
2005                next_offset += envelope_size;
2006            }
2007
2008            let next_out_of_line = decoder.next_out_of_line();
2009            let handles_before = decoder.remaining_handles();
2010            if let Some((inlined, num_bytes, num_handles)) =
2011                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2012            {
2013                let member_inline_size =
2014                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2015                if inlined != (member_inline_size <= 4) {
2016                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2017                }
2018                let inner_offset;
2019                let mut inner_depth = depth.clone();
2020                if inlined {
2021                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2022                    inner_offset = next_offset;
2023                } else {
2024                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2025                    inner_depth.increment()?;
2026                }
2027                let val_ref = self.buffer_results.get_or_insert_with(|| fidl::new_empty!(bool, D));
2028                fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
2029                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2030                {
2031                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2032                }
2033                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2034                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2035                }
2036            }
2037
2038            next_offset += envelope_size;
2039
2040            // Decode the remaining unknown envelopes.
2041            while next_offset < end_offset {
2042                _next_ordinal_to_read += 1;
2043                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2044                next_offset += envelope_size;
2045            }
2046
2047            Ok(())
2048        }
2049    }
2050
2051    impl SessionStopResponse {
2052        #[inline(always)]
2053        fn max_ordinal_present(&self) -> u64 {
2054            if let Some(_) = self.missing_process_mappings {
2055                return 6;
2056            }
2057            if let Some(_) = self.max_sample_time {
2058                return 5;
2059            }
2060            if let Some(_) = self.min_sample_time {
2061                return 4;
2062            }
2063            if let Some(_) = self.median_sample_time {
2064                return 3;
2065            }
2066            if let Some(_) = self.mean_sample_time {
2067                return 2;
2068            }
2069            if let Some(_) = self.samples_collected {
2070                return 1;
2071            }
2072            0
2073        }
2074    }
2075
2076    impl fidl::encoding::ValueTypeMarker for SessionStopResponse {
2077        type Borrowed<'a> = &'a Self;
2078        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2079            value
2080        }
2081    }
2082
2083    unsafe impl fidl::encoding::TypeMarker for SessionStopResponse {
2084        type Owned = Self;
2085
2086        #[inline(always)]
2087        fn inline_align(_context: fidl::encoding::Context) -> usize {
2088            8
2089        }
2090
2091        #[inline(always)]
2092        fn inline_size(_context: fidl::encoding::Context) -> usize {
2093            16
2094        }
2095    }
2096
2097    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SessionStopResponse, D>
2098        for &SessionStopResponse
2099    {
2100        unsafe fn encode(
2101            self,
2102            encoder: &mut fidl::encoding::Encoder<'_, D>,
2103            offset: usize,
2104            mut depth: fidl::encoding::Depth,
2105        ) -> fidl::Result<()> {
2106            encoder.debug_check_bounds::<SessionStopResponse>(offset);
2107            // Vector header
2108            let max_ordinal: u64 = self.max_ordinal_present();
2109            encoder.write_num(max_ordinal, offset);
2110            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2111            // Calling encoder.out_of_line_offset(0) is not allowed.
2112            if max_ordinal == 0 {
2113                return Ok(());
2114            }
2115            depth.increment()?;
2116            let envelope_size = 8;
2117            let bytes_len = max_ordinal as usize * envelope_size;
2118            #[allow(unused_variables)]
2119            let offset = encoder.out_of_line_offset(bytes_len);
2120            let mut _prev_end_offset: usize = 0;
2121            if 1 > max_ordinal {
2122                return Ok(());
2123            }
2124
2125            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2126            // are envelope_size bytes.
2127            let cur_offset: usize = (1 - 1) * envelope_size;
2128
2129            // Zero reserved fields.
2130            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2131
2132            // Safety:
2133            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2134            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2135            //   envelope_size bytes, there is always sufficient room.
2136            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2137                self.samples_collected
2138                    .as_ref()
2139                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2140                encoder,
2141                offset + cur_offset,
2142                depth,
2143            )?;
2144
2145            _prev_end_offset = cur_offset + envelope_size;
2146            if 2 > max_ordinal {
2147                return Ok(());
2148            }
2149
2150            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2151            // are envelope_size bytes.
2152            let cur_offset: usize = (2 - 1) * envelope_size;
2153
2154            // Zero reserved fields.
2155            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2156
2157            // Safety:
2158            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2159            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2160            //   envelope_size bytes, there is always sufficient room.
2161            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2162                self.mean_sample_time
2163                    .as_ref()
2164                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2165                encoder,
2166                offset + cur_offset,
2167                depth,
2168            )?;
2169
2170            _prev_end_offset = cur_offset + envelope_size;
2171            if 3 > max_ordinal {
2172                return Ok(());
2173            }
2174
2175            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2176            // are envelope_size bytes.
2177            let cur_offset: usize = (3 - 1) * envelope_size;
2178
2179            // Zero reserved fields.
2180            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2181
2182            // Safety:
2183            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2184            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2185            //   envelope_size bytes, there is always sufficient room.
2186            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2187                self.median_sample_time
2188                    .as_ref()
2189                    .map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2190                encoder,
2191                offset + cur_offset,
2192                depth,
2193            )?;
2194
2195            _prev_end_offset = cur_offset + envelope_size;
2196            if 4 > max_ordinal {
2197                return Ok(());
2198            }
2199
2200            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2201            // are envelope_size bytes.
2202            let cur_offset: usize = (4 - 1) * envelope_size;
2203
2204            // Zero reserved fields.
2205            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2206
2207            // Safety:
2208            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2209            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2210            //   envelope_size bytes, there is always sufficient room.
2211            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2212                self.min_sample_time.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2213                encoder,
2214                offset + cur_offset,
2215                depth,
2216            )?;
2217
2218            _prev_end_offset = cur_offset + envelope_size;
2219            if 5 > max_ordinal {
2220                return Ok(());
2221            }
2222
2223            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2224            // are envelope_size bytes.
2225            let cur_offset: usize = (5 - 1) * envelope_size;
2226
2227            // Zero reserved fields.
2228            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2229
2230            // Safety:
2231            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2232            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2233            //   envelope_size bytes, there is always sufficient room.
2234            fidl::encoding::encode_in_envelope_optional::<u64, D>(
2235                self.max_sample_time.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2236                encoder,
2237                offset + cur_offset,
2238                depth,
2239            )?;
2240
2241            _prev_end_offset = cur_offset + envelope_size;
2242            if 6 > max_ordinal {
2243                return Ok(());
2244            }
2245
2246            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
2247            // are envelope_size bytes.
2248            let cur_offset: usize = (6 - 1) * envelope_size;
2249
2250            // Zero reserved fields.
2251            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2252
2253            // Safety:
2254            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
2255            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
2256            //   envelope_size bytes, there is always sufficient room.
2257            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u64>, D>(
2258            self.missing_process_mappings.as_ref().map(<fidl::encoding::UnboundedVector<u64> as fidl::encoding::ValueTypeMarker>::borrow),
2259            encoder, offset + cur_offset, depth
2260        )?;
2261
2262            _prev_end_offset = cur_offset + envelope_size;
2263
2264            Ok(())
2265        }
2266    }
2267
2268    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SessionStopResponse {
2269        #[inline(always)]
2270        fn new_empty() -> Self {
2271            Self::default()
2272        }
2273
2274        unsafe fn decode(
2275            &mut self,
2276            decoder: &mut fidl::encoding::Decoder<'_, D>,
2277            offset: usize,
2278            mut depth: fidl::encoding::Depth,
2279        ) -> fidl::Result<()> {
2280            decoder.debug_check_bounds::<Self>(offset);
2281            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2282                None => return Err(fidl::Error::NotNullable),
2283                Some(len) => len,
2284            };
2285            // Calling decoder.out_of_line_offset(0) is not allowed.
2286            if len == 0 {
2287                return Ok(());
2288            };
2289            depth.increment()?;
2290            let envelope_size = 8;
2291            let bytes_len = len * envelope_size;
2292            let offset = decoder.out_of_line_offset(bytes_len)?;
2293            // Decode the envelope for each type.
2294            let mut _next_ordinal_to_read = 0;
2295            let mut next_offset = offset;
2296            let end_offset = offset + bytes_len;
2297            _next_ordinal_to_read += 1;
2298            if next_offset >= end_offset {
2299                return Ok(());
2300            }
2301
2302            // Decode unknown envelopes for gaps in ordinals.
2303            while _next_ordinal_to_read < 1 {
2304                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2305                _next_ordinal_to_read += 1;
2306                next_offset += envelope_size;
2307            }
2308
2309            let next_out_of_line = decoder.next_out_of_line();
2310            let handles_before = decoder.remaining_handles();
2311            if let Some((inlined, num_bytes, num_handles)) =
2312                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2313            {
2314                let member_inline_size =
2315                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2316                if inlined != (member_inline_size <= 4) {
2317                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2318                }
2319                let inner_offset;
2320                let mut inner_depth = depth.clone();
2321                if inlined {
2322                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2323                    inner_offset = next_offset;
2324                } else {
2325                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2326                    inner_depth.increment()?;
2327                }
2328                let val_ref =
2329                    self.samples_collected.get_or_insert_with(|| fidl::new_empty!(u64, D));
2330                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2331                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2332                {
2333                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2334                }
2335                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2336                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2337                }
2338            }
2339
2340            next_offset += envelope_size;
2341            _next_ordinal_to_read += 1;
2342            if next_offset >= end_offset {
2343                return Ok(());
2344            }
2345
2346            // Decode unknown envelopes for gaps in ordinals.
2347            while _next_ordinal_to_read < 2 {
2348                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2349                _next_ordinal_to_read += 1;
2350                next_offset += envelope_size;
2351            }
2352
2353            let next_out_of_line = decoder.next_out_of_line();
2354            let handles_before = decoder.remaining_handles();
2355            if let Some((inlined, num_bytes, num_handles)) =
2356                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2357            {
2358                let member_inline_size =
2359                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2360                if inlined != (member_inline_size <= 4) {
2361                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2362                }
2363                let inner_offset;
2364                let mut inner_depth = depth.clone();
2365                if inlined {
2366                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2367                    inner_offset = next_offset;
2368                } else {
2369                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2370                    inner_depth.increment()?;
2371                }
2372                let val_ref = self.mean_sample_time.get_or_insert_with(|| fidl::new_empty!(u64, D));
2373                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2374                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2375                {
2376                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2377                }
2378                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2379                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2380                }
2381            }
2382
2383            next_offset += envelope_size;
2384            _next_ordinal_to_read += 1;
2385            if next_offset >= end_offset {
2386                return Ok(());
2387            }
2388
2389            // Decode unknown envelopes for gaps in ordinals.
2390            while _next_ordinal_to_read < 3 {
2391                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2392                _next_ordinal_to_read += 1;
2393                next_offset += envelope_size;
2394            }
2395
2396            let next_out_of_line = decoder.next_out_of_line();
2397            let handles_before = decoder.remaining_handles();
2398            if let Some((inlined, num_bytes, num_handles)) =
2399                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2400            {
2401                let member_inline_size =
2402                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2403                if inlined != (member_inline_size <= 4) {
2404                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2405                }
2406                let inner_offset;
2407                let mut inner_depth = depth.clone();
2408                if inlined {
2409                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2410                    inner_offset = next_offset;
2411                } else {
2412                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2413                    inner_depth.increment()?;
2414                }
2415                let val_ref =
2416                    self.median_sample_time.get_or_insert_with(|| fidl::new_empty!(u64, D));
2417                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2418                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2419                {
2420                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2421                }
2422                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2423                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2424                }
2425            }
2426
2427            next_offset += envelope_size;
2428            _next_ordinal_to_read += 1;
2429            if next_offset >= end_offset {
2430                return Ok(());
2431            }
2432
2433            // Decode unknown envelopes for gaps in ordinals.
2434            while _next_ordinal_to_read < 4 {
2435                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2436                _next_ordinal_to_read += 1;
2437                next_offset += envelope_size;
2438            }
2439
2440            let next_out_of_line = decoder.next_out_of_line();
2441            let handles_before = decoder.remaining_handles();
2442            if let Some((inlined, num_bytes, num_handles)) =
2443                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2444            {
2445                let member_inline_size =
2446                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2447                if inlined != (member_inline_size <= 4) {
2448                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2449                }
2450                let inner_offset;
2451                let mut inner_depth = depth.clone();
2452                if inlined {
2453                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2454                    inner_offset = next_offset;
2455                } else {
2456                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2457                    inner_depth.increment()?;
2458                }
2459                let val_ref = self.min_sample_time.get_or_insert_with(|| fidl::new_empty!(u64, D));
2460                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2461                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2462                {
2463                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2464                }
2465                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2466                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2467                }
2468            }
2469
2470            next_offset += envelope_size;
2471            _next_ordinal_to_read += 1;
2472            if next_offset >= end_offset {
2473                return Ok(());
2474            }
2475
2476            // Decode unknown envelopes for gaps in ordinals.
2477            while _next_ordinal_to_read < 5 {
2478                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2479                _next_ordinal_to_read += 1;
2480                next_offset += envelope_size;
2481            }
2482
2483            let next_out_of_line = decoder.next_out_of_line();
2484            let handles_before = decoder.remaining_handles();
2485            if let Some((inlined, num_bytes, num_handles)) =
2486                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2487            {
2488                let member_inline_size =
2489                    <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2490                if inlined != (member_inline_size <= 4) {
2491                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2492                }
2493                let inner_offset;
2494                let mut inner_depth = depth.clone();
2495                if inlined {
2496                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2497                    inner_offset = next_offset;
2498                } else {
2499                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2500                    inner_depth.increment()?;
2501                }
2502                let val_ref = self.max_sample_time.get_or_insert_with(|| fidl::new_empty!(u64, D));
2503                fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
2504                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2505                {
2506                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2507                }
2508                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2509                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2510                }
2511            }
2512
2513            next_offset += envelope_size;
2514            _next_ordinal_to_read += 1;
2515            if next_offset >= end_offset {
2516                return Ok(());
2517            }
2518
2519            // Decode unknown envelopes for gaps in ordinals.
2520            while _next_ordinal_to_read < 6 {
2521                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2522                _next_ordinal_to_read += 1;
2523                next_offset += envelope_size;
2524            }
2525
2526            let next_out_of_line = decoder.next_out_of_line();
2527            let handles_before = decoder.remaining_handles();
2528            if let Some((inlined, num_bytes, num_handles)) =
2529                fidl::encoding::decode_envelope_header(decoder, next_offset)?
2530            {
2531                let member_inline_size = <fidl::encoding::UnboundedVector<u64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2532                if inlined != (member_inline_size <= 4) {
2533                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
2534                }
2535                let inner_offset;
2536                let mut inner_depth = depth.clone();
2537                if inlined {
2538                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2539                    inner_offset = next_offset;
2540                } else {
2541                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2542                    inner_depth.increment()?;
2543                }
2544                let val_ref = self.missing_process_mappings.get_or_insert_with(|| {
2545                    fidl::new_empty!(fidl::encoding::UnboundedVector<u64>, D)
2546                });
2547                fidl::decode!(
2548                    fidl::encoding::UnboundedVector<u64>,
2549                    D,
2550                    val_ref,
2551                    decoder,
2552                    inner_offset,
2553                    inner_depth
2554                )?;
2555                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2556                {
2557                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
2558                }
2559                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2560                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2561                }
2562            }
2563
2564            next_offset += envelope_size;
2565
2566            // Decode the remaining unknown envelopes.
2567            while next_offset < end_offset {
2568                _next_ordinal_to_read += 1;
2569                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2570                next_offset += envelope_size;
2571            }
2572
2573            Ok(())
2574        }
2575    }
2576
2577    impl fidl::encoding::ValueTypeMarker for Counter {
2578        type Borrowed<'a> = &'a Self;
2579        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2580            value
2581        }
2582    }
2583
2584    unsafe impl fidl::encoding::TypeMarker for Counter {
2585        type Owned = Self;
2586
2587        #[inline(always)]
2588        fn inline_align(_context: fidl::encoding::Context) -> usize {
2589            8
2590        }
2591
2592        #[inline(always)]
2593        fn inline_size(_context: fidl::encoding::Context) -> usize {
2594            16
2595        }
2596    }
2597
2598    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Counter, D> for &Counter {
2599        #[inline]
2600        unsafe fn encode(
2601            self,
2602            encoder: &mut fidl::encoding::Encoder<'_, D>,
2603            offset: usize,
2604            _depth: fidl::encoding::Depth,
2605        ) -> fidl::Result<()> {
2606            encoder.debug_check_bounds::<Counter>(offset);
2607            encoder.write_num::<u64>(self.ordinal(), offset);
2608            match self {
2609                Counter::PlatformIndependent(ref val) => {
2610                    fidl::encoding::encode_in_envelope::<CounterId, D>(
2611                        <CounterId as fidl::encoding::ValueTypeMarker>::borrow(val),
2612                        encoder,
2613                        offset + 8,
2614                        _depth,
2615                    )
2616                }
2617                Counter::PlatformDependent(ref val) => {
2618                    fidl::encoding::encode_in_envelope::<u32, D>(
2619                        <u32 as fidl::encoding::ValueTypeMarker>::borrow(val),
2620                        encoder,
2621                        offset + 8,
2622                        _depth,
2623                    )
2624                }
2625                Counter::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2626            }
2627        }
2628    }
2629
2630    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Counter {
2631        #[inline(always)]
2632        fn new_empty() -> Self {
2633            Self::__SourceBreaking { unknown_ordinal: 0 }
2634        }
2635
2636        #[inline]
2637        unsafe fn decode(
2638            &mut self,
2639            decoder: &mut fidl::encoding::Decoder<'_, D>,
2640            offset: usize,
2641            mut depth: fidl::encoding::Depth,
2642        ) -> fidl::Result<()> {
2643            decoder.debug_check_bounds::<Self>(offset);
2644            #[allow(unused_variables)]
2645            let next_out_of_line = decoder.next_out_of_line();
2646            let handles_before = decoder.remaining_handles();
2647            let (ordinal, inlined, num_bytes, num_handles) =
2648                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2649
2650            let member_inline_size = match ordinal {
2651                1 => <CounterId as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2652                2 => <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2653                0 => return Err(fidl::Error::UnknownUnionTag),
2654                _ => num_bytes as usize,
2655            };
2656
2657            if inlined != (member_inline_size <= 4) {
2658                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2659            }
2660            let _inner_offset;
2661            if inlined {
2662                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2663                _inner_offset = offset + 8;
2664            } else {
2665                depth.increment()?;
2666                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2667            }
2668            match ordinal {
2669                1 => {
2670                    #[allow(irrefutable_let_patterns)]
2671                    if let Counter::PlatformIndependent(_) = self {
2672                        // Do nothing, read the value into the object
2673                    } else {
2674                        // Initialize `self` to the right variant
2675                        *self = Counter::PlatformIndependent(fidl::new_empty!(CounterId, D));
2676                    }
2677                    #[allow(irrefutable_let_patterns)]
2678                    if let Counter::PlatformIndependent(ref mut val) = self {
2679                        fidl::decode!(CounterId, D, val, decoder, _inner_offset, depth)?;
2680                    } else {
2681                        unreachable!()
2682                    }
2683                }
2684                2 => {
2685                    #[allow(irrefutable_let_patterns)]
2686                    if let Counter::PlatformDependent(_) = self {
2687                        // Do nothing, read the value into the object
2688                    } else {
2689                        // Initialize `self` to the right variant
2690                        *self = Counter::PlatformDependent(fidl::new_empty!(u32, D));
2691                    }
2692                    #[allow(irrefutable_let_patterns)]
2693                    if let Counter::PlatformDependent(ref mut val) = self {
2694                        fidl::decode!(u32, D, val, decoder, _inner_offset, depth)?;
2695                    } else {
2696                        unreachable!()
2697                    }
2698                }
2699                #[allow(deprecated)]
2700                ordinal => {
2701                    for _ in 0..num_handles {
2702                        decoder.drop_next_handle()?;
2703                    }
2704                    *self = Counter::__SourceBreaking { unknown_ordinal: ordinal };
2705                }
2706            }
2707            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2708                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2709            }
2710            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2711                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2712            }
2713            Ok(())
2714        }
2715    }
2716
2717    impl fidl::encoding::ValueTypeMarker for Task {
2718        type Borrowed<'a> = &'a Self;
2719        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2720            value
2721        }
2722    }
2723
2724    unsafe impl fidl::encoding::TypeMarker for Task {
2725        type Owned = Self;
2726
2727        #[inline(always)]
2728        fn inline_align(_context: fidl::encoding::Context) -> usize {
2729            8
2730        }
2731
2732        #[inline(always)]
2733        fn inline_size(_context: fidl::encoding::Context) -> usize {
2734            16
2735        }
2736    }
2737
2738    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Task, D> for &Task {
2739        #[inline]
2740        unsafe fn encode(
2741            self,
2742            encoder: &mut fidl::encoding::Encoder<'_, D>,
2743            offset: usize,
2744            _depth: fidl::encoding::Depth,
2745        ) -> fidl::Result<()> {
2746            encoder.debug_check_bounds::<Task>(offset);
2747            encoder.write_num::<u64>(self.ordinal(), offset);
2748            match self {
2749                Task::Process(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2750                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2751                    encoder,
2752                    offset + 8,
2753                    _depth,
2754                ),
2755                Task::Thread(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2756                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2757                    encoder,
2758                    offset + 8,
2759                    _depth,
2760                ),
2761                Task::Job(ref val) => fidl::encoding::encode_in_envelope::<u64, D>(
2762                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(val),
2763                    encoder,
2764                    offset + 8,
2765                    _depth,
2766                ),
2767                Task::SystemWide(ref val) => fidl::encoding::encode_in_envelope::<SystemWide, D>(
2768                    <SystemWide as fidl::encoding::ValueTypeMarker>::borrow(val),
2769                    encoder,
2770                    offset + 8,
2771                    _depth,
2772                ),
2773                Task::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2774            }
2775        }
2776    }
2777
2778    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Task {
2779        #[inline(always)]
2780        fn new_empty() -> Self {
2781            Self::__SourceBreaking { unknown_ordinal: 0 }
2782        }
2783
2784        #[inline]
2785        unsafe fn decode(
2786            &mut self,
2787            decoder: &mut fidl::encoding::Decoder<'_, D>,
2788            offset: usize,
2789            mut depth: fidl::encoding::Depth,
2790        ) -> fidl::Result<()> {
2791            decoder.debug_check_bounds::<Self>(offset);
2792            #[allow(unused_variables)]
2793            let next_out_of_line = decoder.next_out_of_line();
2794            let handles_before = decoder.remaining_handles();
2795            let (ordinal, inlined, num_bytes, num_handles) =
2796                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2797
2798            let member_inline_size = match ordinal {
2799                1 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2800                2 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2801                3 => <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2802                4 => <SystemWide as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2803                0 => return Err(fidl::Error::UnknownUnionTag),
2804                _ => num_bytes as usize,
2805            };
2806
2807            if inlined != (member_inline_size <= 4) {
2808                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2809            }
2810            let _inner_offset;
2811            if inlined {
2812                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2813                _inner_offset = offset + 8;
2814            } else {
2815                depth.increment()?;
2816                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2817            }
2818            match ordinal {
2819                1 => {
2820                    #[allow(irrefutable_let_patterns)]
2821                    if let Task::Process(_) = self {
2822                        // Do nothing, read the value into the object
2823                    } else {
2824                        // Initialize `self` to the right variant
2825                        *self = Task::Process(fidl::new_empty!(u64, D));
2826                    }
2827                    #[allow(irrefutable_let_patterns)]
2828                    if let Task::Process(ref mut val) = self {
2829                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2830                    } else {
2831                        unreachable!()
2832                    }
2833                }
2834                2 => {
2835                    #[allow(irrefutable_let_patterns)]
2836                    if let Task::Thread(_) = self {
2837                        // Do nothing, read the value into the object
2838                    } else {
2839                        // Initialize `self` to the right variant
2840                        *self = Task::Thread(fidl::new_empty!(u64, D));
2841                    }
2842                    #[allow(irrefutable_let_patterns)]
2843                    if let Task::Thread(ref mut val) = self {
2844                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2845                    } else {
2846                        unreachable!()
2847                    }
2848                }
2849                3 => {
2850                    #[allow(irrefutable_let_patterns)]
2851                    if let Task::Job(_) = self {
2852                        // Do nothing, read the value into the object
2853                    } else {
2854                        // Initialize `self` to the right variant
2855                        *self = Task::Job(fidl::new_empty!(u64, D));
2856                    }
2857                    #[allow(irrefutable_let_patterns)]
2858                    if let Task::Job(ref mut val) = self {
2859                        fidl::decode!(u64, D, val, decoder, _inner_offset, depth)?;
2860                    } else {
2861                        unreachable!()
2862                    }
2863                }
2864                4 => {
2865                    #[allow(irrefutable_let_patterns)]
2866                    if let Task::SystemWide(_) = self {
2867                        // Do nothing, read the value into the object
2868                    } else {
2869                        // Initialize `self` to the right variant
2870                        *self = Task::SystemWide(fidl::new_empty!(SystemWide, D));
2871                    }
2872                    #[allow(irrefutable_let_patterns)]
2873                    if let Task::SystemWide(ref mut val) = self {
2874                        fidl::decode!(SystemWide, D, val, decoder, _inner_offset, depth)?;
2875                    } else {
2876                        unreachable!()
2877                    }
2878                }
2879                #[allow(deprecated)]
2880                ordinal => {
2881                    for _ in 0..num_handles {
2882                        decoder.drop_next_handle()?;
2883                    }
2884                    *self = Task::__SourceBreaking { unknown_ordinal: ordinal };
2885                }
2886            }
2887            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2888                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2889            }
2890            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2891                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2892            }
2893            Ok(())
2894        }
2895    }
2896}