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