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