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