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