fidl_fuchsia_power_internal__common/
fidl_fuchsia_power_internal__common.rs1#![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#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13#[repr(u32)]
14pub enum CollaborativeRebootReason {
15 SystemUpdate = 1,
18 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
39mod internal {
40 use super::*;
41 unsafe impl fidl::encoding::TypeMarker for CollaborativeRebootReason {
42 type Owned = Self;
43
44 #[inline(always)]
45 fn inline_align(_context: fidl::encoding::Context) -> usize {
46 std::mem::align_of::<u32>()
47 }
48
49 #[inline(always)]
50 fn inline_size(_context: fidl::encoding::Context) -> usize {
51 std::mem::size_of::<u32>()
52 }
53
54 #[inline(always)]
55 fn encode_is_copy() -> bool {
56 true
57 }
58
59 #[inline(always)]
60 fn decode_is_copy() -> bool {
61 false
62 }
63 }
64
65 impl fidl::encoding::ValueTypeMarker for CollaborativeRebootReason {
66 type Borrowed<'a> = Self;
67 #[inline(always)]
68 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
69 *value
70 }
71 }
72
73 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
74 for CollaborativeRebootReason
75 {
76 #[inline]
77 unsafe fn encode(
78 self,
79 encoder: &mut fidl::encoding::Encoder<'_, D>,
80 offset: usize,
81 _depth: fidl::encoding::Depth,
82 ) -> fidl::Result<()> {
83 encoder.debug_check_bounds::<Self>(offset);
84 encoder.write_num(self.into_primitive(), offset);
85 Ok(())
86 }
87 }
88
89 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
90 for CollaborativeRebootReason
91 {
92 #[inline(always)]
93 fn new_empty() -> Self {
94 Self::SystemUpdate
95 }
96
97 #[inline]
98 unsafe fn decode(
99 &mut self,
100 decoder: &mut fidl::encoding::Decoder<'_, D>,
101 offset: usize,
102 _depth: fidl::encoding::Depth,
103 ) -> fidl::Result<()> {
104 decoder.debug_check_bounds::<Self>(offset);
105 let prim = decoder.read_num::<u32>(offset);
106
107 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
108 Ok(())
109 }
110 }
111}