fidl_fuchsia_media2/
fidl_fuchsia_media2.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13/// Used to indicate why a consumer has closed a stream sink connection.
14/// TODO(dalesat): Expand this enum as needed.
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16pub enum ConsumerClosedReason {
17    /// The consumer's client requested that the connection be closed.
18    RequestedByClient,
19    /// The client violated the StreamSink protocol. For example, the client's
20    /// StartSegmeent call did not use a strictly-increasing ID.
21    ProtocolError,
22    /// The client sent an invalid Packet.
23    InvalidPacket,
24    #[doc(hidden)]
25    __SourceBreaking { unknown_ordinal: u32 },
26}
27
28/// Pattern that matches an unknown `ConsumerClosedReason` member.
29#[macro_export]
30macro_rules! ConsumerClosedReasonUnknown {
31    () => {
32        _
33    };
34}
35
36impl ConsumerClosedReason {
37    #[inline]
38    pub fn from_primitive(prim: u32) -> Option<Self> {
39        match prim {
40            1 => Some(Self::RequestedByClient),
41            2 => Some(Self::ProtocolError),
42            3 => Some(Self::InvalidPacket),
43            _ => None,
44        }
45    }
46
47    #[inline]
48    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
49        match prim {
50            1 => Self::RequestedByClient,
51            2 => Self::ProtocolError,
52            3 => Self::InvalidPacket,
53            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
54        }
55    }
56
57    #[inline]
58    pub fn unknown() -> Self {
59        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
60    }
61
62    #[inline]
63    pub const fn into_primitive(self) -> u32 {
64        match self {
65            Self::RequestedByClient => 1,
66            Self::ProtocolError => 2,
67            Self::InvalidPacket => 3,
68            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
69        }
70    }
71
72    #[inline]
73    pub fn is_unknown(&self) -> bool {
74        match self {
75            Self::__SourceBreaking { unknown_ordinal: _ } => true,
76            _ => false,
77        }
78    }
79}
80
81/// Used to indicate why a producer has closed a stream sink connection.
82/// TODO(dalesat): Expand this enum as needed.
83#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
84pub enum ProducerClosedReason {
85    /// The producer's client requested that the connection be closed.
86    RequestedByClient,
87    #[doc(hidden)]
88    __SourceBreaking { unknown_ordinal: u32 },
89}
90
91/// Pattern that matches an unknown `ProducerClosedReason` member.
92#[macro_export]
93macro_rules! ProducerClosedReasonUnknown {
94    () => {
95        _
96    };
97}
98
99impl ProducerClosedReason {
100    #[inline]
101    pub fn from_primitive(prim: u32) -> Option<Self> {
102        match prim {
103            1 => Some(Self::RequestedByClient),
104            _ => None,
105        }
106    }
107
108    #[inline]
109    pub fn from_primitive_allow_unknown(prim: u32) -> Self {
110        match prim {
111            1 => Self::RequestedByClient,
112            unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
113        }
114    }
115
116    #[inline]
117    pub fn unknown() -> Self {
118        Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
119    }
120
121    #[inline]
122    pub const fn into_primitive(self) -> u32 {
123        match self {
124            Self::RequestedByClient => 1,
125            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
126        }
127    }
128
129    #[inline]
130    pub fn is_unknown(&self) -> bool {
131        match self {
132            Self::__SourceBreaking { unknown_ordinal: _ } => true,
133            _ => false,
134        }
135    }
136}
137
138/// As soon as possible.
139#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
140pub struct Asap;
141
142impl fidl::Persistable for Asap {}
143
144/// Describes a packet payload.
145#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146#[repr(C)]
147pub struct PayloadRange {
148    /// The id of the buffer in which the payload resides.
149    pub buffer_id: u32,
150    /// The offset of the payload in the specified buffer.
151    pub offset: u64,
152    /// The size in bytes of the payload.
153    pub size: u64,
154}
155
156impl fidl::Persistable for PayloadRange {}
157
158/// Specifies a real time or a stream time. Real time is expressed using a
159/// system monotonic or reference clock time. Stream time is expressed either as
160/// a duration or as a packet timestamp in the relevant units. This type is used
161/// when a transport control operation is to occur using a time value that is
162/// meaningful when the transport is progressing.
163#[derive(Clone, Debug)]
164pub enum RealOrStreamTime {
165    /// As soon as possible.
166    Asap(Asap),
167    /// Real time according to the system monotonic clock.
168    SystemTime(i64),
169    /// Real time according to the relevant reference clock. If no reference
170    /// clock (other than the system clock) is relevant, this is equivalent to
171    /// `system_time`.
172    ReferenceTime(i64),
173    /// Stream time expressed as a duration (nanoseconds).
174    StreamTime(i64),
175    /// Stream time expressed in the same timestamps that are used on the
176    /// relevant packets.
177    PacketTimestamp(i64),
178    #[doc(hidden)]
179    __SourceBreaking { unknown_ordinal: u64 },
180}
181
182/// Pattern that matches an unknown `RealOrStreamTime` member.
183#[macro_export]
184macro_rules! RealOrStreamTimeUnknown {
185    () => {
186        _
187    };
188}
189
190// Custom PartialEq so that unknown variants are not equal to themselves.
191impl PartialEq for RealOrStreamTime {
192    fn eq(&self, other: &Self) -> bool {
193        match (self, other) {
194            (Self::Asap(x), Self::Asap(y)) => *x == *y,
195            (Self::SystemTime(x), Self::SystemTime(y)) => *x == *y,
196            (Self::ReferenceTime(x), Self::ReferenceTime(y)) => *x == *y,
197            (Self::StreamTime(x), Self::StreamTime(y)) => *x == *y,
198            (Self::PacketTimestamp(x), Self::PacketTimestamp(y)) => *x == *y,
199            _ => false,
200        }
201    }
202}
203
204impl RealOrStreamTime {
205    #[inline]
206    pub fn ordinal(&self) -> u64 {
207        match *self {
208            Self::Asap(_) => 1,
209            Self::SystemTime(_) => 2,
210            Self::ReferenceTime(_) => 3,
211            Self::StreamTime(_) => 4,
212            Self::PacketTimestamp(_) => 5,
213            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
214        }
215    }
216
217    #[inline]
218    pub fn unknown_variant_for_testing() -> Self {
219        Self::__SourceBreaking { unknown_ordinal: 0 }
220    }
221
222    #[inline]
223    pub fn is_unknown(&self) -> bool {
224        match self {
225            Self::__SourceBreaking { .. } => true,
226            _ => false,
227        }
228    }
229}
230
231impl fidl::Persistable for RealOrStreamTime {}
232
233/// Specifies a real time using a system monotonic or reference clock time or an
234/// option specifying ‘as soon as possible’. This type is used when a transport
235/// control operation is to occur using a time value that is meaningful when the
236/// transport is stopped.
237#[derive(Clone, Debug)]
238pub enum RealTime {
239    /// As soon as possible.
240    Asap(Asap),
241    /// Real time according to the system monotonic clock.
242    SystemTime(i64),
243    /// Real time according to the relevant reference clock. If no reference
244    /// clock (other than the system clock) is relevant, this is equivalent to
245    /// `system_time`.
246    ReferenceTime(i64),
247    #[doc(hidden)]
248    __SourceBreaking { unknown_ordinal: u64 },
249}
250
251/// Pattern that matches an unknown `RealTime` member.
252#[macro_export]
253macro_rules! RealTimeUnknown {
254    () => {
255        _
256    };
257}
258
259// Custom PartialEq so that unknown variants are not equal to themselves.
260impl PartialEq for RealTime {
261    fn eq(&self, other: &Self) -> bool {
262        match (self, other) {
263            (Self::Asap(x), Self::Asap(y)) => *x == *y,
264            (Self::SystemTime(x), Self::SystemTime(y)) => *x == *y,
265            (Self::ReferenceTime(x), Self::ReferenceTime(y)) => *x == *y,
266            _ => false,
267        }
268    }
269}
270
271impl RealTime {
272    #[inline]
273    pub fn ordinal(&self) -> u64 {
274        match *self {
275            Self::Asap(_) => 1,
276            Self::SystemTime(_) => 2,
277            Self::ReferenceTime(_) => 3,
278            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
279        }
280    }
281
282    #[inline]
283    pub fn unknown_variant_for_testing() -> Self {
284        Self::__SourceBreaking { unknown_ordinal: 0 }
285    }
286
287    #[inline]
288    pub fn is_unknown(&self) -> bool {
289        match self {
290            Self::__SourceBreaking { .. } => true,
291            _ => false,
292        }
293    }
294}
295
296impl fidl::Persistable for RealTime {}
297
298/// Specifies a stream time either as a duration or as a packet timestamp in the
299/// relevant timestamp units. This type is used when a transport control
300/// operation is to define a positional offset value that is relative to the
301/// beginning of the stream.
302#[derive(Clone, Debug)]
303pub enum StreamTime {
304    /// Stream time expressed as a duration (nanoseconds).
305    StreamTime(i64),
306    /// Stream time expressed in the same timestamps that are used on the
307    /// relevant packets.
308    PacketTimestamp(i64),
309    #[doc(hidden)]
310    __SourceBreaking { unknown_ordinal: u64 },
311}
312
313/// Pattern that matches an unknown `StreamTime` member.
314#[macro_export]
315macro_rules! StreamTimeUnknown {
316    () => {
317        _
318    };
319}
320
321// Custom PartialEq so that unknown variants are not equal to themselves.
322impl PartialEq for StreamTime {
323    fn eq(&self, other: &Self) -> bool {
324        match (self, other) {
325            (Self::StreamTime(x), Self::StreamTime(y)) => *x == *y,
326            (Self::PacketTimestamp(x), Self::PacketTimestamp(y)) => *x == *y,
327            _ => false,
328        }
329    }
330}
331
332impl StreamTime {
333    #[inline]
334    pub fn ordinal(&self) -> u64 {
335        match *self {
336            Self::StreamTime(_) => 1,
337            Self::PacketTimestamp(_) => 2,
338            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
339        }
340    }
341
342    #[inline]
343    pub fn unknown_variant_for_testing() -> Self {
344        Self::__SourceBreaking { unknown_ordinal: 0 }
345    }
346
347    #[inline]
348    pub fn is_unknown(&self) -> bool {
349        match self {
350            Self::__SourceBreaking { .. } => true,
351            _ => false,
352        }
353    }
354}
355
356impl fidl::Persistable for StreamTime {}
357
358mod internal {
359    use super::*;
360    unsafe impl fidl::encoding::TypeMarker for ConsumerClosedReason {
361        type Owned = Self;
362
363        #[inline(always)]
364        fn inline_align(_context: fidl::encoding::Context) -> usize {
365            std::mem::align_of::<u32>()
366        }
367
368        #[inline(always)]
369        fn inline_size(_context: fidl::encoding::Context) -> usize {
370            std::mem::size_of::<u32>()
371        }
372
373        #[inline(always)]
374        fn encode_is_copy() -> bool {
375            false
376        }
377
378        #[inline(always)]
379        fn decode_is_copy() -> bool {
380            false
381        }
382    }
383
384    impl fidl::encoding::ValueTypeMarker for ConsumerClosedReason {
385        type Borrowed<'a> = Self;
386        #[inline(always)]
387        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
388            *value
389        }
390    }
391
392    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
393        for ConsumerClosedReason
394    {
395        #[inline]
396        unsafe fn encode(
397            self,
398            encoder: &mut fidl::encoding::Encoder<'_, D>,
399            offset: usize,
400            _depth: fidl::encoding::Depth,
401        ) -> fidl::Result<()> {
402            encoder.debug_check_bounds::<Self>(offset);
403            encoder.write_num(self.into_primitive(), offset);
404            Ok(())
405        }
406    }
407
408    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ConsumerClosedReason {
409        #[inline(always)]
410        fn new_empty() -> Self {
411            Self::unknown()
412        }
413
414        #[inline]
415        unsafe fn decode(
416            &mut self,
417            decoder: &mut fidl::encoding::Decoder<'_, D>,
418            offset: usize,
419            _depth: fidl::encoding::Depth,
420        ) -> fidl::Result<()> {
421            decoder.debug_check_bounds::<Self>(offset);
422            let prim = decoder.read_num::<u32>(offset);
423
424            *self = Self::from_primitive_allow_unknown(prim);
425            Ok(())
426        }
427    }
428    unsafe impl fidl::encoding::TypeMarker for ProducerClosedReason {
429        type Owned = Self;
430
431        #[inline(always)]
432        fn inline_align(_context: fidl::encoding::Context) -> usize {
433            std::mem::align_of::<u32>()
434        }
435
436        #[inline(always)]
437        fn inline_size(_context: fidl::encoding::Context) -> usize {
438            std::mem::size_of::<u32>()
439        }
440
441        #[inline(always)]
442        fn encode_is_copy() -> bool {
443            false
444        }
445
446        #[inline(always)]
447        fn decode_is_copy() -> bool {
448            false
449        }
450    }
451
452    impl fidl::encoding::ValueTypeMarker for ProducerClosedReason {
453        type Borrowed<'a> = Self;
454        #[inline(always)]
455        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
456            *value
457        }
458    }
459
460    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
461        for ProducerClosedReason
462    {
463        #[inline]
464        unsafe fn encode(
465            self,
466            encoder: &mut fidl::encoding::Encoder<'_, D>,
467            offset: usize,
468            _depth: fidl::encoding::Depth,
469        ) -> fidl::Result<()> {
470            encoder.debug_check_bounds::<Self>(offset);
471            encoder.write_num(self.into_primitive(), offset);
472            Ok(())
473        }
474    }
475
476    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProducerClosedReason {
477        #[inline(always)]
478        fn new_empty() -> Self {
479            Self::unknown()
480        }
481
482        #[inline]
483        unsafe fn decode(
484            &mut self,
485            decoder: &mut fidl::encoding::Decoder<'_, D>,
486            offset: usize,
487            _depth: fidl::encoding::Depth,
488        ) -> fidl::Result<()> {
489            decoder.debug_check_bounds::<Self>(offset);
490            let prim = decoder.read_num::<u32>(offset);
491
492            *self = Self::from_primitive_allow_unknown(prim);
493            Ok(())
494        }
495    }
496
497    impl fidl::encoding::ValueTypeMarker for Asap {
498        type Borrowed<'a> = &'a Self;
499        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
500            value
501        }
502    }
503
504    unsafe impl fidl::encoding::TypeMarker for Asap {
505        type Owned = Self;
506
507        #[inline(always)]
508        fn inline_align(_context: fidl::encoding::Context) -> usize {
509            1
510        }
511
512        #[inline(always)]
513        fn inline_size(_context: fidl::encoding::Context) -> usize {
514            1
515        }
516    }
517
518    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Asap, D> for &Asap {
519        #[inline]
520        unsafe fn encode(
521            self,
522            encoder: &mut fidl::encoding::Encoder<'_, D>,
523            offset: usize,
524            _depth: fidl::encoding::Depth,
525        ) -> fidl::Result<()> {
526            encoder.debug_check_bounds::<Asap>(offset);
527            encoder.write_num(0u8, offset);
528            Ok(())
529        }
530    }
531
532    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Asap {
533        #[inline(always)]
534        fn new_empty() -> Self {
535            Self
536        }
537
538        #[inline]
539        unsafe fn decode(
540            &mut self,
541            decoder: &mut fidl::encoding::Decoder<'_, D>,
542            offset: usize,
543            _depth: fidl::encoding::Depth,
544        ) -> fidl::Result<()> {
545            decoder.debug_check_bounds::<Self>(offset);
546            match decoder.read_num::<u8>(offset) {
547                0 => Ok(()),
548                _ => Err(fidl::Error::Invalid),
549            }
550        }
551    }
552
553    impl fidl::encoding::ValueTypeMarker for PayloadRange {
554        type Borrowed<'a> = &'a Self;
555        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
556            value
557        }
558    }
559
560    unsafe impl fidl::encoding::TypeMarker for PayloadRange {
561        type Owned = Self;
562
563        #[inline(always)]
564        fn inline_align(_context: fidl::encoding::Context) -> usize {
565            8
566        }
567
568        #[inline(always)]
569        fn inline_size(_context: fidl::encoding::Context) -> usize {
570            24
571        }
572    }
573
574    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<PayloadRange, D>
575        for &PayloadRange
576    {
577        #[inline]
578        unsafe fn encode(
579            self,
580            encoder: &mut fidl::encoding::Encoder<'_, D>,
581            offset: usize,
582            _depth: fidl::encoding::Depth,
583        ) -> fidl::Result<()> {
584            encoder.debug_check_bounds::<PayloadRange>(offset);
585            unsafe {
586                // Copy the object into the buffer.
587                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
588                (buf_ptr as *mut PayloadRange)
589                    .write_unaligned((self as *const PayloadRange).read());
590                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
591                // done second because the memcpy will write garbage to these bytes.
592                let padding_ptr = buf_ptr.offset(0) as *mut u64;
593                let padding_mask = 0xffffffff00000000u64;
594                padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
595            }
596            Ok(())
597        }
598    }
599    unsafe impl<
600            D: fidl::encoding::ResourceDialect,
601            T0: fidl::encoding::Encode<u32, D>,
602            T1: fidl::encoding::Encode<u64, D>,
603            T2: fidl::encoding::Encode<u64, D>,
604        > fidl::encoding::Encode<PayloadRange, D> for (T0, T1, T2)
605    {
606        #[inline]
607        unsafe fn encode(
608            self,
609            encoder: &mut fidl::encoding::Encoder<'_, D>,
610            offset: usize,
611            depth: fidl::encoding::Depth,
612        ) -> fidl::Result<()> {
613            encoder.debug_check_bounds::<PayloadRange>(offset);
614            // Zero out padding regions. There's no need to apply masks
615            // because the unmasked parts will be overwritten by fields.
616            unsafe {
617                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
618                (ptr as *mut u64).write_unaligned(0);
619            }
620            // Write the fields.
621            self.0.encode(encoder, offset + 0, depth)?;
622            self.1.encode(encoder, offset + 8, depth)?;
623            self.2.encode(encoder, offset + 16, depth)?;
624            Ok(())
625        }
626    }
627
628    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PayloadRange {
629        #[inline(always)]
630        fn new_empty() -> Self {
631            Self {
632                buffer_id: fidl::new_empty!(u32, D),
633                offset: fidl::new_empty!(u64, D),
634                size: fidl::new_empty!(u64, D),
635            }
636        }
637
638        #[inline]
639        unsafe fn decode(
640            &mut self,
641            decoder: &mut fidl::encoding::Decoder<'_, D>,
642            offset: usize,
643            _depth: fidl::encoding::Depth,
644        ) -> fidl::Result<()> {
645            decoder.debug_check_bounds::<Self>(offset);
646            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
647            // Verify that padding bytes are zero.
648            let ptr = unsafe { buf_ptr.offset(0) };
649            let padval = unsafe { (ptr as *const u64).read_unaligned() };
650            let mask = 0xffffffff00000000u64;
651            let maskedval = padval & mask;
652            if maskedval != 0 {
653                return Err(fidl::Error::NonZeroPadding {
654                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
655                });
656            }
657            // Copy from the buffer into the object.
658            unsafe {
659                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 24);
660            }
661            Ok(())
662        }
663    }
664
665    impl fidl::encoding::ValueTypeMarker for RealOrStreamTime {
666        type Borrowed<'a> = &'a Self;
667        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
668            value
669        }
670    }
671
672    unsafe impl fidl::encoding::TypeMarker for RealOrStreamTime {
673        type Owned = Self;
674
675        #[inline(always)]
676        fn inline_align(_context: fidl::encoding::Context) -> usize {
677            8
678        }
679
680        #[inline(always)]
681        fn inline_size(_context: fidl::encoding::Context) -> usize {
682            16
683        }
684    }
685
686    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RealOrStreamTime, D>
687        for &RealOrStreamTime
688    {
689        #[inline]
690        unsafe fn encode(
691            self,
692            encoder: &mut fidl::encoding::Encoder<'_, D>,
693            offset: usize,
694            _depth: fidl::encoding::Depth,
695        ) -> fidl::Result<()> {
696            encoder.debug_check_bounds::<RealOrStreamTime>(offset);
697            encoder.write_num::<u64>(self.ordinal(), offset);
698            match self {
699                RealOrStreamTime::Asap(ref val) => fidl::encoding::encode_in_envelope::<Asap, D>(
700                    <Asap as fidl::encoding::ValueTypeMarker>::borrow(val),
701                    encoder,
702                    offset + 8,
703                    _depth,
704                ),
705                RealOrStreamTime::SystemTime(ref val) => {
706                    fidl::encoding::encode_in_envelope::<i64, D>(
707                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
708                        encoder,
709                        offset + 8,
710                        _depth,
711                    )
712                }
713                RealOrStreamTime::ReferenceTime(ref val) => {
714                    fidl::encoding::encode_in_envelope::<i64, D>(
715                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
716                        encoder,
717                        offset + 8,
718                        _depth,
719                    )
720                }
721                RealOrStreamTime::StreamTime(ref val) => {
722                    fidl::encoding::encode_in_envelope::<i64, D>(
723                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
724                        encoder,
725                        offset + 8,
726                        _depth,
727                    )
728                }
729                RealOrStreamTime::PacketTimestamp(ref val) => {
730                    fidl::encoding::encode_in_envelope::<i64, D>(
731                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
732                        encoder,
733                        offset + 8,
734                        _depth,
735                    )
736                }
737                RealOrStreamTime::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
738            }
739        }
740    }
741
742    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RealOrStreamTime {
743        #[inline(always)]
744        fn new_empty() -> Self {
745            Self::__SourceBreaking { unknown_ordinal: 0 }
746        }
747
748        #[inline]
749        unsafe fn decode(
750            &mut self,
751            decoder: &mut fidl::encoding::Decoder<'_, D>,
752            offset: usize,
753            mut depth: fidl::encoding::Depth,
754        ) -> fidl::Result<()> {
755            decoder.debug_check_bounds::<Self>(offset);
756            #[allow(unused_variables)]
757            let next_out_of_line = decoder.next_out_of_line();
758            let handles_before = decoder.remaining_handles();
759            let (ordinal, inlined, num_bytes, num_handles) =
760                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
761
762            let member_inline_size = match ordinal {
763                1 => <Asap as fidl::encoding::TypeMarker>::inline_size(decoder.context),
764                2 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
765                3 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
766                4 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
767                5 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
768                0 => return Err(fidl::Error::UnknownUnionTag),
769                _ => num_bytes as usize,
770            };
771
772            if inlined != (member_inline_size <= 4) {
773                return Err(fidl::Error::InvalidInlineBitInEnvelope);
774            }
775            let _inner_offset;
776            if inlined {
777                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
778                _inner_offset = offset + 8;
779            } else {
780                depth.increment()?;
781                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
782            }
783            match ordinal {
784                1 => {
785                    #[allow(irrefutable_let_patterns)]
786                    if let RealOrStreamTime::Asap(_) = self {
787                        // Do nothing, read the value into the object
788                    } else {
789                        // Initialize `self` to the right variant
790                        *self = RealOrStreamTime::Asap(fidl::new_empty!(Asap, D));
791                    }
792                    #[allow(irrefutable_let_patterns)]
793                    if let RealOrStreamTime::Asap(ref mut val) = self {
794                        fidl::decode!(Asap, D, val, decoder, _inner_offset, depth)?;
795                    } else {
796                        unreachable!()
797                    }
798                }
799                2 => {
800                    #[allow(irrefutable_let_patterns)]
801                    if let RealOrStreamTime::SystemTime(_) = self {
802                        // Do nothing, read the value into the object
803                    } else {
804                        // Initialize `self` to the right variant
805                        *self = RealOrStreamTime::SystemTime(fidl::new_empty!(i64, D));
806                    }
807                    #[allow(irrefutable_let_patterns)]
808                    if let RealOrStreamTime::SystemTime(ref mut val) = self {
809                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
810                    } else {
811                        unreachable!()
812                    }
813                }
814                3 => {
815                    #[allow(irrefutable_let_patterns)]
816                    if let RealOrStreamTime::ReferenceTime(_) = self {
817                        // Do nothing, read the value into the object
818                    } else {
819                        // Initialize `self` to the right variant
820                        *self = RealOrStreamTime::ReferenceTime(fidl::new_empty!(i64, D));
821                    }
822                    #[allow(irrefutable_let_patterns)]
823                    if let RealOrStreamTime::ReferenceTime(ref mut val) = self {
824                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
825                    } else {
826                        unreachable!()
827                    }
828                }
829                4 => {
830                    #[allow(irrefutable_let_patterns)]
831                    if let RealOrStreamTime::StreamTime(_) = self {
832                        // Do nothing, read the value into the object
833                    } else {
834                        // Initialize `self` to the right variant
835                        *self = RealOrStreamTime::StreamTime(fidl::new_empty!(i64, D));
836                    }
837                    #[allow(irrefutable_let_patterns)]
838                    if let RealOrStreamTime::StreamTime(ref mut val) = self {
839                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
840                    } else {
841                        unreachable!()
842                    }
843                }
844                5 => {
845                    #[allow(irrefutable_let_patterns)]
846                    if let RealOrStreamTime::PacketTimestamp(_) = self {
847                        // Do nothing, read the value into the object
848                    } else {
849                        // Initialize `self` to the right variant
850                        *self = RealOrStreamTime::PacketTimestamp(fidl::new_empty!(i64, D));
851                    }
852                    #[allow(irrefutable_let_patterns)]
853                    if let RealOrStreamTime::PacketTimestamp(ref mut val) = self {
854                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
855                    } else {
856                        unreachable!()
857                    }
858                }
859                #[allow(deprecated)]
860                ordinal => {
861                    for _ in 0..num_handles {
862                        decoder.drop_next_handle()?;
863                    }
864                    *self = RealOrStreamTime::__SourceBreaking { unknown_ordinal: ordinal };
865                }
866            }
867            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
868                return Err(fidl::Error::InvalidNumBytesInEnvelope);
869            }
870            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
871                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
872            }
873            Ok(())
874        }
875    }
876
877    impl fidl::encoding::ValueTypeMarker for RealTime {
878        type Borrowed<'a> = &'a Self;
879        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
880            value
881        }
882    }
883
884    unsafe impl fidl::encoding::TypeMarker for RealTime {
885        type Owned = Self;
886
887        #[inline(always)]
888        fn inline_align(_context: fidl::encoding::Context) -> usize {
889            8
890        }
891
892        #[inline(always)]
893        fn inline_size(_context: fidl::encoding::Context) -> usize {
894            16
895        }
896    }
897
898    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<RealTime, D> for &RealTime {
899        #[inline]
900        unsafe fn encode(
901            self,
902            encoder: &mut fidl::encoding::Encoder<'_, D>,
903            offset: usize,
904            _depth: fidl::encoding::Depth,
905        ) -> fidl::Result<()> {
906            encoder.debug_check_bounds::<RealTime>(offset);
907            encoder.write_num::<u64>(self.ordinal(), offset);
908            match self {
909                RealTime::Asap(ref val) => fidl::encoding::encode_in_envelope::<Asap, D>(
910                    <Asap as fidl::encoding::ValueTypeMarker>::borrow(val),
911                    encoder,
912                    offset + 8,
913                    _depth,
914                ),
915                RealTime::SystemTime(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
916                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
917                    encoder,
918                    offset + 8,
919                    _depth,
920                ),
921                RealTime::ReferenceTime(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
922                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
923                    encoder,
924                    offset + 8,
925                    _depth,
926                ),
927                RealTime::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
928            }
929        }
930    }
931
932    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RealTime {
933        #[inline(always)]
934        fn new_empty() -> Self {
935            Self::__SourceBreaking { unknown_ordinal: 0 }
936        }
937
938        #[inline]
939        unsafe fn decode(
940            &mut self,
941            decoder: &mut fidl::encoding::Decoder<'_, D>,
942            offset: usize,
943            mut depth: fidl::encoding::Depth,
944        ) -> fidl::Result<()> {
945            decoder.debug_check_bounds::<Self>(offset);
946            #[allow(unused_variables)]
947            let next_out_of_line = decoder.next_out_of_line();
948            let handles_before = decoder.remaining_handles();
949            let (ordinal, inlined, num_bytes, num_handles) =
950                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
951
952            let member_inline_size = match ordinal {
953                1 => <Asap as fidl::encoding::TypeMarker>::inline_size(decoder.context),
954                2 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
955                3 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
956                0 => return Err(fidl::Error::UnknownUnionTag),
957                _ => num_bytes as usize,
958            };
959
960            if inlined != (member_inline_size <= 4) {
961                return Err(fidl::Error::InvalidInlineBitInEnvelope);
962            }
963            let _inner_offset;
964            if inlined {
965                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
966                _inner_offset = offset + 8;
967            } else {
968                depth.increment()?;
969                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
970            }
971            match ordinal {
972                1 => {
973                    #[allow(irrefutable_let_patterns)]
974                    if let RealTime::Asap(_) = self {
975                        // Do nothing, read the value into the object
976                    } else {
977                        // Initialize `self` to the right variant
978                        *self = RealTime::Asap(fidl::new_empty!(Asap, D));
979                    }
980                    #[allow(irrefutable_let_patterns)]
981                    if let RealTime::Asap(ref mut val) = self {
982                        fidl::decode!(Asap, D, val, decoder, _inner_offset, depth)?;
983                    } else {
984                        unreachable!()
985                    }
986                }
987                2 => {
988                    #[allow(irrefutable_let_patterns)]
989                    if let RealTime::SystemTime(_) = self {
990                        // Do nothing, read the value into the object
991                    } else {
992                        // Initialize `self` to the right variant
993                        *self = RealTime::SystemTime(fidl::new_empty!(i64, D));
994                    }
995                    #[allow(irrefutable_let_patterns)]
996                    if let RealTime::SystemTime(ref mut val) = self {
997                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
998                    } else {
999                        unreachable!()
1000                    }
1001                }
1002                3 => {
1003                    #[allow(irrefutable_let_patterns)]
1004                    if let RealTime::ReferenceTime(_) = self {
1005                        // Do nothing, read the value into the object
1006                    } else {
1007                        // Initialize `self` to the right variant
1008                        *self = RealTime::ReferenceTime(fidl::new_empty!(i64, D));
1009                    }
1010                    #[allow(irrefutable_let_patterns)]
1011                    if let RealTime::ReferenceTime(ref mut val) = self {
1012                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1013                    } else {
1014                        unreachable!()
1015                    }
1016                }
1017                #[allow(deprecated)]
1018                ordinal => {
1019                    for _ in 0..num_handles {
1020                        decoder.drop_next_handle()?;
1021                    }
1022                    *self = RealTime::__SourceBreaking { unknown_ordinal: ordinal };
1023                }
1024            }
1025            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1026                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1027            }
1028            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1029                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1030            }
1031            Ok(())
1032        }
1033    }
1034
1035    impl fidl::encoding::ValueTypeMarker for StreamTime {
1036        type Borrowed<'a> = &'a Self;
1037        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1038            value
1039        }
1040    }
1041
1042    unsafe impl fidl::encoding::TypeMarker for StreamTime {
1043        type Owned = Self;
1044
1045        #[inline(always)]
1046        fn inline_align(_context: fidl::encoding::Context) -> usize {
1047            8
1048        }
1049
1050        #[inline(always)]
1051        fn inline_size(_context: fidl::encoding::Context) -> usize {
1052            16
1053        }
1054    }
1055
1056    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StreamTime, D>
1057        for &StreamTime
1058    {
1059        #[inline]
1060        unsafe fn encode(
1061            self,
1062            encoder: &mut fidl::encoding::Encoder<'_, D>,
1063            offset: usize,
1064            _depth: fidl::encoding::Depth,
1065        ) -> fidl::Result<()> {
1066            encoder.debug_check_bounds::<StreamTime>(offset);
1067            encoder.write_num::<u64>(self.ordinal(), offset);
1068            match self {
1069                StreamTime::StreamTime(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
1070                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
1071                    encoder,
1072                    offset + 8,
1073                    _depth,
1074                ),
1075                StreamTime::PacketTimestamp(ref val) => {
1076                    fidl::encoding::encode_in_envelope::<i64, D>(
1077                        <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
1078                        encoder,
1079                        offset + 8,
1080                        _depth,
1081                    )
1082                }
1083                StreamTime::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1084            }
1085        }
1086    }
1087
1088    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StreamTime {
1089        #[inline(always)]
1090        fn new_empty() -> Self {
1091            Self::__SourceBreaking { unknown_ordinal: 0 }
1092        }
1093
1094        #[inline]
1095        unsafe fn decode(
1096            &mut self,
1097            decoder: &mut fidl::encoding::Decoder<'_, D>,
1098            offset: usize,
1099            mut depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            decoder.debug_check_bounds::<Self>(offset);
1102            #[allow(unused_variables)]
1103            let next_out_of_line = decoder.next_out_of_line();
1104            let handles_before = decoder.remaining_handles();
1105            let (ordinal, inlined, num_bytes, num_handles) =
1106                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1107
1108            let member_inline_size = match ordinal {
1109                1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1110                2 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1111                0 => return Err(fidl::Error::UnknownUnionTag),
1112                _ => num_bytes as usize,
1113            };
1114
1115            if inlined != (member_inline_size <= 4) {
1116                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1117            }
1118            let _inner_offset;
1119            if inlined {
1120                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1121                _inner_offset = offset + 8;
1122            } else {
1123                depth.increment()?;
1124                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1125            }
1126            match ordinal {
1127                1 => {
1128                    #[allow(irrefutable_let_patterns)]
1129                    if let StreamTime::StreamTime(_) = self {
1130                        // Do nothing, read the value into the object
1131                    } else {
1132                        // Initialize `self` to the right variant
1133                        *self = StreamTime::StreamTime(fidl::new_empty!(i64, D));
1134                    }
1135                    #[allow(irrefutable_let_patterns)]
1136                    if let StreamTime::StreamTime(ref mut val) = self {
1137                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1138                    } else {
1139                        unreachable!()
1140                    }
1141                }
1142                2 => {
1143                    #[allow(irrefutable_let_patterns)]
1144                    if let StreamTime::PacketTimestamp(_) = self {
1145                        // Do nothing, read the value into the object
1146                    } else {
1147                        // Initialize `self` to the right variant
1148                        *self = StreamTime::PacketTimestamp(fidl::new_empty!(i64, D));
1149                    }
1150                    #[allow(irrefutable_let_patterns)]
1151                    if let StreamTime::PacketTimestamp(ref mut val) = self {
1152                        fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1153                    } else {
1154                        unreachable!()
1155                    }
1156                }
1157                #[allow(deprecated)]
1158                ordinal => {
1159                    for _ in 0..num_handles {
1160                        decoder.drop_next_handle()?;
1161                    }
1162                    *self = StreamTime::__SourceBreaking { unknown_ordinal: ordinal };
1163                }
1164            }
1165            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1166                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1167            }
1168            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1169                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1170            }
1171            Ok(())
1172        }
1173    }
1174}