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