fidl_fuchsia_update_config__common/
fidl_fuchsia_update_config__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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/// An error encountered while administering the user's opt-out preference.
12#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum OptOutAdminError {
14    /// There was an internal error in setting the value.  The client is not
15    /// expected to be able to do something meaningful about this error,
16    /// except to try again later.
17    Internal,
18    #[doc(hidden)]
19    __SourceBreaking { unknown_ordinal: u32 },
20}
21
22/// Pattern that matches an unknown `OptOutAdminError` member.
23#[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/// User specified preference for automatic updates.
70#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
71#[repr(u32)]
72pub enum OptOutPreference {
73    /// Allow all updates to be automatically applied.
74    AllowAllUpdates = 1,
75    /// Only allow security updates to be automatically applied.
76    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
95#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96pub struct OptOutAdminSetRequest {
97    pub value: OptOutPreference,
98}
99
100impl fidl::Persistable for OptOutAdminSetRequest {}
101
102#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
103pub struct OptOutGetResponse {
104    pub value: OptOutPreference,
105}
106
107impl fidl::Persistable for OptOutGetResponse {}
108
109pub mod opt_out_ordinals {
110    pub const GET: u64 = 0x7d905c32077a3cd8;
111}
112
113pub mod opt_out_admin_ordinals {
114    pub const SET: u64 = 0x7c990c7f64cfff27;
115}
116
117mod internal {
118    use super::*;
119    unsafe impl fidl::encoding::TypeMarker for OptOutAdminError {
120        type Owned = Self;
121
122        #[inline(always)]
123        fn inline_align(_context: fidl::encoding::Context) -> usize {
124            std::mem::align_of::<u32>()
125        }
126
127        #[inline(always)]
128        fn inline_size(_context: fidl::encoding::Context) -> usize {
129            std::mem::size_of::<u32>()
130        }
131
132        #[inline(always)]
133        fn encode_is_copy() -> bool {
134            false
135        }
136
137        #[inline(always)]
138        fn decode_is_copy() -> bool {
139            false
140        }
141    }
142
143    impl fidl::encoding::ValueTypeMarker for OptOutAdminError {
144        type Borrowed<'a> = Self;
145        #[inline(always)]
146        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
147            *value
148        }
149    }
150
151    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
152        for OptOutAdminError
153    {
154        #[inline]
155        unsafe fn encode(
156            self,
157            encoder: &mut fidl::encoding::Encoder<'_, D>,
158            offset: usize,
159            _depth: fidl::encoding::Depth,
160        ) -> fidl::Result<()> {
161            encoder.debug_check_bounds::<Self>(offset);
162            encoder.write_num(self.into_primitive(), offset);
163            Ok(())
164        }
165    }
166
167    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminError {
168        #[inline(always)]
169        fn new_empty() -> Self {
170            Self::unknown()
171        }
172
173        #[inline]
174        unsafe fn decode(
175            &mut self,
176            decoder: &mut fidl::encoding::Decoder<'_, D>,
177            offset: usize,
178            _depth: fidl::encoding::Depth,
179        ) -> fidl::Result<()> {
180            decoder.debug_check_bounds::<Self>(offset);
181            let prim = decoder.read_num::<u32>(offset);
182
183            *self = Self::from_primitive_allow_unknown(prim);
184            Ok(())
185        }
186    }
187    unsafe impl fidl::encoding::TypeMarker for OptOutPreference {
188        type Owned = Self;
189
190        #[inline(always)]
191        fn inline_align(_context: fidl::encoding::Context) -> usize {
192            std::mem::align_of::<u32>()
193        }
194
195        #[inline(always)]
196        fn inline_size(_context: fidl::encoding::Context) -> usize {
197            std::mem::size_of::<u32>()
198        }
199
200        #[inline(always)]
201        fn encode_is_copy() -> bool {
202            true
203        }
204
205        #[inline(always)]
206        fn decode_is_copy() -> bool {
207            false
208        }
209    }
210
211    impl fidl::encoding::ValueTypeMarker for OptOutPreference {
212        type Borrowed<'a> = Self;
213        #[inline(always)]
214        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
215            *value
216        }
217    }
218
219    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
220        for OptOutPreference
221    {
222        #[inline]
223        unsafe fn encode(
224            self,
225            encoder: &mut fidl::encoding::Encoder<'_, D>,
226            offset: usize,
227            _depth: fidl::encoding::Depth,
228        ) -> fidl::Result<()> {
229            encoder.debug_check_bounds::<Self>(offset);
230            encoder.write_num(self.into_primitive(), offset);
231            Ok(())
232        }
233    }
234
235    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutPreference {
236        #[inline(always)]
237        fn new_empty() -> Self {
238            Self::AllowAllUpdates
239        }
240
241        #[inline]
242        unsafe fn decode(
243            &mut self,
244            decoder: &mut fidl::encoding::Decoder<'_, D>,
245            offset: usize,
246            _depth: fidl::encoding::Depth,
247        ) -> fidl::Result<()> {
248            decoder.debug_check_bounds::<Self>(offset);
249            let prim = decoder.read_num::<u32>(offset);
250
251            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
252            Ok(())
253        }
254    }
255
256    impl fidl::encoding::ValueTypeMarker for OptOutAdminSetRequest {
257        type Borrowed<'a> = &'a Self;
258        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
259            value
260        }
261    }
262
263    unsafe impl fidl::encoding::TypeMarker for OptOutAdminSetRequest {
264        type Owned = Self;
265
266        #[inline(always)]
267        fn inline_align(_context: fidl::encoding::Context) -> usize {
268            4
269        }
270
271        #[inline(always)]
272        fn inline_size(_context: fidl::encoding::Context) -> usize {
273            4
274        }
275    }
276
277    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutAdminSetRequest, D>
278        for &OptOutAdminSetRequest
279    {
280        #[inline]
281        unsafe fn encode(
282            self,
283            encoder: &mut fidl::encoding::Encoder<'_, D>,
284            offset: usize,
285            _depth: fidl::encoding::Depth,
286        ) -> fidl::Result<()> {
287            encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
288            // Delegate to tuple encoding.
289            fidl::encoding::Encode::<OptOutAdminSetRequest, D>::encode(
290                (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
291                encoder,
292                offset,
293                _depth,
294            )
295        }
296    }
297    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
298        fidl::encoding::Encode<OptOutAdminSetRequest, D> for (T0,)
299    {
300        #[inline]
301        unsafe fn encode(
302            self,
303            encoder: &mut fidl::encoding::Encoder<'_, D>,
304            offset: usize,
305            depth: fidl::encoding::Depth,
306        ) -> fidl::Result<()> {
307            encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
308            // Zero out padding regions. There's no need to apply masks
309            // because the unmasked parts will be overwritten by fields.
310            // Write the fields.
311            self.0.encode(encoder, offset + 0, depth)?;
312            Ok(())
313        }
314    }
315
316    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminSetRequest {
317        #[inline(always)]
318        fn new_empty() -> Self {
319            Self { value: fidl::new_empty!(OptOutPreference, D) }
320        }
321
322        #[inline]
323        unsafe fn decode(
324            &mut self,
325            decoder: &mut fidl::encoding::Decoder<'_, D>,
326            offset: usize,
327            _depth: fidl::encoding::Depth,
328        ) -> fidl::Result<()> {
329            decoder.debug_check_bounds::<Self>(offset);
330            // Verify that padding bytes are zero.
331            fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
332            Ok(())
333        }
334    }
335
336    impl fidl::encoding::ValueTypeMarker for OptOutGetResponse {
337        type Borrowed<'a> = &'a Self;
338        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
339            value
340        }
341    }
342
343    unsafe impl fidl::encoding::TypeMarker for OptOutGetResponse {
344        type Owned = Self;
345
346        #[inline(always)]
347        fn inline_align(_context: fidl::encoding::Context) -> usize {
348            4
349        }
350
351        #[inline(always)]
352        fn inline_size(_context: fidl::encoding::Context) -> usize {
353            4
354        }
355    }
356
357    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutGetResponse, D>
358        for &OptOutGetResponse
359    {
360        #[inline]
361        unsafe fn encode(
362            self,
363            encoder: &mut fidl::encoding::Encoder<'_, D>,
364            offset: usize,
365            _depth: fidl::encoding::Depth,
366        ) -> fidl::Result<()> {
367            encoder.debug_check_bounds::<OptOutGetResponse>(offset);
368            // Delegate to tuple encoding.
369            fidl::encoding::Encode::<OptOutGetResponse, D>::encode(
370                (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
371                encoder,
372                offset,
373                _depth,
374            )
375        }
376    }
377    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
378        fidl::encoding::Encode<OptOutGetResponse, D> for (T0,)
379    {
380        #[inline]
381        unsafe fn encode(
382            self,
383            encoder: &mut fidl::encoding::Encoder<'_, D>,
384            offset: usize,
385            depth: fidl::encoding::Depth,
386        ) -> fidl::Result<()> {
387            encoder.debug_check_bounds::<OptOutGetResponse>(offset);
388            // Zero out padding regions. There's no need to apply masks
389            // because the unmasked parts will be overwritten by fields.
390            // Write the fields.
391            self.0.encode(encoder, offset + 0, depth)?;
392            Ok(())
393        }
394    }
395
396    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutGetResponse {
397        #[inline(always)]
398        fn new_empty() -> Self {
399            Self { value: fidl::new_empty!(OptOutPreference, D) }
400        }
401
402        #[inline]
403        unsafe fn decode(
404            &mut self,
405            decoder: &mut fidl::encoding::Decoder<'_, D>,
406            offset: usize,
407            _depth: fidl::encoding::Depth,
408        ) -> fidl::Result<()> {
409            decoder.debug_check_bounds::<Self>(offset);
410            // Verify that padding bytes are zero.
411            fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
412            Ok(())
413        }
414    }
415}