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<
212                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
213                D,
214            >,
215            T16: fidl::encoding::Encode<fidl::encoding::Vector<u16, 100>, D>,
216            T17: fidl::encoding::Encode<fidl::encoding::Vector<u32, 100>, D>,
217            T18: fidl::encoding::Encode<fidl::encoding::Vector<u64, 100>, D>,
218            T19: fidl::encoding::Encode<fidl::encoding::Vector<u8, 100>, D>,
219        > fidl::encoding::Encode<ReceiverConfig, D>
220        for (
221            T0,
222            T1,
223            T2,
224            T3,
225            T4,
226            T5,
227            T6,
228            T7,
229            T8,
230            T9,
231            T10,
232            T11,
233            T12,
234            T13,
235            T14,
236            T15,
237            T16,
238            T17,
239            T18,
240            T19,
241        )
242    {
243        #[inline]
244        unsafe fn encode(
245            self,
246            encoder: &mut fidl::encoding::Encoder<'_, D>,
247            offset: usize,
248            depth: fidl::encoding::Depth,
249        ) -> fidl::Result<()> {
250            encoder.debug_check_bounds::<ReceiverConfig>(offset);
251            // Zero out padding regions. There's no need to apply masks
252            // because the unmasked parts will be overwritten by fields.
253            unsafe {
254                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
255                (ptr as *mut u64).write_unaligned(0);
256            }
257            unsafe {
258                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
259                (ptr as *mut u64).write_unaligned(0);
260            }
261            unsafe {
262                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
263                (ptr as *mut u64).write_unaligned(0);
264            }
265            unsafe {
266                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(56);
267                (ptr as *mut u64).write_unaligned(0);
268            }
269            // Write the fields.
270            self.0.encode(encoder, offset + 0, depth)?;
271            self.1.encode(encoder, offset + 2, depth)?;
272            self.2.encode(encoder, offset + 4, depth)?;
273            self.3.encode(encoder, offset + 8, depth)?;
274            self.4.encode(encoder, offset + 16, depth)?;
275            self.5.encode(encoder, offset + 24, depth)?;
276            self.6.encode(encoder, offset + 40, depth)?;
277            self.7.encode(encoder, offset + 44, depth)?;
278            self.8.encode(encoder, offset + 48, depth)?;
279            self.9.encode(encoder, offset + 56, depth)?;
280            self.10.encode(encoder, offset + 64, depth)?;
281            self.11.encode(encoder, offset + 80, depth)?;
282            self.12.encode(encoder, offset + 96, depth)?;
283            self.13.encode(encoder, offset + 112, depth)?;
284            self.14.encode(encoder, offset + 128, depth)?;
285            self.15.encode(encoder, offset + 144, depth)?;
286            self.16.encode(encoder, offset + 160, depth)?;
287            self.17.encode(encoder, offset + 176, depth)?;
288            self.18.encode(encoder, offset + 192, depth)?;
289            self.19.encode(encoder, offset + 208, depth)?;
290            Ok(())
291        }
292    }
293
294    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ReceiverConfig {
295        #[inline(always)]
296        fn new_empty() -> Self {
297            Self {
298                my_flag: fidl::new_empty!(bool, D),
299                my_int16: fidl::new_empty!(i16, D),
300                my_int32: fidl::new_empty!(i32, D),
301                my_int64: fidl::new_empty!(i64, D),
302                my_int8: fidl::new_empty!(i8, D),
303                my_string: fidl::new_empty!(fidl::encoding::BoundedString<100>, D),
304                my_uint16: fidl::new_empty!(u16, D),
305                my_uint32: fidl::new_empty!(u32, D),
306                my_uint64: fidl::new_empty!(u64, D),
307                my_uint8: fidl::new_empty!(u8, D),
308                my_vector_of_flag: fidl::new_empty!(fidl::encoding::Vector<bool, 100>, D),
309                my_vector_of_int16: fidl::new_empty!(fidl::encoding::Vector<i16, 100>, D),
310                my_vector_of_int32: fidl::new_empty!(fidl::encoding::Vector<i32, 100>, D),
311                my_vector_of_int64: fidl::new_empty!(fidl::encoding::Vector<i64, 100>, D),
312                my_vector_of_int8: fidl::new_empty!(fidl::encoding::Vector<i8, 100>, D),
313                my_vector_of_string: fidl::new_empty!(
314                    fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
315                    D
316                ),
317                my_vector_of_uint16: fidl::new_empty!(fidl::encoding::Vector<u16, 100>, D),
318                my_vector_of_uint32: fidl::new_empty!(fidl::encoding::Vector<u32, 100>, D),
319                my_vector_of_uint64: fidl::new_empty!(fidl::encoding::Vector<u64, 100>, D),
320                my_vector_of_uint8: fidl::new_empty!(fidl::encoding::Vector<u8, 100>, D),
321            }
322        }
323
324        #[inline]
325        unsafe fn decode(
326            &mut self,
327            decoder: &mut fidl::encoding::Decoder<'_, D>,
328            offset: usize,
329            _depth: fidl::encoding::Depth,
330        ) -> fidl::Result<()> {
331            decoder.debug_check_bounds::<Self>(offset);
332            // Verify that padding bytes are zero.
333            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
334            let padval = unsafe { (ptr as *const u64).read_unaligned() };
335            let mask = 0xff00u64;
336            let maskedval = padval & mask;
337            if maskedval != 0 {
338                return Err(fidl::Error::NonZeroPadding {
339                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
340                });
341            }
342            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
343            let padval = unsafe { (ptr as *const u64).read_unaligned() };
344            let mask = 0xffffffffffffff00u64;
345            let maskedval = padval & mask;
346            if maskedval != 0 {
347                return Err(fidl::Error::NonZeroPadding {
348                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
349                });
350            }
351            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
352            let padval = unsafe { (ptr as *const u64).read_unaligned() };
353            let mask = 0xffff0000u64;
354            let maskedval = padval & mask;
355            if maskedval != 0 {
356                return Err(fidl::Error::NonZeroPadding {
357                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
358                });
359            }
360            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(56) };
361            let padval = unsafe { (ptr as *const u64).read_unaligned() };
362            let mask = 0xffffffffffffff00u64;
363            let maskedval = padval & mask;
364            if maskedval != 0 {
365                return Err(fidl::Error::NonZeroPadding {
366                    padding_start: offset + 56 + ((mask as u64).trailing_zeros() / 8) as usize,
367                });
368            }
369            fidl::decode!(bool, D, &mut self.my_flag, decoder, offset + 0, _depth)?;
370            fidl::decode!(i16, D, &mut self.my_int16, decoder, offset + 2, _depth)?;
371            fidl::decode!(i32, D, &mut self.my_int32, decoder, offset + 4, _depth)?;
372            fidl::decode!(i64, D, &mut self.my_int64, decoder, offset + 8, _depth)?;
373            fidl::decode!(i8, D, &mut self.my_int8, decoder, offset + 16, _depth)?;
374            fidl::decode!(
375                fidl::encoding::BoundedString<100>,
376                D,
377                &mut self.my_string,
378                decoder,
379                offset + 24,
380                _depth
381            )?;
382            fidl::decode!(u16, D, &mut self.my_uint16, decoder, offset + 40, _depth)?;
383            fidl::decode!(u32, D, &mut self.my_uint32, decoder, offset + 44, _depth)?;
384            fidl::decode!(u64, D, &mut self.my_uint64, decoder, offset + 48, _depth)?;
385            fidl::decode!(u8, D, &mut self.my_uint8, decoder, offset + 56, _depth)?;
386            fidl::decode!(fidl::encoding::Vector<bool, 100>, D, &mut self.my_vector_of_flag, decoder, offset + 64, _depth)?;
387            fidl::decode!(fidl::encoding::Vector<i16, 100>, D, &mut self.my_vector_of_int16, decoder, offset + 80, _depth)?;
388            fidl::decode!(fidl::encoding::Vector<i32, 100>, D, &mut self.my_vector_of_int32, decoder, offset + 96, _depth)?;
389            fidl::decode!(fidl::encoding::Vector<i64, 100>, D, &mut self.my_vector_of_int64, decoder, offset + 112, _depth)?;
390            fidl::decode!(fidl::encoding::Vector<i8, 100>, D, &mut self.my_vector_of_int8, decoder, offset + 128, _depth)?;
391            fidl::decode!(
392                fidl::encoding::Vector<fidl::encoding::BoundedString<100>, 100>,
393                D,
394                &mut self.my_vector_of_string,
395                decoder,
396                offset + 144,
397                _depth
398            )?;
399            fidl::decode!(fidl::encoding::Vector<u16, 100>, D, &mut self.my_vector_of_uint16, decoder, offset + 160, _depth)?;
400            fidl::decode!(fidl::encoding::Vector<u32, 100>, D, &mut self.my_vector_of_uint32, decoder, offset + 176, _depth)?;
401            fidl::decode!(fidl::encoding::Vector<u64, 100>, D, &mut self.my_vector_of_uint64, decoder, offset + 192, _depth)?;
402            fidl::decode!(fidl::encoding::Vector<u8, 100>, D, &mut self.my_vector_of_uint8, decoder, offset + 208, _depth)?;
403            Ok(())
404        }
405    }
406}