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