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