fidl_test_structuredconfig_receiver__common/
fidl_test_structuredconfig_receiver__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 ConfigReceiverPuppetGetConfigResponse {
13    pub config: ReceiverConfig,
14}
15
16impl fidl::Persistable for ConfigReceiverPuppetGetConfigResponse {}
17
18#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19pub struct ReceiverConfig {
20    pub my_flag: bool,
21    pub my_int16: i16,
22    pub my_int32: i32,
23    pub my_int64: i64,
24    pub my_int8: i8,
25    pub my_string: String,
26    pub my_uint16: u16,
27    pub my_uint32: u32,
28    pub my_uint64: u64,
29    pub my_uint8: u8,
30    pub my_vector_of_flag: Vec<bool>,
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_int8: Vec<i8>,
35    pub my_vector_of_string: Vec<String>,
36    pub my_vector_of_uint16: Vec<u16>,
37    pub my_vector_of_uint32: Vec<u32>,
38    pub my_vector_of_uint64: Vec<u64>,
39    pub my_vector_of_uint8: Vec<u8>,
40}
41
42impl fidl::Persistable for ReceiverConfig {}
43
44pub mod config_receiver_puppet_ordinals {
45    pub const GET_CONFIG: u64 = 0x243d8db8a2863b24;
46}
47
48mod internal {
49    use super::*;
50
51    impl fidl::encoding::ValueTypeMarker for ConfigReceiverPuppetGetConfigResponse {
52        type Borrowed<'a> = &'a Self;
53        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
54            value
55        }
56    }
57
58    unsafe impl fidl::encoding::TypeMarker for ConfigReceiverPuppetGetConfigResponse {
59        type Owned = Self;
60
61        #[inline(always)]
62        fn inline_align(_context: fidl::encoding::Context) -> usize {
63            8
64        }
65
66        #[inline(always)]
67        fn inline_size(_context: fidl::encoding::Context) -> usize {
68            224
69        }
70    }
71
72    unsafe impl<D: fidl::encoding::ResourceDialect>
73        fidl::encoding::Encode<ConfigReceiverPuppetGetConfigResponse, D>
74        for &ConfigReceiverPuppetGetConfigResponse
75    {
76        #[inline]
77        unsafe fn encode(
78            self,
79            encoder: &mut fidl::encoding::Encoder<'_, D>,
80            offset: usize,
81            _depth: fidl::encoding::Depth,
82        ) -> fidl::Result<()> {
83            encoder.debug_check_bounds::<ConfigReceiverPuppetGetConfigResponse>(offset);
84            // Delegate to tuple encoding.
85            fidl::encoding::Encode::<ConfigReceiverPuppetGetConfigResponse, D>::encode(
86                (<ReceiverConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.config),),
87                encoder,
88                offset,
89                _depth,
90            )
91        }
92    }
93    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<ReceiverConfig, D>>
94        fidl::encoding::Encode<ConfigReceiverPuppetGetConfigResponse, D> for (T0,)
95    {
96        #[inline]
97        unsafe fn encode(
98            self,
99            encoder: &mut fidl::encoding::Encoder<'_, D>,
100            offset: usize,
101            depth: fidl::encoding::Depth,
102        ) -> fidl::Result<()> {
103            encoder.debug_check_bounds::<ConfigReceiverPuppetGetConfigResponse>(offset);
104            // Zero out padding regions. There's no need to apply masks
105            // because the unmasked parts will be overwritten by fields.
106            // Write the fields.
107            self.0.encode(encoder, offset + 0, depth)?;
108            Ok(())
109        }
110    }
111
112    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
113        for ConfigReceiverPuppetGetConfigResponse
114    {
115        #[inline(always)]
116        fn new_empty() -> Self {
117            Self { config: fidl::new_empty!(ReceiverConfig, D) }
118        }
119
120        #[inline]
121        unsafe fn decode(
122            &mut self,
123            decoder: &mut fidl::encoding::Decoder<'_, D>,
124            offset: usize,
125            _depth: fidl::encoding::Depth,
126        ) -> fidl::Result<()> {
127            decoder.debug_check_bounds::<Self>(offset);
128            // Verify that padding bytes are zero.
129            fidl::decode!(ReceiverConfig, D, &mut self.config, decoder, offset + 0, _depth)?;
130            Ok(())
131        }
132    }
133
134    impl fidl::encoding::ValueTypeMarker for ReceiverConfig {
135        type Borrowed<'a> = &'a Self;
136        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
137            value
138        }
139    }
140
141    unsafe impl fidl::encoding::TypeMarker for ReceiverConfig {
142        type Owned = Self;
143
144        #[inline(always)]
145        fn inline_align(_context: fidl::encoding::Context) -> usize {
146            8
147        }
148
149        #[inline(always)]
150        fn inline_size(_context: fidl::encoding::Context) -> usize {
151            224
152        }
153    }
154
155    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ReceiverConfig, D>
156        for &ReceiverConfig
157    {
158        #[inline]
159        unsafe fn encode(
160            self,
161            encoder: &mut fidl::encoding::Encoder<'_, D>,
162            offset: usize,
163            _depth: fidl::encoding::Depth,
164        ) -> fidl::Result<()> {
165            encoder.debug_check_bounds::<ReceiverConfig>(offset);
166            // Delegate to tuple encoding.
167            fidl::encoding::Encode::<ReceiverConfig, D>::encode(
168                (
169                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.my_flag),
170                    <i16 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_int16),
171                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_int32),
172                    <i64 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_int64),
173                    <i8 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_int8),
174                    <fidl::encoding::BoundedString<100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_string),
175                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_uint16),
176                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_uint32),
177                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_uint64),
178                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.my_uint8),
179                    <fidl::encoding::Vector<bool, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_flag),
180                    <fidl::encoding::Vector<i16, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_int16),
181                    <fidl::encoding::Vector<i32, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_int32),
182                    <fidl::encoding::Vector<i64, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_int64),
183                    <fidl::encoding::Vector<i8, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_int8),
184                    <fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_string),
185                    <fidl::encoding::Vector<u16, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_uint16),
186                    <fidl::encoding::Vector<u32, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_uint32),
187                    <fidl::encoding::Vector<u64, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_uint64),
188                    <fidl::encoding::Vector<u8, 100> as fidl::encoding::ValueTypeMarker>::borrow(&self.my_vector_of_uint8),
189                ),
190                encoder, offset, _depth
191            )
192        }
193    }
194    unsafe impl<
195        D: fidl::encoding::ResourceDialect,
196        T0: fidl::encoding::Encode<bool, D>,
197        T1: fidl::encoding::Encode<i16, D>,
198        T2: fidl::encoding::Encode<i32, D>,
199        T3: fidl::encoding::Encode<i64, D>,
200        T4: fidl::encoding::Encode<i8, D>,
201        T5: fidl::encoding::Encode<fidl::encoding::BoundedString<100>, D>,
202        T6: fidl::encoding::Encode<u16, D>,
203        T7: fidl::encoding::Encode<u32, D>,
204        T8: fidl::encoding::Encode<u64, D>,
205        T9: fidl::encoding::Encode<u8, D>,
206        T10: fidl::encoding::Encode<fidl::encoding::Vector<bool, 100>, D>,
207        T11: fidl::encoding::Encode<fidl::encoding::Vector<i16, 100>, D>,
208        T12: fidl::encoding::Encode<fidl::encoding::Vector<i32, 100>, D>,
209        T13: fidl::encoding::Encode<fidl::encoding::Vector<i64, 100>, D>,
210        T14: fidl::encoding::Encode<fidl::encoding::Vector<i8, 100>, D>,
211        T15: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>, D>,
212        T16: fidl::encoding::Encode<fidl::encoding::Vector<u16, 100>, D>,
213        T17: fidl::encoding::Encode<fidl::encoding::Vector<u32, 100>, D>,
214        T18: fidl::encoding::Encode<fidl::encoding::Vector<u64, 100>, D>,
215        T19: fidl::encoding::Encode<fidl::encoding::Vector<u8, 100>, D>,
216    > fidl::encoding::Encode<ReceiverConfig, D>
217        for (
218            T0,
219            T1,
220            T2,
221            T3,
222            T4,
223            T5,
224            T6,
225            T7,
226            T8,
227            T9,
228            T10,
229            T11,
230            T12,
231            T13,
232            T14,
233            T15,
234            T16,
235            T17,
236            T18,
237            T19,
238        )
239    {
240        #[inline]
241        unsafe fn encode(
242            self,
243            encoder: &mut fidl::encoding::Encoder<'_, D>,
244            offset: usize,
245            depth: fidl::encoding::Depth,
246        ) -> fidl::Result<()> {
247            encoder.debug_check_bounds::<ReceiverConfig>(offset);
248            // Zero out padding regions. There's no need to apply masks
249            // because the unmasked parts will be overwritten by fields.
250            unsafe {
251                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
252                (ptr as *mut u64).write_unaligned(0);
253            }
254            unsafe {
255                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
256                (ptr as *mut u64).write_unaligned(0);
257            }
258            unsafe {
259                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
260                (ptr as *mut u64).write_unaligned(0);
261            }
262            unsafe {
263                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(56);
264                (ptr as *mut u64).write_unaligned(0);
265            }
266            // Write the fields.
267            self.0.encode(encoder, offset + 0, depth)?;
268            self.1.encode(encoder, offset + 2, depth)?;
269            self.2.encode(encoder, offset + 4, depth)?;
270            self.3.encode(encoder, offset + 8, depth)?;
271            self.4.encode(encoder, offset + 16, depth)?;
272            self.5.encode(encoder, offset + 24, depth)?;
273            self.6.encode(encoder, offset + 40, depth)?;
274            self.7.encode(encoder, offset + 44, depth)?;
275            self.8.encode(encoder, offset + 48, depth)?;
276            self.9.encode(encoder, offset + 56, depth)?;
277            self.10.encode(encoder, offset + 64, depth)?;
278            self.11.encode(encoder, offset + 80, depth)?;
279            self.12.encode(encoder, offset + 96, depth)?;
280            self.13.encode(encoder, offset + 112, depth)?;
281            self.14.encode(encoder, offset + 128, depth)?;
282            self.15.encode(encoder, offset + 144, depth)?;
283            self.16.encode(encoder, offset + 160, depth)?;
284            self.17.encode(encoder, offset + 176, depth)?;
285            self.18.encode(encoder, offset + 192, depth)?;
286            self.19.encode(encoder, offset + 208, depth)?;
287            Ok(())
288        }
289    }
290
291    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReceiverConfig {
292        #[inline(always)]
293        fn new_empty() -> Self {
294            Self {
295                my_flag: fidl::new_empty!(bool, D),
296                my_int16: fidl::new_empty!(i16, D),
297                my_int32: fidl::new_empty!(i32, D),
298                my_int64: fidl::new_empty!(i64, D),
299                my_int8: fidl::new_empty!(i8, D),
300                my_string: fidl::new_empty!(fidl::encoding::BoundedString<100>, D),
301                my_uint16: fidl::new_empty!(u16, D),
302                my_uint32: fidl::new_empty!(u32, D),
303                my_uint64: fidl::new_empty!(u64, D),
304                my_uint8: fidl::new_empty!(u8, D),
305                my_vector_of_flag: fidl::new_empty!(fidl::encoding::Vector<bool, 100>, D),
306                my_vector_of_int16: fidl::new_empty!(fidl::encoding::Vector<i16, 100>, D),
307                my_vector_of_int32: fidl::new_empty!(fidl::encoding::Vector<i32, 100>, D),
308                my_vector_of_int64: fidl::new_empty!(fidl::encoding::Vector<i64, 100>, D),
309                my_vector_of_int8: fidl::new_empty!(fidl::encoding::Vector<i8, 100>, D),
310                my_vector_of_string: fidl::new_empty!(
311                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
312                    D
313                ),
314                my_vector_of_uint16: fidl::new_empty!(fidl::encoding::Vector<u16, 100>, D),
315                my_vector_of_uint32: fidl::new_empty!(fidl::encoding::Vector<u32, 100>, D),
316                my_vector_of_uint64: fidl::new_empty!(fidl::encoding::Vector<u64, 100>, D),
317                my_vector_of_uint8: fidl::new_empty!(fidl::encoding::Vector<u8, 100>, D),
318            }
319        }
320
321        #[inline]
322        unsafe fn decode(
323            &mut self,
324            decoder: &mut fidl::encoding::Decoder<'_, D>,
325            offset: usize,
326            _depth: fidl::encoding::Depth,
327        ) -> fidl::Result<()> {
328            decoder.debug_check_bounds::<Self>(offset);
329            // Verify that padding bytes are zero.
330            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
331            let padval = unsafe { (ptr as *const u64).read_unaligned() };
332            let mask = 0xff00u64;
333            let maskedval = padval & mask;
334            if maskedval != 0 {
335                return Err(fidl::Error::NonZeroPadding {
336                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
337                });
338            }
339            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
340            let padval = unsafe { (ptr as *const u64).read_unaligned() };
341            let mask = 0xffffffffffffff00u64;
342            let maskedval = padval & mask;
343            if maskedval != 0 {
344                return Err(fidl::Error::NonZeroPadding {
345                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
346                });
347            }
348            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
349            let padval = unsafe { (ptr as *const u64).read_unaligned() };
350            let mask = 0xffff0000u64;
351            let maskedval = padval & mask;
352            if maskedval != 0 {
353                return Err(fidl::Error::NonZeroPadding {
354                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
355                });
356            }
357            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(56) };
358            let padval = unsafe { (ptr as *const u64).read_unaligned() };
359            let mask = 0xffffffffffffff00u64;
360            let maskedval = padval & mask;
361            if maskedval != 0 {
362                return Err(fidl::Error::NonZeroPadding {
363                    padding_start: offset + 56 + ((mask as u64).trailing_zeros() / 8) as usize,
364                });
365            }
366            fidl::decode!(bool, D, &mut self.my_flag, decoder, offset + 0, _depth)?;
367            fidl::decode!(i16, D, &mut self.my_int16, decoder, offset + 2, _depth)?;
368            fidl::decode!(i32, D, &mut self.my_int32, decoder, offset + 4, _depth)?;
369            fidl::decode!(i64, D, &mut self.my_int64, decoder, offset + 8, _depth)?;
370            fidl::decode!(i8, D, &mut self.my_int8, decoder, offset + 16, _depth)?;
371            fidl::decode!(
372                fidl::encoding::BoundedString<100>,
373                D,
374                &mut self.my_string,
375                decoder,
376                offset + 24,
377                _depth
378            )?;
379            fidl::decode!(u16, D, &mut self.my_uint16, decoder, offset + 40, _depth)?;
380            fidl::decode!(u32, D, &mut self.my_uint32, decoder, offset + 44, _depth)?;
381            fidl::decode!(u64, D, &mut self.my_uint64, decoder, offset + 48, _depth)?;
382            fidl::decode!(u8, D, &mut self.my_uint8, decoder, offset + 56, _depth)?;
383            fidl::decode!(fidl::encoding::Vector<bool, 100>, D, &mut self.my_vector_of_flag, decoder, offset + 64, _depth)?;
384            fidl::decode!(fidl::encoding::Vector<i16, 100>, D, &mut self.my_vector_of_int16, decoder, offset + 80, _depth)?;
385            fidl::decode!(fidl::encoding::Vector<i32, 100>, D, &mut self.my_vector_of_int32, decoder, offset + 96, _depth)?;
386            fidl::decode!(fidl::encoding::Vector<i64, 100>, D, &mut self.my_vector_of_int64, decoder, offset + 112, _depth)?;
387            fidl::decode!(fidl::encoding::Vector<i8, 100>, D, &mut self.my_vector_of_int8, decoder, offset + 128, _depth)?;
388            fidl::decode!(
389                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
390                D,
391                &mut self.my_vector_of_string,
392                decoder,
393                offset + 144,
394                _depth
395            )?;
396            fidl::decode!(fidl::encoding::Vector<u16, 100>, D, &mut self.my_vector_of_uint16, decoder, offset + 160, _depth)?;
397            fidl::decode!(fidl::encoding::Vector<u32, 100>, D, &mut self.my_vector_of_uint32, decoder, offset + 176, _depth)?;
398            fidl::decode!(fidl::encoding::Vector<u64, 100>, D, &mut self.my_vector_of_uint64, decoder, offset + 192, _depth)?;
399            fidl::decode!(fidl::encoding::Vector<u8, 100>, D, &mut self.my_vector_of_uint8, decoder, offset + 208, _depth)?;
400            Ok(())
401        }
402    }
403}