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