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
109mod internal {
110    use super::*;
111    unsafe impl fidl::encoding::TypeMarker for OptOutAdminError {
112        type Owned = Self;
113
114        #[inline(always)]
115        fn inline_align(_context: fidl::encoding::Context) -> usize {
116            std::mem::align_of::<u32>()
117        }
118
119        #[inline(always)]
120        fn inline_size(_context: fidl::encoding::Context) -> usize {
121            std::mem::size_of::<u32>()
122        }
123
124        #[inline(always)]
125        fn encode_is_copy() -> bool {
126            false
127        }
128
129        #[inline(always)]
130        fn decode_is_copy() -> bool {
131            false
132        }
133    }
134
135    impl fidl::encoding::ValueTypeMarker for OptOutAdminError {
136        type Borrowed<'a> = Self;
137        #[inline(always)]
138        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
139            *value
140        }
141    }
142
143    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
144        for OptOutAdminError
145    {
146        #[inline]
147        unsafe fn encode(
148            self,
149            encoder: &mut fidl::encoding::Encoder<'_, D>,
150            offset: usize,
151            _depth: fidl::encoding::Depth,
152        ) -> fidl::Result<()> {
153            encoder.debug_check_bounds::<Self>(offset);
154            encoder.write_num(self.into_primitive(), offset);
155            Ok(())
156        }
157    }
158
159    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminError {
160        #[inline(always)]
161        fn new_empty() -> Self {
162            Self::unknown()
163        }
164
165        #[inline]
166        unsafe fn decode(
167            &mut self,
168            decoder: &mut fidl::encoding::Decoder<'_, D>,
169            offset: usize,
170            _depth: fidl::encoding::Depth,
171        ) -> fidl::Result<()> {
172            decoder.debug_check_bounds::<Self>(offset);
173            let prim = decoder.read_num::<u32>(offset);
174
175            *self = Self::from_primitive_allow_unknown(prim);
176            Ok(())
177        }
178    }
179    unsafe impl fidl::encoding::TypeMarker for OptOutPreference {
180        type Owned = Self;
181
182        #[inline(always)]
183        fn inline_align(_context: fidl::encoding::Context) -> usize {
184            std::mem::align_of::<u32>()
185        }
186
187        #[inline(always)]
188        fn inline_size(_context: fidl::encoding::Context) -> usize {
189            std::mem::size_of::<u32>()
190        }
191
192        #[inline(always)]
193        fn encode_is_copy() -> bool {
194            true
195        }
196
197        #[inline(always)]
198        fn decode_is_copy() -> bool {
199            false
200        }
201    }
202
203    impl fidl::encoding::ValueTypeMarker for OptOutPreference {
204        type Borrowed<'a> = Self;
205        #[inline(always)]
206        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
207            *value
208        }
209    }
210
211    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
212        for OptOutPreference
213    {
214        #[inline]
215        unsafe fn encode(
216            self,
217            encoder: &mut fidl::encoding::Encoder<'_, D>,
218            offset: usize,
219            _depth: fidl::encoding::Depth,
220        ) -> fidl::Result<()> {
221            encoder.debug_check_bounds::<Self>(offset);
222            encoder.write_num(self.into_primitive(), offset);
223            Ok(())
224        }
225    }
226
227    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutPreference {
228        #[inline(always)]
229        fn new_empty() -> Self {
230            Self::AllowAllUpdates
231        }
232
233        #[inline]
234        unsafe fn decode(
235            &mut self,
236            decoder: &mut fidl::encoding::Decoder<'_, D>,
237            offset: usize,
238            _depth: fidl::encoding::Depth,
239        ) -> fidl::Result<()> {
240            decoder.debug_check_bounds::<Self>(offset);
241            let prim = decoder.read_num::<u32>(offset);
242
243            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
244            Ok(())
245        }
246    }
247
248    impl fidl::encoding::ValueTypeMarker for OptOutAdminSetRequest {
249        type Borrowed<'a> = &'a Self;
250        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
251            value
252        }
253    }
254
255    unsafe impl fidl::encoding::TypeMarker for OptOutAdminSetRequest {
256        type Owned = Self;
257
258        #[inline(always)]
259        fn inline_align(_context: fidl::encoding::Context) -> usize {
260            4
261        }
262
263        #[inline(always)]
264        fn inline_size(_context: fidl::encoding::Context) -> usize {
265            4
266        }
267    }
268
269    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutAdminSetRequest, D>
270        for &OptOutAdminSetRequest
271    {
272        #[inline]
273        unsafe fn encode(
274            self,
275            encoder: &mut fidl::encoding::Encoder<'_, D>,
276            offset: usize,
277            _depth: fidl::encoding::Depth,
278        ) -> fidl::Result<()> {
279            encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
280            // Delegate to tuple encoding.
281            fidl::encoding::Encode::<OptOutAdminSetRequest, D>::encode(
282                (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
283                encoder,
284                offset,
285                _depth,
286            )
287        }
288    }
289    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
290        fidl::encoding::Encode<OptOutAdminSetRequest, D> for (T0,)
291    {
292        #[inline]
293        unsafe fn encode(
294            self,
295            encoder: &mut fidl::encoding::Encoder<'_, D>,
296            offset: usize,
297            depth: fidl::encoding::Depth,
298        ) -> fidl::Result<()> {
299            encoder.debug_check_bounds::<OptOutAdminSetRequest>(offset);
300            // Zero out padding regions. There's no need to apply masks
301            // because the unmasked parts will be overwritten by fields.
302            // Write the fields.
303            self.0.encode(encoder, offset + 0, depth)?;
304            Ok(())
305        }
306    }
307
308    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutAdminSetRequest {
309        #[inline(always)]
310        fn new_empty() -> Self {
311            Self { value: fidl::new_empty!(OptOutPreference, D) }
312        }
313
314        #[inline]
315        unsafe fn decode(
316            &mut self,
317            decoder: &mut fidl::encoding::Decoder<'_, D>,
318            offset: usize,
319            _depth: fidl::encoding::Depth,
320        ) -> fidl::Result<()> {
321            decoder.debug_check_bounds::<Self>(offset);
322            // Verify that padding bytes are zero.
323            fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
324            Ok(())
325        }
326    }
327
328    impl fidl::encoding::ValueTypeMarker for OptOutGetResponse {
329        type Borrowed<'a> = &'a Self;
330        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
331            value
332        }
333    }
334
335    unsafe impl fidl::encoding::TypeMarker for OptOutGetResponse {
336        type Owned = Self;
337
338        #[inline(always)]
339        fn inline_align(_context: fidl::encoding::Context) -> usize {
340            4
341        }
342
343        #[inline(always)]
344        fn inline_size(_context: fidl::encoding::Context) -> usize {
345            4
346        }
347    }
348
349    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<OptOutGetResponse, D>
350        for &OptOutGetResponse
351    {
352        #[inline]
353        unsafe fn encode(
354            self,
355            encoder: &mut fidl::encoding::Encoder<'_, D>,
356            offset: usize,
357            _depth: fidl::encoding::Depth,
358        ) -> fidl::Result<()> {
359            encoder.debug_check_bounds::<OptOutGetResponse>(offset);
360            // Delegate to tuple encoding.
361            fidl::encoding::Encode::<OptOutGetResponse, D>::encode(
362                (<OptOutPreference as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
363                encoder,
364                offset,
365                _depth,
366            )
367        }
368    }
369    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<OptOutPreference, D>>
370        fidl::encoding::Encode<OptOutGetResponse, D> for (T0,)
371    {
372        #[inline]
373        unsafe fn encode(
374            self,
375            encoder: &mut fidl::encoding::Encoder<'_, D>,
376            offset: usize,
377            depth: fidl::encoding::Depth,
378        ) -> fidl::Result<()> {
379            encoder.debug_check_bounds::<OptOutGetResponse>(offset);
380            // Zero out padding regions. There's no need to apply masks
381            // because the unmasked parts will be overwritten by fields.
382            // Write the fields.
383            self.0.encode(encoder, offset + 0, depth)?;
384            Ok(())
385        }
386    }
387
388    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OptOutGetResponse {
389        #[inline(always)]
390        fn new_empty() -> Self {
391            Self { value: fidl::new_empty!(OptOutPreference, D) }
392        }
393
394        #[inline]
395        unsafe fn decode(
396            &mut self,
397            decoder: &mut fidl::encoding::Decoder<'_, D>,
398            offset: usize,
399            _depth: fidl::encoding::Depth,
400        ) -> fidl::Result<()> {
401            decoder.debug_check_bounds::<Self>(offset);
402            // Verify that padding bytes are zero.
403            fidl::decode!(OptOutPreference, D, &mut self.value, decoder, offset + 0, _depth)?;
404            Ok(())
405        }
406    }
407}