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