fidl_fuchsia_power_profile_common/
fidl_fuchsia_power_profile_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 Profile {
15 Idle = 1,
18 BackgroundActive = 2,
22 UserActive = 3,
25}
26
27impl Profile {
28 #[inline]
29 pub fn from_primitive(prim: u32) -> Option<Self> {
30 match prim {
31 1 => Some(Self::Idle),
32 2 => Some(Self::BackgroundActive),
33 3 => Some(Self::UserActive),
34 _ => None,
35 }
36 }
37
38 #[inline]
39 pub const fn into_primitive(self) -> u32 {
40 self as u32
41 }
42
43 #[deprecated = "Strict enums should not use `is_unknown`"]
44 #[inline]
45 pub fn is_unknown(&self) -> bool {
46 false
47 }
48}
49
50#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51pub struct WatcherWatchResponse {
52 pub profile: Profile,
53}
54
55impl fidl::Persistable for WatcherWatchResponse {}
56
57mod internal {
58 use super::*;
59 unsafe impl fidl::encoding::TypeMarker for Profile {
60 type Owned = Self;
61
62 #[inline(always)]
63 fn inline_align(_context: fidl::encoding::Context) -> usize {
64 std::mem::align_of::<u32>()
65 }
66
67 #[inline(always)]
68 fn inline_size(_context: fidl::encoding::Context) -> usize {
69 std::mem::size_of::<u32>()
70 }
71
72 #[inline(always)]
73 fn encode_is_copy() -> bool {
74 true
75 }
76
77 #[inline(always)]
78 fn decode_is_copy() -> bool {
79 false
80 }
81 }
82
83 impl fidl::encoding::ValueTypeMarker for Profile {
84 type Borrowed<'a> = Self;
85 #[inline(always)]
86 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
87 *value
88 }
89 }
90
91 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Profile {
92 #[inline]
93 unsafe fn encode(
94 self,
95 encoder: &mut fidl::encoding::Encoder<'_, D>,
96 offset: usize,
97 _depth: fidl::encoding::Depth,
98 ) -> fidl::Result<()> {
99 encoder.debug_check_bounds::<Self>(offset);
100 encoder.write_num(self.into_primitive(), offset);
101 Ok(())
102 }
103 }
104
105 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Profile {
106 #[inline(always)]
107 fn new_empty() -> Self {
108 Self::Idle
109 }
110
111 #[inline]
112 unsafe fn decode(
113 &mut self,
114 decoder: &mut fidl::encoding::Decoder<'_, D>,
115 offset: usize,
116 _depth: fidl::encoding::Depth,
117 ) -> fidl::Result<()> {
118 decoder.debug_check_bounds::<Self>(offset);
119 let prim = decoder.read_num::<u32>(offset);
120
121 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
122 Ok(())
123 }
124 }
125
126 impl fidl::encoding::ValueTypeMarker for WatcherWatchResponse {
127 type Borrowed<'a> = &'a Self;
128 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
129 value
130 }
131 }
132
133 unsafe impl fidl::encoding::TypeMarker for WatcherWatchResponse {
134 type Owned = Self;
135
136 #[inline(always)]
137 fn inline_align(_context: fidl::encoding::Context) -> usize {
138 4
139 }
140
141 #[inline(always)]
142 fn inline_size(_context: fidl::encoding::Context) -> usize {
143 4
144 }
145 }
146
147 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WatcherWatchResponse, D>
148 for &WatcherWatchResponse
149 {
150 #[inline]
151 unsafe fn encode(
152 self,
153 encoder: &mut fidl::encoding::Encoder<'_, D>,
154 offset: usize,
155 _depth: fidl::encoding::Depth,
156 ) -> fidl::Result<()> {
157 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
158 fidl::encoding::Encode::<WatcherWatchResponse, D>::encode(
160 (<Profile as fidl::encoding::ValueTypeMarker>::borrow(&self.profile),),
161 encoder,
162 offset,
163 _depth,
164 )
165 }
166 }
167 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<Profile, D>>
168 fidl::encoding::Encode<WatcherWatchResponse, D> for (T0,)
169 {
170 #[inline]
171 unsafe fn encode(
172 self,
173 encoder: &mut fidl::encoding::Encoder<'_, D>,
174 offset: usize,
175 depth: fidl::encoding::Depth,
176 ) -> fidl::Result<()> {
177 encoder.debug_check_bounds::<WatcherWatchResponse>(offset);
178 self.0.encode(encoder, offset + 0, depth)?;
182 Ok(())
183 }
184 }
185
186 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WatcherWatchResponse {
187 #[inline(always)]
188 fn new_empty() -> Self {
189 Self { profile: fidl::new_empty!(Profile, D) }
190 }
191
192 #[inline]
193 unsafe fn decode(
194 &mut self,
195 decoder: &mut fidl::encoding::Decoder<'_, D>,
196 offset: usize,
197 _depth: fidl::encoding::Depth,
198 ) -> fidl::Result<()> {
199 decoder.debug_check_bounds::<Self>(offset);
200 fidl::decode!(Profile, D, &mut self.profile, decoder, offset + 0, _depth)?;
202 Ok(())
203 }
204 }
205}