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 SIGNAL_ACK_INTERRUPT: u32 = 16777216;
12
13bitflags! {
14 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
15 pub struct InterruptOptions: u32 {
16 const WAKEABLE = 1;
19 const TIMESTAMP_MONO = 2;
22 }
23}
24
25impl InterruptOptions {
26 #[inline(always)]
27 pub fn from_bits_allow_unknown(bits: u32) -> Self {
28 Self::from_bits_retain(bits)
29 }
30
31 #[inline(always)]
32 pub fn has_unknown_bits(&self) -> bool {
33 self.get_unknown_bits() != 0
34 }
35
36 #[inline(always)]
37 pub fn get_unknown_bits(&self) -> u32 {
38 self.bits() & !Self::all().bits()
39 }
40}
41
42#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
44#[repr(u32)]
45pub enum BufferMode {
46 Input = 0,
47 OutputLow = 1,
48 OutputHigh = 2,
49}
50
51impl BufferMode {
52 #[inline]
53 pub fn from_primitive(prim: u32) -> Option<Self> {
54 match prim {
55 0 => Some(Self::Input),
56 1 => Some(Self::OutputLow),
57 2 => Some(Self::OutputHigh),
58 _ => None,
59 }
60 }
61
62 #[inline]
63 pub const fn into_primitive(self) -> u32 {
64 self as u32
65 }
66}
67
68#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
69#[repr(u32)]
70pub enum InterruptMode {
71 EdgeLow = 0,
72 EdgeHigh = 1,
73 EdgeBoth = 2,
74 LevelLow = 3,
75 LevelHigh = 4,
76}
77
78impl InterruptMode {
79 #[inline]
80 pub fn from_primitive(prim: u32) -> Option<Self> {
81 match prim {
82 0 => Some(Self::EdgeLow),
83 1 => Some(Self::EdgeHigh),
84 2 => Some(Self::EdgeBoth),
85 3 => Some(Self::LevelLow),
86 4 => Some(Self::LevelHigh),
87 _ => None,
88 }
89 }
90
91 #[inline]
92 pub const fn into_primitive(self) -> u32 {
93 self as u32
94 }
95}
96
97#[derive(Clone, Debug, PartialEq)]
98pub struct GpioConfigureInterruptRequest {
99 pub config: InterruptConfiguration,
100}
101
102impl fidl::Persistable for GpioConfigureInterruptRequest {}
103
104#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
105pub struct GpioGetInterruptRequest {
106 pub options: InterruptOptions,
107}
108
109impl fidl::Persistable for GpioGetInterruptRequest {}
110
111#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
112pub struct GpioSetBufferModeRequest {
113 pub mode: BufferMode,
114}
115
116impl fidl::Persistable for GpioSetBufferModeRequest {}
117
118#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
119pub struct GpioReadResponse {
120 pub value: bool,
121}
122
123impl fidl::Persistable for GpioReadResponse {}
124
125#[derive(Clone, Debug, Default, PartialEq)]
126pub struct InterruptConfiguration {
127 pub mode: Option<InterruptMode>,
128 #[doc(hidden)]
129 pub __source_breaking: fidl::marker::SourceBreaking,
130}
131
132impl fidl::Persistable for InterruptConfiguration {}
133
134pub mod gpio_ordinals {
135 pub const READ: u64 = 0x5fdfe4816ed6a7b0;
136 pub const SET_BUFFER_MODE: u64 = 0x6c766846a5d634c3;
137 pub const GET_INTERRUPT: u64 = 0x6638c6b4471c7d05;
138 pub const CONFIGURE_INTERRUPT: u64 = 0x65a8a4db7d0f3ca3;
139 pub const RELEASE_INTERRUPT: u64 = 0x423a4009bfef9946;
140}
141
142mod internal {
143 use super::*;
144 unsafe impl fidl::encoding::TypeMarker for InterruptOptions {
145 type Owned = Self;
146
147 #[inline(always)]
148 fn inline_align(_context: fidl::encoding::Context) -> usize {
149 4
150 }
151
152 #[inline(always)]
153 fn inline_size(_context: fidl::encoding::Context) -> usize {
154 4
155 }
156 }
157
158 impl fidl::encoding::ValueTypeMarker for InterruptOptions {
159 type Borrowed<'a> = Self;
160 #[inline(always)]
161 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
162 *value
163 }
164 }
165
166 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
167 for InterruptOptions
168 {
169 #[inline]
170 unsafe fn encode(
171 self,
172 encoder: &mut fidl::encoding::Encoder<'_, D>,
173 offset: usize,
174 _depth: fidl::encoding::Depth,
175 ) -> fidl::Result<()> {
176 encoder.debug_check_bounds::<Self>(offset);
177 encoder.write_num(self.bits(), offset);
178 Ok(())
179 }
180 }
181
182 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterruptOptions {
183 #[inline(always)]
184 fn new_empty() -> Self {
185 Self::empty()
186 }
187
188 #[inline]
189 unsafe fn decode(
190 &mut self,
191 decoder: &mut fidl::encoding::Decoder<'_, D>,
192 offset: usize,
193 _depth: fidl::encoding::Depth,
194 ) -> fidl::Result<()> {
195 decoder.debug_check_bounds::<Self>(offset);
196 let prim = decoder.read_num::<u32>(offset);
197 *self = Self::from_bits_allow_unknown(prim);
198 Ok(())
199 }
200 }
201 unsafe impl fidl::encoding::TypeMarker for BufferMode {
202 type Owned = Self;
203
204 #[inline(always)]
205 fn inline_align(_context: fidl::encoding::Context) -> usize {
206 std::mem::align_of::<u32>()
207 }
208
209 #[inline(always)]
210 fn inline_size(_context: fidl::encoding::Context) -> usize {
211 std::mem::size_of::<u32>()
212 }
213
214 #[inline(always)]
215 fn encode_is_copy() -> bool {
216 true
217 }
218
219 #[inline(always)]
220 fn decode_is_copy() -> bool {
221 false
222 }
223 }
224
225 impl fidl::encoding::ValueTypeMarker for BufferMode {
226 type Borrowed<'a> = Self;
227 #[inline(always)]
228 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
229 *value
230 }
231 }
232
233 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for BufferMode {
234 #[inline]
235 unsafe fn encode(
236 self,
237 encoder: &mut fidl::encoding::Encoder<'_, D>,
238 offset: usize,
239 _depth: fidl::encoding::Depth,
240 ) -> fidl::Result<()> {
241 encoder.debug_check_bounds::<Self>(offset);
242 encoder.write_num(self.into_primitive(), offset);
243 Ok(())
244 }
245 }
246
247 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BufferMode {
248 #[inline(always)]
249 fn new_empty() -> Self {
250 Self::Input
251 }
252
253 #[inline]
254 unsafe fn decode(
255 &mut self,
256 decoder: &mut fidl::encoding::Decoder<'_, D>,
257 offset: usize,
258 _depth: fidl::encoding::Depth,
259 ) -> fidl::Result<()> {
260 decoder.debug_check_bounds::<Self>(offset);
261 let prim = decoder.read_num::<u32>(offset);
262
263 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
264 Ok(())
265 }
266 }
267 unsafe impl fidl::encoding::TypeMarker for InterruptMode {
268 type Owned = Self;
269
270 #[inline(always)]
271 fn inline_align(_context: fidl::encoding::Context) -> usize {
272 std::mem::align_of::<u32>()
273 }
274
275 #[inline(always)]
276 fn inline_size(_context: fidl::encoding::Context) -> usize {
277 std::mem::size_of::<u32>()
278 }
279
280 #[inline(always)]
281 fn encode_is_copy() -> bool {
282 true
283 }
284
285 #[inline(always)]
286 fn decode_is_copy() -> bool {
287 false
288 }
289 }
290
291 impl fidl::encoding::ValueTypeMarker for InterruptMode {
292 type Borrowed<'a> = Self;
293 #[inline(always)]
294 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
295 *value
296 }
297 }
298
299 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for InterruptMode {
300 #[inline]
301 unsafe fn encode(
302 self,
303 encoder: &mut fidl::encoding::Encoder<'_, D>,
304 offset: usize,
305 _depth: fidl::encoding::Depth,
306 ) -> fidl::Result<()> {
307 encoder.debug_check_bounds::<Self>(offset);
308 encoder.write_num(self.into_primitive(), offset);
309 Ok(())
310 }
311 }
312
313 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InterruptMode {
314 #[inline(always)]
315 fn new_empty() -> Self {
316 Self::EdgeLow
317 }
318
319 #[inline]
320 unsafe fn decode(
321 &mut self,
322 decoder: &mut fidl::encoding::Decoder<'_, D>,
323 offset: usize,
324 _depth: fidl::encoding::Depth,
325 ) -> fidl::Result<()> {
326 decoder.debug_check_bounds::<Self>(offset);
327 let prim = decoder.read_num::<u32>(offset);
328
329 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
330 Ok(())
331 }
332 }
333
334 impl fidl::encoding::ValueTypeMarker for GpioConfigureInterruptRequest {
335 type Borrowed<'a> = &'a Self;
336 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
337 value
338 }
339 }
340
341 unsafe impl fidl::encoding::TypeMarker for GpioConfigureInterruptRequest {
342 type Owned = Self;
343
344 #[inline(always)]
345 fn inline_align(_context: fidl::encoding::Context) -> usize {
346 8
347 }
348
349 #[inline(always)]
350 fn inline_size(_context: fidl::encoding::Context) -> usize {
351 16
352 }
353 }
354
355 unsafe impl<D: fidl::encoding::ResourceDialect>
356 fidl::encoding::Encode<GpioConfigureInterruptRequest, D>
357 for &GpioConfigureInterruptRequest
358 {
359 #[inline]
360 unsafe fn encode(
361 self,
362 encoder: &mut fidl::encoding::Encoder<'_, D>,
363 offset: usize,
364 _depth: fidl::encoding::Depth,
365 ) -> fidl::Result<()> {
366 encoder.debug_check_bounds::<GpioConfigureInterruptRequest>(offset);
367 fidl::encoding::Encode::<GpioConfigureInterruptRequest, D>::encode(
369 (<InterruptConfiguration as fidl::encoding::ValueTypeMarker>::borrow(&self.config),),
370 encoder,
371 offset,
372 _depth,
373 )
374 }
375 }
376 unsafe impl<
377 D: fidl::encoding::ResourceDialect,
378 T0: fidl::encoding::Encode<InterruptConfiguration, D>,
379 > fidl::encoding::Encode<GpioConfigureInterruptRequest, D> for (T0,)
380 {
381 #[inline]
382 unsafe fn encode(
383 self,
384 encoder: &mut fidl::encoding::Encoder<'_, D>,
385 offset: usize,
386 depth: fidl::encoding::Depth,
387 ) -> fidl::Result<()> {
388 encoder.debug_check_bounds::<GpioConfigureInterruptRequest>(offset);
389 self.0.encode(encoder, offset + 0, depth)?;
393 Ok(())
394 }
395 }
396
397 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
398 for GpioConfigureInterruptRequest
399 {
400 #[inline(always)]
401 fn new_empty() -> Self {
402 Self { config: fidl::new_empty!(InterruptConfiguration, D) }
403 }
404
405 #[inline]
406 unsafe fn decode(
407 &mut self,
408 decoder: &mut fidl::encoding::Decoder<'_, D>,
409 offset: usize,
410 _depth: fidl::encoding::Depth,
411 ) -> fidl::Result<()> {
412 decoder.debug_check_bounds::<Self>(offset);
413 fidl::decode!(
415 InterruptConfiguration,
416 D,
417 &mut self.config,
418 decoder,
419 offset + 0,
420 _depth
421 )?;
422 Ok(())
423 }
424 }
425
426 impl fidl::encoding::ValueTypeMarker for GpioGetInterruptRequest {
427 type Borrowed<'a> = &'a Self;
428 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
429 value
430 }
431 }
432
433 unsafe impl fidl::encoding::TypeMarker for GpioGetInterruptRequest {
434 type Owned = Self;
435
436 #[inline(always)]
437 fn inline_align(_context: fidl::encoding::Context) -> usize {
438 4
439 }
440
441 #[inline(always)]
442 fn inline_size(_context: fidl::encoding::Context) -> usize {
443 4
444 }
445 }
446
447 unsafe impl<D: fidl::encoding::ResourceDialect>
448 fidl::encoding::Encode<GpioGetInterruptRequest, D> for &GpioGetInterruptRequest
449 {
450 #[inline]
451 unsafe fn encode(
452 self,
453 encoder: &mut fidl::encoding::Encoder<'_, D>,
454 offset: usize,
455 _depth: fidl::encoding::Depth,
456 ) -> fidl::Result<()> {
457 encoder.debug_check_bounds::<GpioGetInterruptRequest>(offset);
458 fidl::encoding::Encode::<GpioGetInterruptRequest, D>::encode(
460 (<InterruptOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),),
461 encoder,
462 offset,
463 _depth,
464 )
465 }
466 }
467 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<InterruptOptions, D>>
468 fidl::encoding::Encode<GpioGetInterruptRequest, D> for (T0,)
469 {
470 #[inline]
471 unsafe fn encode(
472 self,
473 encoder: &mut fidl::encoding::Encoder<'_, D>,
474 offset: usize,
475 depth: fidl::encoding::Depth,
476 ) -> fidl::Result<()> {
477 encoder.debug_check_bounds::<GpioGetInterruptRequest>(offset);
478 self.0.encode(encoder, offset + 0, depth)?;
482 Ok(())
483 }
484 }
485
486 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
487 for GpioGetInterruptRequest
488 {
489 #[inline(always)]
490 fn new_empty() -> Self {
491 Self { options: fidl::new_empty!(InterruptOptions, D) }
492 }
493
494 #[inline]
495 unsafe fn decode(
496 &mut self,
497 decoder: &mut fidl::encoding::Decoder<'_, D>,
498 offset: usize,
499 _depth: fidl::encoding::Depth,
500 ) -> fidl::Result<()> {
501 decoder.debug_check_bounds::<Self>(offset);
502 fidl::decode!(InterruptOptions, D, &mut self.options, decoder, offset + 0, _depth)?;
504 Ok(())
505 }
506 }
507
508 impl fidl::encoding::ValueTypeMarker for GpioSetBufferModeRequest {
509 type Borrowed<'a> = &'a Self;
510 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
511 value
512 }
513 }
514
515 unsafe impl fidl::encoding::TypeMarker for GpioSetBufferModeRequest {
516 type Owned = Self;
517
518 #[inline(always)]
519 fn inline_align(_context: fidl::encoding::Context) -> usize {
520 4
521 }
522
523 #[inline(always)]
524 fn inline_size(_context: fidl::encoding::Context) -> usize {
525 4
526 }
527 }
528
529 unsafe impl<D: fidl::encoding::ResourceDialect>
530 fidl::encoding::Encode<GpioSetBufferModeRequest, D> for &GpioSetBufferModeRequest
531 {
532 #[inline]
533 unsafe fn encode(
534 self,
535 encoder: &mut fidl::encoding::Encoder<'_, D>,
536 offset: usize,
537 _depth: fidl::encoding::Depth,
538 ) -> fidl::Result<()> {
539 encoder.debug_check_bounds::<GpioSetBufferModeRequest>(offset);
540 fidl::encoding::Encode::<GpioSetBufferModeRequest, D>::encode(
542 (<BufferMode as fidl::encoding::ValueTypeMarker>::borrow(&self.mode),),
543 encoder,
544 offset,
545 _depth,
546 )
547 }
548 }
549 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BufferMode, D>>
550 fidl::encoding::Encode<GpioSetBufferModeRequest, D> for (T0,)
551 {
552 #[inline]
553 unsafe fn encode(
554 self,
555 encoder: &mut fidl::encoding::Encoder<'_, D>,
556 offset: usize,
557 depth: fidl::encoding::Depth,
558 ) -> fidl::Result<()> {
559 encoder.debug_check_bounds::<GpioSetBufferModeRequest>(offset);
560 self.0.encode(encoder, offset + 0, depth)?;
564 Ok(())
565 }
566 }
567
568 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
569 for GpioSetBufferModeRequest
570 {
571 #[inline(always)]
572 fn new_empty() -> Self {
573 Self { mode: fidl::new_empty!(BufferMode, D) }
574 }
575
576 #[inline]
577 unsafe fn decode(
578 &mut self,
579 decoder: &mut fidl::encoding::Decoder<'_, D>,
580 offset: usize,
581 _depth: fidl::encoding::Depth,
582 ) -> fidl::Result<()> {
583 decoder.debug_check_bounds::<Self>(offset);
584 fidl::decode!(BufferMode, D, &mut self.mode, decoder, offset + 0, _depth)?;
586 Ok(())
587 }
588 }
589
590 impl fidl::encoding::ValueTypeMarker for GpioReadResponse {
591 type Borrowed<'a> = &'a Self;
592 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
593 value
594 }
595 }
596
597 unsafe impl fidl::encoding::TypeMarker for GpioReadResponse {
598 type Owned = Self;
599
600 #[inline(always)]
601 fn inline_align(_context: fidl::encoding::Context) -> usize {
602 1
603 }
604
605 #[inline(always)]
606 fn inline_size(_context: fidl::encoding::Context) -> usize {
607 1
608 }
609 }
610
611 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GpioReadResponse, D>
612 for &GpioReadResponse
613 {
614 #[inline]
615 unsafe fn encode(
616 self,
617 encoder: &mut fidl::encoding::Encoder<'_, D>,
618 offset: usize,
619 _depth: fidl::encoding::Depth,
620 ) -> fidl::Result<()> {
621 encoder.debug_check_bounds::<GpioReadResponse>(offset);
622 fidl::encoding::Encode::<GpioReadResponse, D>::encode(
624 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
625 encoder,
626 offset,
627 _depth,
628 )
629 }
630 }
631 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
632 fidl::encoding::Encode<GpioReadResponse, D> for (T0,)
633 {
634 #[inline]
635 unsafe fn encode(
636 self,
637 encoder: &mut fidl::encoding::Encoder<'_, D>,
638 offset: usize,
639 depth: fidl::encoding::Depth,
640 ) -> fidl::Result<()> {
641 encoder.debug_check_bounds::<GpioReadResponse>(offset);
642 self.0.encode(encoder, offset + 0, depth)?;
646 Ok(())
647 }
648 }
649
650 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GpioReadResponse {
651 #[inline(always)]
652 fn new_empty() -> Self {
653 Self { value: fidl::new_empty!(bool, D) }
654 }
655
656 #[inline]
657 unsafe fn decode(
658 &mut self,
659 decoder: &mut fidl::encoding::Decoder<'_, D>,
660 offset: usize,
661 _depth: fidl::encoding::Depth,
662 ) -> fidl::Result<()> {
663 decoder.debug_check_bounds::<Self>(offset);
664 fidl::decode!(bool, D, &mut self.value, decoder, offset + 0, _depth)?;
666 Ok(())
667 }
668 }
669
670 impl InterruptConfiguration {
671 #[inline(always)]
672 fn max_ordinal_present(&self) -> u64 {
673 if let Some(_) = self.mode {
674 return 1;
675 }
676 0
677 }
678 }
679
680 impl fidl::encoding::ValueTypeMarker for InterruptConfiguration {
681 type Borrowed<'a> = &'a Self;
682 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
683 value
684 }
685 }
686
687 unsafe impl fidl::encoding::TypeMarker for InterruptConfiguration {
688 type Owned = Self;
689
690 #[inline(always)]
691 fn inline_align(_context: fidl::encoding::Context) -> usize {
692 8
693 }
694
695 #[inline(always)]
696 fn inline_size(_context: fidl::encoding::Context) -> usize {
697 16
698 }
699 }
700
701 unsafe impl<D: fidl::encoding::ResourceDialect>
702 fidl::encoding::Encode<InterruptConfiguration, D> for &InterruptConfiguration
703 {
704 unsafe fn encode(
705 self,
706 encoder: &mut fidl::encoding::Encoder<'_, D>,
707 offset: usize,
708 mut depth: fidl::encoding::Depth,
709 ) -> fidl::Result<()> {
710 encoder.debug_check_bounds::<InterruptConfiguration>(offset);
711 let max_ordinal: u64 = self.max_ordinal_present();
713 encoder.write_num(max_ordinal, offset);
714 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
715 if max_ordinal == 0 {
717 return Ok(());
718 }
719 depth.increment()?;
720 let envelope_size = 8;
721 let bytes_len = max_ordinal as usize * envelope_size;
722 #[allow(unused_variables)]
723 let offset = encoder.out_of_line_offset(bytes_len);
724 let mut _prev_end_offset: usize = 0;
725 if 1 > max_ordinal {
726 return Ok(());
727 }
728
729 let cur_offset: usize = (1 - 1) * envelope_size;
732
733 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
735
736 fidl::encoding::encode_in_envelope_optional::<InterruptMode, D>(
741 self.mode.as_ref().map(<InterruptMode as fidl::encoding::ValueTypeMarker>::borrow),
742 encoder,
743 offset + cur_offset,
744 depth,
745 )?;
746
747 _prev_end_offset = cur_offset + envelope_size;
748
749 Ok(())
750 }
751 }
752
753 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
754 for InterruptConfiguration
755 {
756 #[inline(always)]
757 fn new_empty() -> Self {
758 Self::default()
759 }
760
761 unsafe fn decode(
762 &mut self,
763 decoder: &mut fidl::encoding::Decoder<'_, D>,
764 offset: usize,
765 mut depth: fidl::encoding::Depth,
766 ) -> fidl::Result<()> {
767 decoder.debug_check_bounds::<Self>(offset);
768 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
769 None => return Err(fidl::Error::NotNullable),
770 Some(len) => len,
771 };
772 if len == 0 {
774 return Ok(());
775 };
776 depth.increment()?;
777 let envelope_size = 8;
778 let bytes_len = len * envelope_size;
779 let offset = decoder.out_of_line_offset(bytes_len)?;
780 let mut _next_ordinal_to_read = 0;
782 let mut next_offset = offset;
783 let end_offset = offset + bytes_len;
784 _next_ordinal_to_read += 1;
785 if next_offset >= end_offset {
786 return Ok(());
787 }
788
789 while _next_ordinal_to_read < 1 {
791 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
792 _next_ordinal_to_read += 1;
793 next_offset += envelope_size;
794 }
795
796 let next_out_of_line = decoder.next_out_of_line();
797 let handles_before = decoder.remaining_handles();
798 if let Some((inlined, num_bytes, num_handles)) =
799 fidl::encoding::decode_envelope_header(decoder, next_offset)?
800 {
801 let member_inline_size =
802 <InterruptMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
803 if inlined != (member_inline_size <= 4) {
804 return Err(fidl::Error::InvalidInlineBitInEnvelope);
805 }
806 let inner_offset;
807 let mut inner_depth = depth.clone();
808 if inlined {
809 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
810 inner_offset = next_offset;
811 } else {
812 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
813 inner_depth.increment()?;
814 }
815 let val_ref = self.mode.get_or_insert_with(|| fidl::new_empty!(InterruptMode, D));
816 fidl::decode!(InterruptMode, D, val_ref, decoder, inner_offset, inner_depth)?;
817 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
818 {
819 return Err(fidl::Error::InvalidNumBytesInEnvelope);
820 }
821 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
822 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
823 }
824 }
825
826 next_offset += envelope_size;
827
828 while next_offset < end_offset {
830 _next_ordinal_to_read += 1;
831 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
832 next_offset += envelope_size;
833 }
834
835 Ok(())
836 }
837 }
838}