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