Skip to main content

fidl_cf_sc_internal_starnixkernelstructuredconfig_common/
fidl_cf_sc_internal_starnixkernelstructuredconfig_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 critical_mb_threshold: u32,
14    pub extra_features: Vec<String>,
15    pub out_of_memory_mb_threshold: u32,
16    pub prefetch: bool,
17    pub warning_mb_threshold: u32,
18}
19
20impl fidl::Persistable for Config {}
21
22mod internal {
23    use super::*;
24
25    impl fidl::encoding::ValueTypeMarker for Config {
26        type Borrowed<'a> = &'a Self;
27        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
28            value
29        }
30    }
31
32    unsafe impl fidl::encoding::TypeMarker for Config {
33        type Owned = Self;
34
35        #[inline(always)]
36        fn inline_align(_context: fidl::encoding::Context) -> usize {
37            8
38        }
39
40        #[inline(always)]
41        fn inline_size(_context: fidl::encoding::Context) -> usize {
42            40
43        }
44    }
45
46    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
47        #[inline]
48        unsafe fn encode(
49            self,
50            encoder: &mut fidl::encoding::Encoder<'_, D>,
51            offset: usize,
52            _depth: fidl::encoding::Depth,
53        ) -> fidl::Result<()> {
54            encoder.debug_check_bounds::<Config>(offset);
55            // Delegate to tuple encoding.
56            fidl::encoding::Encode::<Config, D>::encode(
57                (
58                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.critical_mb_threshold),
59                    <fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.extra_features),
60                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.out_of_memory_mb_threshold),
61                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.prefetch),
62                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.warning_mb_threshold),
63                ),
64                encoder, offset, _depth
65            )
66        }
67    }
68    unsafe impl<
69        D: fidl::encoding::ResourceDialect,
70        T0: fidl::encoding::Encode<u32, D>,
71        T1: fidl::encoding::Encode<
72                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
73                D,
74            >,
75        T2: fidl::encoding::Encode<u32, D>,
76        T3: fidl::encoding::Encode<bool, D>,
77        T4: fidl::encoding::Encode<u32, D>,
78    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4)
79    {
80        #[inline]
81        unsafe fn encode(
82            self,
83            encoder: &mut fidl::encoding::Encoder<'_, D>,
84            offset: usize,
85            depth: fidl::encoding::Depth,
86        ) -> fidl::Result<()> {
87            encoder.debug_check_bounds::<Config>(offset);
88            // Zero out padding regions. There's no need to apply masks
89            // because the unmasked parts will be overwritten by fields.
90            unsafe {
91                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
92                (ptr as *mut u64).write_unaligned(0);
93            }
94            unsafe {
95                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
96                (ptr as *mut u64).write_unaligned(0);
97            }
98            unsafe {
99                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
100                (ptr as *mut u64).write_unaligned(0);
101            }
102            // Write the fields.
103            self.0.encode(encoder, offset + 0, depth)?;
104            self.1.encode(encoder, offset + 8, depth)?;
105            self.2.encode(encoder, offset + 24, depth)?;
106            self.3.encode(encoder, offset + 28, depth)?;
107            self.4.encode(encoder, offset + 32, depth)?;
108            Ok(())
109        }
110    }
111
112    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
113        #[inline(always)]
114        fn new_empty() -> Self {
115            Self {
116                critical_mb_threshold: fidl::new_empty!(u32, D),
117                extra_features: fidl::new_empty!(
118                    fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
119                    D
120                ),
121                out_of_memory_mb_threshold: fidl::new_empty!(u32, D),
122                prefetch: fidl::new_empty!(bool, D),
123                warning_mb_threshold: fidl::new_empty!(u32, D),
124            }
125        }
126
127        #[inline]
128        unsafe fn decode(
129            &mut self,
130            decoder: &mut fidl::encoding::Decoder<'_, D>,
131            offset: usize,
132            _depth: fidl::encoding::Depth,
133        ) -> fidl::Result<()> {
134            decoder.debug_check_bounds::<Self>(offset);
135            // Verify that padding bytes are zero.
136            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
137            let padval = unsafe { (ptr as *const u64).read_unaligned() };
138            let mask = 0xffffffff00000000u64;
139            let maskedval = padval & mask;
140            if maskedval != 0 {
141                return Err(fidl::Error::NonZeroPadding {
142                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
143                });
144            }
145            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
146            let padval = unsafe { (ptr as *const u64).read_unaligned() };
147            let mask = 0xffffff0000000000u64;
148            let maskedval = padval & mask;
149            if maskedval != 0 {
150                return Err(fidl::Error::NonZeroPadding {
151                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
152                });
153            }
154            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
155            let padval = unsafe { (ptr as *const u64).read_unaligned() };
156            let mask = 0xffffffff00000000u64;
157            let maskedval = padval & mask;
158            if maskedval != 0 {
159                return Err(fidl::Error::NonZeroPadding {
160                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
161                });
162            }
163            fidl::decode!(u32, D, &mut self.critical_mb_threshold, decoder, offset + 0, _depth)?;
164            fidl::decode!(
165                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 1024>,
166                D,
167                &mut self.extra_features,
168                decoder,
169                offset + 8,
170                _depth
171            )?;
172            fidl::decode!(
173                u32,
174                D,
175                &mut self.out_of_memory_mb_threshold,
176                decoder,
177                offset + 24,
178                _depth
179            )?;
180            fidl::decode!(bool, D, &mut self.prefetch, decoder, offset + 28, _depth)?;
181            fidl::decode!(u32, D, &mut self.warning_mb_threshold, decoder, offset + 32, _depth)?;
182            Ok(())
183        }
184    }
185}