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_SUSPEND_STATES: u32 = 256;
13
14#[derive(Clone, Debug, Default, PartialEq)]
15pub struct SuspendState {
16 pub resume_latency: Option<i64>,
19 #[doc(hidden)]
20 pub __source_breaking: fidl::marker::SourceBreaking,
21}
22
23impl fidl::Persistable for SuspendState {}
24
25#[derive(Clone, Debug, Default, PartialEq)]
26pub struct SuspenderSuspendRequest {
27 pub state_index: Option<u64>,
32 #[doc(hidden)]
33 pub __source_breaking: fidl::marker::SourceBreaking,
34}
35
36impl fidl::Persistable for SuspenderSuspendRequest {}
37
38#[derive(Clone, Debug, Default, PartialEq)]
39pub struct SuspenderGetSuspendStatesResponse {
40 pub suspend_states: Option<Vec<SuspendState>>,
41 #[doc(hidden)]
42 pub __source_breaking: fidl::marker::SourceBreaking,
43}
44
45impl fidl::Persistable for SuspenderGetSuspendStatesResponse {}
46
47#[derive(Clone, Debug, Default, PartialEq)]
48pub struct SuspenderSuspendResponse {
49 pub reason: Option<WakeReason>,
52 pub suspend_duration: Option<i64>,
55 pub suspend_overhead: Option<i64>,
58 #[doc(hidden)]
59 pub __source_breaking: fidl::marker::SourceBreaking,
60}
61
62impl fidl::Persistable for SuspenderSuspendResponse {}
63
64#[derive(Clone, Debug, Default, PartialEq)]
65pub struct WakeReason {
66 pub wake_vectors: Option<Vec<u64>>,
70 pub soft_wake_vectors: Option<Vec<u64>>,
73 #[doc(hidden)]
74 pub __source_breaking: fidl::marker::SourceBreaking,
75}
76
77impl fidl::Persistable for WakeReason {}
78
79mod internal {
80 use super::*;
81
82 impl SuspendState {
83 #[inline(always)]
84 fn max_ordinal_present(&self) -> u64 {
85 if let Some(_) = self.resume_latency {
86 return 1;
87 }
88 0
89 }
90 }
91
92 impl fidl::encoding::ValueTypeMarker for SuspendState {
93 type Borrowed<'a> = &'a Self;
94 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
95 value
96 }
97 }
98
99 unsafe impl fidl::encoding::TypeMarker for SuspendState {
100 type Owned = Self;
101
102 #[inline(always)]
103 fn inline_align(_context: fidl::encoding::Context) -> usize {
104 8
105 }
106
107 #[inline(always)]
108 fn inline_size(_context: fidl::encoding::Context) -> usize {
109 16
110 }
111 }
112
113 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<SuspendState, D>
114 for &SuspendState
115 {
116 unsafe fn encode(
117 self,
118 encoder: &mut fidl::encoding::Encoder<'_, D>,
119 offset: usize,
120 mut depth: fidl::encoding::Depth,
121 ) -> fidl::Result<()> {
122 encoder.debug_check_bounds::<SuspendState>(offset);
123 let max_ordinal: u64 = self.max_ordinal_present();
125 encoder.write_num(max_ordinal, offset);
126 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
127 if max_ordinal == 0 {
129 return Ok(());
130 }
131 depth.increment()?;
132 let envelope_size = 8;
133 let bytes_len = max_ordinal as usize * envelope_size;
134 #[allow(unused_variables)]
135 let offset = encoder.out_of_line_offset(bytes_len);
136 let mut _prev_end_offset: usize = 0;
137 if 1 > max_ordinal {
138 return Ok(());
139 }
140
141 let cur_offset: usize = (1 - 1) * envelope_size;
144
145 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
147
148 fidl::encoding::encode_in_envelope_optional::<i64, D>(
153 self.resume_latency.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
154 encoder,
155 offset + cur_offset,
156 depth,
157 )?;
158
159 _prev_end_offset = cur_offset + envelope_size;
160
161 Ok(())
162 }
163 }
164
165 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for SuspendState {
166 #[inline(always)]
167 fn new_empty() -> Self {
168 Self::default()
169 }
170
171 unsafe fn decode(
172 &mut self,
173 decoder: &mut fidl::encoding::Decoder<'_, D>,
174 offset: usize,
175 mut depth: fidl::encoding::Depth,
176 ) -> fidl::Result<()> {
177 decoder.debug_check_bounds::<Self>(offset);
178 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
179 None => return Err(fidl::Error::NotNullable),
180 Some(len) => len,
181 };
182 if len == 0 {
184 return Ok(());
185 };
186 depth.increment()?;
187 let envelope_size = 8;
188 let bytes_len = len * envelope_size;
189 let offset = decoder.out_of_line_offset(bytes_len)?;
190 let mut _next_ordinal_to_read = 0;
192 let mut next_offset = offset;
193 let end_offset = offset + bytes_len;
194 _next_ordinal_to_read += 1;
195 if next_offset >= end_offset {
196 return Ok(());
197 }
198
199 while _next_ordinal_to_read < 1 {
201 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
202 _next_ordinal_to_read += 1;
203 next_offset += envelope_size;
204 }
205
206 let next_out_of_line = decoder.next_out_of_line();
207 let handles_before = decoder.remaining_handles();
208 if let Some((inlined, num_bytes, num_handles)) =
209 fidl::encoding::decode_envelope_header(decoder, next_offset)?
210 {
211 let member_inline_size =
212 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
213 if inlined != (member_inline_size <= 4) {
214 return Err(fidl::Error::InvalidInlineBitInEnvelope);
215 }
216 let inner_offset;
217 let mut inner_depth = depth.clone();
218 if inlined {
219 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
220 inner_offset = next_offset;
221 } else {
222 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
223 inner_depth.increment()?;
224 }
225 let val_ref = self.resume_latency.get_or_insert_with(|| fidl::new_empty!(i64, D));
226 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
227 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
228 {
229 return Err(fidl::Error::InvalidNumBytesInEnvelope);
230 }
231 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
232 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
233 }
234 }
235
236 next_offset += envelope_size;
237
238 while next_offset < end_offset {
240 _next_ordinal_to_read += 1;
241 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
242 next_offset += envelope_size;
243 }
244
245 Ok(())
246 }
247 }
248
249 impl SuspenderSuspendRequest {
250 #[inline(always)]
251 fn max_ordinal_present(&self) -> u64 {
252 if let Some(_) = self.state_index {
253 return 1;
254 }
255 0
256 }
257 }
258
259 impl fidl::encoding::ValueTypeMarker for SuspenderSuspendRequest {
260 type Borrowed<'a> = &'a Self;
261 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
262 value
263 }
264 }
265
266 unsafe impl fidl::encoding::TypeMarker for SuspenderSuspendRequest {
267 type Owned = Self;
268
269 #[inline(always)]
270 fn inline_align(_context: fidl::encoding::Context) -> usize {
271 8
272 }
273
274 #[inline(always)]
275 fn inline_size(_context: fidl::encoding::Context) -> usize {
276 16
277 }
278 }
279
280 unsafe impl<D: fidl::encoding::ResourceDialect>
281 fidl::encoding::Encode<SuspenderSuspendRequest, D> for &SuspenderSuspendRequest
282 {
283 unsafe fn encode(
284 self,
285 encoder: &mut fidl::encoding::Encoder<'_, D>,
286 offset: usize,
287 mut depth: fidl::encoding::Depth,
288 ) -> fidl::Result<()> {
289 encoder.debug_check_bounds::<SuspenderSuspendRequest>(offset);
290 let max_ordinal: u64 = self.max_ordinal_present();
292 encoder.write_num(max_ordinal, offset);
293 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
294 if max_ordinal == 0 {
296 return Ok(());
297 }
298 depth.increment()?;
299 let envelope_size = 8;
300 let bytes_len = max_ordinal as usize * envelope_size;
301 #[allow(unused_variables)]
302 let offset = encoder.out_of_line_offset(bytes_len);
303 let mut _prev_end_offset: usize = 0;
304 if 1 > max_ordinal {
305 return Ok(());
306 }
307
308 let cur_offset: usize = (1 - 1) * envelope_size;
311
312 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
314
315 fidl::encoding::encode_in_envelope_optional::<u64, D>(
320 self.state_index.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
321 encoder,
322 offset + cur_offset,
323 depth,
324 )?;
325
326 _prev_end_offset = cur_offset + envelope_size;
327
328 Ok(())
329 }
330 }
331
332 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
333 for SuspenderSuspendRequest
334 {
335 #[inline(always)]
336 fn new_empty() -> Self {
337 Self::default()
338 }
339
340 unsafe fn decode(
341 &mut self,
342 decoder: &mut fidl::encoding::Decoder<'_, D>,
343 offset: usize,
344 mut depth: fidl::encoding::Depth,
345 ) -> fidl::Result<()> {
346 decoder.debug_check_bounds::<Self>(offset);
347 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
348 None => return Err(fidl::Error::NotNullable),
349 Some(len) => len,
350 };
351 if len == 0 {
353 return Ok(());
354 };
355 depth.increment()?;
356 let envelope_size = 8;
357 let bytes_len = len * envelope_size;
358 let offset = decoder.out_of_line_offset(bytes_len)?;
359 let mut _next_ordinal_to_read = 0;
361 let mut next_offset = offset;
362 let end_offset = offset + bytes_len;
363 _next_ordinal_to_read += 1;
364 if next_offset >= end_offset {
365 return Ok(());
366 }
367
368 while _next_ordinal_to_read < 1 {
370 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
371 _next_ordinal_to_read += 1;
372 next_offset += envelope_size;
373 }
374
375 let next_out_of_line = decoder.next_out_of_line();
376 let handles_before = decoder.remaining_handles();
377 if let Some((inlined, num_bytes, num_handles)) =
378 fidl::encoding::decode_envelope_header(decoder, next_offset)?
379 {
380 let member_inline_size =
381 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
382 if inlined != (member_inline_size <= 4) {
383 return Err(fidl::Error::InvalidInlineBitInEnvelope);
384 }
385 let inner_offset;
386 let mut inner_depth = depth.clone();
387 if inlined {
388 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
389 inner_offset = next_offset;
390 } else {
391 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
392 inner_depth.increment()?;
393 }
394 let val_ref = self.state_index.get_or_insert_with(|| fidl::new_empty!(u64, D));
395 fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
396 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
397 {
398 return Err(fidl::Error::InvalidNumBytesInEnvelope);
399 }
400 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
401 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
402 }
403 }
404
405 next_offset += envelope_size;
406
407 while next_offset < end_offset {
409 _next_ordinal_to_read += 1;
410 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
411 next_offset += envelope_size;
412 }
413
414 Ok(())
415 }
416 }
417
418 impl SuspenderGetSuspendStatesResponse {
419 #[inline(always)]
420 fn max_ordinal_present(&self) -> u64 {
421 if let Some(_) = self.suspend_states {
422 return 1;
423 }
424 0
425 }
426 }
427
428 impl fidl::encoding::ValueTypeMarker for SuspenderGetSuspendStatesResponse {
429 type Borrowed<'a> = &'a Self;
430 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
431 value
432 }
433 }
434
435 unsafe impl fidl::encoding::TypeMarker for SuspenderGetSuspendStatesResponse {
436 type Owned = Self;
437
438 #[inline(always)]
439 fn inline_align(_context: fidl::encoding::Context) -> usize {
440 8
441 }
442
443 #[inline(always)]
444 fn inline_size(_context: fidl::encoding::Context) -> usize {
445 16
446 }
447 }
448
449 unsafe impl<D: fidl::encoding::ResourceDialect>
450 fidl::encoding::Encode<SuspenderGetSuspendStatesResponse, D>
451 for &SuspenderGetSuspendStatesResponse
452 {
453 unsafe fn encode(
454 self,
455 encoder: &mut fidl::encoding::Encoder<'_, D>,
456 offset: usize,
457 mut depth: fidl::encoding::Depth,
458 ) -> fidl::Result<()> {
459 encoder.debug_check_bounds::<SuspenderGetSuspendStatesResponse>(offset);
460 let max_ordinal: u64 = self.max_ordinal_present();
462 encoder.write_num(max_ordinal, offset);
463 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
464 if max_ordinal == 0 {
466 return Ok(());
467 }
468 depth.increment()?;
469 let envelope_size = 8;
470 let bytes_len = max_ordinal as usize * envelope_size;
471 #[allow(unused_variables)]
472 let offset = encoder.out_of_line_offset(bytes_len);
473 let mut _prev_end_offset: usize = 0;
474 if 1 > max_ordinal {
475 return Ok(());
476 }
477
478 let cur_offset: usize = (1 - 1) * envelope_size;
481
482 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
484
485 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<SuspendState, 256>, D>(
490 self.suspend_states.as_ref().map(<fidl::encoding::Vector<SuspendState, 256> as fidl::encoding::ValueTypeMarker>::borrow),
491 encoder, offset + cur_offset, depth
492 )?;
493
494 _prev_end_offset = cur_offset + envelope_size;
495
496 Ok(())
497 }
498 }
499
500 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
501 for SuspenderGetSuspendStatesResponse
502 {
503 #[inline(always)]
504 fn new_empty() -> Self {
505 Self::default()
506 }
507
508 unsafe fn decode(
509 &mut self,
510 decoder: &mut fidl::encoding::Decoder<'_, D>,
511 offset: usize,
512 mut depth: fidl::encoding::Depth,
513 ) -> fidl::Result<()> {
514 decoder.debug_check_bounds::<Self>(offset);
515 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
516 None => return Err(fidl::Error::NotNullable),
517 Some(len) => len,
518 };
519 if len == 0 {
521 return Ok(());
522 };
523 depth.increment()?;
524 let envelope_size = 8;
525 let bytes_len = len * envelope_size;
526 let offset = decoder.out_of_line_offset(bytes_len)?;
527 let mut _next_ordinal_to_read = 0;
529 let mut next_offset = offset;
530 let end_offset = offset + bytes_len;
531 _next_ordinal_to_read += 1;
532 if next_offset >= end_offset {
533 return Ok(());
534 }
535
536 while _next_ordinal_to_read < 1 {
538 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
539 _next_ordinal_to_read += 1;
540 next_offset += envelope_size;
541 }
542
543 let next_out_of_line = decoder.next_out_of_line();
544 let handles_before = decoder.remaining_handles();
545 if let Some((inlined, num_bytes, num_handles)) =
546 fidl::encoding::decode_envelope_header(decoder, next_offset)?
547 {
548 let member_inline_size = <fidl::encoding::Vector<SuspendState, 256> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
549 if inlined != (member_inline_size <= 4) {
550 return Err(fidl::Error::InvalidInlineBitInEnvelope);
551 }
552 let inner_offset;
553 let mut inner_depth = depth.clone();
554 if inlined {
555 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
556 inner_offset = next_offset;
557 } else {
558 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
559 inner_depth.increment()?;
560 }
561 let val_ref = self.suspend_states.get_or_insert_with(
562 || fidl::new_empty!(fidl::encoding::Vector<SuspendState, 256>, D),
563 );
564 fidl::decode!(fidl::encoding::Vector<SuspendState, 256>, D, val_ref, decoder, inner_offset, inner_depth)?;
565 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
566 {
567 return Err(fidl::Error::InvalidNumBytesInEnvelope);
568 }
569 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
570 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
571 }
572 }
573
574 next_offset += envelope_size;
575
576 while next_offset < end_offset {
578 _next_ordinal_to_read += 1;
579 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
580 next_offset += envelope_size;
581 }
582
583 Ok(())
584 }
585 }
586
587 impl SuspenderSuspendResponse {
588 #[inline(always)]
589 fn max_ordinal_present(&self) -> u64 {
590 if let Some(_) = self.suspend_overhead {
591 return 3;
592 }
593 if let Some(_) = self.suspend_duration {
594 return 2;
595 }
596 if let Some(_) = self.reason {
597 return 1;
598 }
599 0
600 }
601 }
602
603 impl fidl::encoding::ValueTypeMarker for SuspenderSuspendResponse {
604 type Borrowed<'a> = &'a Self;
605 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
606 value
607 }
608 }
609
610 unsafe impl fidl::encoding::TypeMarker for SuspenderSuspendResponse {
611 type Owned = Self;
612
613 #[inline(always)]
614 fn inline_align(_context: fidl::encoding::Context) -> usize {
615 8
616 }
617
618 #[inline(always)]
619 fn inline_size(_context: fidl::encoding::Context) -> usize {
620 16
621 }
622 }
623
624 unsafe impl<D: fidl::encoding::ResourceDialect>
625 fidl::encoding::Encode<SuspenderSuspendResponse, D> for &SuspenderSuspendResponse
626 {
627 unsafe fn encode(
628 self,
629 encoder: &mut fidl::encoding::Encoder<'_, D>,
630 offset: usize,
631 mut depth: fidl::encoding::Depth,
632 ) -> fidl::Result<()> {
633 encoder.debug_check_bounds::<SuspenderSuspendResponse>(offset);
634 let max_ordinal: u64 = self.max_ordinal_present();
636 encoder.write_num(max_ordinal, offset);
637 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
638 if max_ordinal == 0 {
640 return Ok(());
641 }
642 depth.increment()?;
643 let envelope_size = 8;
644 let bytes_len = max_ordinal as usize * envelope_size;
645 #[allow(unused_variables)]
646 let offset = encoder.out_of_line_offset(bytes_len);
647 let mut _prev_end_offset: usize = 0;
648 if 1 > max_ordinal {
649 return Ok(());
650 }
651
652 let cur_offset: usize = (1 - 1) * envelope_size;
655
656 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
658
659 fidl::encoding::encode_in_envelope_optional::<WakeReason, D>(
664 self.reason.as_ref().map(<WakeReason as fidl::encoding::ValueTypeMarker>::borrow),
665 encoder,
666 offset + cur_offset,
667 depth,
668 )?;
669
670 _prev_end_offset = cur_offset + envelope_size;
671 if 2 > max_ordinal {
672 return Ok(());
673 }
674
675 let cur_offset: usize = (2 - 1) * envelope_size;
678
679 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
681
682 fidl::encoding::encode_in_envelope_optional::<i64, D>(
687 self.suspend_duration
688 .as_ref()
689 .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
690 encoder,
691 offset + cur_offset,
692 depth,
693 )?;
694
695 _prev_end_offset = cur_offset + envelope_size;
696 if 3 > max_ordinal {
697 return Ok(());
698 }
699
700 let cur_offset: usize = (3 - 1) * envelope_size;
703
704 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
706
707 fidl::encoding::encode_in_envelope_optional::<i64, D>(
712 self.suspend_overhead
713 .as_ref()
714 .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
715 encoder,
716 offset + cur_offset,
717 depth,
718 )?;
719
720 _prev_end_offset = cur_offset + envelope_size;
721
722 Ok(())
723 }
724 }
725
726 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
727 for SuspenderSuspendResponse
728 {
729 #[inline(always)]
730 fn new_empty() -> Self {
731 Self::default()
732 }
733
734 unsafe fn decode(
735 &mut self,
736 decoder: &mut fidl::encoding::Decoder<'_, D>,
737 offset: usize,
738 mut depth: fidl::encoding::Depth,
739 ) -> fidl::Result<()> {
740 decoder.debug_check_bounds::<Self>(offset);
741 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
742 None => return Err(fidl::Error::NotNullable),
743 Some(len) => len,
744 };
745 if len == 0 {
747 return Ok(());
748 };
749 depth.increment()?;
750 let envelope_size = 8;
751 let bytes_len = len * envelope_size;
752 let offset = decoder.out_of_line_offset(bytes_len)?;
753 let mut _next_ordinal_to_read = 0;
755 let mut next_offset = offset;
756 let end_offset = offset + bytes_len;
757 _next_ordinal_to_read += 1;
758 if next_offset >= end_offset {
759 return Ok(());
760 }
761
762 while _next_ordinal_to_read < 1 {
764 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
765 _next_ordinal_to_read += 1;
766 next_offset += envelope_size;
767 }
768
769 let next_out_of_line = decoder.next_out_of_line();
770 let handles_before = decoder.remaining_handles();
771 if let Some((inlined, num_bytes, num_handles)) =
772 fidl::encoding::decode_envelope_header(decoder, next_offset)?
773 {
774 let member_inline_size =
775 <WakeReason as fidl::encoding::TypeMarker>::inline_size(decoder.context);
776 if inlined != (member_inline_size <= 4) {
777 return Err(fidl::Error::InvalidInlineBitInEnvelope);
778 }
779 let inner_offset;
780 let mut inner_depth = depth.clone();
781 if inlined {
782 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
783 inner_offset = next_offset;
784 } else {
785 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
786 inner_depth.increment()?;
787 }
788 let val_ref = self.reason.get_or_insert_with(|| fidl::new_empty!(WakeReason, D));
789 fidl::decode!(WakeReason, D, val_ref, decoder, inner_offset, inner_depth)?;
790 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
791 {
792 return Err(fidl::Error::InvalidNumBytesInEnvelope);
793 }
794 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
795 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
796 }
797 }
798
799 next_offset += envelope_size;
800 _next_ordinal_to_read += 1;
801 if next_offset >= end_offset {
802 return Ok(());
803 }
804
805 while _next_ordinal_to_read < 2 {
807 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
808 _next_ordinal_to_read += 1;
809 next_offset += envelope_size;
810 }
811
812 let next_out_of_line = decoder.next_out_of_line();
813 let handles_before = decoder.remaining_handles();
814 if let Some((inlined, num_bytes, num_handles)) =
815 fidl::encoding::decode_envelope_header(decoder, next_offset)?
816 {
817 let member_inline_size =
818 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
819 if inlined != (member_inline_size <= 4) {
820 return Err(fidl::Error::InvalidInlineBitInEnvelope);
821 }
822 let inner_offset;
823 let mut inner_depth = depth.clone();
824 if inlined {
825 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
826 inner_offset = next_offset;
827 } else {
828 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
829 inner_depth.increment()?;
830 }
831 let val_ref = self.suspend_duration.get_or_insert_with(|| fidl::new_empty!(i64, D));
832 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
833 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
834 {
835 return Err(fidl::Error::InvalidNumBytesInEnvelope);
836 }
837 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
838 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
839 }
840 }
841
842 next_offset += envelope_size;
843 _next_ordinal_to_read += 1;
844 if next_offset >= end_offset {
845 return Ok(());
846 }
847
848 while _next_ordinal_to_read < 3 {
850 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
851 _next_ordinal_to_read += 1;
852 next_offset += envelope_size;
853 }
854
855 let next_out_of_line = decoder.next_out_of_line();
856 let handles_before = decoder.remaining_handles();
857 if let Some((inlined, num_bytes, num_handles)) =
858 fidl::encoding::decode_envelope_header(decoder, next_offset)?
859 {
860 let member_inline_size =
861 <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
862 if inlined != (member_inline_size <= 4) {
863 return Err(fidl::Error::InvalidInlineBitInEnvelope);
864 }
865 let inner_offset;
866 let mut inner_depth = depth.clone();
867 if inlined {
868 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
869 inner_offset = next_offset;
870 } else {
871 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
872 inner_depth.increment()?;
873 }
874 let val_ref = self.suspend_overhead.get_or_insert_with(|| fidl::new_empty!(i64, D));
875 fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
876 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
877 {
878 return Err(fidl::Error::InvalidNumBytesInEnvelope);
879 }
880 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
881 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
882 }
883 }
884
885 next_offset += envelope_size;
886
887 while next_offset < end_offset {
889 _next_ordinal_to_read += 1;
890 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
891 next_offset += envelope_size;
892 }
893
894 Ok(())
895 }
896 }
897
898 impl WakeReason {
899 #[inline(always)]
900 fn max_ordinal_present(&self) -> u64 {
901 if let Some(_) = self.soft_wake_vectors {
902 return 2;
903 }
904 if let Some(_) = self.wake_vectors {
905 return 1;
906 }
907 0
908 }
909 }
910
911 impl fidl::encoding::ValueTypeMarker for WakeReason {
912 type Borrowed<'a> = &'a Self;
913 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
914 value
915 }
916 }
917
918 unsafe impl fidl::encoding::TypeMarker for WakeReason {
919 type Owned = Self;
920
921 #[inline(always)]
922 fn inline_align(_context: fidl::encoding::Context) -> usize {
923 8
924 }
925
926 #[inline(always)]
927 fn inline_size(_context: fidl::encoding::Context) -> usize {
928 16
929 }
930 }
931
932 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WakeReason, D>
933 for &WakeReason
934 {
935 unsafe fn encode(
936 self,
937 encoder: &mut fidl::encoding::Encoder<'_, D>,
938 offset: usize,
939 mut depth: fidl::encoding::Depth,
940 ) -> fidl::Result<()> {
941 encoder.debug_check_bounds::<WakeReason>(offset);
942 let max_ordinal: u64 = self.max_ordinal_present();
944 encoder.write_num(max_ordinal, offset);
945 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
946 if max_ordinal == 0 {
948 return Ok(());
949 }
950 depth.increment()?;
951 let envelope_size = 8;
952 let bytes_len = max_ordinal as usize * envelope_size;
953 #[allow(unused_variables)]
954 let offset = encoder.out_of_line_offset(bytes_len);
955 let mut _prev_end_offset: usize = 0;
956 if 1 > max_ordinal {
957 return Ok(());
958 }
959
960 let cur_offset: usize = (1 - 1) * envelope_size;
963
964 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
966
967 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u64>, D>(
972 self.wake_vectors.as_ref().map(<fidl::encoding::UnboundedVector<u64> as fidl::encoding::ValueTypeMarker>::borrow),
973 encoder, offset + cur_offset, depth
974 )?;
975
976 _prev_end_offset = cur_offset + envelope_size;
977 if 2 > max_ordinal {
978 return Ok(());
979 }
980
981 let cur_offset: usize = (2 - 1) * envelope_size;
984
985 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
987
988 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u64>, D>(
993 self.soft_wake_vectors.as_ref().map(<fidl::encoding::UnboundedVector<u64> as fidl::encoding::ValueTypeMarker>::borrow),
994 encoder, offset + cur_offset, depth
995 )?;
996
997 _prev_end_offset = cur_offset + envelope_size;
998
999 Ok(())
1000 }
1001 }
1002
1003 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WakeReason {
1004 #[inline(always)]
1005 fn new_empty() -> Self {
1006 Self::default()
1007 }
1008
1009 unsafe fn decode(
1010 &mut self,
1011 decoder: &mut fidl::encoding::Decoder<'_, D>,
1012 offset: usize,
1013 mut depth: fidl::encoding::Depth,
1014 ) -> fidl::Result<()> {
1015 decoder.debug_check_bounds::<Self>(offset);
1016 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1017 None => return Err(fidl::Error::NotNullable),
1018 Some(len) => len,
1019 };
1020 if len == 0 {
1022 return Ok(());
1023 };
1024 depth.increment()?;
1025 let envelope_size = 8;
1026 let bytes_len = len * envelope_size;
1027 let offset = decoder.out_of_line_offset(bytes_len)?;
1028 let mut _next_ordinal_to_read = 0;
1030 let mut next_offset = offset;
1031 let end_offset = offset + bytes_len;
1032 _next_ordinal_to_read += 1;
1033 if next_offset >= end_offset {
1034 return Ok(());
1035 }
1036
1037 while _next_ordinal_to_read < 1 {
1039 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1040 _next_ordinal_to_read += 1;
1041 next_offset += envelope_size;
1042 }
1043
1044 let next_out_of_line = decoder.next_out_of_line();
1045 let handles_before = decoder.remaining_handles();
1046 if let Some((inlined, num_bytes, num_handles)) =
1047 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1048 {
1049 let member_inline_size = <fidl::encoding::UnboundedVector<u64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1050 if inlined != (member_inline_size <= 4) {
1051 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1052 }
1053 let inner_offset;
1054 let mut inner_depth = depth.clone();
1055 if inlined {
1056 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1057 inner_offset = next_offset;
1058 } else {
1059 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1060 inner_depth.increment()?;
1061 }
1062 let val_ref = self.wake_vectors.get_or_insert_with(|| {
1063 fidl::new_empty!(fidl::encoding::UnboundedVector<u64>, D)
1064 });
1065 fidl::decode!(
1066 fidl::encoding::UnboundedVector<u64>,
1067 D,
1068 val_ref,
1069 decoder,
1070 inner_offset,
1071 inner_depth
1072 )?;
1073 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1074 {
1075 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1076 }
1077 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1078 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1079 }
1080 }
1081
1082 next_offset += envelope_size;
1083 _next_ordinal_to_read += 1;
1084 if next_offset >= end_offset {
1085 return Ok(());
1086 }
1087
1088 while _next_ordinal_to_read < 2 {
1090 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1091 _next_ordinal_to_read += 1;
1092 next_offset += envelope_size;
1093 }
1094
1095 let next_out_of_line = decoder.next_out_of_line();
1096 let handles_before = decoder.remaining_handles();
1097 if let Some((inlined, num_bytes, num_handles)) =
1098 fidl::encoding::decode_envelope_header(decoder, next_offset)?
1099 {
1100 let member_inline_size = <fidl::encoding::UnboundedVector<u64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1101 if inlined != (member_inline_size <= 4) {
1102 return Err(fidl::Error::InvalidInlineBitInEnvelope);
1103 }
1104 let inner_offset;
1105 let mut inner_depth = depth.clone();
1106 if inlined {
1107 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1108 inner_offset = next_offset;
1109 } else {
1110 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1111 inner_depth.increment()?;
1112 }
1113 let val_ref = self.soft_wake_vectors.get_or_insert_with(|| {
1114 fidl::new_empty!(fidl::encoding::UnboundedVector<u64>, D)
1115 });
1116 fidl::decode!(
1117 fidl::encoding::UnboundedVector<u64>,
1118 D,
1119 val_ref,
1120 decoder,
1121 inner_offset,
1122 inner_depth
1123 )?;
1124 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1125 {
1126 return Err(fidl::Error::InvalidNumBytesInEnvelope);
1127 }
1128 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1129 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1130 }
1131 }
1132
1133 next_offset += envelope_size;
1134
1135 while next_offset < end_offset {
1137 _next_ordinal_to_read += 1;
1138 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1139 next_offset += envelope_size;
1140 }
1141
1142 Ok(())
1143 }
1144 }
1145}