fidl_test_sagcontrol__common/
fidl_test_sagcontrol__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 SetSystemActivityGovernorStateError {
15 NotSupported = 1,
18 Internal = 2,
20}
21
22impl SetSystemActivityGovernorStateError {
23 #[inline]
24 pub fn from_primitive(prim: u32) -> Option<Self> {
25 match prim {
26 1 => Some(Self::NotSupported),
27 2 => Some(Self::Internal),
28 _ => None,
29 }
30 }
31
32 #[inline]
33 pub const fn into_primitive(self) -> u32 {
34 self as u32
35 }
36}
37
38#[derive(Clone, Debug, Default, PartialEq)]
39pub struct SystemActivityGovernorState {
40 pub execution_state_level: Option<fidl_fuchsia_power_system__common::ExecutionStateLevel>,
41 pub application_activity_level:
42 Option<fidl_fuchsia_power_system__common::ApplicationActivityLevel>,
43 #[doc(hidden)]
44 pub __source_breaking: fidl::marker::SourceBreaking,
45}
46
47impl fidl::Persistable for SystemActivityGovernorState {}
48
49pub mod state_ordinals {
50 pub const SET: u64 = 0x212842d46b8459f8;
51 pub const GET: u64 = 0x65b19621b5644fdb;
52 pub const SET_BOOT_COMPLETE: u64 = 0x7dded2028ad39365;
53 pub const WATCH: u64 = 0x434b0aa4bbac7965;
54}
55
56mod internal {
57 use super::*;
58 unsafe impl fidl::encoding::TypeMarker for SetSystemActivityGovernorStateError {
59 type Owned = Self;
60
61 #[inline(always)]
62 fn inline_align(_context: fidl::encoding::Context) -> usize {
63 std::mem::align_of::<u32>()
64 }
65
66 #[inline(always)]
67 fn inline_size(_context: fidl::encoding::Context) -> usize {
68 std::mem::size_of::<u32>()
69 }
70
71 #[inline(always)]
72 fn encode_is_copy() -> bool {
73 true
74 }
75
76 #[inline(always)]
77 fn decode_is_copy() -> bool {
78 false
79 }
80 }
81
82 impl fidl::encoding::ValueTypeMarker for SetSystemActivityGovernorStateError {
83 type Borrowed<'a> = Self;
84 #[inline(always)]
85 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
86 *value
87 }
88 }
89
90 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
91 for SetSystemActivityGovernorStateError
92 {
93 #[inline]
94 unsafe fn encode(
95 self,
96 encoder: &mut fidl::encoding::Encoder<'_, D>,
97 offset: usize,
98 _depth: fidl::encoding::Depth,
99 ) -> fidl::Result<()> {
100 encoder.debug_check_bounds::<Self>(offset);
101 encoder.write_num(self.into_primitive(), offset);
102 Ok(())
103 }
104 }
105
106 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
107 for SetSystemActivityGovernorStateError
108 {
109 #[inline(always)]
110 fn new_empty() -> Self {
111 Self::NotSupported
112 }
113
114 #[inline]
115 unsafe fn decode(
116 &mut self,
117 decoder: &mut fidl::encoding::Decoder<'_, D>,
118 offset: usize,
119 _depth: fidl::encoding::Depth,
120 ) -> fidl::Result<()> {
121 decoder.debug_check_bounds::<Self>(offset);
122 let prim = decoder.read_num::<u32>(offset);
123
124 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
125 Ok(())
126 }
127 }
128
129 impl SystemActivityGovernorState {
130 #[inline(always)]
131 fn max_ordinal_present(&self) -> u64 {
132 if let Some(_) = self.application_activity_level {
133 return 2;
134 }
135 if let Some(_) = self.execution_state_level {
136 return 1;
137 }
138 0
139 }
140 }
141
142 impl fidl::encoding::ValueTypeMarker for SystemActivityGovernorState {
143 type Borrowed<'a> = &'a Self;
144 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
145 value
146 }
147 }
148
149 unsafe impl fidl::encoding::TypeMarker for SystemActivityGovernorState {
150 type Owned = Self;
151
152 #[inline(always)]
153 fn inline_align(_context: fidl::encoding::Context) -> usize {
154 8
155 }
156
157 #[inline(always)]
158 fn inline_size(_context: fidl::encoding::Context) -> usize {
159 16
160 }
161 }
162
163 unsafe impl<D: fidl::encoding::ResourceDialect>
164 fidl::encoding::Encode<SystemActivityGovernorState, D> for &SystemActivityGovernorState
165 {
166 unsafe fn encode(
167 self,
168 encoder: &mut fidl::encoding::Encoder<'_, D>,
169 offset: usize,
170 mut depth: fidl::encoding::Depth,
171 ) -> fidl::Result<()> {
172 encoder.debug_check_bounds::<SystemActivityGovernorState>(offset);
173 let max_ordinal: u64 = self.max_ordinal_present();
175 encoder.write_num(max_ordinal, offset);
176 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
177 if max_ordinal == 0 {
179 return Ok(());
180 }
181 depth.increment()?;
182 let envelope_size = 8;
183 let bytes_len = max_ordinal as usize * envelope_size;
184 #[allow(unused_variables)]
185 let offset = encoder.out_of_line_offset(bytes_len);
186 let mut _prev_end_offset: usize = 0;
187 if 1 > max_ordinal {
188 return Ok(());
189 }
190
191 let cur_offset: usize = (1 - 1) * envelope_size;
194
195 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
197
198 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_power_system__common::ExecutionStateLevel, D>(
203 self.execution_state_level.as_ref().map(<fidl_fuchsia_power_system__common::ExecutionStateLevel as fidl::encoding::ValueTypeMarker>::borrow),
204 encoder, offset + cur_offset, depth
205 )?;
206
207 _prev_end_offset = cur_offset + envelope_size;
208 if 2 > max_ordinal {
209 return Ok(());
210 }
211
212 let cur_offset: usize = (2 - 1) * envelope_size;
215
216 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
218
219 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_power_system__common::ApplicationActivityLevel, D>(
224 self.application_activity_level.as_ref().map(<fidl_fuchsia_power_system__common::ApplicationActivityLevel as fidl::encoding::ValueTypeMarker>::borrow),
225 encoder, offset + cur_offset, depth
226 )?;
227
228 _prev_end_offset = cur_offset + envelope_size;
229
230 Ok(())
231 }
232 }
233
234 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
235 for SystemActivityGovernorState
236 {
237 #[inline(always)]
238 fn new_empty() -> Self {
239 Self::default()
240 }
241
242 unsafe fn decode(
243 &mut self,
244 decoder: &mut fidl::encoding::Decoder<'_, D>,
245 offset: usize,
246 mut depth: fidl::encoding::Depth,
247 ) -> fidl::Result<()> {
248 decoder.debug_check_bounds::<Self>(offset);
249 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
250 None => return Err(fidl::Error::NotNullable),
251 Some(len) => len,
252 };
253 if len == 0 {
255 return Ok(());
256 };
257 depth.increment()?;
258 let envelope_size = 8;
259 let bytes_len = len * envelope_size;
260 let offset = decoder.out_of_line_offset(bytes_len)?;
261 let mut _next_ordinal_to_read = 0;
263 let mut next_offset = offset;
264 let end_offset = offset + bytes_len;
265 _next_ordinal_to_read += 1;
266 if next_offset >= end_offset {
267 return Ok(());
268 }
269
270 while _next_ordinal_to_read < 1 {
272 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
273 _next_ordinal_to_read += 1;
274 next_offset += envelope_size;
275 }
276
277 let next_out_of_line = decoder.next_out_of_line();
278 let handles_before = decoder.remaining_handles();
279 if let Some((inlined, num_bytes, num_handles)) =
280 fidl::encoding::decode_envelope_header(decoder, next_offset)?
281 {
282 let member_inline_size = <fidl_fuchsia_power_system__common::ExecutionStateLevel as fidl::encoding::TypeMarker>::inline_size(decoder.context);
283 if inlined != (member_inline_size <= 4) {
284 return Err(fidl::Error::InvalidInlineBitInEnvelope);
285 }
286 let inner_offset;
287 let mut inner_depth = depth.clone();
288 if inlined {
289 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
290 inner_offset = next_offset;
291 } else {
292 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
293 inner_depth.increment()?;
294 }
295 let val_ref = self.execution_state_level.get_or_insert_with(|| {
296 fidl::new_empty!(fidl_fuchsia_power_system__common::ExecutionStateLevel, D)
297 });
298 fidl::decode!(
299 fidl_fuchsia_power_system__common::ExecutionStateLevel,
300 D,
301 val_ref,
302 decoder,
303 inner_offset,
304 inner_depth
305 )?;
306 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
307 {
308 return Err(fidl::Error::InvalidNumBytesInEnvelope);
309 }
310 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
311 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
312 }
313 }
314
315 next_offset += envelope_size;
316 _next_ordinal_to_read += 1;
317 if next_offset >= end_offset {
318 return Ok(());
319 }
320
321 while _next_ordinal_to_read < 2 {
323 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
324 _next_ordinal_to_read += 1;
325 next_offset += envelope_size;
326 }
327
328 let next_out_of_line = decoder.next_out_of_line();
329 let handles_before = decoder.remaining_handles();
330 if let Some((inlined, num_bytes, num_handles)) =
331 fidl::encoding::decode_envelope_header(decoder, next_offset)?
332 {
333 let member_inline_size = <fidl_fuchsia_power_system__common::ApplicationActivityLevel as fidl::encoding::TypeMarker>::inline_size(decoder.context);
334 if inlined != (member_inline_size <= 4) {
335 return Err(fidl::Error::InvalidInlineBitInEnvelope);
336 }
337 let inner_offset;
338 let mut inner_depth = depth.clone();
339 if inlined {
340 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
341 inner_offset = next_offset;
342 } else {
343 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
344 inner_depth.increment()?;
345 }
346 let val_ref = self.application_activity_level.get_or_insert_with(|| {
347 fidl::new_empty!(fidl_fuchsia_power_system__common::ApplicationActivityLevel, D)
348 });
349 fidl::decode!(
350 fidl_fuchsia_power_system__common::ApplicationActivityLevel,
351 D,
352 val_ref,
353 decoder,
354 inner_offset,
355 inner_depth
356 )?;
357 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
358 {
359 return Err(fidl::Error::InvalidNumBytesInEnvelope);
360 }
361 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
362 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
363 }
364 }
365
366 next_offset += envelope_size;
367
368 while next_offset < end_offset {
370 _next_ordinal_to_read += 1;
371 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
372 next_offset += envelope_size;
373 }
374
375 Ok(())
376 }
377 }
378}