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