fidl_fuchsia_net_power_common/
fidl_fuchsia_net_power_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
11pub const GROUP_WAKEUP_SIGNAL: u32 = 16777216;
13
14pub const MAX_NAME_LEN: u8 = 255;
15
16pub const WAITER_ASLEEP_SIGNAL: u32 = 33554432;
18
19pub const WAITER_AWAKE_SIGNAL: u32 = 16777216;
21
22#[derive(Clone, Debug, Default, PartialEq)]
23pub struct WakeGroupOptions {
24 pub debug_name: Option<String>,
32 #[doc(hidden)]
33 pub __source_breaking: fidl::marker::SourceBreaking,
34}
35
36impl fidl::Persistable for WakeGroupOptions {}
37
38pub mod wake_group_provider_ordinals {
39 pub const CREATE_WAKE_GROUP: u64 = 0x3c6a15f6c6b1447f;
40}
41
42mod internal {
43 use super::*;
44
45 impl WakeGroupOptions {
46 #[inline(always)]
47 fn max_ordinal_present(&self) -> u64 {
48 if let Some(_) = self.debug_name {
49 return 1;
50 }
51 0
52 }
53 }
54
55 impl fidl::encoding::ValueTypeMarker for WakeGroupOptions {
56 type Borrowed<'a> = &'a Self;
57 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
58 value
59 }
60 }
61
62 unsafe impl fidl::encoding::TypeMarker for WakeGroupOptions {
63 type Owned = Self;
64
65 #[inline(always)]
66 fn inline_align(_context: fidl::encoding::Context) -> usize {
67 8
68 }
69
70 #[inline(always)]
71 fn inline_size(_context: fidl::encoding::Context) -> usize {
72 16
73 }
74 }
75
76 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<WakeGroupOptions, D>
77 for &WakeGroupOptions
78 {
79 unsafe fn encode(
80 self,
81 encoder: &mut fidl::encoding::Encoder<'_, D>,
82 offset: usize,
83 mut depth: fidl::encoding::Depth,
84 ) -> fidl::Result<()> {
85 encoder.debug_check_bounds::<WakeGroupOptions>(offset);
86 let max_ordinal: u64 = self.max_ordinal_present();
88 encoder.write_num(max_ordinal, offset);
89 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
90 if max_ordinal == 0 {
92 return Ok(());
93 }
94 depth.increment()?;
95 let envelope_size = 8;
96 let bytes_len = max_ordinal as usize * envelope_size;
97 #[allow(unused_variables)]
98 let offset = encoder.out_of_line_offset(bytes_len);
99 let mut _prev_end_offset: usize = 0;
100 if 1 > max_ordinal {
101 return Ok(());
102 }
103
104 let cur_offset: usize = (1 - 1) * envelope_size;
107
108 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
110
111 fidl::encoding::encode_in_envelope_optional::<fidl::encoding::BoundedString<255>, D>(
116 self.debug_name.as_ref().map(
117 <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow,
118 ),
119 encoder,
120 offset + cur_offset,
121 depth,
122 )?;
123
124 _prev_end_offset = cur_offset + envelope_size;
125
126 Ok(())
127 }
128 }
129
130 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WakeGroupOptions {
131 #[inline(always)]
132 fn new_empty() -> Self {
133 Self::default()
134 }
135
136 unsafe fn decode(
137 &mut self,
138 decoder: &mut fidl::encoding::Decoder<'_, D>,
139 offset: usize,
140 mut depth: fidl::encoding::Depth,
141 ) -> fidl::Result<()> {
142 decoder.debug_check_bounds::<Self>(offset);
143 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
144 None => return Err(fidl::Error::NotNullable),
145 Some(len) => len,
146 };
147 if len == 0 {
149 return Ok(());
150 };
151 depth.increment()?;
152 let envelope_size = 8;
153 let bytes_len = len * envelope_size;
154 let offset = decoder.out_of_line_offset(bytes_len)?;
155 let mut _next_ordinal_to_read = 0;
157 let mut next_offset = offset;
158 let end_offset = offset + bytes_len;
159 _next_ordinal_to_read += 1;
160 if next_offset >= end_offset {
161 return Ok(());
162 }
163
164 while _next_ordinal_to_read < 1 {
166 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
167 _next_ordinal_to_read += 1;
168 next_offset += envelope_size;
169 }
170
171 let next_out_of_line = decoder.next_out_of_line();
172 let handles_before = decoder.remaining_handles();
173 if let Some((inlined, num_bytes, num_handles)) =
174 fidl::encoding::decode_envelope_header(decoder, next_offset)?
175 {
176 let member_inline_size =
177 <fidl::encoding::BoundedString<255> as fidl::encoding::TypeMarker>::inline_size(
178 decoder.context,
179 );
180 if inlined != (member_inline_size <= 4) {
181 return Err(fidl::Error::InvalidInlineBitInEnvelope);
182 }
183 let inner_offset;
184 let mut inner_depth = depth.clone();
185 if inlined {
186 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
187 inner_offset = next_offset;
188 } else {
189 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
190 inner_depth.increment()?;
191 }
192 let val_ref = self
193 .debug_name
194 .get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<255>, D));
195 fidl::decode!(
196 fidl::encoding::BoundedString<255>,
197 D,
198 val_ref,
199 decoder,
200 inner_offset,
201 inner_depth
202 )?;
203 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
204 {
205 return Err(fidl::Error::InvalidNumBytesInEnvelope);
206 }
207 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
208 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
209 }
210 }
211
212 next_offset += envelope_size;
213
214 while next_offset < end_offset {
216 _next_ordinal_to_read += 1;
217 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
218 next_offset += envelope_size;
219 }
220
221 Ok(())
222 }
223 }
224}