fidl_fuchsia_bluetooth_rfcomm_test__common/
fidl_fuchsia_bluetooth_rfcomm_test__common.rs1#![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)]
15#[repr(u32)]
16pub enum Status {
17 Ok = 0,
18 OverrunError = 1,
19 ParityError = 2,
20 FramingError = 3,
21}
22
23impl Status {
24 #[inline]
25 pub fn from_primitive(prim: u32) -> Option<Self> {
26 match prim {
27 0 => Some(Self::Ok),
28 1 => Some(Self::OverrunError),
29 2 => Some(Self::ParityError),
30 3 => Some(Self::FramingError),
31 _ => None,
32 }
33 }
34
35 #[inline]
36 pub const fn into_primitive(self) -> u32 {
37 self as u32
38 }
39}
40
41#[derive(Clone, Debug, PartialEq)]
42pub struct RfcommTestDisconnectRequest {
43 pub id: fidl_fuchsia_bluetooth__common::PeerId,
44}
45
46impl fidl::Persistable for RfcommTestDisconnectRequest {}
47
48#[derive(Clone, Debug, PartialEq)]
49pub struct RfcommTestRemoteLineStatusRequest {
50 pub id: fidl_fuchsia_bluetooth__common::PeerId,
51 pub channel_number: u8,
52 pub status: Status,
53}
54
55impl fidl::Persistable for RfcommTestRemoteLineStatusRequest {}
56
57pub mod rfcomm_test_ordinals {
58 pub const DISCONNECT: u64 = 0x6173bb03e37ddddf;
59 pub const REMOTE_LINE_STATUS: u64 = 0x3689603441392637;
60}
61
62mod internal {
63 use super::*;
64 unsafe impl fidl::encoding::TypeMarker for Status {
65 type Owned = Self;
66
67 #[inline(always)]
68 fn inline_align(_context: fidl::encoding::Context) -> usize {
69 std::mem::align_of::<u32>()
70 }
71
72 #[inline(always)]
73 fn inline_size(_context: fidl::encoding::Context) -> usize {
74 std::mem::size_of::<u32>()
75 }
76
77 #[inline(always)]
78 fn encode_is_copy() -> bool {
79 true
80 }
81
82 #[inline(always)]
83 fn decode_is_copy() -> bool {
84 false
85 }
86 }
87
88 impl fidl::encoding::ValueTypeMarker for Status {
89 type Borrowed<'a> = Self;
90 #[inline(always)]
91 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
92 *value
93 }
94 }
95
96 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Status {
97 #[inline]
98 unsafe fn encode(
99 self,
100 encoder: &mut fidl::encoding::Encoder<'_, D>,
101 offset: usize,
102 _depth: fidl::encoding::Depth,
103 ) -> fidl::Result<()> {
104 encoder.debug_check_bounds::<Self>(offset);
105 encoder.write_num(self.into_primitive(), offset);
106 Ok(())
107 }
108 }
109
110 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Status {
111 #[inline(always)]
112 fn new_empty() -> Self {
113 Self::Ok
114 }
115
116 #[inline]
117 unsafe fn decode(
118 &mut self,
119 decoder: &mut fidl::encoding::Decoder<'_, D>,
120 offset: usize,
121 _depth: fidl::encoding::Depth,
122 ) -> fidl::Result<()> {
123 decoder.debug_check_bounds::<Self>(offset);
124 let prim = decoder.read_num::<u32>(offset);
125
126 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
127 Ok(())
128 }
129 }
130
131 impl fidl::encoding::ValueTypeMarker for RfcommTestDisconnectRequest {
132 type Borrowed<'a> = &'a Self;
133 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
134 value
135 }
136 }
137
138 unsafe impl fidl::encoding::TypeMarker for RfcommTestDisconnectRequest {
139 type Owned = Self;
140
141 #[inline(always)]
142 fn inline_align(_context: fidl::encoding::Context) -> usize {
143 8
144 }
145
146 #[inline(always)]
147 fn inline_size(_context: fidl::encoding::Context) -> usize {
148 8
149 }
150 }
151
152 unsafe impl<D: fidl::encoding::ResourceDialect>
153 fidl::encoding::Encode<RfcommTestDisconnectRequest, D> for &RfcommTestDisconnectRequest
154 {
155 #[inline]
156 unsafe fn encode(
157 self,
158 encoder: &mut fidl::encoding::Encoder<'_, D>,
159 offset: usize,
160 _depth: fidl::encoding::Depth,
161 ) -> fidl::Result<()> {
162 encoder.debug_check_bounds::<RfcommTestDisconnectRequest>(offset);
163 fidl::encoding::Encode::<RfcommTestDisconnectRequest, D>::encode(
165 (
166 <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
167 ),
168 encoder, offset, _depth
169 )
170 }
171 }
172 unsafe impl<
173 D: fidl::encoding::ResourceDialect,
174 T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth__common::PeerId, D>,
175 > fidl::encoding::Encode<RfcommTestDisconnectRequest, D> for (T0,)
176 {
177 #[inline]
178 unsafe fn encode(
179 self,
180 encoder: &mut fidl::encoding::Encoder<'_, D>,
181 offset: usize,
182 depth: fidl::encoding::Depth,
183 ) -> fidl::Result<()> {
184 encoder.debug_check_bounds::<RfcommTestDisconnectRequest>(offset);
185 self.0.encode(encoder, offset + 0, depth)?;
189 Ok(())
190 }
191 }
192
193 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
194 for RfcommTestDisconnectRequest
195 {
196 #[inline(always)]
197 fn new_empty() -> Self {
198 Self { id: fidl::new_empty!(fidl_fuchsia_bluetooth__common::PeerId, D) }
199 }
200
201 #[inline]
202 unsafe fn decode(
203 &mut self,
204 decoder: &mut fidl::encoding::Decoder<'_, D>,
205 offset: usize,
206 _depth: fidl::encoding::Depth,
207 ) -> fidl::Result<()> {
208 decoder.debug_check_bounds::<Self>(offset);
209 fidl::decode!(
211 fidl_fuchsia_bluetooth__common::PeerId,
212 D,
213 &mut self.id,
214 decoder,
215 offset + 0,
216 _depth
217 )?;
218 Ok(())
219 }
220 }
221
222 impl fidl::encoding::ValueTypeMarker for RfcommTestRemoteLineStatusRequest {
223 type Borrowed<'a> = &'a Self;
224 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
225 value
226 }
227 }
228
229 unsafe impl fidl::encoding::TypeMarker for RfcommTestRemoteLineStatusRequest {
230 type Owned = Self;
231
232 #[inline(always)]
233 fn inline_align(_context: fidl::encoding::Context) -> usize {
234 8
235 }
236
237 #[inline(always)]
238 fn inline_size(_context: fidl::encoding::Context) -> usize {
239 16
240 }
241 }
242
243 unsafe impl<D: fidl::encoding::ResourceDialect>
244 fidl::encoding::Encode<RfcommTestRemoteLineStatusRequest, D>
245 for &RfcommTestRemoteLineStatusRequest
246 {
247 #[inline]
248 unsafe fn encode(
249 self,
250 encoder: &mut fidl::encoding::Encoder<'_, D>,
251 offset: usize,
252 _depth: fidl::encoding::Depth,
253 ) -> fidl::Result<()> {
254 encoder.debug_check_bounds::<RfcommTestRemoteLineStatusRequest>(offset);
255 fidl::encoding::Encode::<RfcommTestRemoteLineStatusRequest, D>::encode(
257 (
258 <fidl_fuchsia_bluetooth__common::PeerId as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
259 <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.channel_number),
260 <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
261 ),
262 encoder, offset, _depth
263 )
264 }
265 }
266 unsafe impl<
267 D: fidl::encoding::ResourceDialect,
268 T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth__common::PeerId, D>,
269 T1: fidl::encoding::Encode<u8, D>,
270 T2: fidl::encoding::Encode<Status, D>,
271 > fidl::encoding::Encode<RfcommTestRemoteLineStatusRequest, D> for (T0, T1, T2)
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::<RfcommTestRemoteLineStatusRequest>(offset);
281 unsafe {
284 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
285 (ptr as *mut u64).write_unaligned(0);
286 }
287 self.0.encode(encoder, offset + 0, depth)?;
289 self.1.encode(encoder, offset + 8, depth)?;
290 self.2.encode(encoder, offset + 12, depth)?;
291 Ok(())
292 }
293 }
294
295 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
296 for RfcommTestRemoteLineStatusRequest
297 {
298 #[inline(always)]
299 fn new_empty() -> Self {
300 Self {
301 id: fidl::new_empty!(fidl_fuchsia_bluetooth__common::PeerId, D),
302 channel_number: fidl::new_empty!(u8, D),
303 status: fidl::new_empty!(Status, D),
304 }
305 }
306
307 #[inline]
308 unsafe fn decode(
309 &mut self,
310 decoder: &mut fidl::encoding::Decoder<'_, D>,
311 offset: usize,
312 _depth: fidl::encoding::Depth,
313 ) -> fidl::Result<()> {
314 decoder.debug_check_bounds::<Self>(offset);
315 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
317 let padval = unsafe { (ptr as *const u64).read_unaligned() };
318 let mask = 0xffffff00u64;
319 let maskedval = padval & mask;
320 if maskedval != 0 {
321 return Err(fidl::Error::NonZeroPadding {
322 padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
323 });
324 }
325 fidl::decode!(
326 fidl_fuchsia_bluetooth__common::PeerId,
327 D,
328 &mut self.id,
329 decoder,
330 offset + 0,
331 _depth
332 )?;
333 fidl::decode!(u8, D, &mut self.channel_number, decoder, offset + 8, _depth)?;
334 fidl::decode!(Status, D, &mut self.status, decoder, offset + 12, _depth)?;
335 Ok(())
336 }
337 }
338}