fidl_test_proxy_stress__common/
fidl_test_proxy_stress__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 StressorEchoRequest {
13    pub content: String,
14}
15
16impl fidl::Persistable for StressorEchoRequest {}
17
18#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
19pub struct StressorEchoResponse {
20    pub content: String,
21}
22
23impl fidl::Persistable for StressorEchoResponse {}
24
25#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26#[repr(C)]
27pub struct StressorStuffSocketResponse {
28    pub bytes_written: u32,
29}
30
31impl fidl::Persistable for StressorStuffSocketResponse {}
32
33pub mod stressor_ordinals {
34    pub const STUFF_SOCKET: u64 = 0x3270057179f1ae49;
35    pub const ECHO: u64 = 0x4463eecf18ad1bd1;
36}
37
38mod internal {
39    use super::*;
40
41    impl fidl::encoding::ValueTypeMarker for StressorEchoRequest {
42        type Borrowed<'a> = &'a Self;
43        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
44            value
45        }
46    }
47
48    unsafe impl fidl::encoding::TypeMarker for StressorEchoRequest {
49        type Owned = Self;
50
51        #[inline(always)]
52        fn inline_align(_context: fidl::encoding::Context) -> usize {
53            8
54        }
55
56        #[inline(always)]
57        fn inline_size(_context: fidl::encoding::Context) -> usize {
58            16
59        }
60    }
61
62    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StressorEchoRequest, D>
63        for &StressorEchoRequest
64    {
65        #[inline]
66        unsafe fn encode(
67            self,
68            encoder: &mut fidl::encoding::Encoder<'_, D>,
69            offset: usize,
70            _depth: fidl::encoding::Depth,
71        ) -> fidl::Result<()> {
72            encoder.debug_check_bounds::<StressorEchoRequest>(offset);
73            // Delegate to tuple encoding.
74            fidl::encoding::Encode::<StressorEchoRequest, D>::encode(
75                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
76                    &self.content,
77                ),),
78                encoder,
79                offset,
80                _depth,
81            )
82        }
83    }
84    unsafe impl<
85            D: fidl::encoding::ResourceDialect,
86            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
87        > fidl::encoding::Encode<StressorEchoRequest, D> for (T0,)
88    {
89        #[inline]
90        unsafe fn encode(
91            self,
92            encoder: &mut fidl::encoding::Encoder<'_, D>,
93            offset: usize,
94            depth: fidl::encoding::Depth,
95        ) -> fidl::Result<()> {
96            encoder.debug_check_bounds::<StressorEchoRequest>(offset);
97            // Zero out padding regions. There's no need to apply masks
98            // because the unmasked parts will be overwritten by fields.
99            // Write the fields.
100            self.0.encode(encoder, offset + 0, depth)?;
101            Ok(())
102        }
103    }
104
105    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StressorEchoRequest {
106        #[inline(always)]
107        fn new_empty() -> Self {
108            Self { content: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
109        }
110
111        #[inline]
112        unsafe fn decode(
113            &mut self,
114            decoder: &mut fidl::encoding::Decoder<'_, D>,
115            offset: usize,
116            _depth: fidl::encoding::Depth,
117        ) -> fidl::Result<()> {
118            decoder.debug_check_bounds::<Self>(offset);
119            // Verify that padding bytes are zero.
120            fidl::decode!(
121                fidl::encoding::BoundedString<1024>,
122                D,
123                &mut self.content,
124                decoder,
125                offset + 0,
126                _depth
127            )?;
128            Ok(())
129        }
130    }
131
132    impl fidl::encoding::ValueTypeMarker for StressorEchoResponse {
133        type Borrowed<'a> = &'a Self;
134        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
135            value
136        }
137    }
138
139    unsafe impl fidl::encoding::TypeMarker for StressorEchoResponse {
140        type Owned = Self;
141
142        #[inline(always)]
143        fn inline_align(_context: fidl::encoding::Context) -> usize {
144            8
145        }
146
147        #[inline(always)]
148        fn inline_size(_context: fidl::encoding::Context) -> usize {
149            16
150        }
151    }
152
153    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StressorEchoResponse, D>
154        for &StressorEchoResponse
155    {
156        #[inline]
157        unsafe fn encode(
158            self,
159            encoder: &mut fidl::encoding::Encoder<'_, D>,
160            offset: usize,
161            _depth: fidl::encoding::Depth,
162        ) -> fidl::Result<()> {
163            encoder.debug_check_bounds::<StressorEchoResponse>(offset);
164            // Delegate to tuple encoding.
165            fidl::encoding::Encode::<StressorEchoResponse, D>::encode(
166                (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
167                    &self.content,
168                ),),
169                encoder,
170                offset,
171                _depth,
172            )
173        }
174    }
175    unsafe impl<
176            D: fidl::encoding::ResourceDialect,
177            T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
178        > fidl::encoding::Encode<StressorEchoResponse, D> for (T0,)
179    {
180        #[inline]
181        unsafe fn encode(
182            self,
183            encoder: &mut fidl::encoding::Encoder<'_, D>,
184            offset: usize,
185            depth: fidl::encoding::Depth,
186        ) -> fidl::Result<()> {
187            encoder.debug_check_bounds::<StressorEchoResponse>(offset);
188            // Zero out padding regions. There's no need to apply masks
189            // because the unmasked parts will be overwritten by fields.
190            // Write the fields.
191            self.0.encode(encoder, offset + 0, depth)?;
192            Ok(())
193        }
194    }
195
196    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StressorEchoResponse {
197        #[inline(always)]
198        fn new_empty() -> Self {
199            Self { content: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
200        }
201
202        #[inline]
203        unsafe fn decode(
204            &mut self,
205            decoder: &mut fidl::encoding::Decoder<'_, D>,
206            offset: usize,
207            _depth: fidl::encoding::Depth,
208        ) -> fidl::Result<()> {
209            decoder.debug_check_bounds::<Self>(offset);
210            // Verify that padding bytes are zero.
211            fidl::decode!(
212                fidl::encoding::BoundedString<1024>,
213                D,
214                &mut self.content,
215                decoder,
216                offset + 0,
217                _depth
218            )?;
219            Ok(())
220        }
221    }
222
223    impl fidl::encoding::ValueTypeMarker for StressorStuffSocketResponse {
224        type Borrowed<'a> = &'a Self;
225        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
226            value
227        }
228    }
229
230    unsafe impl fidl::encoding::TypeMarker for StressorStuffSocketResponse {
231        type Owned = Self;
232
233        #[inline(always)]
234        fn inline_align(_context: fidl::encoding::Context) -> usize {
235            4
236        }
237
238        #[inline(always)]
239        fn inline_size(_context: fidl::encoding::Context) -> usize {
240            4
241        }
242        #[inline(always)]
243        fn encode_is_copy() -> bool {
244            true
245        }
246
247        #[inline(always)]
248        fn decode_is_copy() -> bool {
249            true
250        }
251    }
252
253    unsafe impl<D: fidl::encoding::ResourceDialect>
254        fidl::encoding::Encode<StressorStuffSocketResponse, D> for &StressorStuffSocketResponse
255    {
256        #[inline]
257        unsafe fn encode(
258            self,
259            encoder: &mut fidl::encoding::Encoder<'_, D>,
260            offset: usize,
261            _depth: fidl::encoding::Depth,
262        ) -> fidl::Result<()> {
263            encoder.debug_check_bounds::<StressorStuffSocketResponse>(offset);
264            unsafe {
265                // Copy the object into the buffer.
266                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
267                (buf_ptr as *mut StressorStuffSocketResponse)
268                    .write_unaligned((self as *const StressorStuffSocketResponse).read());
269                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
270                // done second because the memcpy will write garbage to these bytes.
271            }
272            Ok(())
273        }
274    }
275    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
276        fidl::encoding::Encode<StressorStuffSocketResponse, D> for (T0,)
277    {
278        #[inline]
279        unsafe fn encode(
280            self,
281            encoder: &mut fidl::encoding::Encoder<'_, D>,
282            offset: usize,
283            depth: fidl::encoding::Depth,
284        ) -> fidl::Result<()> {
285            encoder.debug_check_bounds::<StressorStuffSocketResponse>(offset);
286            // Zero out padding regions. There's no need to apply masks
287            // because the unmasked parts will be overwritten by fields.
288            // Write the fields.
289            self.0.encode(encoder, offset + 0, depth)?;
290            Ok(())
291        }
292    }
293
294    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
295        for StressorStuffSocketResponse
296    {
297        #[inline(always)]
298        fn new_empty() -> Self {
299            Self { bytes_written: fidl::new_empty!(u32, D) }
300        }
301
302        #[inline]
303        unsafe fn decode(
304            &mut self,
305            decoder: &mut fidl::encoding::Decoder<'_, D>,
306            offset: usize,
307            _depth: fidl::encoding::Depth,
308        ) -> fidl::Result<()> {
309            decoder.debug_check_bounds::<Self>(offset);
310            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
311            // Verify that padding bytes are zero.
312            // Copy from the buffer into the object.
313            unsafe {
314                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
315            }
316            Ok(())
317        }
318    }
319}