fidl_fuchsia_test_syscalls_common/
fidl_fuchsia_test_syscalls_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 ControlSetSuspendEnterResultRequest {
14    pub status: i32,
15}
16
17impl fidl::Persistable for ControlSetSuspendEnterResultRequest {}
18
19/// Internal state of the code instrumented with tests syscalls.
20#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
21#[repr(C)]
22pub struct State {
23    /// Number of calls to zx_system_suspend_enter for the lifetime of this
24    /// test fixture.
25    pub zx_system_suspend_enter_calls_count: u32,
26}
27
28impl fidl::Persistable for State {}
29
30mod internal {
31    use super::*;
32
33    impl fidl::encoding::ValueTypeMarker for ControlSetSuspendEnterResultRequest {
34        type Borrowed<'a> = &'a Self;
35        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
36            value
37        }
38    }
39
40    unsafe impl fidl::encoding::TypeMarker for ControlSetSuspendEnterResultRequest {
41        type Owned = Self;
42
43        #[inline(always)]
44        fn inline_align(_context: fidl::encoding::Context) -> usize {
45            4
46        }
47
48        #[inline(always)]
49        fn inline_size(_context: fidl::encoding::Context) -> usize {
50            4
51        }
52        #[inline(always)]
53        fn encode_is_copy() -> bool {
54            true
55        }
56
57        #[inline(always)]
58        fn decode_is_copy() -> bool {
59            true
60        }
61    }
62
63    unsafe impl<D: fidl::encoding::ResourceDialect>
64        fidl::encoding::Encode<ControlSetSuspendEnterResultRequest, D>
65        for &ControlSetSuspendEnterResultRequest
66    {
67        #[inline]
68        unsafe fn encode(
69            self,
70            encoder: &mut fidl::encoding::Encoder<'_, D>,
71            offset: usize,
72            _depth: fidl::encoding::Depth,
73        ) -> fidl::Result<()> {
74            encoder.debug_check_bounds::<ControlSetSuspendEnterResultRequest>(offset);
75            unsafe {
76                // Copy the object into the buffer.
77                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
78                (buf_ptr as *mut ControlSetSuspendEnterResultRequest)
79                    .write_unaligned((self as *const ControlSetSuspendEnterResultRequest).read());
80                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
81                // done second because the memcpy will write garbage to these bytes.
82            }
83            Ok(())
84        }
85    }
86    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
87        fidl::encoding::Encode<ControlSetSuspendEnterResultRequest, 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::<ControlSetSuspendEnterResultRequest>(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>
106        for ControlSetSuspendEnterResultRequest
107    {
108        #[inline(always)]
109        fn new_empty() -> Self {
110            Self { status: fidl::new_empty!(i32, D) }
111        }
112
113        #[inline]
114        unsafe fn decode(
115            &mut self,
116            decoder: &mut fidl::encoding::Decoder<'_, D>,
117            offset: usize,
118            _depth: fidl::encoding::Depth,
119        ) -> fidl::Result<()> {
120            decoder.debug_check_bounds::<Self>(offset);
121            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
122            // Verify that padding bytes are zero.
123            // Copy from the buffer into the object.
124            unsafe {
125                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
126            }
127            Ok(())
128        }
129    }
130
131    impl fidl::encoding::ValueTypeMarker for State {
132        type Borrowed<'a> = &'a Self;
133        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
134            value
135        }
136    }
137
138    unsafe impl fidl::encoding::TypeMarker for State {
139        type Owned = Self;
140
141        #[inline(always)]
142        fn inline_align(_context: fidl::encoding::Context) -> usize {
143            4
144        }
145
146        #[inline(always)]
147        fn inline_size(_context: fidl::encoding::Context) -> usize {
148            4
149        }
150        #[inline(always)]
151        fn encode_is_copy() -> bool {
152            true
153        }
154
155        #[inline(always)]
156        fn decode_is_copy() -> bool {
157            true
158        }
159    }
160
161    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<State, D> for &State {
162        #[inline]
163        unsafe fn encode(
164            self,
165            encoder: &mut fidl::encoding::Encoder<'_, D>,
166            offset: usize,
167            _depth: fidl::encoding::Depth,
168        ) -> fidl::Result<()> {
169            encoder.debug_check_bounds::<State>(offset);
170            unsafe {
171                // Copy the object into the buffer.
172                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
173                (buf_ptr as *mut State).write_unaligned((self as *const State).read());
174                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
175                // done second because the memcpy will write garbage to these bytes.
176            }
177            Ok(())
178        }
179    }
180    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
181        fidl::encoding::Encode<State, D> for (T0,)
182    {
183        #[inline]
184        unsafe fn encode(
185            self,
186            encoder: &mut fidl::encoding::Encoder<'_, D>,
187            offset: usize,
188            depth: fidl::encoding::Depth,
189        ) -> fidl::Result<()> {
190            encoder.debug_check_bounds::<State>(offset);
191            // Zero out padding regions. There's no need to apply masks
192            // because the unmasked parts will be overwritten by fields.
193            // Write the fields.
194            self.0.encode(encoder, offset + 0, depth)?;
195            Ok(())
196        }
197    }
198
199    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for State {
200        #[inline(always)]
201        fn new_empty() -> Self {
202            Self { zx_system_suspend_enter_calls_count: fidl::new_empty!(u32, D) }
203        }
204
205        #[inline]
206        unsafe fn decode(
207            &mut self,
208            decoder: &mut fidl::encoding::Decoder<'_, D>,
209            offset: usize,
210            _depth: fidl::encoding::Depth,
211        ) -> fidl::Result<()> {
212            decoder.debug_check_bounds::<Self>(offset);
213            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
214            // Verify that padding bytes are zero.
215            // Copy from the buffer into the object.
216            unsafe {
217                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
218            }
219            Ok(())
220        }
221    }
222}