fidl_fuchsia_power_metrics_common/
fidl_fuchsia_power_metrics_common.rs

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