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