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