fidl_cf_sc_internal_systemupdaterconfig__common/
fidl_cf_sc_internal_systemupdaterconfig__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#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13    pub concurrent_blob_fetches: u16,
14    pub concurrent_package_resolves: u16,
15    pub manifest_public_keys: Vec<String>,
16}
17
18impl fidl::Persistable for Config {}
19
20mod internal {
21    use super::*;
22
23    impl fidl::encoding::ValueTypeMarker for Config {
24        type Borrowed<'a> = &'a Self;
25        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
26            value
27        }
28    }
29
30    unsafe impl fidl::encoding::TypeMarker for Config {
31        type Owned = Self;
32
33        #[inline(always)]
34        fn inline_align(_context: fidl::encoding::Context) -> usize {
35            8
36        }
37
38        #[inline(always)]
39        fn inline_size(_context: fidl::encoding::Context) -> usize {
40            24
41        }
42    }
43
44    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
45        #[inline]
46        unsafe fn encode(
47            self,
48            encoder: &mut fidl::encoding::Encoder<'_, D>,
49            offset: usize,
50            _depth: fidl::encoding::Depth,
51        ) -> fidl::Result<()> {
52            encoder.debug_check_bounds::<Config>(offset);
53            // Delegate to tuple encoding.
54            fidl::encoding::Encode::<Config, D>::encode(
55                (
56                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.concurrent_blob_fetches),
57                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.concurrent_package_resolves),
58                    <fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10> as fidl::encoding::ValueTypeMarker>::borrow(&self.manifest_public_keys),
59                ),
60                encoder, offset, _depth
61            )
62        }
63    }
64    unsafe impl<
65        D: fidl::encoding::ResourceDialect,
66        T0: fidl::encoding::Encode<u16, D>,
67        T1: fidl::encoding::Encode<u16, D>,
68        T2: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>, D>,
69    > fidl::encoding::Encode<Config, D> for (T0, T1, T2)
70    {
71        #[inline]
72        unsafe fn encode(
73            self,
74            encoder: &mut fidl::encoding::Encoder<'_, D>,
75            offset: usize,
76            depth: fidl::encoding::Depth,
77        ) -> fidl::Result<()> {
78            encoder.debug_check_bounds::<Config>(offset);
79            // Zero out padding regions. There's no need to apply masks
80            // because the unmasked parts will be overwritten by fields.
81            unsafe {
82                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
83                (ptr as *mut u64).write_unaligned(0);
84            }
85            // Write the fields.
86            self.0.encode(encoder, offset + 0, depth)?;
87            self.1.encode(encoder, offset + 2, depth)?;
88            self.2.encode(encoder, offset + 8, depth)?;
89            Ok(())
90        }
91    }
92
93    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
94        #[inline(always)]
95        fn new_empty() -> Self {
96            Self {
97                concurrent_blob_fetches: fidl::new_empty!(u16, D),
98                concurrent_package_resolves: fidl::new_empty!(u16, D),
99                manifest_public_keys: fidl::new_empty!(
100                    fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>,
101                    D
102                ),
103            }
104        }
105
106        #[inline]
107        unsafe fn decode(
108            &mut self,
109            decoder: &mut fidl::encoding::Decoder<'_, D>,
110            offset: usize,
111            _depth: fidl::encoding::Depth,
112        ) -> fidl::Result<()> {
113            decoder.debug_check_bounds::<Self>(offset);
114            // Verify that padding bytes are zero.
115            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
116            let padval = unsafe { (ptr as *const u64).read_unaligned() };
117            let mask = 0xffffffff00000000u64;
118            let maskedval = padval & mask;
119            if maskedval != 0 {
120                return Err(fidl::Error::NonZeroPadding {
121                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
122                });
123            }
124            fidl::decode!(u16, D, &mut self.concurrent_blob_fetches, decoder, offset + 0, _depth)?;
125            fidl::decode!(
126                u16,
127                D,
128                &mut self.concurrent_package_resolves,
129                decoder,
130                offset + 2,
131                _depth
132            )?;
133            fidl::decode!(
134                fidl::encoding::Vector<fidl::encoding::BoundedString<64>, 10>,
135                D,
136                &mut self.manifest_public_keys,
137                decoder,
138                offset + 8,
139                _depth
140            )?;
141            Ok(())
142        }
143    }
144}