fidl_fuchsia_examples_gizmo__common/
fidl_fuchsia_examples_gizmo__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 DeviceGetHardwareIdResponse {
14    pub response: u32,
15}
16
17impl fidl::Persistable for DeviceGetHardwareIdResponse {}
18
19pub mod device_ordinals {
20    pub const GET_HARDWARE_ID: u64 = 0x6e5b9839214b7e74;
21    pub const GET_EVENT: u64 = 0x54a8bb5532184e0e;
22}
23
24mod internal {
25    use super::*;
26
27    impl fidl::encoding::ValueTypeMarker for DeviceGetHardwareIdResponse {
28        type Borrowed<'a> = &'a Self;
29        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
30            value
31        }
32    }
33
34    unsafe impl fidl::encoding::TypeMarker for DeviceGetHardwareIdResponse {
35        type Owned = Self;
36
37        #[inline(always)]
38        fn inline_align(_context: fidl::encoding::Context) -> usize {
39            4
40        }
41
42        #[inline(always)]
43        fn inline_size(_context: fidl::encoding::Context) -> usize {
44            4
45        }
46        #[inline(always)]
47        fn encode_is_copy() -> bool {
48            true
49        }
50
51        #[inline(always)]
52        fn decode_is_copy() -> bool {
53            true
54        }
55    }
56
57    unsafe impl<D: fidl::encoding::ResourceDialect>
58        fidl::encoding::Encode<DeviceGetHardwareIdResponse, D> for &DeviceGetHardwareIdResponse
59    {
60        #[inline]
61        unsafe fn encode(
62            self,
63            encoder: &mut fidl::encoding::Encoder<'_, D>,
64            offset: usize,
65            _depth: fidl::encoding::Depth,
66        ) -> fidl::Result<()> {
67            encoder.debug_check_bounds::<DeviceGetHardwareIdResponse>(offset);
68            unsafe {
69                // Copy the object into the buffer.
70                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
71                (buf_ptr as *mut DeviceGetHardwareIdResponse)
72                    .write_unaligned((self as *const DeviceGetHardwareIdResponse).read());
73                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
74                // done second because the memcpy will write garbage to these bytes.
75            }
76            Ok(())
77        }
78    }
79    unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
80        fidl::encoding::Encode<DeviceGetHardwareIdResponse, D> for (T0,)
81    {
82        #[inline]
83        unsafe fn encode(
84            self,
85            encoder: &mut fidl::encoding::Encoder<'_, D>,
86            offset: usize,
87            depth: fidl::encoding::Depth,
88        ) -> fidl::Result<()> {
89            encoder.debug_check_bounds::<DeviceGetHardwareIdResponse>(offset);
90            // Zero out padding regions. There's no need to apply masks
91            // because the unmasked parts will be overwritten by fields.
92            // Write the fields.
93            self.0.encode(encoder, offset + 0, depth)?;
94            Ok(())
95        }
96    }
97
98    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
99        for DeviceGetHardwareIdResponse
100    {
101        #[inline(always)]
102        fn new_empty() -> Self {
103            Self { response: fidl::new_empty!(u32, D) }
104        }
105
106        #[inline]
107        unsafe fn decode(
108            &mut self,
109            decoder: &mut fidl::encoding::Decoder<'_, D>,
110            offset: usize,
111            _depth: fidl::encoding::Depth,
112        ) -> fidl::Result<()> {
113            decoder.debug_check_bounds::<Self>(offset);
114            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
115            // Verify that padding bytes are zero.
116            // Copy from the buffer into the object.
117            unsafe {
118                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
119            }
120            Ok(())
121        }
122    }
123}