Skip to main content

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