fidl_cf_sc_internal_btdeviceidprofileconfig_common/
fidl_cf_sc_internal_btdeviceidprofileconfig_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(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13 pub primary: bool,
14 pub product_id: u16,
15 pub service_description: String,
16 pub vendor_id: u16,
17 pub version: u16,
18}
19
20impl fidl::Persistable for Config {}
21
22mod internal {
23 use super::*;
24
25 impl fidl::encoding::ValueTypeMarker for Config {
26 type Borrowed<'a> = &'a Self;
27 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
28 value
29 }
30 }
31
32 unsafe impl fidl::encoding::TypeMarker for Config {
33 type Owned = Self;
34
35 #[inline(always)]
36 fn inline_align(_context: fidl::encoding::Context) -> usize {
37 8
38 }
39
40 #[inline(always)]
41 fn inline_size(_context: fidl::encoding::Context) -> usize {
42 32
43 }
44 }
45
46 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
47 #[inline]
48 unsafe fn encode(
49 self,
50 encoder: &mut fidl::encoding::Encoder<'_, D>,
51 offset: usize,
52 _depth: fidl::encoding::Depth,
53 ) -> fidl::Result<()> {
54 encoder.debug_check_bounds::<Config>(offset);
55 fidl::encoding::Encode::<Config, D>::encode(
57 (
58 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.primary),
59 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.product_id),
60 <fidl::encoding::BoundedString<200> as fidl::encoding::ValueTypeMarker>::borrow(
61 &self.service_description,
62 ),
63 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.vendor_id),
64 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.version),
65 ),
66 encoder,
67 offset,
68 _depth,
69 )
70 }
71 }
72 unsafe impl<
73 D: fidl::encoding::ResourceDialect,
74 T0: fidl::encoding::Encode<bool, D>,
75 T1: fidl::encoding::Encode<u16, D>,
76 T2: fidl::encoding::Encode<fidl::encoding::BoundedString<200>, D>,
77 T3: fidl::encoding::Encode<u16, D>,
78 T4: fidl::encoding::Encode<u16, D>,
79 > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4)
80 {
81 #[inline]
82 unsafe fn encode(
83 self,
84 encoder: &mut fidl::encoding::Encoder<'_, D>,
85 offset: usize,
86 depth: fidl::encoding::Depth,
87 ) -> fidl::Result<()> {
88 encoder.debug_check_bounds::<Config>(offset);
89 unsafe {
92 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
93 (ptr as *mut u64).write_unaligned(0);
94 }
95 unsafe {
96 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
97 (ptr as *mut u64).write_unaligned(0);
98 }
99 self.0.encode(encoder, offset + 0, depth)?;
101 self.1.encode(encoder, offset + 2, depth)?;
102 self.2.encode(encoder, offset + 8, depth)?;
103 self.3.encode(encoder, offset + 24, depth)?;
104 self.4.encode(encoder, offset + 26, depth)?;
105 Ok(())
106 }
107 }
108
109 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
110 #[inline(always)]
111 fn new_empty() -> Self {
112 Self {
113 primary: fidl::new_empty!(bool, D),
114 product_id: fidl::new_empty!(u16, D),
115 service_description: fidl::new_empty!(fidl::encoding::BoundedString<200>, D),
116 vendor_id: fidl::new_empty!(u16, D),
117 version: fidl::new_empty!(u16, D),
118 }
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 ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
131 let padval = unsafe { (ptr as *const u64).read_unaligned() };
132 let mask = 0xffffffff0000ff00u64;
133 let maskedval = padval & mask;
134 if maskedval != 0 {
135 return Err(fidl::Error::NonZeroPadding {
136 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
137 });
138 }
139 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
140 let padval = unsafe { (ptr as *const u64).read_unaligned() };
141 let mask = 0xffffffff00000000u64;
142 let maskedval = padval & mask;
143 if maskedval != 0 {
144 return Err(fidl::Error::NonZeroPadding {
145 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
146 });
147 }
148 fidl::decode!(bool, D, &mut self.primary, decoder, offset + 0, _depth)?;
149 fidl::decode!(u16, D, &mut self.product_id, decoder, offset + 2, _depth)?;
150 fidl::decode!(
151 fidl::encoding::BoundedString<200>,
152 D,
153 &mut self.service_description,
154 decoder,
155 offset + 8,
156 _depth
157 )?;
158 fidl::decode!(u16, D, &mut self.vendor_id, decoder, offset + 24, _depth)?;
159 fidl::decode!(u16, D, &mut self.version, decoder, offset + 26, _depth)?;
160 Ok(())
161 }
162 }
163}