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 DeviceStartRequest {
104 pub id: u64,
105 pub resolution: Resolution,
106 pub ticks: u64,
107}
108
109impl fidl::Persistable for DeviceStartRequest {}
110
111#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112#[repr(C)]
113pub struct DeviceStopRequest {
114 pub id: u64,
115}
116
117impl fidl::Persistable for DeviceStopRequest {}
118
119#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
120#[repr(C)]
121pub struct DeviceGetTicksLeftResponse {
122 pub ticks: u64,
123}
124
125impl fidl::Persistable for DeviceGetTicksLeftResponse {}
126
127#[derive(Clone, Debug, Default, PartialEq)]
129pub struct TimerProperties {
130 pub id: Option<u64>,
137 pub supported_resolutions: Option<Vec<Resolution>>,
141 pub max_ticks: Option<u64>,
159 pub supports_event: Option<bool>,
164 pub supports_wait: Option<bool>,
169 #[doc(hidden)]
170 pub __source_breaking: fidl::marker::SourceBreaking,
171}
172
173impl fidl::Persistable for TimerProperties {}
174
175#[derive(Clone, Debug)]
177pub enum Resolution {
178 Duration(i64),
180 #[doc(hidden)]
181 __SourceBreaking { unknown_ordinal: u64 },
182}
183
184#[macro_export]
186macro_rules! ResolutionUnknown {
187 () => {
188 _
189 };
190}
191
192impl PartialEq for Resolution {
194 fn eq(&self, other: &Self) -> bool {
195 match (self, other) {
196 (Self::Duration(x), Self::Duration(y)) => *x == *y,
197 _ => false,
198 }
199 }
200}
201
202impl Resolution {
203 #[inline]
204 pub fn ordinal(&self) -> u64 {
205 match *self {
206 Self::Duration(_) => 1,
207 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
208 }
209 }
210
211 #[inline]
212 pub fn unknown_variant_for_testing() -> Self {
213 Self::__SourceBreaking { unknown_ordinal: 0 }
214 }
215
216 #[inline]
217 pub fn is_unknown(&self) -> bool {
218 match self {
219 Self::__SourceBreaking { .. } => true,
220 _ => false,
221 }
222 }
223}
224
225impl fidl::Persistable for Resolution {}
226
227mod internal {
228 use super::*;
229 unsafe impl fidl::encoding::TypeMarker for DriverError {
230 type Owned = Self;
231
232 #[inline(always)]
233 fn inline_align(_context: fidl::encoding::Context) -> usize {
234 std::mem::align_of::<u32>()
235 }
236
237 #[inline(always)]
238 fn inline_size(_context: fidl::encoding::Context) -> usize {
239 std::mem::size_of::<u32>()
240 }
241
242 #[inline(always)]
243 fn encode_is_copy() -> bool {
244 false
245 }
246
247 #[inline(always)]
248 fn decode_is_copy() -> bool {
249 false
250 }
251 }
252
253 impl fidl::encoding::ValueTypeMarker for DriverError {
254 type Borrowed<'a> = Self;
255 #[inline(always)]
256 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
257 *value
258 }
259 }
260
261 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DriverError {
262 #[inline]
263 unsafe fn encode(
264 self,
265 encoder: &mut fidl::encoding::Encoder<'_, D>,
266 offset: usize,
267 _depth: fidl::encoding::Depth,
268 ) -> fidl::Result<()> {
269 encoder.debug_check_bounds::<Self>(offset);
270 encoder.write_num(self.into_primitive(), offset);
271 Ok(())
272 }
273 }
274
275 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DriverError {
276 #[inline(always)]
277 fn new_empty() -> Self {
278 Self::unknown()
279 }
280
281 #[inline]
282 unsafe fn decode(
283 &mut self,
284 decoder: &mut fidl::encoding::Decoder<'_, D>,
285 offset: usize,
286 _depth: fidl::encoding::Depth,
287 ) -> fidl::Result<()> {
288 decoder.debug_check_bounds::<Self>(offset);
289 let prim = decoder.read_num::<u32>(offset);
290
291 *self = Self::from_primitive_allow_unknown(prim);
292 Ok(())
293 }
294 }
295
296 impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftRequest {
297 type Borrowed<'a> = &'a Self;
298 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
299 value
300 }
301 }
302
303 unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftRequest {
304 type Owned = Self;
305
306 #[inline(always)]
307 fn inline_align(_context: fidl::encoding::Context) -> usize {
308 8
309 }
310
311 #[inline(always)]
312 fn inline_size(_context: fidl::encoding::Context) -> usize {
313 8
314 }
315 #[inline(always)]
316 fn encode_is_copy() -> bool {
317 true
318 }
319
320 #[inline(always)]
321 fn decode_is_copy() -> bool {
322 true
323 }
324 }
325
326 unsafe impl<D: fidl::encoding::ResourceDialect>
327 fidl::encoding::Encode<DeviceGetTicksLeftRequest, D> for &DeviceGetTicksLeftRequest
328 {
329 #[inline]
330 unsafe fn encode(
331 self,
332 encoder: &mut fidl::encoding::Encoder<'_, D>,
333 offset: usize,
334 _depth: fidl::encoding::Depth,
335 ) -> fidl::Result<()> {
336 encoder.debug_check_bounds::<DeviceGetTicksLeftRequest>(offset);
337 unsafe {
338 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
340 (buf_ptr as *mut DeviceGetTicksLeftRequest)
341 .write_unaligned((self as *const DeviceGetTicksLeftRequest).read());
342 }
345 Ok(())
346 }
347 }
348 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
349 fidl::encoding::Encode<DeviceGetTicksLeftRequest, D> for (T0,)
350 {
351 #[inline]
352 unsafe fn encode(
353 self,
354 encoder: &mut fidl::encoding::Encoder<'_, D>,
355 offset: usize,
356 depth: fidl::encoding::Depth,
357 ) -> fidl::Result<()> {
358 encoder.debug_check_bounds::<DeviceGetTicksLeftRequest>(offset);
359 self.0.encode(encoder, offset + 0, depth)?;
363 Ok(())
364 }
365 }
366
367 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
368 for DeviceGetTicksLeftRequest
369 {
370 #[inline(always)]
371 fn new_empty() -> Self {
372 Self { id: fidl::new_empty!(u64, D) }
373 }
374
375 #[inline]
376 unsafe fn decode(
377 &mut self,
378 decoder: &mut fidl::encoding::Decoder<'_, D>,
379 offset: usize,
380 _depth: fidl::encoding::Depth,
381 ) -> fidl::Result<()> {
382 decoder.debug_check_bounds::<Self>(offset);
383 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
384 unsafe {
387 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
388 }
389 Ok(())
390 }
391 }
392
393 impl fidl::encoding::ValueTypeMarker for DeviceStartRequest {
394 type Borrowed<'a> = &'a Self;
395 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
396 value
397 }
398 }
399
400 unsafe impl fidl::encoding::TypeMarker for DeviceStartRequest {
401 type Owned = Self;
402
403 #[inline(always)]
404 fn inline_align(_context: fidl::encoding::Context) -> usize {
405 8
406 }
407
408 #[inline(always)]
409 fn inline_size(_context: fidl::encoding::Context) -> usize {
410 32
411 }
412 }
413
414 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceStartRequest, D>
415 for &DeviceStartRequest
416 {
417 #[inline]
418 unsafe fn encode(
419 self,
420 encoder: &mut fidl::encoding::Encoder<'_, D>,
421 offset: usize,
422 _depth: fidl::encoding::Depth,
423 ) -> fidl::Result<()> {
424 encoder.debug_check_bounds::<DeviceStartRequest>(offset);
425 fidl::encoding::Encode::<DeviceStartRequest, D>::encode(
427 (
428 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
429 <Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
430 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
431 ),
432 encoder,
433 offset,
434 _depth,
435 )
436 }
437 }
438 unsafe impl<
439 D: fidl::encoding::ResourceDialect,
440 T0: fidl::encoding::Encode<u64, D>,
441 T1: fidl::encoding::Encode<Resolution, D>,
442 T2: fidl::encoding::Encode<u64, D>,
443 > fidl::encoding::Encode<DeviceStartRequest, D> for (T0, T1, T2)
444 {
445 #[inline]
446 unsafe fn encode(
447 self,
448 encoder: &mut fidl::encoding::Encoder<'_, D>,
449 offset: usize,
450 depth: fidl::encoding::Depth,
451 ) -> fidl::Result<()> {
452 encoder.debug_check_bounds::<DeviceStartRequest>(offset);
453 self.0.encode(encoder, offset + 0, depth)?;
457 self.1.encode(encoder, offset + 8, depth)?;
458 self.2.encode(encoder, offset + 24, depth)?;
459 Ok(())
460 }
461 }
462
463 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStartRequest {
464 #[inline(always)]
465 fn new_empty() -> Self {
466 Self {
467 id: fidl::new_empty!(u64, D),
468 resolution: fidl::new_empty!(Resolution, D),
469 ticks: fidl::new_empty!(u64, D),
470 }
471 }
472
473 #[inline]
474 unsafe fn decode(
475 &mut self,
476 decoder: &mut fidl::encoding::Decoder<'_, D>,
477 offset: usize,
478 _depth: fidl::encoding::Depth,
479 ) -> fidl::Result<()> {
480 decoder.debug_check_bounds::<Self>(offset);
481 fidl::decode!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
483 fidl::decode!(Resolution, D, &mut self.resolution, decoder, offset + 8, _depth)?;
484 fidl::decode!(u64, D, &mut self.ticks, decoder, offset + 24, _depth)?;
485 Ok(())
486 }
487 }
488
489 impl fidl::encoding::ValueTypeMarker for DeviceStopRequest {
490 type Borrowed<'a> = &'a Self;
491 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
492 value
493 }
494 }
495
496 unsafe impl fidl::encoding::TypeMarker for DeviceStopRequest {
497 type Owned = Self;
498
499 #[inline(always)]
500 fn inline_align(_context: fidl::encoding::Context) -> usize {
501 8
502 }
503
504 #[inline(always)]
505 fn inline_size(_context: fidl::encoding::Context) -> usize {
506 8
507 }
508 #[inline(always)]
509 fn encode_is_copy() -> bool {
510 true
511 }
512
513 #[inline(always)]
514 fn decode_is_copy() -> bool {
515 true
516 }
517 }
518
519 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceStopRequest, D>
520 for &DeviceStopRequest
521 {
522 #[inline]
523 unsafe fn encode(
524 self,
525 encoder: &mut fidl::encoding::Encoder<'_, D>,
526 offset: usize,
527 _depth: fidl::encoding::Depth,
528 ) -> fidl::Result<()> {
529 encoder.debug_check_bounds::<DeviceStopRequest>(offset);
530 unsafe {
531 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
533 (buf_ptr as *mut DeviceStopRequest)
534 .write_unaligned((self as *const DeviceStopRequest).read());
535 }
538 Ok(())
539 }
540 }
541 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
542 fidl::encoding::Encode<DeviceStopRequest, D> for (T0,)
543 {
544 #[inline]
545 unsafe fn encode(
546 self,
547 encoder: &mut fidl::encoding::Encoder<'_, D>,
548 offset: usize,
549 depth: fidl::encoding::Depth,
550 ) -> fidl::Result<()> {
551 encoder.debug_check_bounds::<DeviceStopRequest>(offset);
552 self.0.encode(encoder, offset + 0, depth)?;
556 Ok(())
557 }
558 }
559
560 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStopRequest {
561 #[inline(always)]
562 fn new_empty() -> Self {
563 Self { id: fidl::new_empty!(u64, D) }
564 }
565
566 #[inline]
567 unsafe fn decode(
568 &mut self,
569 decoder: &mut fidl::encoding::Decoder<'_, D>,
570 offset: usize,
571 _depth: fidl::encoding::Depth,
572 ) -> fidl::Result<()> {
573 decoder.debug_check_bounds::<Self>(offset);
574 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
575 unsafe {
578 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
579 }
580 Ok(())
581 }
582 }
583
584 impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftResponse {
585 type Borrowed<'a> = &'a Self;
586 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
587 value
588 }
589 }
590
591 unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftResponse {
592 type Owned = Self;
593
594 #[inline(always)]
595 fn inline_align(_context: fidl::encoding::Context) -> usize {
596 8
597 }
598
599 #[inline(always)]
600 fn inline_size(_context: fidl::encoding::Context) -> usize {
601 8
602 }
603 #[inline(always)]
604 fn encode_is_copy() -> bool {
605 true
606 }
607
608 #[inline(always)]
609 fn decode_is_copy() -> bool {
610 true
611 }
612 }
613
614 unsafe impl<D: fidl::encoding::ResourceDialect>
615 fidl::encoding::Encode<DeviceGetTicksLeftResponse, D> for &DeviceGetTicksLeftResponse
616 {
617 #[inline]
618 unsafe fn encode(
619 self,
620 encoder: &mut fidl::encoding::Encoder<'_, D>,
621 offset: usize,
622 _depth: fidl::encoding::Depth,
623 ) -> fidl::Result<()> {
624 encoder.debug_check_bounds::<DeviceGetTicksLeftResponse>(offset);
625 unsafe {
626 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
628 (buf_ptr as *mut DeviceGetTicksLeftResponse)
629 .write_unaligned((self as *const DeviceGetTicksLeftResponse).read());
630 }
633 Ok(())
634 }
635 }
636 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
637 fidl::encoding::Encode<DeviceGetTicksLeftResponse, D> for (T0,)
638 {
639 #[inline]
640 unsafe fn encode(
641 self,
642 encoder: &mut fidl::encoding::Encoder<'_, D>,
643 offset: usize,
644 depth: fidl::encoding::Depth,
645 ) -> fidl::Result<()> {
646 encoder.debug_check_bounds::<DeviceGetTicksLeftResponse>(offset);
647 self.0.encode(encoder, offset + 0, depth)?;
651 Ok(())
652 }
653 }
654
655 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
656 for DeviceGetTicksLeftResponse
657 {
658 #[inline(always)]
659 fn new_empty() -> Self {
660 Self { ticks: fidl::new_empty!(u64, D) }
661 }
662
663 #[inline]
664 unsafe fn decode(
665 &mut self,
666 decoder: &mut fidl::encoding::Decoder<'_, D>,
667 offset: usize,
668 _depth: fidl::encoding::Depth,
669 ) -> fidl::Result<()> {
670 decoder.debug_check_bounds::<Self>(offset);
671 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
672 unsafe {
675 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
676 }
677 Ok(())
678 }
679 }
680
681 impl TimerProperties {
682 #[inline(always)]
683 fn max_ordinal_present(&self) -> u64 {
684 if let Some(_) = self.supports_wait {
685 return 5;
686 }
687 if let Some(_) = self.supports_event {
688 return 4;
689 }
690 if let Some(_) = self.max_ticks {
691 return 3;
692 }
693 if let Some(_) = self.supported_resolutions {
694 return 2;
695 }
696 if let Some(_) = self.id {
697 return 1;
698 }
699 0
700 }
701 }
702
703 impl fidl::encoding::ValueTypeMarker for TimerProperties {
704 type Borrowed<'a> = &'a Self;
705 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
706 value
707 }
708 }
709
710 unsafe impl fidl::encoding::TypeMarker for TimerProperties {
711 type Owned = Self;
712
713 #[inline(always)]
714 fn inline_align(_context: fidl::encoding::Context) -> usize {
715 8
716 }
717
718 #[inline(always)]
719 fn inline_size(_context: fidl::encoding::Context) -> usize {
720 16
721 }
722 }
723
724 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<TimerProperties, D>
725 for &TimerProperties
726 {
727 unsafe fn encode(
728 self,
729 encoder: &mut fidl::encoding::Encoder<'_, D>,
730 offset: usize,
731 mut depth: fidl::encoding::Depth,
732 ) -> fidl::Result<()> {
733 encoder.debug_check_bounds::<TimerProperties>(offset);
734 let max_ordinal: u64 = self.max_ordinal_present();
736 encoder.write_num(max_ordinal, offset);
737 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
738 if max_ordinal == 0 {
740 return Ok(());
741 }
742 depth.increment()?;
743 let envelope_size = 8;
744 let bytes_len = max_ordinal as usize * envelope_size;
745 #[allow(unused_variables)]
746 let offset = encoder.out_of_line_offset(bytes_len);
747 let mut _prev_end_offset: usize = 0;
748 if 1 > max_ordinal {
749 return Ok(());
750 }
751
752 let cur_offset: usize = (1 - 1) * envelope_size;
755
756 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
758
759 fidl::encoding::encode_in_envelope_optional::<u64, D>(
764 self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
765 encoder,
766 offset + cur_offset,
767 depth,
768 )?;
769
770 _prev_end_offset = cur_offset + envelope_size;
771 if 2 > max_ordinal {
772 return Ok(());
773 }
774
775 let cur_offset: usize = (2 - 1) * envelope_size;
778
779 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
781
782 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Resolution, 64>, D>(
787 self.supported_resolutions.as_ref().map(<fidl::encoding::Vector<Resolution, 64> as fidl::encoding::ValueTypeMarker>::borrow),
788 encoder, offset + cur_offset, depth
789 )?;
790
791 _prev_end_offset = cur_offset + envelope_size;
792 if 3 > max_ordinal {
793 return Ok(());
794 }
795
796 let cur_offset: usize = (3 - 1) * envelope_size;
799
800 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
802
803 fidl::encoding::encode_in_envelope_optional::<u64, D>(
808 self.max_ticks.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
809 encoder,
810 offset + cur_offset,
811 depth,
812 )?;
813
814 _prev_end_offset = cur_offset + envelope_size;
815 if 4 > max_ordinal {
816 return Ok(());
817 }
818
819 let cur_offset: usize = (4 - 1) * envelope_size;
822
823 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
825
826 fidl::encoding::encode_in_envelope_optional::<bool, D>(
831 self.supports_event.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
832 encoder,
833 offset + cur_offset,
834 depth,
835 )?;
836
837 _prev_end_offset = cur_offset + envelope_size;
838 if 5 > max_ordinal {
839 return Ok(());
840 }
841
842 let cur_offset: usize = (5 - 1) * envelope_size;
845
846 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
848
849 fidl::encoding::encode_in_envelope_optional::<bool, D>(
854 self.supports_wait.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
855 encoder,
856 offset + cur_offset,
857 depth,
858 )?;
859
860 _prev_end_offset = cur_offset + envelope_size;
861
862 Ok(())
863 }
864 }
865
866 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TimerProperties {
867 #[inline(always)]
868 fn new_empty() -> Self {
869 Self::default()
870 }
871
872 unsafe fn decode(
873 &mut self,
874 decoder: &mut fidl::encoding::Decoder<'_, D>,
875 offset: usize,
876 mut depth: fidl::encoding::Depth,
877 ) -> fidl::Result<()> {
878 decoder.debug_check_bounds::<Self>(offset);
879 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
880 None => return Err(fidl::Error::NotNullable),
881 Some(len) => len,
882 };
883 if len == 0 {
885 return Ok(());
886 };
887 depth.increment()?;
888 let envelope_size = 8;
889 let bytes_len = len * envelope_size;
890 let offset = decoder.out_of_line_offset(bytes_len)?;
891 let mut _next_ordinal_to_read = 0;
893 let mut next_offset = offset;
894 let end_offset = offset + bytes_len;
895 _next_ordinal_to_read += 1;
896 if next_offset >= end_offset {
897 return Ok(());
898 }
899
900 while _next_ordinal_to_read < 1 {
902 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
903 _next_ordinal_to_read += 1;
904 next_offset += envelope_size;
905 }
906
907 let next_out_of_line = decoder.next_out_of_line();
908 let handles_before = decoder.remaining_handles();
909 if let Some((inlined, num_bytes, num_handles)) =
910 fidl::encoding::decode_envelope_header(decoder, next_offset)?
911 {
912 let member_inline_size =
913 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
914 if inlined != (member_inline_size <= 4) {
915 return Err(fidl::Error::InvalidInlineBitInEnvelope);
916 }
917 let inner_offset;
918 let mut inner_depth = depth.clone();
919 if inlined {
920 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
921 inner_offset = next_offset;
922 } else {
923 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
924 inner_depth.increment()?;
925 }
926 let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
927 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
928 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
929 {
930 return Err(fidl::Error::InvalidNumBytesInEnvelope);
931 }
932 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
933 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
934 }
935 }
936
937 next_offset += envelope_size;
938 _next_ordinal_to_read += 1;
939 if next_offset >= end_offset {
940 return Ok(());
941 }
942
943 while _next_ordinal_to_read < 2 {
945 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
946 _next_ordinal_to_read += 1;
947 next_offset += envelope_size;
948 }
949
950 let next_out_of_line = decoder.next_out_of_line();
951 let handles_before = decoder.remaining_handles();
952 if let Some((inlined, num_bytes, num_handles)) =
953 fidl::encoding::decode_envelope_header(decoder, next_offset)?
954 {
955 let member_inline_size = <fidl::encoding::Vector<Resolution, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
956 if inlined != (member_inline_size <= 4) {
957 return Err(fidl::Error::InvalidInlineBitInEnvelope);
958 }
959 let inner_offset;
960 let mut inner_depth = depth.clone();
961 if inlined {
962 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
963 inner_offset = next_offset;
964 } else {
965 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
966 inner_depth.increment()?;
967 }
968 let val_ref = self.supported_resolutions.get_or_insert_with(
969 || fidl::new_empty!(fidl::encoding::Vector<Resolution, 64>, D),
970 );
971 fidl::decode!(fidl::encoding::Vector<Resolution, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
972 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
973 {
974 return Err(fidl::Error::InvalidNumBytesInEnvelope);
975 }
976 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
977 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
978 }
979 }
980
981 next_offset += envelope_size;
982 _next_ordinal_to_read += 1;
983 if next_offset >= end_offset {
984 return Ok(());
985 }
986
987 while _next_ordinal_to_read < 3 {
989 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
990 _next_ordinal_to_read += 1;
991 next_offset += envelope_size;
992 }
993
994 let next_out_of_line = decoder.next_out_of_line();
995 let handles_before = decoder.remaining_handles();
996 if let Some((inlined, num_bytes, num_handles)) =
997 fidl::encoding::decode_envelope_header(decoder, next_offset)?
998 {
999 let member_inline_size =
1000 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1001 if inlined != (member_inline_size <= 4) {
1002 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1003 }
1004 let inner_offset;
1005 let mut inner_depth = depth.clone();
1006 if inlined {
1007 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1008 inner_offset = next_offset;
1009 } else {
1010 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1011 inner_depth.increment()?;
1012 }
1013 let val_ref = self.max_ticks.get_or_insert_with(|| fidl::new_empty!(u64, D));
1014 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
1015 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1016 {
1017 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1018 }
1019 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1020 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1021 }
1022 }
1023
1024 next_offset += envelope_size;
1025 _next_ordinal_to_read += 1;
1026 if next_offset >= end_offset {
1027 return Ok(());
1028 }
1029
1030 while _next_ordinal_to_read < 4 {
1032 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1033 _next_ordinal_to_read += 1;
1034 next_offset += envelope_size;
1035 }
1036
1037 let next_out_of_line = decoder.next_out_of_line();
1038 let handles_before = decoder.remaining_handles();
1039 if let Some((inlined, num_bytes, num_handles)) =
1040 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1041 {
1042 let member_inline_size =
1043 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1044 if inlined != (member_inline_size <= 4) {
1045 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1046 }
1047 let inner_offset;
1048 let mut inner_depth = depth.clone();
1049 if inlined {
1050 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1051 inner_offset = next_offset;
1052 } else {
1053 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1054 inner_depth.increment()?;
1055 }
1056 let val_ref = self.supports_event.get_or_insert_with(|| fidl::new_empty!(bool, D));
1057 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1058 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1059 {
1060 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1061 }
1062 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1063 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1064 }
1065 }
1066
1067 next_offset += envelope_size;
1068 _next_ordinal_to_read += 1;
1069 if next_offset >= end_offset {
1070 return Ok(());
1071 }
1072
1073 while _next_ordinal_to_read < 5 {
1075 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1076 _next_ordinal_to_read += 1;
1077 next_offset += envelope_size;
1078 }
1079
1080 let next_out_of_line = decoder.next_out_of_line();
1081 let handles_before = decoder.remaining_handles();
1082 if let Some((inlined, num_bytes, num_handles)) =
1083 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1084 {
1085 let member_inline_size =
1086 <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1087 if inlined != (member_inline_size <= 4) {
1088 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1089 }
1090 let inner_offset;
1091 let mut inner_depth = depth.clone();
1092 if inlined {
1093 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1094 inner_offset = next_offset;
1095 } else {
1096 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1097 inner_depth.increment()?;
1098 }
1099 let val_ref = self.supports_wait.get_or_insert_with(|| fidl::new_empty!(bool, D));
1100 fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
1101 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1102 {
1103 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1104 }
1105 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1106 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1107 }
1108 }
1109
1110 next_offset += envelope_size;
1111
1112 while next_offset < end_offset {
1114 _next_ordinal_to_read += 1;
1115 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1116 next_offset += envelope_size;
1117 }
1118
1119 Ok(())
1120 }
1121 }
1122
1123 impl fidl::encoding::ValueTypeMarker for Resolution {
1124 type Borrowed<'a> = &'a Self;
1125 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1126 value
1127 }
1128 }
1129
1130 unsafe impl fidl::encoding::TypeMarker for Resolution {
1131 type Owned = Self;
1132
1133 #[inline(always)]
1134 fn inline_align(_context: fidl::encoding::Context) -> usize {
1135 8
1136 }
1137
1138 #[inline(always)]
1139 fn inline_size(_context: fidl::encoding::Context) -> usize {
1140 16
1141 }
1142 }
1143
1144 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Resolution, D>
1145 for &Resolution
1146 {
1147 #[inline]
1148 unsafe fn encode(
1149 self,
1150 encoder: &mut fidl::encoding::Encoder<'_, D>,
1151 offset: usize,
1152 _depth: fidl::encoding::Depth,
1153 ) -> fidl::Result<()> {
1154 encoder.debug_check_bounds::<Resolution>(offset);
1155 encoder.write_num::<u64>(self.ordinal(), offset);
1156 match self {
1157 Resolution::Duration(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
1158 <i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
1159 encoder,
1160 offset + 8,
1161 _depth,
1162 ),
1163 Resolution::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1164 }
1165 }
1166 }
1167
1168 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Resolution {
1169 #[inline(always)]
1170 fn new_empty() -> Self {
1171 Self::__SourceBreaking { unknown_ordinal: 0 }
1172 }
1173
1174 #[inline]
1175 unsafe fn decode(
1176 &mut self,
1177 decoder: &mut fidl::encoding::Decoder<'_, D>,
1178 offset: usize,
1179 mut depth: fidl::encoding::Depth,
1180 ) -> fidl::Result<()> {
1181 decoder.debug_check_bounds::<Self>(offset);
1182 #[allow(unused_variables)]
1183 let next_out_of_line = decoder.next_out_of_line();
1184 let handles_before = decoder.remaining_handles();
1185 let (ordinal, inlined, num_bytes, num_handles) =
1186 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1187
1188 let member_inline_size = match ordinal {
1189 1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1190 0 => return Err(fidl::Error::UnknownUnionTag),
1191 _ => num_bytes as usize,
1192 };
1193
1194 if inlined != (member_inline_size <= 4) {
1195 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1196 }
1197 let _inner_offset;
1198 if inlined {
1199 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1200 _inner_offset = offset + 8;
1201 } else {
1202 depth.increment()?;
1203 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1204 }
1205 match ordinal {
1206 1 => {
1207 #[allow(irrefutable_let_patterns)]
1208 if let Resolution::Duration(_) = self {
1209 } else {
1211 *self = Resolution::Duration(fidl::new_empty!(i64, D));
1213 }
1214 #[allow(irrefutable_let_patterns)]
1215 if let Resolution::Duration(ref mut val) = self {
1216 fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
1217 } else {
1218 unreachable!()
1219 }
1220 }
1221 #[allow(deprecated)]
1222 ordinal => {
1223 for _ in 0..num_handles {
1224 decoder.drop_next_handle()?;
1225 }
1226 *self = Resolution::__SourceBreaking { unknown_ordinal: ordinal };
1227 }
1228 }
1229 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1230 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1231 }
1232 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1233 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1234 }
1235 Ok(())
1236 }
1237 }
1238}