fidl_cf_sc_internal_btgapconfig_common/
fidl_cf_sc_internal_btgapconfig_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 bredr_connectable: bool,
14 pub bredr_security_mode: String,
15 pub le_background_scanning: bool,
16 pub le_privacy: bool,
17 pub le_security_mode: String,
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 48
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.bredr_connectable),
59 <fidl::encoding::BoundedString<21> as fidl::encoding::ValueTypeMarker>::borrow(
60 &self.bredr_security_mode,
61 ),
62 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.le_background_scanning),
63 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.le_privacy),
64 <fidl::encoding::BoundedString<21> as fidl::encoding::ValueTypeMarker>::borrow(
65 &self.le_security_mode,
66 ),
67 ),
68 encoder,
69 offset,
70 _depth,
71 )
72 }
73 }
74 unsafe impl<
75 D: fidl::encoding::ResourceDialect,
76 T0: fidl::encoding::Encode<bool, D>,
77 T1: fidl::encoding::Encode<fidl::encoding::BoundedString<21>, D>,
78 T2: fidl::encoding::Encode<bool, D>,
79 T3: fidl::encoding::Encode<bool, D>,
80 T4: fidl::encoding::Encode<fidl::encoding::BoundedString<21>, D>,
81 > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4)
82 {
83 #[inline]
84 unsafe fn encode(
85 self,
86 encoder: &mut fidl::encoding::Encoder<'_, D>,
87 offset: usize,
88 depth: fidl::encoding::Depth,
89 ) -> fidl::Result<()> {
90 encoder.debug_check_bounds::<Config>(offset);
91 unsafe {
94 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
95 (ptr as *mut u64).write_unaligned(0);
96 }
97 unsafe {
98 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
99 (ptr as *mut u64).write_unaligned(0);
100 }
101 self.0.encode(encoder, offset + 0, depth)?;
103 self.1.encode(encoder, offset + 8, depth)?;
104 self.2.encode(encoder, offset + 24, depth)?;
105 self.3.encode(encoder, offset + 25, depth)?;
106 self.4.encode(encoder, offset + 32, depth)?;
107 Ok(())
108 }
109 }
110
111 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
112 #[inline(always)]
113 fn new_empty() -> Self {
114 Self {
115 bredr_connectable: fidl::new_empty!(bool, D),
116 bredr_security_mode: fidl::new_empty!(fidl::encoding::BoundedString<21>, D),
117 le_background_scanning: fidl::new_empty!(bool, D),
118 le_privacy: fidl::new_empty!(bool, D),
119 le_security_mode: fidl::new_empty!(fidl::encoding::BoundedString<21>, D),
120 }
121 }
122
123 #[inline]
124 unsafe fn decode(
125 &mut self,
126 decoder: &mut fidl::encoding::Decoder<'_, D>,
127 offset: usize,
128 _depth: fidl::encoding::Depth,
129 ) -> fidl::Result<()> {
130 decoder.debug_check_bounds::<Self>(offset);
131 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
133 let padval = unsafe { (ptr as *const u64).read_unaligned() };
134 let mask = 0xffffffffffffff00u64;
135 let maskedval = padval & mask;
136 if maskedval != 0 {
137 return Err(fidl::Error::NonZeroPadding {
138 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
139 });
140 }
141 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
142 let padval = unsafe { (ptr as *const u64).read_unaligned() };
143 let mask = 0xffffffffffff0000u64;
144 let maskedval = padval & mask;
145 if maskedval != 0 {
146 return Err(fidl::Error::NonZeroPadding {
147 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
148 });
149 }
150 fidl::decode!(bool, D, &mut self.bredr_connectable, decoder, offset + 0, _depth)?;
151 fidl::decode!(
152 fidl::encoding::BoundedString<21>,
153 D,
154 &mut self.bredr_security_mode,
155 decoder,
156 offset + 8,
157 _depth
158 )?;
159 fidl::decode!(bool, D, &mut self.le_background_scanning, decoder, offset + 24, _depth)?;
160 fidl::decode!(bool, D, &mut self.le_privacy, decoder, offset + 25, _depth)?;
161 fidl::decode!(
162 fidl::encoding::BoundedString<21>,
163 D,
164 &mut self.le_security_mode,
165 decoder,
166 offset + 32,
167 _depth
168 )?;
169 Ok(())
170 }
171 }
172}