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