fidl_fuchsia_power_internal_common/
fidl_fuchsia_power_internal_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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
11/// The reason why a collaborative reboot was scheduled.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum CollaborativeRebootReason {
15    /// A new system update has been downloaded. A reboot is required to apply
16    /// the update.
17    SystemUpdate = 1,
18    /// The configured netstack version on the system has changed. A reboot is
19    /// required to start the new Netstack.
20    NetstackMigration = 2,
21}
22
23impl CollaborativeRebootReason {
24    #[inline]
25    pub fn from_primitive(prim: u32) -> Option<Self> {
26        match prim {
27            1 => Some(Self::SystemUpdate),
28            2 => Some(Self::NetstackMigration),
29            _ => None,
30        }
31    }
32
33    #[inline]
34    pub const fn into_primitive(self) -> u32 {
35        self as u32
36    }
37
38    #[deprecated = "Strict enums should not use `is_unknown`"]
39    #[inline]
40    pub fn is_unknown(&self) -> bool {
41        false
42    }
43}
44
45mod internal {
46    use super::*;
47    unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootReason {
48        type Owned = Self;
49
50        #[inline(always)]
51        fn inline_align(_context: fidl::encoding::Context) -> usize {
52            std::mem::align_of::<u32>()
53        }
54
55        #[inline(always)]
56        fn inline_size(_context: fidl::encoding::Context) -> usize {
57            std::mem::size_of::<u32>()
58        }
59
60        #[inline(always)]
61        fn encode_is_copy() -> bool {
62            true
63        }
64
65        #[inline(always)]
66        fn decode_is_copy() -> bool {
67            false
68        }
69    }
70
71    impl fidl::encoding::ValueTypeMarker for CollaborativeRebootReason {
72        type Borrowed<'a> = Self;
73        #[inline(always)]
74        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
75            *value
76        }
77    }
78
79    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
80        for CollaborativeRebootReason
81    {
82        #[inline]
83        unsafe fn encode(
84            self,
85            encoder: &mut fidl::encoding::Encoder<'_, D>,
86            offset: usize,
87            _depth: fidl::encoding::Depth,
88        ) -> fidl::Result<()> {
89            encoder.debug_check_bounds::<Self>(offset);
90            encoder.write_num(self.into_primitive(), offset);
91            Ok(())
92        }
93    }
94
95    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
96        for CollaborativeRebootReason
97    {
98        #[inline(always)]
99        fn new_empty() -> Self {
100            Self::SystemUpdate
101        }
102
103        #[inline]
104        unsafe fn decode(
105            &mut self,
106            decoder: &mut fidl::encoding::Decoder<'_, D>,
107            offset: usize,
108            _depth: fidl::encoding::Depth,
109        ) -> fidl::Result<()> {
110            decoder.debug_check_bounds::<Self>(offset);
111            let prim = decoder.read_num::<u32>(offset);
112
113            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
114            Ok(())
115        }
116    }
117}