fidl_test_proxy_stress_common/
fidl_test_proxy_stress_common.rs1#![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
33mod internal {
34 use super::*;
35
36 impl fidl::encoding::ValueTypeMarker for StressorEchoRequest {
37 type Borrowed<'a> = &'a Self;
38 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
39 value
40 }
41 }
42
43 unsafe impl fidl::encoding::TypeMarker for StressorEchoRequest {
44 type Owned = Self;
45
46 #[inline(always)]
47 fn inline_align(_context: fidl::encoding::Context) -> usize {
48 8
49 }
50
51 #[inline(always)]
52 fn inline_size(_context: fidl::encoding::Context) -> usize {
53 16
54 }
55 }
56
57 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StressorEchoRequest, D>
58 for &StressorEchoRequest
59 {
60 #[inline]
61 unsafe fn encode(
62 self,
63 encoder: &mut fidl::encoding::Encoder<'_, D>,
64 offset: usize,
65 _depth: fidl::encoding::Depth,
66 ) -> fidl::Result<()> {
67 encoder.debug_check_bounds::<StressorEchoRequest>(offset);
68 fidl::encoding::Encode::<StressorEchoRequest, D>::encode(
70 (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
71 &self.content,
72 ),),
73 encoder,
74 offset,
75 _depth,
76 )
77 }
78 }
79 unsafe impl<
80 D: fidl::encoding::ResourceDialect,
81 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
82 > fidl::encoding::Encode<StressorEchoRequest, D> for (T0,)
83 {
84 #[inline]
85 unsafe fn encode(
86 self,
87 encoder: &mut fidl::encoding::Encoder<'_, D>,
88 offset: usize,
89 depth: fidl::encoding::Depth,
90 ) -> fidl::Result<()> {
91 encoder.debug_check_bounds::<StressorEchoRequest>(offset);
92 self.0.encode(encoder, offset + 0, depth)?;
96 Ok(())
97 }
98 }
99
100 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StressorEchoRequest {
101 #[inline(always)]
102 fn new_empty() -> Self {
103 Self { content: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
104 }
105
106 #[inline]
107 unsafe fn decode(
108 &mut self,
109 decoder: &mut fidl::encoding::Decoder<'_, D>,
110 offset: usize,
111 _depth: fidl::encoding::Depth,
112 ) -> fidl::Result<()> {
113 decoder.debug_check_bounds::<Self>(offset);
114 fidl::decode!(
116 fidl::encoding::BoundedString<1024>,
117 D,
118 &mut self.content,
119 decoder,
120 offset + 0,
121 _depth
122 )?;
123 Ok(())
124 }
125 }
126
127 impl fidl::encoding::ValueTypeMarker for StressorEchoResponse {
128 type Borrowed<'a> = &'a Self;
129 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
130 value
131 }
132 }
133
134 unsafe impl fidl::encoding::TypeMarker for StressorEchoResponse {
135 type Owned = Self;
136
137 #[inline(always)]
138 fn inline_align(_context: fidl::encoding::Context) -> usize {
139 8
140 }
141
142 #[inline(always)]
143 fn inline_size(_context: fidl::encoding::Context) -> usize {
144 16
145 }
146 }
147
148 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StressorEchoResponse, D>
149 for &StressorEchoResponse
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::<StressorEchoResponse>(offset);
159 fidl::encoding::Encode::<StressorEchoResponse, D>::encode(
161 (<fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(
162 &self.content,
163 ),),
164 encoder,
165 offset,
166 _depth,
167 )
168 }
169 }
170 unsafe impl<
171 D: fidl::encoding::ResourceDialect,
172 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
173 > fidl::encoding::Encode<StressorEchoResponse, D> for (T0,)
174 {
175 #[inline]
176 unsafe fn encode(
177 self,
178 encoder: &mut fidl::encoding::Encoder<'_, D>,
179 offset: usize,
180 depth: fidl::encoding::Depth,
181 ) -> fidl::Result<()> {
182 encoder.debug_check_bounds::<StressorEchoResponse>(offset);
183 self.0.encode(encoder, offset + 0, depth)?;
187 Ok(())
188 }
189 }
190
191 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StressorEchoResponse {
192 #[inline(always)]
193 fn new_empty() -> Self {
194 Self { content: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D) }
195 }
196
197 #[inline]
198 unsafe fn decode(
199 &mut self,
200 decoder: &mut fidl::encoding::Decoder<'_, D>,
201 offset: usize,
202 _depth: fidl::encoding::Depth,
203 ) -> fidl::Result<()> {
204 decoder.debug_check_bounds::<Self>(offset);
205 fidl::decode!(
207 fidl::encoding::BoundedString<1024>,
208 D,
209 &mut self.content,
210 decoder,
211 offset + 0,
212 _depth
213 )?;
214 Ok(())
215 }
216 }
217
218 impl fidl::encoding::ValueTypeMarker for StressorStuffSocketResponse {
219 type Borrowed<'a> = &'a Self;
220 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
221 value
222 }
223 }
224
225 unsafe impl fidl::encoding::TypeMarker for StressorStuffSocketResponse {
226 type Owned = Self;
227
228 #[inline(always)]
229 fn inline_align(_context: fidl::encoding::Context) -> usize {
230 4
231 }
232
233 #[inline(always)]
234 fn inline_size(_context: fidl::encoding::Context) -> usize {
235 4
236 }
237 #[inline(always)]
238 fn encode_is_copy() -> bool {
239 true
240 }
241
242 #[inline(always)]
243 fn decode_is_copy() -> bool {
244 true
245 }
246 }
247
248 unsafe impl<D: fidl::encoding::ResourceDialect>
249 fidl::encoding::Encode<StressorStuffSocketResponse, D> for &StressorStuffSocketResponse
250 {
251 #[inline]
252 unsafe fn encode(
253 self,
254 encoder: &mut fidl::encoding::Encoder<'_, D>,
255 offset: usize,
256 _depth: fidl::encoding::Depth,
257 ) -> fidl::Result<()> {
258 encoder.debug_check_bounds::<StressorStuffSocketResponse>(offset);
259 unsafe {
260 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
262 (buf_ptr as *mut StressorStuffSocketResponse)
263 .write_unaligned((self as *const StressorStuffSocketResponse).read());
264 }
267 Ok(())
268 }
269 }
270 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
271 fidl::encoding::Encode<StressorStuffSocketResponse, D> for (T0,)
272 {
273 #[inline]
274 unsafe fn encode(
275 self,
276 encoder: &mut fidl::encoding::Encoder<'_, D>,
277 offset: usize,
278 depth: fidl::encoding::Depth,
279 ) -> fidl::Result<()> {
280 encoder.debug_check_bounds::<StressorStuffSocketResponse>(offset);
281 self.0.encode(encoder, offset + 0, depth)?;
285 Ok(())
286 }
287 }
288
289 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
290 for StressorStuffSocketResponse
291 {
292 #[inline(always)]
293 fn new_empty() -> Self {
294 Self { bytes_written: fidl::new_empty!(u32, D) }
295 }
296
297 #[inline]
298 unsafe fn decode(
299 &mut self,
300 decoder: &mut fidl::encoding::Decoder<'_, D>,
301 offset: usize,
302 _depth: fidl::encoding::Depth,
303 ) -> fidl::Result<()> {
304 decoder.debug_check_bounds::<Self>(offset);
305 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
306 unsafe {
309 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
310 }
311 Ok(())
312 }
313 }
314}