Skip to main content

fidl_cf_sc_internal_labproxyconfig_common/
fidl_cf_sc_internal_labproxyconfig_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, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13    pub audit_capacity: u32,
14    pub enabled: bool,
15    pub max_deadline_ns: u64,
16    pub max_delay_ns: u64,
17    pub max_ops_per_second: u32,
18    pub max_sequence_duration_ns: u64,
19    pub max_sequence_items: u32,
20    pub max_snapshot_items: u32,
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            48
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            // Delegate to tuple encoding.
59            fidl::encoding::Encode::<Config, D>::encode(
60                (
61                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.audit_capacity),
62                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enabled),
63                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_deadline_ns),
64                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_delay_ns),
65                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_ops_per_second),
66                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(
67                        &self.max_sequence_duration_ns,
68                    ),
69                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_sequence_items),
70                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_snapshot_items),
71                ),
72                encoder,
73                offset,
74                _depth,
75            )
76        }
77    }
78    unsafe impl<
79        D: fidl::encoding::ResourceDialect,
80        T0: fidl::encoding::Encode<u32, D>,
81        T1: fidl::encoding::Encode<bool, D>,
82        T2: fidl::encoding::Encode<u64, D>,
83        T3: fidl::encoding::Encode<u64, D>,
84        T4: fidl::encoding::Encode<u32, D>,
85        T5: fidl::encoding::Encode<u64, D>,
86        T6: fidl::encoding::Encode<u32, D>,
87        T7: fidl::encoding::Encode<u32, D>,
88    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7)
89    {
90        #[inline]
91        unsafe fn encode(
92            self,
93            encoder: &mut fidl::encoding::Encoder<'_, D>,
94            offset: usize,
95            depth: fidl::encoding::Depth,
96        ) -> fidl::Result<()> {
97            encoder.debug_check_bounds::<Config>(offset);
98            // Zero out padding regions. There's no need to apply masks
99            // because the unmasked parts will be overwritten by fields.
100            unsafe {
101                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
102                (ptr as *mut u64).write_unaligned(0);
103            }
104            unsafe {
105                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
106                (ptr as *mut u64).write_unaligned(0);
107            }
108            // Write the fields.
109            self.0.encode(encoder, offset + 0, depth)?;
110            self.1.encode(encoder, offset + 4, depth)?;
111            self.2.encode(encoder, offset + 8, depth)?;
112            self.3.encode(encoder, offset + 16, depth)?;
113            self.4.encode(encoder, offset + 24, depth)?;
114            self.5.encode(encoder, offset + 32, depth)?;
115            self.6.encode(encoder, offset + 40, depth)?;
116            self.7.encode(encoder, offset + 44, depth)?;
117            Ok(())
118        }
119    }
120
121    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
122        #[inline(always)]
123        fn new_empty() -> Self {
124            Self {
125                audit_capacity: fidl::new_empty!(u32, D),
126                enabled: fidl::new_empty!(bool, D),
127                max_deadline_ns: fidl::new_empty!(u64, D),
128                max_delay_ns: fidl::new_empty!(u64, D),
129                max_ops_per_second: fidl::new_empty!(u32, D),
130                max_sequence_duration_ns: fidl::new_empty!(u64, D),
131                max_sequence_items: fidl::new_empty!(u32, D),
132                max_snapshot_items: fidl::new_empty!(u32, D),
133            }
134        }
135
136        #[inline]
137        unsafe fn decode(
138            &mut self,
139            decoder: &mut fidl::encoding::Decoder<'_, D>,
140            offset: usize,
141            _depth: fidl::encoding::Depth,
142        ) -> fidl::Result<()> {
143            decoder.debug_check_bounds::<Self>(offset);
144            // Verify that padding bytes are zero.
145            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
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 + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
152                });
153            }
154            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
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 + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
161                });
162            }
163            fidl::decode!(u32, D, &mut self.audit_capacity, decoder, offset + 0, _depth)?;
164            fidl::decode!(bool, D, &mut self.enabled, decoder, offset + 4, _depth)?;
165            fidl::decode!(u64, D, &mut self.max_deadline_ns, decoder, offset + 8, _depth)?;
166            fidl::decode!(u64, D, &mut self.max_delay_ns, decoder, offset + 16, _depth)?;
167            fidl::decode!(u32, D, &mut self.max_ops_per_second, decoder, offset + 24, _depth)?;
168            fidl::decode!(
169                u64,
170                D,
171                &mut self.max_sequence_duration_ns,
172                decoder,
173                offset + 32,
174                _depth
175            )?;
176            fidl::decode!(u32, D, &mut self.max_sequence_items, decoder, offset + 40, _depth)?;
177            fidl::decode!(u32, D, &mut self.max_snapshot_items, decoder, offset + 44, _depth)?;
178            Ok(())
179        }
180    }
181}