fidl_fuchsia_update_config_common/
fidl_fuchsia_update_config_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)]
13pub enum OptOutAdminError {
14 Internal,
18 #[doc(hidden)]
19 __SourceBreaking { unknown_ordinal: u32 },
20}
21
22#[macro_export]
24macro_rules! OptOutAdminErrorUnknown {
25 () => {
26 _
27 };
28}
29
30impl OptOutAdminError {
31 #[inline]
32 pub fn from_primitive(prim: u32) -> Option<Self> {
33 match prim {
34 1 => Some(Self::Internal),
35 _ => None,
36 }
37 }
38
39 #[inline]
40 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
41 match prim {
42 1 => Self::Internal,
43 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
44 }
45 }
46
47 #[inline]
48 pub fn unknown() -> Self {
49 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
50 }
51
52 #[inline]
53 pub const fn into_primitive(self) -> u32 {
54 match self {
55 Self::Internal => 1,
56 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
57 }
58 }
59
60 #[inline]
61 pub fn is_unknown(&self) -> bool {
62 match self {
63 Self::__SourceBreaking { unknown_ordinal: _ } => true,
64 _ => false,
65 }
66 }
67}
68
69#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
71#[repr(u32)]
72pub enum OptOutPreference {
73 AllowAllUpdates = 1,
75 AllowOnlySecurityUpdates = 2,
77}
78
79impl OptOutPreference {
80 #[inline]
81 pub fn from_primitive(prim: u32) -> Option<Self> {
82 match prim {
83 1 => Some(Self::AllowAllUpdates),
84 2 => Some(Self::AllowOnlySecurityUpdates),
85 _ => None,
86 }
87 }
88
89 #[inline]
90 pub const fn into_primitive(self) -> u32 {
91 self as u32
92 }
93
94 #[deprecated = "Strict enums should not use `is_unknown`"]
95 #[inline]
96 pub fn is_unknown(&self) -> bool {
97 false
98 }
99}
100
101#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
102pub struct OptOutAdminSetRequest {
103 pub value: OptOutPreference,
104}
105
106impl fidl::Persistable for OptOutAdminSetRequest {}
107
108#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
109pub struct OptOutGetResponse {
110 pub value: OptOutPreference,
111}
112
113impl fidl::Persistable for OptOutGetResponse {}
114
115mod internal {
116 use super::*;
117 unsafe impl fidl::encoding::TypeMarker for OptOutAdminError {
118 type Owned = Self;
119
120 #[inline(always)]
121 fn inline_align(_context: fidl::encoding::Context) -> usize {
122 std::mem::align_of::<u32>()
123 }
124
125 #[inline(always)]
126 fn inline_size(_context: fidl::encoding::Context) -> usize {
127 std::mem::size_of::<u32>()
128 }
129
130 #[inline(always)]
131 fn encode_is_copy() -> bool {
132 false
133 }
134
135 #[inline(always)]
136 fn decode_is_copy() -> bool {
137 false
138 }
139 }
140
141 impl fidl::encoding::ValueTypeMarker for OptOutAdminError {
142 type Borrowed<'a> = Self;
143 #[inline(always)]
144 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
145 *value
146 }
147 }
148
149 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
150 for OptOutAdminError
151 {
152 #[inline]
153 unsafe fn encode(
154 self,
155 encoder: &mut fidl::encoding::Encoder<'_, D>,
156 offset: usize,
157 _depth: fidl::encoding::Depth,
158 ) -> fidl::Result<()> {
159 encoder.debug_check_bounds::<Self>(offset);
160 encoder.write_num(self.into_primitive(), offset);
161 Ok(())
162 }
163 }
164
165 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminError {
166 #[inline(always)]
167 fn new_empty() -> Self {
168 Self::unknown()
169 }
170
171 #[inline]
172 unsafe fn decode(
173 &mut self,
174 decoder: &mut fidl::encoding::Decoder<'_, D>,
175 offset: usize,
176 _depth: fidl::encoding::Depth,
177 ) -> fidl::Result<()> {
178 decoder.debug_check_bounds::<Self>(offset);
179 let prim = decoder.read_num::<u32>(offset);
180
181 *self = Self::from_primitive_allow_unknown(prim);
182 Ok(())
183 }
184 }
185 unsafe impl fidl::encoding::TypeMarker for OptOutPreference {
186 type Owned = Self;
187
188 #[inline(always)]
189 fn inline_align(_context: fidl::encoding::Context) -> usize {
190 std::mem::align_of::<u32>()
191 }
192
193 #[inline(always)]
194 fn inline_size(_context: fidl::encoding::Context) -> usize {
195 std::mem::size_of::<u32>()
196 }
197
198 #[inline(always)]
199 fn encode_is_copy() -> bool {
200 true
201 }
202
203 #[inline(always)]
204 fn decode_is_copy() -> bool {
205 false
206 }
207 }
208
209 impl fidl::encoding::ValueTypeMarker for OptOutPreference {
210 type Borrowed<'a> = Self;
211 #[inline(always)]
212 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
213 *value
214 }
215 }
216
217 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
218 for OptOutPreference
219 {
220 #[inline]
221 unsafe fn encode(
222 self,
223 encoder: &mut fidl::encoding::Encoder<'_, D>,
224 offset: usize,
225 _depth: fidl::encoding::Depth,
226 ) -> fidl::Result<()> {
227 encoder.debug_check_bounds::<Self>(offset);
228 encoder.write_num(self.into_primitive(), offset);
229 Ok(())
230 }
231 }
232
233 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutPreference {
234 #[inline(always)]
235 fn new_empty() -> Self {
236 Self::AllowAllUpdates
237 }
238
239 #[inline]
240 unsafe fn decode(
241 &mut self,
242 decoder: &mut fidl::encoding::Decoder<'_, D>,
243 offset: usize,
244 _depth: fidl::encoding::Depth,
245 ) -> fidl::Result<()> {
246 decoder.debug_check_bounds::<Self>(offset);
247 let prim = decoder.read_num::<u32>(offset);
248
249 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
250 Ok(())
251 }
252 }
253
254 impl fidl::encoding::ValueTypeMarker for OptOutAdminSetRequest {
255 type Borrowed<'a> = &'a Self;
256 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
257 value
258 }
259 }
260
261 unsafe impl fidl::encoding::TypeMarker for OptOutAdminSetRequest {
262 type Owned = Self;
263
264 #[inline(always)]
265 fn inline_align(_context: fidl::encoding::Context) -> usize {
266 4
267 }
268
269 #[inline(always)]
270 fn inline_size(_context: fidl::encoding::Context) -> usize {
271 4
272 }
273 }
274
275 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutAdminSetRequest, D>
276 for &OptOutAdminSetRequest
277 {
278 #[inline]
279 unsafe fn encode(
280 self,
281 encoder: &mut fidl::encoding::Encoder<'_, D>,
282 offset: usize,
283 _depth: fidl::encoding::Depth,
284 ) -> fidl::Result<()> {
285 encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
286 fidl::encoding::Encode::<OptOutAdminSetRequest, D>::encode(
288 (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
289 encoder,
290 offset,
291 _depth,
292 )
293 }
294 }
295 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
296 fidl::encoding::Encode<OptOutAdminSetRequest, D> for (T0,)
297 {
298 #[inline]
299 unsafe fn encode(
300 self,
301 encoder: &mut fidl::encoding::Encoder<'_, D>,
302 offset: usize,
303 depth: fidl::encoding::Depth,
304 ) -> fidl::Result<()> {
305 encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
306 self.0.encode(encoder, offset + 0, depth)?;
310 Ok(())
311 }
312 }
313
314 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminSetRequest {
315 #[inline(always)]
316 fn new_empty() -> Self {
317 Self { value: fidl::new_empty!(OptOutPreference, D) }
318 }
319
320 #[inline]
321 unsafe fn decode(
322 &mut self,
323 decoder: &mut fidl::encoding::Decoder<'_, D>,
324 offset: usize,
325 _depth: fidl::encoding::Depth,
326 ) -> fidl::Result<()> {
327 decoder.debug_check_bounds::<Self>(offset);
328 fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
330 Ok(())
331 }
332 }
333
334 impl fidl::encoding::ValueTypeMarker for OptOutGetResponse {
335 type Borrowed<'a> = &'a Self;
336 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
337 value
338 }
339 }
340
341 unsafe impl fidl::encoding::TypeMarker for OptOutGetResponse {
342 type Owned = Self;
343
344 #[inline(always)]
345 fn inline_align(_context: fidl::encoding::Context) -> usize {
346 4
347 }
348
349 #[inline(always)]
350 fn inline_size(_context: fidl::encoding::Context) -> usize {
351 4
352 }
353 }
354
355 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutGetResponse, D>
356 for &OptOutGetResponse
357 {
358 #[inline]
359 unsafe fn encode(
360 self,
361 encoder: &mut fidl::encoding::Encoder<'_, D>,
362 offset: usize,
363 _depth: fidl::encoding::Depth,
364 ) -> fidl::Result<()> {
365 encoder.debug_check_bounds::<OptOutGetResponse>(offset);
366 fidl::encoding::Encode::<OptOutGetResponse, D>::encode(
368 (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
369 encoder,
370 offset,
371 _depth,
372 )
373 }
374 }
375 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
376 fidl::encoding::Encode<OptOutGetResponse, D> for (T0,)
377 {
378 #[inline]
379 unsafe fn encode(
380 self,
381 encoder: &mut fidl::encoding::Encoder<'_, D>,
382 offset: usize,
383 depth: fidl::encoding::Depth,
384 ) -> fidl::Result<()> {
385 encoder.debug_check_bounds::<OptOutGetResponse>(offset);
386 self.0.encode(encoder, offset + 0, depth)?;
390 Ok(())
391 }
392 }
393
394 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutGetResponse {
395 #[inline(always)]
396 fn new_empty() -> Self {
397 Self { value: fidl::new_empty!(OptOutPreference, D) }
398 }
399
400 #[inline]
401 unsafe fn decode(
402 &mut self,
403 decoder: &mut fidl::encoding::Decoder<'_, D>,
404 offset: usize,
405 _depth: fidl::encoding::Depth,
406 ) -> fidl::Result<()> {
407 decoder.debug_check_bounds::<Self>(offset);
408 fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
410 Ok(())
411 }
412 }
413}