fidl_fuchsia_example_power_common/
fidl_fuchsia_example_power_common.rs
1#![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
28mod internal {
29 use super::*;
30
31 impl fidl::encoding::ValueTypeMarker for CounterGetResponse {
32 type Borrowed<'a> = &'a Self;
33 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
34 value
35 }
36 }
37
38 unsafe impl fidl::encoding::TypeMarker for CounterGetResponse {
39 type Owned = Self;
40
41 #[inline(always)]
42 fn inline_align(_context: fidl::encoding::Context) -> usize {
43 8
44 }
45
46 #[inline(always)]
47 fn inline_size(_context: fidl::encoding::Context) -> usize {
48 8
49 }
50 #[inline(always)]
51 fn encode_is_copy() -> bool {
52 true
53 }
54
55 #[inline(always)]
56 fn decode_is_copy() -> bool {
57 true
58 }
59 }
60
61 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CounterGetResponse, D>
62 for &CounterGetResponse
63 {
64 #[inline]
65 unsafe fn encode(
66 self,
67 encoder: &mut fidl::encoding::Encoder<'_, D>,
68 offset: usize,
69 _depth: fidl::encoding::Depth,
70 ) -> fidl::Result<()> {
71 encoder.debug_check_bounds::<CounterGetResponse>(offset);
72 unsafe {
73 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
75 (buf_ptr as *mut CounterGetResponse)
76 .write_unaligned((self as *const CounterGetResponse).read());
77 }
80 Ok(())
81 }
82 }
83 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
84 fidl::encoding::Encode<CounterGetResponse, D> for (T0,)
85 {
86 #[inline]
87 unsafe fn encode(
88 self,
89 encoder: &mut fidl::encoding::Encoder<'_, D>,
90 offset: usize,
91 depth: fidl::encoding::Depth,
92 ) -> fidl::Result<()> {
93 encoder.debug_check_bounds::<CounterGetResponse>(offset);
94 self.0.encode(encoder, offset + 0, depth)?;
98 Ok(())
99 }
100 }
101
102 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CounterGetResponse {
103 #[inline(always)]
104 fn new_empty() -> Self {
105 Self { count: fidl::new_empty!(u64, D) }
106 }
107
108 #[inline]
109 unsafe fn decode(
110 &mut self,
111 decoder: &mut fidl::encoding::Decoder<'_, D>,
112 offset: usize,
113 _depth: fidl::encoding::Depth,
114 ) -> fidl::Result<()> {
115 decoder.debug_check_bounds::<Self>(offset);
116 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
117 unsafe {
120 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
121 }
122 Ok(())
123 }
124 }
125
126 impl fidl::encoding::ValueTypeMarker for FrameControlStartFrameRequest {
127 type Borrowed<'a> = &'a Self;
128 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
129 value
130 }
131 }
132
133 unsafe impl fidl::encoding::TypeMarker for FrameControlStartFrameRequest {
134 type Owned = Self;
135
136 #[inline(always)]
137 fn inline_align(_context: fidl::encoding::Context) -> usize {
138 2
139 }
140
141 #[inline(always)]
142 fn inline_size(_context: fidl::encoding::Context) -> usize {
143 4
144 }
145 #[inline(always)]
146 fn encode_is_copy() -> bool {
147 true
148 }
149
150 #[inline(always)]
151 fn decode_is_copy() -> bool {
152 true
153 }
154 }
155
156 unsafe impl<D: fidl::encoding::ResourceDialect>
157 fidl::encoding::Encode<FrameControlStartFrameRequest, D>
158 for &FrameControlStartFrameRequest
159 {
160 #[inline]
161 unsafe fn encode(
162 self,
163 encoder: &mut fidl::encoding::Encoder<'_, D>,
164 offset: usize,
165 _depth: fidl::encoding::Depth,
166 ) -> fidl::Result<()> {
167 encoder.debug_check_bounds::<FrameControlStartFrameRequest>(offset);
168 unsafe {
169 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
171 (buf_ptr as *mut FrameControlStartFrameRequest)
172 .write_unaligned((self as *const FrameControlStartFrameRequest).read());
173 }
176 Ok(())
177 }
178 }
179 unsafe impl<
180 D: fidl::encoding::ResourceDialect,
181 T0: fidl::encoding::Encode<u16, D>,
182 T1: fidl::encoding::Encode<u16, D>,
183 > fidl::encoding::Encode<FrameControlStartFrameRequest, D> for (T0, T1)
184 {
185 #[inline]
186 unsafe fn encode(
187 self,
188 encoder: &mut fidl::encoding::Encoder<'_, D>,
189 offset: usize,
190 depth: fidl::encoding::Depth,
191 ) -> fidl::Result<()> {
192 encoder.debug_check_bounds::<FrameControlStartFrameRequest>(offset);
193 self.0.encode(encoder, offset + 0, depth)?;
197 self.1.encode(encoder, offset + 2, depth)?;
198 Ok(())
199 }
200 }
201
202 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
203 for FrameControlStartFrameRequest
204 {
205 #[inline(always)]
206 fn new_empty() -> Self {
207 Self {
208 duration_ms: fidl::new_empty!(u16, D),
209 rate_change_offset_ms: fidl::new_empty!(u16, D),
210 }
211 }
212
213 #[inline]
214 unsafe fn decode(
215 &mut self,
216 decoder: &mut fidl::encoding::Decoder<'_, D>,
217 offset: usize,
218 _depth: fidl::encoding::Depth,
219 ) -> fidl::Result<()> {
220 decoder.debug_check_bounds::<Self>(offset);
221 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
222 unsafe {
225 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
226 }
227 Ok(())
228 }
229 }
230}