fidl_fuchsia_example_power__common/
fidl_fuchsia_example_power__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 CounterGetResponse {
14    pub count: u64,
15}
16
17impl fidl::Persistable for CounterGetResponse {}
18
19#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
20#[repr(C)]
21pub struct FrameControlStartFrameRequest {
22    pub duration_ms: u16,
23    pub rate_change_offset_ms: u16,
24}
25
26impl fidl::Persistable for FrameControlStartFrameRequest {}
27
28pub mod counter_ordinals {
29    pub const GET: u64 = 0x3944f6d91c5b8ad8;
30}
31
32pub mod frame_control_ordinals {
33    pub const START_FRAME: u64 = 0x187c1cc46de29b5e;
34}
35
36pub mod message_source_ordinals {
37    pub const RECEIVE_MESSAGES: u64 = 0x23351bdac594c749;
38    pub const RECEIVE_BATON: u64 = 0x18ed150a92dd23ee;
39}
40
41mod internal {
42    use super::*;
43
44    impl fidl::encoding::ValueTypeMarker for CounterGetResponse {
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 CounterGetResponse {
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> fidl::encoding::Encode<CounterGetResponse, D>
75        for &CounterGetResponse
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::<CounterGetResponse>(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 CounterGetResponse)
89                    .write_unaligned((self as *const CounterGetResponse).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<u64, D>>
97        fidl::encoding::Encode<CounterGetResponse, 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::<CounterGetResponse>(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> for CounterGetResponse {
116        #[inline(always)]
117        fn new_empty() -> Self {
118            Self { count: fidl::new_empty!(u64, D) }
119        }
120
121        #[inline]
122        unsafe fn decode(
123            &mut self,
124            decoder: &mut fidl::encoding::Decoder<'_, D>,
125            offset: usize,
126            _depth: fidl::encoding::Depth,
127        ) -> fidl::Result<()> {
128            decoder.debug_check_bounds::<Self>(offset);
129            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
130            // Verify that padding bytes are zero.
131            // Copy from the buffer into the object.
132            unsafe {
133                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
134            }
135            Ok(())
136        }
137    }
138
139    impl fidl::encoding::ValueTypeMarker for FrameControlStartFrameRequest {
140        type Borrowed<'a> = &'a Self;
141        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
142            value
143        }
144    }
145
146    unsafe impl fidl::encoding::TypeMarker for FrameControlStartFrameRequest {
147        type Owned = Self;
148
149        #[inline(always)]
150        fn inline_align(_context: fidl::encoding::Context) -> usize {
151            2
152        }
153
154        #[inline(always)]
155        fn inline_size(_context: fidl::encoding::Context) -> usize {
156            4
157        }
158        #[inline(always)]
159        fn encode_is_copy() -> bool {
160            true
161        }
162
163        #[inline(always)]
164        fn decode_is_copy() -> bool {
165            true
166        }
167    }
168
169    unsafe impl<D: fidl::encoding::ResourceDialect>
170        fidl::encoding::Encode<FrameControlStartFrameRequest, D>
171        for &FrameControlStartFrameRequest
172    {
173        #[inline]
174        unsafe fn encode(
175            self,
176            encoder: &mut fidl::encoding::Encoder<'_, D>,
177            offset: usize,
178            _depth: fidl::encoding::Depth,
179        ) -> fidl::Result<()> {
180            encoder.debug_check_bounds::<FrameControlStartFrameRequest>(offset);
181            unsafe {
182                // Copy the object into the buffer.
183                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
184                (buf_ptr as *mut FrameControlStartFrameRequest)
185                    .write_unaligned((self as *const FrameControlStartFrameRequest).read());
186                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
187                // done second because the memcpy will write garbage to these bytes.
188            }
189            Ok(())
190        }
191    }
192    unsafe impl<
193            D: fidl::encoding::ResourceDialect,
194            T0: fidl::encoding::Encode<u16, D>,
195            T1: fidl::encoding::Encode<u16, D>,
196        > fidl::encoding::Encode<FrameControlStartFrameRequest, D> for (T0, T1)
197    {
198        #[inline]
199        unsafe fn encode(
200            self,
201            encoder: &mut fidl::encoding::Encoder<'_, D>,
202            offset: usize,
203            depth: fidl::encoding::Depth,
204        ) -> fidl::Result<()> {
205            encoder.debug_check_bounds::<FrameControlStartFrameRequest>(offset);
206            // Zero out padding regions. There's no need to apply masks
207            // because the unmasked parts will be overwritten by fields.
208            // Write the fields.
209            self.0.encode(encoder, offset + 0, depth)?;
210            self.1.encode(encoder, offset + 2, depth)?;
211            Ok(())
212        }
213    }
214
215    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
216        for FrameControlStartFrameRequest
217    {
218        #[inline(always)]
219        fn new_empty() -> Self {
220            Self {
221                duration_ms: fidl::new_empty!(u16, D),
222                rate_change_offset_ms: fidl::new_empty!(u16, D),
223            }
224        }
225
226        #[inline]
227        unsafe fn decode(
228            &mut self,
229            decoder: &mut fidl::encoding::Decoder<'_, D>,
230            offset: usize,
231            _depth: fidl::encoding::Depth,
232        ) -> fidl::Result<()> {
233            decoder.debug_check_bounds::<Self>(offset);
234            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
235            // Verify that padding bytes are zero.
236            // Copy from the buffer into the object.
237            unsafe {
238                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
239            }
240            Ok(())
241        }
242    }
243}