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