fidl_fuchsia_examples_inspect_common/
fidl_fuchsia_examples_inspect_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)]
12#[repr(C)]
13pub struct FizzBuzzExecuteRequest {
14    pub count: u32,
15}
16
17impl fidl::Persistable for FizzBuzzExecuteRequest {}
18
19#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20pub struct FizzBuzzExecuteResponse {
21    pub response: String,
22}
23
24impl fidl::Persistable for FizzBuzzExecuteResponse {}
25
26#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct ReverserReverseRequest {
28    pub input: String,
29}
30
31impl fidl::Persistable for ReverserReverseRequest {}
32
33#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
34pub struct ReverserReverseResponse {
35    pub response: String,
36}
37
38impl fidl::Persistable for ReverserReverseResponse {}
39
40mod internal {
41    use super::*;
42
43    impl fidl::encoding::ValueTypeMarker for FizzBuzzExecuteRequest {
44        type Borrowed<'a> = &'a Self;
45        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
46            value
47        }
48    }
49
50    unsafe impl fidl::encoding::TypeMarker for FizzBuzzExecuteRequest {
51        type Owned = Self;
52
53        #[inline(always)]
54        fn inline_align(_context: fidl::encoding::Context) -> usize {
55            4
56        }
57
58        #[inline(always)]
59        fn inline_size(_context: fidl::encoding::Context) -> usize {
60            4
61        }
62        #[inline(always)]
63        fn encode_is_copy() -> bool {
64            true
65        }
66
67        #[inline(always)]
68        fn decode_is_copy() -> bool {
69            true
70        }
71    }
72
73    unsafe impl<D: fidl::encoding::ResourceDialect>
74        fidl::encoding::Encode<FizzBuzzExecuteRequest, D> for &FizzBuzzExecuteRequest
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::<FizzBuzzExecuteRequest>(offset);
84            unsafe {
85                // Copy the object into the buffer.
86                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
87                (buf_ptr as *mut FizzBuzzExecuteRequest)
88                    .write_unaligned((self as *const FizzBuzzExecuteRequest).read());
89                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
90                // done second because the memcpy will write garbage to these bytes.
91            }
92            Ok(())
93        }
94    }
95    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
96        fidl::encoding::Encode<FizzBuzzExecuteRequest, D> for (T0,)
97    {
98        #[inline]
99        unsafe fn encode(
100            self,
101            encoder: &mut fidl::encoding::Encoder<'_, D>,
102            offset: usize,
103            depth: fidl::encoding::Depth,
104        ) -> fidl::Result<()> {
105            encoder.debug_check_bounds::<FizzBuzzExecuteRequest>(offset);
106            // Zero out padding regions. There's no need to apply masks
107            // because the unmasked parts will be overwritten by fields.
108            // Write the fields.
109            self.0.encode(encoder, offset + 0, depth)?;
110            Ok(())
111        }
112    }
113
114    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
115        for FizzBuzzExecuteRequest
116    {
117        #[inline(always)]
118        fn new_empty() -> Self {
119            Self { count: fidl::new_empty!(u32, D) }
120        }
121
122        #[inline]
123        unsafe fn decode(
124            &mut self,
125            decoder: &mut fidl::encoding::Decoder<'_, D>,
126            offset: usize,
127            _depth: fidl::encoding::Depth,
128        ) -> fidl::Result<()> {
129            decoder.debug_check_bounds::<Self>(offset);
130            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
131            // Verify that padding bytes are zero.
132            // Copy from the buffer into the object.
133            unsafe {
134                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
135            }
136            Ok(())
137        }
138    }
139
140    impl fidl::encoding::ValueTypeMarker for FizzBuzzExecuteResponse {
141        type Borrowed<'a> = &'a Self;
142        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
143            value
144        }
145    }
146
147    unsafe impl fidl::encoding::TypeMarker for FizzBuzzExecuteResponse {
148        type Owned = Self;
149
150        #[inline(always)]
151        fn inline_align(_context: fidl::encoding::Context) -> usize {
152            8
153        }
154
155        #[inline(always)]
156        fn inline_size(_context: fidl::encoding::Context) -> usize {
157            16
158        }
159    }
160
161    unsafe impl<D: fidl::encoding::ResourceDialect>
162        fidl::encoding::Encode<FizzBuzzExecuteResponse, D> for &FizzBuzzExecuteResponse
163    {
164        #[inline]
165        unsafe fn encode(
166            self,
167            encoder: &mut fidl::encoding::Encoder<'_, D>,
168            offset: usize,
169            _depth: fidl::encoding::Depth,
170        ) -> fidl::Result<()> {
171            encoder.debug_check_bounds::<FizzBuzzExecuteResponse>(offset);
172            // Delegate to tuple encoding.
173            fidl::encoding::Encode::<FizzBuzzExecuteResponse, D>::encode(
174                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
175                    &self.response,
176                ),),
177                encoder,
178                offset,
179                _depth,
180            )
181        }
182    }
183    unsafe impl<
184            D: fidl::encoding::ResourceDialect,
185            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
186        > fidl::encoding::Encode<FizzBuzzExecuteResponse, D> for (T0,)
187    {
188        #[inline]
189        unsafe fn encode(
190            self,
191            encoder: &mut fidl::encoding::Encoder<'_, D>,
192            offset: usize,
193            depth: fidl::encoding::Depth,
194        ) -> fidl::Result<()> {
195            encoder.debug_check_bounds::<FizzBuzzExecuteResponse>(offset);
196            // Zero out padding regions. There's no need to apply masks
197            // because the unmasked parts will be overwritten by fields.
198            // Write the fields.
199            self.0.encode(encoder, offset + 0, depth)?;
200            Ok(())
201        }
202    }
203
204    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
205        for FizzBuzzExecuteResponse
206    {
207        #[inline(always)]
208        fn new_empty() -> Self {
209            Self { response: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
210        }
211
212        #[inline]
213        unsafe fn decode(
214            &mut self,
215            decoder: &mut fidl::encoding::Decoder<'_, D>,
216            offset: usize,
217            _depth: fidl::encoding::Depth,
218        ) -> fidl::Result<()> {
219            decoder.debug_check_bounds::<Self>(offset);
220            // Verify that padding bytes are zero.
221            fidl::decode!(
222                fidl::encoding::BoundedString<1024>,
223                D,
224                &mut self.response,
225                decoder,
226                offset + 0,
227                _depth
228            )?;
229            Ok(())
230        }
231    }
232
233    impl fidl::encoding::ValueTypeMarker for ReverserReverseRequest {
234        type Borrowed<'a> = &'a Self;
235        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
236            value
237        }
238    }
239
240    unsafe impl fidl::encoding::TypeMarker for ReverserReverseRequest {
241        type Owned = Self;
242
243        #[inline(always)]
244        fn inline_align(_context: fidl::encoding::Context) -> usize {
245            8
246        }
247
248        #[inline(always)]
249        fn inline_size(_context: fidl::encoding::Context) -> usize {
250            16
251        }
252    }
253
254    unsafe impl<D: fidl::encoding::ResourceDialect>
255        fidl::encoding::Encode<ReverserReverseRequest, D> for &ReverserReverseRequest
256    {
257        #[inline]
258        unsafe fn encode(
259            self,
260            encoder: &mut fidl::encoding::Encoder<'_, D>,
261            offset: usize,
262            _depth: fidl::encoding::Depth,
263        ) -> fidl::Result<()> {
264            encoder.debug_check_bounds::<ReverserReverseRequest>(offset);
265            // Delegate to tuple encoding.
266            fidl::encoding::Encode::<ReverserReverseRequest, D>::encode(
267                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
268                    &self.input,
269                ),),
270                encoder,
271                offset,
272                _depth,
273            )
274        }
275    }
276    unsafe impl<
277            D: fidl::encoding::ResourceDialect,
278            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
279        > fidl::encoding::Encode<ReverserReverseRequest, D> for (T0,)
280    {
281        #[inline]
282        unsafe fn encode(
283            self,
284            encoder: &mut fidl::encoding::Encoder<'_, D>,
285            offset: usize,
286            depth: fidl::encoding::Depth,
287        ) -> fidl::Result<()> {
288            encoder.debug_check_bounds::<ReverserReverseRequest>(offset);
289            // Zero out padding regions. There's no need to apply masks
290            // because the unmasked parts will be overwritten by fields.
291            // Write the fields.
292            self.0.encode(encoder, offset + 0, depth)?;
293            Ok(())
294        }
295    }
296
297    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
298        for ReverserReverseRequest
299    {
300        #[inline(always)]
301        fn new_empty() -> Self {
302            Self { input: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
303        }
304
305        #[inline]
306        unsafe fn decode(
307            &mut self,
308            decoder: &mut fidl::encoding::Decoder<'_, D>,
309            offset: usize,
310            _depth: fidl::encoding::Depth,
311        ) -> fidl::Result<()> {
312            decoder.debug_check_bounds::<Self>(offset);
313            // Verify that padding bytes are zero.
314            fidl::decode!(
315                fidl::encoding::BoundedString<1024>,
316                D,
317                &mut self.input,
318                decoder,
319                offset + 0,
320                _depth
321            )?;
322            Ok(())
323        }
324    }
325
326    impl fidl::encoding::ValueTypeMarker for ReverserReverseResponse {
327        type Borrowed<'a> = &'a Self;
328        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
329            value
330        }
331    }
332
333    unsafe impl fidl::encoding::TypeMarker for ReverserReverseResponse {
334        type Owned = Self;
335
336        #[inline(always)]
337        fn inline_align(_context: fidl::encoding::Context) -> usize {
338            8
339        }
340
341        #[inline(always)]
342        fn inline_size(_context: fidl::encoding::Context) -> usize {
343            16
344        }
345    }
346
347    unsafe impl<D: fidl::encoding::ResourceDialect>
348        fidl::encoding::Encode<ReverserReverseResponse, D> for &ReverserReverseResponse
349    {
350        #[inline]
351        unsafe fn encode(
352            self,
353            encoder: &mut fidl::encoding::Encoder<'_, D>,
354            offset: usize,
355            _depth: fidl::encoding::Depth,
356        ) -> fidl::Result<()> {
357            encoder.debug_check_bounds::<ReverserReverseResponse>(offset);
358            // Delegate to tuple encoding.
359            fidl::encoding::Encode::<ReverserReverseResponse, D>::encode(
360                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
361                    &self.response,
362                ),),
363                encoder,
364                offset,
365                _depth,
366            )
367        }
368    }
369    unsafe impl<
370            D: fidl::encoding::ResourceDialect,
371            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
372        > fidl::encoding::Encode<ReverserReverseResponse, D> for (T0,)
373    {
374        #[inline]
375        unsafe fn encode(
376            self,
377            encoder: &mut fidl::encoding::Encoder<'_, D>,
378            offset: usize,
379            depth: fidl::encoding::Depth,
380        ) -> fidl::Result<()> {
381            encoder.debug_check_bounds::<ReverserReverseResponse>(offset);
382            // Zero out padding regions. There's no need to apply masks
383            // because the unmasked parts will be overwritten by fields.
384            // Write the fields.
385            self.0.encode(encoder, offset + 0, depth)?;
386            Ok(())
387        }
388    }
389
390    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
391        for ReverserReverseResponse
392    {
393        #[inline(always)]
394        fn new_empty() -> Self {
395            Self { response: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
396        }
397
398        #[inline]
399        unsafe fn decode(
400            &mut self,
401            decoder: &mut fidl::encoding::Decoder<'_, D>,
402            offset: usize,
403            _depth: fidl::encoding::Depth,
404        ) -> fidl::Result<()> {
405            decoder.debug_check_bounds::<Self>(offset);
406            // Verify that padding bytes are zero.
407            fidl::decode!(
408                fidl::encoding::BoundedString<1024>,
409                D,
410                &mut self.response,
411                decoder,
412                offset + 0,
413                _depth
414            )?;
415            Ok(())
416        }
417    }
418}