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 enable_utc_time_adjustment: bool,
17    pub extra_features: Vec<String>,
18    pub mlock_always_onfault: bool,
19    pub mlock_pin_flavor: String,
20    pub selinux_exceptions: Vec<String>,
21    pub ui_visual_debugging_level: u8,
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            88
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                    <fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.additional_mounts),
63                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.cached_zx_map_info_bytes),
64                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.crash_report_throttling),
65                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enable_utc_time_adjustment),
66                    <fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.extra_features),
67                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.mlock_always_onfault),
68                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.mlock_pin_flavor),
69                    <fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.selinux_exceptions),
70                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.ui_visual_debugging_level),
71                ),
72                encoder, offset, _depth
73            )
74        }
75    }
76    unsafe impl<
77        D: fidl::encoding::ResourceDialect,
78        T0: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>, D>,
79        T1: fidl::encoding::Encode<u32, D>,
80        T2: fidl::encoding::Encode<bool, D>,
81        T3: fidl::encoding::Encode<bool, D>,
82        T4: fidl::encoding::Encode<
83                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
84                D,
85            >,
86        T5: fidl::encoding::Encode<bool, D>,
87        T6: fidl::encoding::Encode<fidl::encoding::BoundedString<100>, D>,
88        T7: fidl::encoding::Encode<
89                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
90                D,
91            >,
92        T8: fidl::encoding::Encode<u8, D>,
93    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
94    {
95        #[inline]
96        unsafe fn encode(
97            self,
98            encoder: &mut fidl::encoding::Encoder<'_, D>,
99            offset: usize,
100            depth: fidl::encoding::Depth,
101        ) -> fidl::Result<()> {
102            encoder.debug_check_bounds::<Config>(offset);
103            // Zero out padding regions. There's no need to apply masks
104            // because the unmasked parts will be overwritten by fields.
105            unsafe {
106                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
107                (ptr as *mut u64).write_unaligned(0);
108            }
109            unsafe {
110                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
111                (ptr as *mut u64).write_unaligned(0);
112            }
113            unsafe {
114                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(80);
115                (ptr as *mut u64).write_unaligned(0);
116            }
117            // Write the fields.
118            self.0.encode(encoder, offset + 0, depth)?;
119            self.1.encode(encoder, offset + 16, depth)?;
120            self.2.encode(encoder, offset + 20, depth)?;
121            self.3.encode(encoder, offset + 21, depth)?;
122            self.4.encode(encoder, offset + 24, depth)?;
123            self.5.encode(encoder, offset + 40, depth)?;
124            self.6.encode(encoder, offset + 48, depth)?;
125            self.7.encode(encoder, offset + 64, depth)?;
126            self.8.encode(encoder, offset + 80, depth)?;
127            Ok(())
128        }
129    }
130
131    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
132        #[inline(always)]
133        fn new_empty() -> Self {
134            Self {
135                additional_mounts: fidl::new_empty!(
136                    fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>,
137                    D
138                ),
139                cached_zx_map_info_bytes: fidl::new_empty!(u32, D),
140                crash_report_throttling: fidl::new_empty!(bool, D),
141                enable_utc_time_adjustment: fidl::new_empty!(bool, D),
142                extra_features: fidl::new_empty!(
143                    fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
144                    D
145                ),
146                mlock_always_onfault: fidl::new_empty!(bool, D),
147                mlock_pin_flavor: fidl::new_empty!(fidl::encoding::BoundedString<100>, D),
148                selinux_exceptions: fidl::new_empty!(
149                    fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
150                    D
151                ),
152                ui_visual_debugging_level: fidl::new_empty!(u8, D),
153            }
154        }
155
156        #[inline]
157        unsafe fn decode(
158            &mut self,
159            decoder: &mut fidl::encoding::Decoder<'_, D>,
160            offset: usize,
161            _depth: fidl::encoding::Depth,
162        ) -> fidl::Result<()> {
163            decoder.debug_check_bounds::<Self>(offset);
164            // Verify that padding bytes are zero.
165            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
166            let padval = unsafe { (ptr as *const u64).read_unaligned() };
167            let mask = 0xffff000000000000u64;
168            let maskedval = padval & mask;
169            if maskedval != 0 {
170                return Err(fidl::Error::NonZeroPadding {
171                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
172                });
173            }
174            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
175            let padval = unsafe { (ptr as *const u64).read_unaligned() };
176            let mask = 0xffffffffffffff00u64;
177            let maskedval = padval & mask;
178            if maskedval != 0 {
179                return Err(fidl::Error::NonZeroPadding {
180                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
181                });
182            }
183            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(80) };
184            let padval = unsafe { (ptr as *const u64).read_unaligned() };
185            let mask = 0xffffffffffffff00u64;
186            let maskedval = padval & mask;
187            if maskedval != 0 {
188                return Err(fidl::Error::NonZeroPadding {
189                    padding_start: offset + 80 + ((mask as u64).trailing_zeros() / 8) as usize,
190                });
191            }
192            fidl::decode!(
193                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>,
194                D,
195                &mut self.additional_mounts,
196                decoder,
197                offset + 0,
198                _depth
199            )?;
200            fidl::decode!(
201                u32,
202                D,
203                &mut self.cached_zx_map_info_bytes,
204                decoder,
205                offset + 16,
206                _depth
207            )?;
208            fidl::decode!(
209                bool,
210                D,
211                &mut self.crash_report_throttling,
212                decoder,
213                offset + 20,
214                _depth
215            )?;
216            fidl::decode!(
217                bool,
218                D,
219                &mut self.enable_utc_time_adjustment,
220                decoder,
221                offset + 21,
222                _depth
223            )?;
224            fidl::decode!(
225                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
226                D,
227                &mut self.extra_features,
228                decoder,
229                offset + 24,
230                _depth
231            )?;
232            fidl::decode!(bool, D, &mut self.mlock_always_onfault, decoder, offset + 40, _depth)?;
233            fidl::decode!(
234                fidl::encoding::BoundedString<100>,
235                D,
236                &mut self.mlock_pin_flavor,
237                decoder,
238                offset + 48,
239                _depth
240            )?;
241            fidl::decode!(
242                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
243                D,
244                &mut self.selinux_exceptions,
245                decoder,
246                offset + 64,
247                _depth
248            )?;
249            fidl::decode!(
250                u8,
251                D,
252                &mut self.ui_visual_debugging_level,
253                decoder,
254                offset + 80,
255                _depth
256            )?;
257            Ok(())
258        }
259    }
260}