Skip to main content

fidl_cf_sc_internal_hfphandsfreeprofileconfig__common/
fidl_cf_sc_internal_hfphandsfreeprofileconfig__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, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13    pub call_waiting_or_three_way_calling: bool,
14    pub cli_presentation_capability: bool,
15    pub controller_encoding_cvsd: bool,
16    pub controller_encoding_msbc: bool,
17    pub ec_or_nr: bool,
18    pub enhanced_voice_recognition: bool,
19    pub enhanced_voice_recognition_with_text: bool,
20    pub offload_type: String,
21    pub remote_volume_control: bool,
22    pub voice_recognition_activation: bool,
23    pub wide_band_speech: bool,
24}
25
26impl fidl::Persistable for Config {}
27
28mod internal {
29    use super::*;
30
31    impl fidl::encoding::ValueTypeMarker for Config {
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 Config {
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            32
49        }
50    }
51
52    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
53        #[inline]
54        unsafe fn encode(
55            self,
56            encoder: &mut fidl::encoding::Encoder<'_, D>,
57            offset: usize,
58            _depth: fidl::encoding::Depth,
59        ) -> fidl::Result<()> {
60            encoder.debug_check_bounds::<Config>(offset);
61            // Delegate to tuple encoding.
62            fidl::encoding::Encode::<Config, D>::encode(
63                (
64                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
65                        &self.call_waiting_or_three_way_calling,
66                    ),
67                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
68                        &self.cli_presentation_capability,
69                    ),
70                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
71                        &self.controller_encoding_cvsd,
72                    ),
73                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
74                        &self.controller_encoding_msbc,
75                    ),
76                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.ec_or_nr),
77                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
78                        &self.enhanced_voice_recognition,
79                    ),
80                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
81                        &self.enhanced_voice_recognition_with_text,
82                    ),
83                    <fidl::encoding::BoundedString<8> as fidl::encoding::ValueTypeMarker>::borrow(
84                        &self.offload_type,
85                    ),
86                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.remote_volume_control),
87                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
88                        &self.voice_recognition_activation,
89                    ),
90                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.wide_band_speech),
91                ),
92                encoder,
93                offset,
94                _depth,
95            )
96        }
97    }
98    unsafe impl<
99        D: fidl::encoding::ResourceDialect,
100        T0: fidl::encoding::Encode<bool, D>,
101        T1: fidl::encoding::Encode<bool, D>,
102        T2: fidl::encoding::Encode<bool, D>,
103        T3: fidl::encoding::Encode<bool, D>,
104        T4: fidl::encoding::Encode<bool, D>,
105        T5: fidl::encoding::Encode<bool, D>,
106        T6: fidl::encoding::Encode<bool, D>,
107        T7: fidl::encoding::Encode<fidl::encoding::BoundedString<8>, D>,
108        T8: fidl::encoding::Encode<bool, D>,
109        T9: fidl::encoding::Encode<bool, D>,
110        T10: fidl::encoding::Encode<bool, D>,
111    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
112    {
113        #[inline]
114        unsafe fn encode(
115            self,
116            encoder: &mut fidl::encoding::Encoder<'_, D>,
117            offset: usize,
118            depth: fidl::encoding::Depth,
119        ) -> fidl::Result<()> {
120            encoder.debug_check_bounds::<Config>(offset);
121            // Zero out padding regions. There's no need to apply masks
122            // because the unmasked parts will be overwritten by fields.
123            unsafe {
124                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
125                (ptr as *mut u64).write_unaligned(0);
126            }
127            unsafe {
128                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
129                (ptr as *mut u64).write_unaligned(0);
130            }
131            // Write the fields.
132            self.0.encode(encoder, offset + 0, depth)?;
133            self.1.encode(encoder, offset + 1, depth)?;
134            self.2.encode(encoder, offset + 2, depth)?;
135            self.3.encode(encoder, offset + 3, depth)?;
136            self.4.encode(encoder, offset + 4, depth)?;
137            self.5.encode(encoder, offset + 5, depth)?;
138            self.6.encode(encoder, offset + 6, depth)?;
139            self.7.encode(encoder, offset + 8, depth)?;
140            self.8.encode(encoder, offset + 24, depth)?;
141            self.9.encode(encoder, offset + 25, depth)?;
142            self.10.encode(encoder, offset + 26, depth)?;
143            Ok(())
144        }
145    }
146
147    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
148        #[inline(always)]
149        fn new_empty() -> Self {
150            Self {
151                call_waiting_or_three_way_calling: fidl::new_empty!(bool, D),
152                cli_presentation_capability: fidl::new_empty!(bool, D),
153                controller_encoding_cvsd: fidl::new_empty!(bool, D),
154                controller_encoding_msbc: fidl::new_empty!(bool, D),
155                ec_or_nr: fidl::new_empty!(bool, D),
156                enhanced_voice_recognition: fidl::new_empty!(bool, D),
157                enhanced_voice_recognition_with_text: fidl::new_empty!(bool, D),
158                offload_type: fidl::new_empty!(fidl::encoding::BoundedString<8>, D),
159                remote_volume_control: fidl::new_empty!(bool, D),
160                voice_recognition_activation: fidl::new_empty!(bool, D),
161                wide_band_speech: fidl::new_empty!(bool, D),
162            }
163        }
164
165        #[inline]
166        unsafe fn decode(
167            &mut self,
168            decoder: &mut fidl::encoding::Decoder<'_, D>,
169            offset: usize,
170            _depth: fidl::encoding::Depth,
171        ) -> fidl::Result<()> {
172            decoder.debug_check_bounds::<Self>(offset);
173            // Verify that padding bytes are zero.
174            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
175            let padval = unsafe { (ptr as *const u64).read_unaligned() };
176            let mask = 0xff00000000000000u64;
177            let maskedval = padval & mask;
178            if maskedval != 0 {
179                return Err(fidl::Error::NonZeroPadding {
180                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
181                });
182            }
183            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
184            let padval = unsafe { (ptr as *const u64).read_unaligned() };
185            let mask = 0xffffffffff000000u64;
186            let maskedval = padval & mask;
187            if maskedval != 0 {
188                return Err(fidl::Error::NonZeroPadding {
189                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
190                });
191            }
192            fidl::decode!(
193                bool,
194                D,
195                &mut self.call_waiting_or_three_way_calling,
196                decoder,
197                offset + 0,
198                _depth
199            )?;
200            fidl::decode!(
201                bool,
202                D,
203                &mut self.cli_presentation_capability,
204                decoder,
205                offset + 1,
206                _depth
207            )?;
208            fidl::decode!(
209                bool,
210                D,
211                &mut self.controller_encoding_cvsd,
212                decoder,
213                offset + 2,
214                _depth
215            )?;
216            fidl::decode!(
217                bool,
218                D,
219                &mut self.controller_encoding_msbc,
220                decoder,
221                offset + 3,
222                _depth
223            )?;
224            fidl::decode!(bool, D, &mut self.ec_or_nr, decoder, offset + 4, _depth)?;
225            fidl::decode!(
226                bool,
227                D,
228                &mut self.enhanced_voice_recognition,
229                decoder,
230                offset + 5,
231                _depth
232            )?;
233            fidl::decode!(
234                bool,
235                D,
236                &mut self.enhanced_voice_recognition_with_text,
237                decoder,
238                offset + 6,
239                _depth
240            )?;
241            fidl::decode!(
242                fidl::encoding::BoundedString<8>,
243                D,
244                &mut self.offload_type,
245                decoder,
246                offset + 8,
247                _depth
248            )?;
249            fidl::decode!(bool, D, &mut self.remote_volume_control, decoder, offset + 24, _depth)?;
250            fidl::decode!(
251                bool,
252                D,
253                &mut self.voice_recognition_activation,
254                decoder,
255                offset + 25,
256                _depth
257            )?;
258            fidl::decode!(bool, D, &mut self.wide_band_speech, decoder, offset + 26, _depth)?;
259            Ok(())
260        }
261    }
262}