Skip to main content

fidl_cf_sc_internal_pkgcacheconfig_common/
fidl_cf_sc_internal_pkgcacheconfig_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 all_packages_executable: bool,
14    pub blob_download_resumption_attempts_limit: u32,
15    pub blob_fetch_concurrency_limit: u16,
16    pub blob_network_body_timeout_seconds: u32,
17    pub blob_network_header_timeout_seconds: u32,
18    pub enable_upgradable_packages: bool,
19    pub require_system_image: bool,
20    pub system_image_hash: String,
21    pub use_driver_blob_paging: bool,
22}
23
24impl fidl::Persistable for Config {}
25
26mod internal {
27    use super::*;
28
29    impl fidl::encoding::ValueTypeMarker for Config {
30        type Borrowed<'a> = &'a Self;
31        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
32            value
33        }
34    }
35
36    unsafe impl fidl::encoding::TypeMarker for Config {
37        type Owned = Self;
38
39        #[inline(always)]
40        fn inline_align(_context: fidl::encoding::Context) -> usize {
41            8
42        }
43
44        #[inline(always)]
45        fn inline_size(_context: fidl::encoding::Context) -> usize {
46            48
47        }
48    }
49
50    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
51        #[inline]
52        unsafe fn encode(
53            self,
54            encoder: &mut fidl::encoding::Encoder<'_, D>,
55            offset: usize,
56            _depth: fidl::encoding::Depth,
57        ) -> fidl::Result<()> {
58            encoder.debug_check_bounds::<Config>(offset);
59            // Delegate to tuple encoding.
60            fidl::encoding::Encode::<Config, D>::encode(
61                (
62                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
63                        &self.all_packages_executable,
64                    ),
65                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(
66                        &self.blob_download_resumption_attempts_limit,
67                    ),
68                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(
69                        &self.blob_fetch_concurrency_limit,
70                    ),
71                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(
72                        &self.blob_network_body_timeout_seconds,
73                    ),
74                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(
75                        &self.blob_network_header_timeout_seconds,
76                    ),
77                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
78                        &self.enable_upgradable_packages,
79                    ),
80                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.require_system_image),
81                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(
82                        &self.system_image_hash,
83                    ),
84                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.use_driver_blob_paging),
85                ),
86                encoder,
87                offset,
88                _depth,
89            )
90        }
91    }
92    unsafe impl<
93        D: fidl::encoding::ResourceDialect,
94        T0: fidl::encoding::Encode<bool, D>,
95        T1: fidl::encoding::Encode<u32, D>,
96        T2: fidl::encoding::Encode<u16, D>,
97        T3: fidl::encoding::Encode<u32, D>,
98        T4: fidl::encoding::Encode<u32, D>,
99        T5: fidl::encoding::Encode<bool, D>,
100        T6: fidl::encoding::Encode<bool, D>,
101        T7: fidl::encoding::Encode<fidl::encoding::BoundedString<100>, D>,
102        T8: fidl::encoding::Encode<bool, D>,
103    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
104    {
105        #[inline]
106        unsafe fn encode(
107            self,
108            encoder: &mut fidl::encoding::Encoder<'_, D>,
109            offset: usize,
110            depth: fidl::encoding::Depth,
111        ) -> fidl::Result<()> {
112            encoder.debug_check_bounds::<Config>(offset);
113            // Zero out padding regions. There's no need to apply masks
114            // because the unmasked parts will be overwritten by fields.
115            unsafe {
116                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
117                (ptr as *mut u64).write_unaligned(0);
118            }
119            unsafe {
120                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
121                (ptr as *mut u64).write_unaligned(0);
122            }
123            unsafe {
124                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
125                (ptr as *mut u64).write_unaligned(0);
126            }
127            unsafe {
128                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
129                (ptr as *mut u64).write_unaligned(0);
130            }
131            // Write the fields.
132            self.0.encode(encoder, offset + 0, depth)?;
133            self.1.encode(encoder, offset + 4, depth)?;
134            self.2.encode(encoder, offset + 8, depth)?;
135            self.3.encode(encoder, offset + 12, depth)?;
136            self.4.encode(encoder, offset + 16, depth)?;
137            self.5.encode(encoder, offset + 20, depth)?;
138            self.6.encode(encoder, offset + 21, depth)?;
139            self.7.encode(encoder, offset + 24, depth)?;
140            self.8.encode(encoder, offset + 40, depth)?;
141            Ok(())
142        }
143    }
144
145    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
146        #[inline(always)]
147        fn new_empty() -> Self {
148            Self {
149                all_packages_executable: fidl::new_empty!(bool, D),
150                blob_download_resumption_attempts_limit: fidl::new_empty!(u32, D),
151                blob_fetch_concurrency_limit: fidl::new_empty!(u16, D),
152                blob_network_body_timeout_seconds: fidl::new_empty!(u32, D),
153                blob_network_header_timeout_seconds: fidl::new_empty!(u32, D),
154                enable_upgradable_packages: fidl::new_empty!(bool, D),
155                require_system_image: fidl::new_empty!(bool, D),
156                system_image_hash: fidl::new_empty!(fidl::encoding::BoundedString<100>, D),
157                use_driver_blob_paging: fidl::new_empty!(bool, D),
158            }
159        }
160
161        #[inline]
162        unsafe fn decode(
163            &mut self,
164            decoder: &mut fidl::encoding::Decoder<'_, D>,
165            offset: usize,
166            _depth: fidl::encoding::Depth,
167        ) -> fidl::Result<()> {
168            decoder.debug_check_bounds::<Self>(offset);
169            // Verify that padding bytes are zero.
170            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
171            let padval = unsafe { (ptr as *const u64).read_unaligned() };
172            let mask = 0xffffff00u64;
173            let maskedval = padval & mask;
174            if maskedval != 0 {
175                return Err(fidl::Error::NonZeroPadding {
176                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
177                });
178            }
179            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
180            let padval = unsafe { (ptr as *const u64).read_unaligned() };
181            let mask = 0xffff0000u64;
182            let maskedval = padval & mask;
183            if maskedval != 0 {
184                return Err(fidl::Error::NonZeroPadding {
185                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
186                });
187            }
188            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
189            let padval = unsafe { (ptr as *const u64).read_unaligned() };
190            let mask = 0xffff000000000000u64;
191            let maskedval = padval & mask;
192            if maskedval != 0 {
193                return Err(fidl::Error::NonZeroPadding {
194                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
195                });
196            }
197            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
198            let padval = unsafe { (ptr as *const u64).read_unaligned() };
199            let mask = 0xffffffffffffff00u64;
200            let maskedval = padval & mask;
201            if maskedval != 0 {
202                return Err(fidl::Error::NonZeroPadding {
203                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
204                });
205            }
206            fidl::decode!(bool, D, &mut self.all_packages_executable, decoder, offset + 0, _depth)?;
207            fidl::decode!(
208                u32,
209                D,
210                &mut self.blob_download_resumption_attempts_limit,
211                decoder,
212                offset + 4,
213                _depth
214            )?;
215            fidl::decode!(
216                u16,
217                D,
218                &mut self.blob_fetch_concurrency_limit,
219                decoder,
220                offset + 8,
221                _depth
222            )?;
223            fidl::decode!(
224                u32,
225                D,
226                &mut self.blob_network_body_timeout_seconds,
227                decoder,
228                offset + 12,
229                _depth
230            )?;
231            fidl::decode!(
232                u32,
233                D,
234                &mut self.blob_network_header_timeout_seconds,
235                decoder,
236                offset + 16,
237                _depth
238            )?;
239            fidl::decode!(
240                bool,
241                D,
242                &mut self.enable_upgradable_packages,
243                decoder,
244                offset + 20,
245                _depth
246            )?;
247            fidl::decode!(bool, D, &mut self.require_system_image, decoder, offset + 21, _depth)?;
248            fidl::decode!(
249                fidl::encoding::BoundedString<100>,
250                D,
251                &mut self.system_image_hash,
252                decoder,
253                offset + 24,
254                _depth
255            )?;
256            fidl::decode!(bool, D, &mut self.use_driver_blob_paging, decoder, offset + 40, _depth)?;
257            Ok(())
258        }
259    }
260}