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
11pub const MAX_COUNT_RESOLUTIONS: u32 = 64;
13
14pub const MAX_COUNT_TIMERS: u32 = 64;
16
17#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
19pub enum DriverError {
20 InternalError,
22 NotSupported,
24 InvalidArgs,
26 BadState,
29 Canceled,
31 #[doc(hidden)]
32 __SourceBreaking { unknown_ordinal: u32 },
33}
34
35#[macro_export]
37macro_rules! DriverErrorUnknown {
38 () => {
39 _
40 };
41}
42
43impl DriverError {
44 #[inline]
45 pub fn from_primitive(prim: u32) -> Option<Self> {
46 match prim {
47 1 => Some(Self::InternalError),
48 2 => Some(Self::NotSupported),
49 3 => Some(Self::InvalidArgs),
50 4 => Some(Self::BadState),
51 5 => Some(Self::Canceled),
52 _ => None,
53 }
54 }
55
56 #[inline]
57 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
58 match prim {
59 1 => Self::InternalError,
60 2 => Self::NotSupported,
61 3 => Self::InvalidArgs,
62 4 => Self::BadState,
63 5 => Self::Canceled,
64 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
65 }
66 }
67
68 #[inline]
69 pub fn unknown() -> Self {
70 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
71 }
72
73 #[inline]
74 pub const fn into_primitive(self) -> u32 {
75 match self {
76 Self::InternalError => 1,
77 Self::NotSupported => 2,
78 Self::InvalidArgs => 3,
79 Self::BadState => 4,
80 Self::Canceled => 5,
81 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
82 }
83 }
84
85 #[inline]
86 pub fn is_unknown(&self) -> bool {
87 match self {
88 Self::__SourceBreaking { unknown_ordinal: _ } => true,
89 _ => false,
90 }
91 }
92}
93
94#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
95#[repr(C)]
96pub struct DeviceGetTicksLeftRequest {
97 pub id: u64,
98}
99
100impl fidl::Persistable for DeviceGetTicksLeftRequest {}
101
102#[derive(Clone, Debug, PartialEq)]
103pub struct DeviceReadClockRequest {
104 pub id: u64,
105 pub resolution: Resolution,
106}
107
108impl fidl::Persistable for DeviceReadClockRequest {}
109
110#[derive(Clone, Debug, PartialEq)]
111pub struct DeviceReadTimerRequest {
112 pub id: u64,
113 pub resolution: Resolution,
114}
115
116impl fidl::Persistable for DeviceReadTimerRequest {}
117
118#[derive(Clone, Debug, PartialEq)]
119pub struct DeviceStartRequest {
120 pub id: u64,
121 pub resolution: Resolution,
122 pub ticks: u64,
123}
124
125impl fidl::Persistable for DeviceStartRequest {}
126
127#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
128#[repr(C)]
129pub struct DeviceStopRequest {
130 pub id: u64,
131}
132
133impl fidl::Persistable for DeviceStopRequest {}
134
135#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
136#[repr(C)]
137pub struct DeviceGetTicksLeftResponse {
138 pub ticks: u64,
139}
140
141impl fidl::Persistable for DeviceGetTicksLeftResponse {}
142
143#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
144#[repr(C)]
145pub struct DeviceReadClockResponse {
146 pub ticks: u64,
147}
148
149impl fidl::Persistable for DeviceReadClockResponse {}
150
151#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
152#[repr(C)]
153pub struct DeviceReadTimerResponse {
154 pub ticks: u64,
155}
156
157impl fidl::Persistable for DeviceReadTimerResponse {}
158
159#[derive(Clone, Debug, Default, PartialEq)]
161pub struct TimerProperties {
162 pub id: Option<u64>,
169 pub supported_resolutions: Option<Vec<Resolution>>,
173 pub max_ticks: Option<u64>,
191 pub supports_event: Option<bool>,
196 pub supports_wait: Option<bool>,
201 pub supports_read: Option<bool>,
206 #[doc(hidden)]
207 pub __source_breaking: fidl::marker::SourceBreaking,
208}
209
210impl fidl::Persistable for TimerProperties {}
211
212#[derive(Clone, Debug)]
214pub enum Resolution {
215 Duration(i64),
217 #[doc(hidden)]
218 __SourceBreaking { unknown_ordinal: u64 },
219}
220
221#[macro_export]
223macro_rules! ResolutionUnknown {
224 () => {
225 _
226 };
227}
228
229impl PartialEq for Resolution {
231 fn eq(&self, other: &Self) -> bool {
232 match (self, other) {
233 (Self::Duration(x), Self::Duration(y)) => *x == *y,
234 _ => false,
235 }
236 }
237}
238
239impl Resolution {
240 #[inline]
241 pub fn ordinal(&self) -> u64 {
242 match *self {
243 Self::Duration(_) => 1,
244 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
245 }
246 }
247
248 #[inline]
249 pub fn unknown_variant_for_testing() -> Self {
250 Self::__SourceBreaking { unknown_ordinal: 0 }
251 }
252
253 #[inline]
254 pub fn is_unknown(&self) -> bool {
255 match self {
256 Self::__SourceBreaking { .. } => true,
257 _ => false,
258 }
259 }
260}
261
262impl fidl::Persistable for Resolution {}
263
264pub mod device_ordinals {
265 pub const START: u64 = 0x5a0a193b0467cc8a;
266 pub const READ_TIMER: u64 = 0x4430d0e336ffb5e9;
267 pub const READ_CLOCK: u64 = 0x49aae10e0fb621ab;
268 pub const STOP: u64 = 0x77e4cd1c3841a0e2;
269 pub const GET_TICKS_LEFT: u64 = 0xde2a48ae7d4b4ea;
270 pub const SET_EVENT: u64 = 0x1027024d25ffa820;
271 pub const START_AND_WAIT: u64 = 0x716f415cdf234e0f;
272 pub const START_AND_WAIT2: u64 = 0x5f2aaf21254d3238;
273 pub const GET_PROPERTIES: u64 = 0x6bc22ab4c9396cbb;
274}
275
276mod internal {
277 use super::*;
278 unsafe impl fidl::encoding::TypeMarker for DriverError {
279 type Owned = Self;
280
281 #[inline(always)]
282 fn inline_align(_context: fidl::encoding::Context) -> usize {
283 std::mem::align_of::<u32>()
284 }
285
286 #[inline(always)]
287 fn inline_size(_context: fidl::encoding::Context) -> usize {
288 std::mem::size_of::<u32>()
289 }
290
291 #[inline(always)]
292 fn encode_is_copy() -> bool {
293 false
294 }
295
296 #[inline(always)]
297 fn decode_is_copy() -> bool {
298 false
299 }
300 }
301
302 impl fidl::encoding::ValueTypeMarker for DriverError {
303 type Borrowed<'a> = Self;
304 #[inline(always)]
305 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
306 *value
307 }
308 }
309
310 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DriverError {
311 #[inline]
312 unsafe fn encode(
313 self,
314 encoder: &mut fidl::encoding::Encoder<'_, D>,
315 offset: usize,
316 _depth: fidl::encoding::Depth,
317 ) -> fidl::Result<()> {
318 encoder.debug_check_bounds::<Self>(offset);
319 encoder.write_num(self.into_primitive(), offset);
320 Ok(())
321 }
322 }
323
324 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DriverError {
325 #[inline(always)]
326 fn new_empty() -> Self {
327 Self::unknown()
328 }
329
330 #[inline]
331 unsafe fn decode(
332 &mut self,
333 decoder: &mut fidl::encoding::Decoder<'_, D>,
334 offset: usize,
335 _depth: fidl::encoding::Depth,
336 ) -> fidl::Result<()> {
337 decoder.debug_check_bounds::<Self>(offset);
338 let prim = decoder.read_num::<u32>(offset);
339
340 *self = Self::from_primitive_allow_unknown(prim);
341 Ok(())
342 }
343 }
344
345 impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftRequest {
346 type Borrowed<'a> = &'a Self;
347 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
348 value
349 }
350 }
351
352 unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftRequest {
353 type Owned = Self;
354
355 #[inline(always)]
356 fn inline_align(_context: fidl::encoding::Context) -> usize {
357 8
358 }
359
360 #[inline(always)]
361 fn inline_size(_context: fidl::encoding::Context) -> usize {
362 8
363 }
364 #[inline(always)]
365 fn encode_is_copy() -> bool {
366 true
367 }
368
369 #[inline(always)]
370 fn decode_is_copy() -> bool {
371 true
372 }
373 }
374
375 unsafe impl<D: fidl::encoding::ResourceDialect>
376 fidl::encoding::Encode<DeviceGetTicksLeftRequest, D> for &DeviceGetTicksLeftRequest
377 {
378 #[inline]
379 unsafe fn encode(
380 self,
381 encoder: &mut fidl::encoding::Encoder<'_, D>,
382 offset: usize,
383 _depth: fidl::encoding::Depth,
384 ) -> fidl::Result<()> {
385 encoder.debug_check_bounds::<DeviceGetTicksLeftRequest>(offset);
386 unsafe {
387 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
389 (buf_ptr as *mut DeviceGetTicksLeftRequest)
390 .write_unaligned((self as *const DeviceGetTicksLeftRequest).read());
391 }
394 Ok(())
395 }
396 }
397 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
398 fidl::encoding::Encode<DeviceGetTicksLeftRequest, D> for (T0,)
399 {
400 #[inline]
401 unsafe fn encode(
402 self,
403 encoder: &mut fidl::encoding::Encoder<'_, D>,
404 offset: usize,
405 depth: fidl::encoding::Depth,
406 ) -> fidl::Result<()> {
407 encoder.debug_check_bounds::<DeviceGetTicksLeftRequest>(offset);
408 self.0.encode(encoder, offset + 0, depth)?;
412 Ok(())
413 }
414 }
415
416 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
417 for DeviceGetTicksLeftRequest
418 {
419 #[inline(always)]
420 fn new_empty() -> Self {
421 Self { id: fidl::new_empty!(u64, D) }
422 }
423
424 #[inline]
425 unsafe fn decode(
426 &mut self,
427 decoder: &mut fidl::encoding::Decoder<'_, D>,
428 offset: usize,
429 _depth: fidl::encoding::Depth,
430 ) -> fidl::Result<()> {
431 decoder.debug_check_bounds::<Self>(offset);
432 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
433 unsafe {
436 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
437 }
438 Ok(())
439 }
440 }
441
442 impl fidl::encoding::ValueTypeMarker for DeviceReadClockRequest {
443 type Borrowed<'a> = &'a Self;
444 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
445 value
446 }
447 }
448
449 unsafe impl fidl::encoding::TypeMarker for DeviceReadClockRequest {
450 type Owned = Self;
451
452 #[inline(always)]
453 fn inline_align(_context: fidl::encoding::Context) -> usize {
454 8
455 }
456
457 #[inline(always)]
458 fn inline_size(_context: fidl::encoding::Context) -> usize {
459 24
460 }
461 }
462
463 unsafe impl<D: fidl::encoding::ResourceDialect>
464 fidl::encoding::Encode<DeviceReadClockRequest, D> for &DeviceReadClockRequest
465 {
466 #[inline]
467 unsafe fn encode(
468 self,
469 encoder: &mut fidl::encoding::Encoder<'_, D>,
470 offset: usize,
471 _depth: fidl::encoding::Depth,
472 ) -> fidl::Result<()> {
473 encoder.debug_check_bounds::<DeviceReadClockRequest>(offset);
474 fidl::encoding::Encode::<DeviceReadClockRequest, D>::encode(
476 (
477 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
478 <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
479 ),
480 encoder,
481 offset,
482 _depth,
483 )
484 }
485 }
486 unsafe impl<
487 D: fidl::encoding::ResourceDialect,
488 T0: fidl::encoding::Encode<u64, D>,
489 T1: fidl::encoding::Encode<Resolution, D>,
490 > fidl::encoding::Encode<DeviceReadClockRequest, D> for (T0, T1)
491 {
492 #[inline]
493 unsafe fn encode(
494 self,
495 encoder: &mut fidl::encoding::Encoder<'_, D>,
496 offset: usize,
497 depth: fidl::encoding::Depth,
498 ) -> fidl::Result<()> {
499 encoder.debug_check_bounds::<DeviceReadClockRequest>(offset);
500 self.0.encode(encoder, offset + 0, depth)?;
504 self.1.encode(encoder, offset + 8, depth)?;
505 Ok(())
506 }
507 }
508
509 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
510 for DeviceReadClockRequest
511 {
512 #[inline(always)]
513 fn new_empty() -> Self {
514 Self { id: fidl::new_empty!(u64, D), resolution: fidl::new_empty!(Resolution, D) }
515 }
516
517 #[inline]
518 unsafe fn decode(
519 &mut self,
520 decoder: &mut fidl::encoding::Decoder<'_, D>,
521 offset: usize,
522 _depth: fidl::encoding::Depth,
523 ) -> fidl::Result<()> {
524 decoder.debug_check_bounds::<Self>(offset);
525 fidl::decode!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
527 fidl::decode!(Resolution, D, &mut self.resolution, decoder, offset + 8, _depth)?;
528 Ok(())
529 }
530 }
531
532 impl fidl::encoding::ValueTypeMarker for DeviceReadTimerRequest {
533 type Borrowed<'a> = &'a Self;
534 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
535 value
536 }
537 }
538
539 unsafe impl fidl::encoding::TypeMarker for DeviceReadTimerRequest {
540 type Owned = Self;
541
542 #[inline(always)]
543 fn inline_align(_context: fidl::encoding::Context) -> usize {
544 8
545 }
546
547 #[inline(always)]
548 fn inline_size(_context: fidl::encoding::Context) -> usize {
549 24
550 }
551 }
552
553 unsafe impl<D: fidl::encoding::ResourceDialect>
554 fidl::encoding::Encode<DeviceReadTimerRequest, D> for &DeviceReadTimerRequest
555 {
556 #[inline]
557 unsafe fn encode(
558 self,
559 encoder: &mut fidl::encoding::Encoder<'_, D>,
560 offset: usize,
561 _depth: fidl::encoding::Depth,
562 ) -> fidl::Result<()> {
563 encoder.debug_check_bounds::<DeviceReadTimerRequest>(offset);
564 fidl::encoding::Encode::<DeviceReadTimerRequest, D>::encode(
566 (
567 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
568 <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
569 ),
570 encoder,
571 offset,
572 _depth,
573 )
574 }
575 }
576 unsafe impl<
577 D: fidl::encoding::ResourceDialect,
578 T0: fidl::encoding::Encode<u64, D>,
579 T1: fidl::encoding::Encode<Resolution, D>,
580 > fidl::encoding::Encode<DeviceReadTimerRequest, D> for (T0, T1)
581 {
582 #[inline]
583 unsafe fn encode(
584 self,
585 encoder: &mut fidl::encoding::Encoder<'_, D>,
586 offset: usize,
587 depth: fidl::encoding::Depth,
588 ) -> fidl::Result<()> {
589 encoder.debug_check_bounds::<DeviceReadTimerRequest>(offset);
590 self.0.encode(encoder, offset + 0, depth)?;
594 self.1.encode(encoder, offset + 8, depth)?;
595 Ok(())
596 }
597 }
598
599 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
600 for DeviceReadTimerRequest
601 {
602 #[inline(always)]
603 fn new_empty() -> Self {
604 Self { id: fidl::new_empty!(u64, D), resolution: fidl::new_empty!(Resolution, D) }
605 }
606
607 #[inline]
608 unsafe fn decode(
609 &mut self,
610 decoder: &mut fidl::encoding::Decoder<'_, D>,
611 offset: usize,
612 _depth: fidl::encoding::Depth,
613 ) -> fidl::Result<()> {
614 decoder.debug_check_bounds::<Self>(offset);
615 fidl::decode!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
617 fidl::decode!(Resolution, D, &mut self.resolution, decoder, offset + 8, _depth)?;
618 Ok(())
619 }
620 }
621
622 impl fidl::encoding::ValueTypeMarker for DeviceStartRequest {
623 type Borrowed<'a> = &'a Self;
624 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
625 value
626 }
627 }
628
629 unsafe impl fidl::encoding::TypeMarker for DeviceStartRequest {
630 type Owned = Self;
631
632 #[inline(always)]
633 fn inline_align(_context: fidl::encoding::Context) -> usize {
634 8
635 }
636
637 #[inline(always)]
638 fn inline_size(_context: fidl::encoding::Context) -> usize {
639 32
640 }
641 }
642
643 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceStartRequest, D>
644 for &DeviceStartRequest
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::<DeviceStartRequest>(offset);
654 fidl::encoding::Encode::<DeviceStartRequest, D>::encode(
656 (
657 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
658 <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
659 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
660 ),
661 encoder,
662 offset,
663 _depth,
664 )
665 }
666 }
667 unsafe impl<
668 D: fidl::encoding::ResourceDialect,
669 T0: fidl::encoding::Encode<u64, D>,
670 T1: fidl::encoding::Encode<Resolution, D>,
671 T2: fidl::encoding::Encode<u64, D>,
672 > fidl::encoding::Encode<DeviceStartRequest, D> for (T0, T1, T2)
673 {
674 #[inline]
675 unsafe fn encode(
676 self,
677 encoder: &mut fidl::encoding::Encoder<'_, D>,
678 offset: usize,
679 depth: fidl::encoding::Depth,
680 ) -> fidl::Result<()> {
681 encoder.debug_check_bounds::<DeviceStartRequest>(offset);
682 self.0.encode(encoder, offset + 0, depth)?;
686 self.1.encode(encoder, offset + 8, depth)?;
687 self.2.encode(encoder, offset + 24, depth)?;
688 Ok(())
689 }
690 }
691
692 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStartRequest {
693 #[inline(always)]
694 fn new_empty() -> Self {
695 Self {
696 id: fidl::new_empty!(u64, D),
697 resolution: fidl::new_empty!(Resolution, D),
698 ticks: fidl::new_empty!(u64, D),
699 }
700 }
701
702 #[inline]
703 unsafe fn decode(
704 &mut self,
705 decoder: &mut fidl::encoding::Decoder<'_, D>,
706 offset: usize,
707 _depth: fidl::encoding::Depth,
708 ) -> fidl::Result<()> {
709 decoder.debug_check_bounds::<Self>(offset);
710 fidl::decode!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
712 fidl::decode!(Resolution, D, &mut self.resolution, decoder, offset + 8, _depth)?;
713 fidl::decode!(u64, D, &mut self.ticks, decoder, offset + 24, _depth)?;
714 Ok(())
715 }
716 }
717
718 impl fidl::encoding::ValueTypeMarker for DeviceStopRequest {
719 type Borrowed<'a> = &'a Self;
720 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
721 value
722 }
723 }
724
725 unsafe impl fidl::encoding::TypeMarker for DeviceStopRequest {
726 type Owned = Self;
727
728 #[inline(always)]
729 fn inline_align(_context: fidl::encoding::Context) -> usize {
730 8
731 }
732
733 #[inline(always)]
734 fn inline_size(_context: fidl::encoding::Context) -> usize {
735 8
736 }
737 #[inline(always)]
738 fn encode_is_copy() -> bool {
739 true
740 }
741
742 #[inline(always)]
743 fn decode_is_copy() -> bool {
744 true
745 }
746 }
747
748 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceStopRequest, D>
749 for &DeviceStopRequest
750 {
751 #[inline]
752 unsafe fn encode(
753 self,
754 encoder: &mut fidl::encoding::Encoder<'_, D>,
755 offset: usize,
756 _depth: fidl::encoding::Depth,
757 ) -> fidl::Result<()> {
758 encoder.debug_check_bounds::<DeviceStopRequest>(offset);
759 unsafe {
760 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
762 (buf_ptr as *mut DeviceStopRequest)
763 .write_unaligned((self as *const DeviceStopRequest).read());
764 }
767 Ok(())
768 }
769 }
770 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
771 fidl::encoding::Encode<DeviceStopRequest, D> for (T0,)
772 {
773 #[inline]
774 unsafe fn encode(
775 self,
776 encoder: &mut fidl::encoding::Encoder<'_, D>,
777 offset: usize,
778 depth: fidl::encoding::Depth,
779 ) -> fidl::Result<()> {
780 encoder.debug_check_bounds::<DeviceStopRequest>(offset);
781 self.0.encode(encoder, offset + 0, depth)?;
785 Ok(())
786 }
787 }
788
789 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStopRequest {
790 #[inline(always)]
791 fn new_empty() -> Self {
792 Self { id: fidl::new_empty!(u64, D) }
793 }
794
795 #[inline]
796 unsafe fn decode(
797 &mut self,
798 decoder: &mut fidl::encoding::Decoder<'_, D>,
799 offset: usize,
800 _depth: fidl::encoding::Depth,
801 ) -> fidl::Result<()> {
802 decoder.debug_check_bounds::<Self>(offset);
803 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
804 unsafe {
807 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
808 }
809 Ok(())
810 }
811 }
812
813 impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftResponse {
814 type Borrowed<'a> = &'a Self;
815 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
816 value
817 }
818 }
819
820 unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftResponse {
821 type Owned = Self;
822
823 #[inline(always)]
824 fn inline_align(_context: fidl::encoding::Context) -> usize {
825 8
826 }
827
828 #[inline(always)]
829 fn inline_size(_context: fidl::encoding::Context) -> usize {
830 8
831 }
832 #[inline(always)]
833 fn encode_is_copy() -> bool {
834 true
835 }
836
837 #[inline(always)]
838 fn decode_is_copy() -> bool {
839 true
840 }
841 }
842
843 unsafe impl<D: fidl::encoding::ResourceDialect>
844 fidl::encoding::Encode<DeviceGetTicksLeftResponse, D> for &DeviceGetTicksLeftResponse
845 {
846 #[inline]
847 unsafe fn encode(
848 self,
849 encoder: &mut fidl::encoding::Encoder<'_, D>,
850 offset: usize,
851 _depth: fidl::encoding::Depth,
852 ) -> fidl::Result<()> {
853 encoder.debug_check_bounds::<DeviceGetTicksLeftResponse>(offset);
854 unsafe {
855 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
857 (buf_ptr as *mut DeviceGetTicksLeftResponse)
858 .write_unaligned((self as *const DeviceGetTicksLeftResponse).read());
859 }
862 Ok(())
863 }
864 }
865 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
866 fidl::encoding::Encode<DeviceGetTicksLeftResponse, D> for (T0,)
867 {
868 #[inline]
869 unsafe fn encode(
870 self,
871 encoder: &mut fidl::encoding::Encoder<'_, D>,
872 offset: usize,
873 depth: fidl::encoding::Depth,
874 ) -> fidl::Result<()> {
875 encoder.debug_check_bounds::<DeviceGetTicksLeftResponse>(offset);
876 self.0.encode(encoder, offset + 0, depth)?;
880 Ok(())
881 }
882 }
883
884 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
885 for DeviceGetTicksLeftResponse
886 {
887 #[inline(always)]
888 fn new_empty() -> Self {
889 Self { ticks: fidl::new_empty!(u64, D) }
890 }
891
892 #[inline]
893 unsafe fn decode(
894 &mut self,
895 decoder: &mut fidl::encoding::Decoder<'_, D>,
896 offset: usize,
897 _depth: fidl::encoding::Depth,
898 ) -> fidl::Result<()> {
899 decoder.debug_check_bounds::<Self>(offset);
900 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
901 unsafe {
904 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
905 }
906 Ok(())
907 }
908 }
909
910 impl fidl::encoding::ValueTypeMarker for DeviceReadClockResponse {
911 type Borrowed<'a> = &'a Self;
912 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
913 value
914 }
915 }
916
917 unsafe impl fidl::encoding::TypeMarker for DeviceReadClockResponse {
918 type Owned = Self;
919
920 #[inline(always)]
921 fn inline_align(_context: fidl::encoding::Context) -> usize {
922 8
923 }
924
925 #[inline(always)]
926 fn inline_size(_context: fidl::encoding::Context) -> usize {
927 8
928 }
929 #[inline(always)]
930 fn encode_is_copy() -> bool {
931 true
932 }
933
934 #[inline(always)]
935 fn decode_is_copy() -> bool {
936 true
937 }
938 }
939
940 unsafe impl<D: fidl::encoding::ResourceDialect>
941 fidl::encoding::Encode<DeviceReadClockResponse, D> for &DeviceReadClockResponse
942 {
943 #[inline]
944 unsafe fn encode(
945 self,
946 encoder: &mut fidl::encoding::Encoder<'_, D>,
947 offset: usize,
948 _depth: fidl::encoding::Depth,
949 ) -> fidl::Result<()> {
950 encoder.debug_check_bounds::<DeviceReadClockResponse>(offset);
951 unsafe {
952 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
954 (buf_ptr as *mut DeviceReadClockResponse)
955 .write_unaligned((self as *const DeviceReadClockResponse).read());
956 }
959 Ok(())
960 }
961 }
962 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
963 fidl::encoding::Encode<DeviceReadClockResponse, D> for (T0,)
964 {
965 #[inline]
966 unsafe fn encode(
967 self,
968 encoder: &mut fidl::encoding::Encoder<'_, D>,
969 offset: usize,
970 depth: fidl::encoding::Depth,
971 ) -> fidl::Result<()> {
972 encoder.debug_check_bounds::<DeviceReadClockResponse>(offset);
973 self.0.encode(encoder, offset + 0, depth)?;
977 Ok(())
978 }
979 }
980
981 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
982 for DeviceReadClockResponse
983 {
984 #[inline(always)]
985 fn new_empty() -> Self {
986 Self { ticks: fidl::new_empty!(u64, D) }
987 }
988
989 #[inline]
990 unsafe fn decode(
991 &mut self,
992 decoder: &mut fidl::encoding::Decoder<'_, D>,
993 offset: usize,
994 _depth: fidl::encoding::Depth,
995 ) -> fidl::Result<()> {
996 decoder.debug_check_bounds::<Self>(offset);
997 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
998 unsafe {
1001 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1002 }
1003 Ok(())
1004 }
1005 }
1006
1007 impl fidl::encoding::ValueTypeMarker for DeviceReadTimerResponse {
1008 type Borrowed<'a> = &'a Self;
1009 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1010 value
1011 }
1012 }
1013
1014 unsafe impl fidl::encoding::TypeMarker for DeviceReadTimerResponse {
1015 type Owned = Self;
1016
1017 #[inline(always)]
1018 fn inline_align(_context: fidl::encoding::Context) -> usize {
1019 8
1020 }
1021
1022 #[inline(always)]
1023 fn inline_size(_context: fidl::encoding::Context) -> usize {
1024 8
1025 }
1026 #[inline(always)]
1027 fn encode_is_copy() -> bool {
1028 true
1029 }
1030
1031 #[inline(always)]
1032 fn decode_is_copy() -> bool {
1033 true
1034 }
1035 }
1036
1037 unsafe impl<D: fidl::encoding::ResourceDialect>
1038 fidl::encoding::Encode<DeviceReadTimerResponse, D> for &DeviceReadTimerResponse
1039 {
1040 #[inline]
1041 unsafe fn encode(
1042 self,
1043 encoder: &mut fidl::encoding::Encoder<'_, D>,
1044 offset: usize,
1045 _depth: fidl::encoding::Depth,
1046 ) -> fidl::Result<()> {
1047 encoder.debug_check_bounds::<DeviceReadTimerResponse>(offset);
1048 unsafe {
1049 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1051 (buf_ptr as *mut DeviceReadTimerResponse)
1052 .write_unaligned((self as *const DeviceReadTimerResponse).read());
1053 }
1056 Ok(())
1057 }
1058 }
1059 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
1060 fidl::encoding::Encode<DeviceReadTimerResponse, D> for (T0,)
1061 {
1062 #[inline]
1063 unsafe fn encode(
1064 self,
1065 encoder: &mut fidl::encoding::Encoder<'_, D>,
1066 offset: usize,
1067 depth: fidl::encoding::Depth,
1068 ) -> fidl::Result<()> {
1069 encoder.debug_check_bounds::<DeviceReadTimerResponse>(offset);
1070 self.0.encode(encoder, offset + 0, depth)?;
1074 Ok(())
1075 }
1076 }
1077
1078 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1079 for DeviceReadTimerResponse
1080 {
1081 #[inline(always)]
1082 fn new_empty() -> Self {
1083 Self { ticks: fidl::new_empty!(u64, D) }
1084 }
1085
1086 #[inline]
1087 unsafe fn decode(
1088 &mut self,
1089 decoder: &mut fidl::encoding::Decoder<'_, D>,
1090 offset: usize,
1091 _depth: fidl::encoding::Depth,
1092 ) -> fidl::Result<()> {
1093 decoder.debug_check_bounds::<Self>(offset);
1094 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1095 unsafe {
1098 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1099 }
1100 Ok(())
1101 }
1102 }
1103
1104 impl TimerProperties {
1105 #[inline(always)]
1106 fn max_ordinal_present(&self) -> u64 {
1107 if let Some(_) = self.supports_read {
1108 return 6;
1109 }
1110 if let Some(_) = self.supports_wait {
1111 return 5;
1112 }
1113 if let Some(_) = self.supports_event {
1114 return 4;
1115 }
1116 if let Some(_) = self.max_ticks {
1117 return 3;
1118 }
1119 if let Some(_) = self.supported_resolutions {
1120 return 2;
1121 }
1122 if let Some(_) = self.id {
1123 return 1;
1124 }
1125 0
1126 }
1127 }
1128
1129 impl fidl::encoding::ValueTypeMarker for TimerProperties {
1130 type Borrowed<'a> = &'a Self;
1131 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1132 value
1133 }
1134 }
1135
1136 unsafe impl fidl::encoding::TypeMarker for TimerProperties {
1137 type Owned = Self;
1138
1139 #[inline(always)]
1140 fn inline_align(_context: fidl::encoding::Context) -> usize {
1141 8
1142 }
1143
1144 #[inline(always)]
1145 fn inline_size(_context: fidl::encoding::Context) -> usize {
1146 16
1147 }
1148 }
1149
1150 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TimerProperties, D>
1151 for &TimerProperties
1152 {
1153 unsafe fn encode(
1154 self,
1155 encoder: &mut fidl::encoding::Encoder<'_, D>,
1156 offset: usize,
1157 mut depth: fidl::encoding::Depth,
1158 ) -> fidl::Result<()> {
1159 encoder.debug_check_bounds::<TimerProperties>(offset);
1160 let max_ordinal: u64 = self.max_ordinal_present();
1162 encoder.write_num(max_ordinal, offset);
1163 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1164 if max_ordinal == 0 {
1166 return Ok(());
1167 }
1168 depth.increment()?;
1169 let envelope_size = 8;
1170 let bytes_len = max_ordinal as usize * envelope_size;
1171 #[allow(unused_variables)]
1172 let offset = encoder.out_of_line_offset(bytes_len);
1173 let mut _prev_end_offset: usize = 0;
1174 if 1 > max_ordinal {
1175 return Ok(());
1176 }
1177
1178 let cur_offset: usize = (1 - 1) * envelope_size;
1181
1182 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1184
1185 fidl::encoding::encode_in_envelope_optional::<u64, D>(
1190 self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1191 encoder,
1192 offset + cur_offset,
1193 depth,
1194 )?;
1195
1196 _prev_end_offset = cur_offset + envelope_size;
1197 if 2 > max_ordinal {
1198 return Ok(());
1199 }
1200
1201 let cur_offset: usize = (2 - 1) * envelope_size;
1204
1205 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1207
1208 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Resolution, 64>, D>(
1213 self.supported_resolutions.as_ref().map(<fidl::encoding::Vector<Resolution, 64> as fidl::encoding::ValueTypeMarker>::borrow),
1214 encoder, offset + cur_offset, depth
1215 )?;
1216
1217 _prev_end_offset = cur_offset + envelope_size;
1218 if 3 > max_ordinal {
1219 return Ok(());
1220 }
1221
1222 let cur_offset: usize = (3 - 1) * envelope_size;
1225
1226 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1228
1229 fidl::encoding::encode_in_envelope_optional::<u64, D>(
1234 self.max_ticks.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1235 encoder,
1236 offset + cur_offset,
1237 depth,
1238 )?;
1239
1240 _prev_end_offset = cur_offset + envelope_size;
1241 if 4 > max_ordinal {
1242 return Ok(());
1243 }
1244
1245 let cur_offset: usize = (4 - 1) * envelope_size;
1248
1249 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1251
1252 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1257 self.supports_event.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1258 encoder,
1259 offset + cur_offset,
1260 depth,
1261 )?;
1262
1263 _prev_end_offset = cur_offset + envelope_size;
1264 if 5 > max_ordinal {
1265 return Ok(());
1266 }
1267
1268 let cur_offset: usize = (5 - 1) * envelope_size;
1271
1272 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1274
1275 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1280 self.supports_wait.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1281 encoder,
1282 offset + cur_offset,
1283 depth,
1284 )?;
1285
1286 _prev_end_offset = cur_offset + envelope_size;
1287 if 6 > max_ordinal {
1288 return Ok(());
1289 }
1290
1291 let cur_offset: usize = (6 - 1) * envelope_size;
1294
1295 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1297
1298 fidl::encoding::encode_in_envelope_optional::<bool, D>(
1303 self.supports_read.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
1304 encoder,
1305 offset + cur_offset,
1306 depth,
1307 )?;
1308
1309 _prev_end_offset = cur_offset + envelope_size;
1310
1311 Ok(())
1312 }
1313 }
1314
1315 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TimerProperties {
1316 #[inline(always)]
1317 fn new_empty() -> Self {
1318 Self::default()
1319 }
1320
1321 unsafe fn decode(
1322 &mut self,
1323 decoder: &mut fidl::encoding::Decoder<'_, D>,
1324 offset: usize,
1325 mut depth: fidl::encoding::Depth,
1326 ) -> fidl::Result<()> {
1327 decoder.debug_check_bounds::<Self>(offset);
1328 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1329 None => return Err(fidl::Error::NotNullable),
1330 Some(len) => len,
1331 };
1332 if len == 0 {
1334 return Ok(());
1335 };
1336 depth.increment()?;
1337 let envelope_size = 8;
1338 let bytes_len = len * envelope_size;
1339 let offset = decoder.out_of_line_offset(bytes_len)?;
1340 let mut _next_ordinal_to_read = 0;
1342 let mut next_offset = offset;
1343 let end_offset = offset + bytes_len;
1344 _next_ordinal_to_read += 1;
1345 if next_offset >= end_offset {
1346 return Ok(());
1347 }
1348
1349 while _next_ordinal_to_read < 1 {
1351 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1352 _next_ordinal_to_read += 1;
1353 next_offset += envelope_size;
1354 }
1355
1356 let next_out_of_line = decoder.next_out_of_line();
1357 let handles_before = decoder.remaining_handles();
1358 if let Some((inlined, num_bytes, num_handles)) =
1359 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1360 {
1361 let member_inline_size =
1362 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1363 if inlined != (member_inline_size <= 4) {
1364 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1365 }
1366 let inner_offset;
1367 let mut inner_depth = depth.clone();
1368 if inlined {
1369 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1370 inner_offset = next_offset;
1371 } else {
1372 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1373 inner_depth.increment()?;
1374 }
1375 let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
1376 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1377 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1378 {
1379 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1380 }
1381 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1382 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1383 }
1384 }
1385
1386 next_offset += envelope_size;
1387 _next_ordinal_to_read += 1;
1388 if next_offset >= end_offset {
1389 return Ok(());
1390 }
1391
1392 while _next_ordinal_to_read < 2 {
1394 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1395 _next_ordinal_to_read += 1;
1396 next_offset += envelope_size;
1397 }
1398
1399 let next_out_of_line = decoder.next_out_of_line();
1400 let handles_before = decoder.remaining_handles();
1401 if let Some((inlined, num_bytes, num_handles)) =
1402 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1403 {
1404 let member_inline_size = <fidl::encoding::Vector<Resolution, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1405 if inlined != (member_inline_size <= 4) {
1406 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1407 }
1408 let inner_offset;
1409 let mut inner_depth = depth.clone();
1410 if inlined {
1411 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1412 inner_offset = next_offset;
1413 } else {
1414 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1415 inner_depth.increment()?;
1416 }
1417 let val_ref = self.supported_resolutions.get_or_insert_with(
1418 || fidl::new_empty!(fidl::encoding::Vector<Resolution, 64>, D),
1419 );
1420 fidl::decode!(fidl::encoding::Vector<Resolution, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
1421 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1422 {
1423 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1424 }
1425 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1426 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1427 }
1428 }
1429
1430 next_offset += envelope_size;
1431 _next_ordinal_to_read += 1;
1432 if next_offset >= end_offset {
1433 return Ok(());
1434 }
1435
1436 while _next_ordinal_to_read < 3 {
1438 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1439 _next_ordinal_to_read += 1;
1440 next_offset += envelope_size;
1441 }
1442
1443 let next_out_of_line = decoder.next_out_of_line();
1444 let handles_before = decoder.remaining_handles();
1445 if let Some((inlined, num_bytes, num_handles)) =
1446 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1447 {
1448 let member_inline_size =
1449 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1450 if inlined != (member_inline_size <= 4) {
1451 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1452 }
1453 let inner_offset;
1454 let mut inner_depth = depth.clone();
1455 if inlined {
1456 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1457 inner_offset = next_offset;
1458 } else {
1459 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1460 inner_depth.increment()?;
1461 }
1462 let val_ref = self.max_ticks.get_or_insert_with(|| fidl::new_empty!(u64, D));
1463 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1464 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1465 {
1466 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1467 }
1468 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1469 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1470 }
1471 }
1472
1473 next_offset += envelope_size;
1474 _next_ordinal_to_read += 1;
1475 if next_offset >= end_offset {
1476 return Ok(());
1477 }
1478
1479 while _next_ordinal_to_read < 4 {
1481 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1482 _next_ordinal_to_read += 1;
1483 next_offset += envelope_size;
1484 }
1485
1486 let next_out_of_line = decoder.next_out_of_line();
1487 let handles_before = decoder.remaining_handles();
1488 if let Some((inlined, num_bytes, num_handles)) =
1489 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1490 {
1491 let member_inline_size =
1492 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1493 if inlined != (member_inline_size <= 4) {
1494 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1495 }
1496 let inner_offset;
1497 let mut inner_depth = depth.clone();
1498 if inlined {
1499 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1500 inner_offset = next_offset;
1501 } else {
1502 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1503 inner_depth.increment()?;
1504 }
1505 let val_ref = self.supports_event.get_or_insert_with(|| fidl::new_empty!(bool, D));
1506 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1507 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1508 {
1509 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1510 }
1511 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1512 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1513 }
1514 }
1515
1516 next_offset += envelope_size;
1517 _next_ordinal_to_read += 1;
1518 if next_offset >= end_offset {
1519 return Ok(());
1520 }
1521
1522 while _next_ordinal_to_read < 5 {
1524 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1525 _next_ordinal_to_read += 1;
1526 next_offset += envelope_size;
1527 }
1528
1529 let next_out_of_line = decoder.next_out_of_line();
1530 let handles_before = decoder.remaining_handles();
1531 if let Some((inlined, num_bytes, num_handles)) =
1532 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1533 {
1534 let member_inline_size =
1535 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1536 if inlined != (member_inline_size <= 4) {
1537 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1538 }
1539 let inner_offset;
1540 let mut inner_depth = depth.clone();
1541 if inlined {
1542 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1543 inner_offset = next_offset;
1544 } else {
1545 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1546 inner_depth.increment()?;
1547 }
1548 let val_ref = self.supports_wait.get_or_insert_with(|| fidl::new_empty!(bool, D));
1549 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1550 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1551 {
1552 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1553 }
1554 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1555 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1556 }
1557 }
1558
1559 next_offset += envelope_size;
1560 _next_ordinal_to_read += 1;
1561 if next_offset >= end_offset {
1562 return Ok(());
1563 }
1564
1565 while _next_ordinal_to_read < 6 {
1567 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1568 _next_ordinal_to_read += 1;
1569 next_offset += envelope_size;
1570 }
1571
1572 let next_out_of_line = decoder.next_out_of_line();
1573 let handles_before = decoder.remaining_handles();
1574 if let Some((inlined, num_bytes, num_handles)) =
1575 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1576 {
1577 let member_inline_size =
1578 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1579 if inlined != (member_inline_size <= 4) {
1580 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1581 }
1582 let inner_offset;
1583 let mut inner_depth = depth.clone();
1584 if inlined {
1585 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1586 inner_offset = next_offset;
1587 } else {
1588 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1589 inner_depth.increment()?;
1590 }
1591 let val_ref = self.supports_read.get_or_insert_with(|| fidl::new_empty!(bool, D));
1592 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1593 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1594 {
1595 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1596 }
1597 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1598 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1599 }
1600 }
1601
1602 next_offset += envelope_size;
1603
1604 while next_offset < end_offset {
1606 _next_ordinal_to_read += 1;
1607 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1608 next_offset += envelope_size;
1609 }
1610
1611 Ok(())
1612 }
1613 }
1614
1615 impl fidl::encoding::ValueTypeMarker for Resolution {
1616 type Borrowed<'a> = &'a Self;
1617 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1618 value
1619 }
1620 }
1621
1622 unsafe impl fidl::encoding::TypeMarker for Resolution {
1623 type Owned = Self;
1624
1625 #[inline(always)]
1626 fn inline_align(_context: fidl::encoding::Context) -> usize {
1627 8
1628 }
1629
1630 #[inline(always)]
1631 fn inline_size(_context: fidl::encoding::Context) -> usize {
1632 16
1633 }
1634 }
1635
1636 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Resolution, D>
1637 for &Resolution
1638 {
1639 #[inline]
1640 unsafe fn encode(
1641 self,
1642 encoder: &mut fidl::encoding::Encoder<'_, D>,
1643 offset: usize,
1644 _depth: fidl::encoding::Depth,
1645 ) -> fidl::Result<()> {
1646 encoder.debug_check_bounds::<Resolution>(offset);
1647 encoder.write_num::<u64>(self.ordinal(), offset);
1648 match self {
1649 Resolution::Duration(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
1650 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
1651 encoder,
1652 offset + 8,
1653 _depth,
1654 ),
1655 Resolution::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1656 }
1657 }
1658 }
1659
1660 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Resolution {
1661 #[inline(always)]
1662 fn new_empty() -> Self {
1663 Self::__SourceBreaking { unknown_ordinal: 0 }
1664 }
1665
1666 #[inline]
1667 unsafe fn decode(
1668 &mut self,
1669 decoder: &mut fidl::encoding::Decoder<'_, D>,
1670 offset: usize,
1671 mut depth: fidl::encoding::Depth,
1672 ) -> fidl::Result<()> {
1673 decoder.debug_check_bounds::<Self>(offset);
1674 #[allow(unused_variables)]
1675 let next_out_of_line = decoder.next_out_of_line();
1676 let handles_before = decoder.remaining_handles();
1677 let (ordinal, inlined, num_bytes, num_handles) =
1678 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1679
1680 let member_inline_size = match ordinal {
1681 1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1682 0 => return Err(fidl::Error::UnknownUnionTag),
1683 _ => num_bytes as usize,
1684 };
1685
1686 if inlined != (member_inline_size <= 4) {
1687 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1688 }
1689 let _inner_offset;
1690 if inlined {
1691 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1692 _inner_offset = offset + 8;
1693 } else {
1694 depth.increment()?;
1695 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1696 }
1697 match ordinal {
1698 1 => {
1699 #[allow(irrefutable_let_patterns)]
1700 if let Resolution::Duration(_) = self {
1701 } else {
1703 *self = Resolution::Duration(fidl::new_empty!(i64, D));
1705 }
1706 #[allow(irrefutable_let_patterns)]
1707 if let Resolution::Duration(ref mut val) = self {
1708 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1709 } else {
1710 unreachable!()
1711 }
1712 }
1713 #[allow(deprecated)]
1714 ordinal => {
1715 for _ in 0..num_handles {
1716 decoder.drop_next_handle()?;
1717 }
1718 *self = Resolution::__SourceBreaking { unknown_ordinal: ordinal };
1719 }
1720 }
1721 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1722 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1723 }
1724 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1725 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1726 }
1727 Ok(())
1728 }
1729 }
1730}