Skip to main content

fidl_cf_sc_internal_hfpprofileconfig_common/
fidl_cf_sc_internal_hfpprofileconfig_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 attach_phone_number_to_voice_tag: bool,
14    pub controller_encoding_cvsd: bool,
15    pub controller_encoding_msbc: bool,
16    pub echo_canceling_and_noise_reduction: bool,
17    pub enhanced_call_controls: bool,
18    pub offload_type: String,
19    pub reject_incoming_voice_call: bool,
20    pub three_way_calling: bool,
21    pub wide_band_speech: bool,
22}
23
24impl fidl::Persistable for Config {}
25
26mod internal {
27    use super::*;
28
29    impl fidl::encoding::ValueTypeMarker for Config {
30        type Borrowed<'a> = &'a Self;
31        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
32            value
33        }
34    }
35
36    unsafe impl fidl::encoding::TypeMarker for Config {
37        type Owned = Self;
38
39        #[inline(always)]
40        fn inline_align(_context: fidl::encoding::Context) -> usize {
41            8
42        }
43
44        #[inline(always)]
45        fn inline_size(_context: fidl::encoding::Context) -> usize {
46            32
47        }
48    }
49
50    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
51        #[inline]
52        unsafe fn encode(
53            self,
54            encoder: &mut fidl::encoding::Encoder<'_, D>,
55            offset: usize,
56            _depth: fidl::encoding::Depth,
57        ) -> fidl::Result<()> {
58            encoder.debug_check_bounds::<Config>(offset);
59            // Delegate to tuple encoding.
60            fidl::encoding::Encode::<Config, D>::encode(
61                (
62                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
63                        &self.attach_phone_number_to_voice_tag,
64                    ),
65                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
66                        &self.controller_encoding_cvsd,
67                    ),
68                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
69                        &self.controller_encoding_msbc,
70                    ),
71                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
72                        &self.echo_canceling_and_noise_reduction,
73                    ),
74                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.enhanced_call_controls),
75                    <fidl::encoding::BoundedString<8> as fidl::encoding::ValueTypeMarker>::borrow(
76                        &self.offload_type,
77                    ),
78                    <bool as fidl::encoding::ValueTypeMarker>::borrow(
79                        &self.reject_incoming_voice_call,
80                    ),
81                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.three_way_calling),
82                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.wide_band_speech),
83                ),
84                encoder,
85                offset,
86                _depth,
87            )
88        }
89    }
90    unsafe impl<
91        D: fidl::encoding::ResourceDialect,
92        T0: fidl::encoding::Encode<bool, D>,
93        T1: fidl::encoding::Encode<bool, D>,
94        T2: fidl::encoding::Encode<bool, D>,
95        T3: fidl::encoding::Encode<bool, D>,
96        T4: fidl::encoding::Encode<bool, D>,
97        T5: fidl::encoding::Encode<fidl::encoding::BoundedString<8>, D>,
98        T6: fidl::encoding::Encode<bool, D>,
99        T7: fidl::encoding::Encode<bool, D>,
100        T8: fidl::encoding::Encode<bool, D>,
101    > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8)
102    {
103        #[inline]
104        unsafe fn encode(
105            self,
106            encoder: &mut fidl::encoding::Encoder<'_, D>,
107            offset: usize,
108            depth: fidl::encoding::Depth,
109        ) -> fidl::Result<()> {
110            encoder.debug_check_bounds::<Config>(offset);
111            // Zero out padding regions. There's no need to apply masks
112            // because the unmasked parts will be overwritten by fields.
113            unsafe {
114                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
115                (ptr as *mut u64).write_unaligned(0);
116            }
117            unsafe {
118                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
119                (ptr as *mut u64).write_unaligned(0);
120            }
121            // Write the fields.
122            self.0.encode(encoder, offset + 0, depth)?;
123            self.1.encode(encoder, offset + 1, depth)?;
124            self.2.encode(encoder, offset + 2, depth)?;
125            self.3.encode(encoder, offset + 3, depth)?;
126            self.4.encode(encoder, offset + 4, depth)?;
127            self.5.encode(encoder, offset + 8, depth)?;
128            self.6.encode(encoder, offset + 24, depth)?;
129            self.7.encode(encoder, offset + 25, depth)?;
130            self.8.encode(encoder, offset + 26, depth)?;
131            Ok(())
132        }
133    }
134
135    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
136        #[inline(always)]
137        fn new_empty() -> Self {
138            Self {
139                attach_phone_number_to_voice_tag: fidl::new_empty!(bool, D),
140                controller_encoding_cvsd: fidl::new_empty!(bool, D),
141                controller_encoding_msbc: fidl::new_empty!(bool, D),
142                echo_canceling_and_noise_reduction: fidl::new_empty!(bool, D),
143                enhanced_call_controls: fidl::new_empty!(bool, D),
144                offload_type: fidl::new_empty!(fidl::encoding::BoundedString<8>, D),
145                reject_incoming_voice_call: fidl::new_empty!(bool, D),
146                three_way_calling: fidl::new_empty!(bool, D),
147                wide_band_speech: fidl::new_empty!(bool, D),
148            }
149        }
150
151        #[inline]
152        unsafe fn decode(
153            &mut self,
154            decoder: &mut fidl::encoding::Decoder<'_, D>,
155            offset: usize,
156            _depth: fidl::encoding::Depth,
157        ) -> fidl::Result<()> {
158            decoder.debug_check_bounds::<Self>(offset);
159            // Verify that padding bytes are zero.
160            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
161            let padval = unsafe { (ptr as *const u64).read_unaligned() };
162            let mask = 0xffffff0000000000u64;
163            let maskedval = padval & mask;
164            if maskedval != 0 {
165                return Err(fidl::Error::NonZeroPadding {
166                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
167                });
168            }
169            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
170            let padval = unsafe { (ptr as *const u64).read_unaligned() };
171            let mask = 0xffffffffff000000u64;
172            let maskedval = padval & mask;
173            if maskedval != 0 {
174                return Err(fidl::Error::NonZeroPadding {
175                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
176                });
177            }
178            fidl::decode!(
179                bool,
180                D,
181                &mut self.attach_phone_number_to_voice_tag,
182                decoder,
183                offset + 0,
184                _depth
185            )?;
186            fidl::decode!(
187                bool,
188                D,
189                &mut self.controller_encoding_cvsd,
190                decoder,
191                offset + 1,
192                _depth
193            )?;
194            fidl::decode!(
195                bool,
196                D,
197                &mut self.controller_encoding_msbc,
198                decoder,
199                offset + 2,
200                _depth
201            )?;
202            fidl::decode!(
203                bool,
204                D,
205                &mut self.echo_canceling_and_noise_reduction,
206                decoder,
207                offset + 3,
208                _depth
209            )?;
210            fidl::decode!(bool, D, &mut self.enhanced_call_controls, decoder, offset + 4, _depth)?;
211            fidl::decode!(
212                fidl::encoding::BoundedString<8>,
213                D,
214                &mut self.offload_type,
215                decoder,
216                offset + 8,
217                _depth
218            )?;
219            fidl::decode!(
220                bool,
221                D,
222                &mut self.reject_incoming_voice_call,
223                decoder,
224                offset + 24,
225                _depth
226            )?;
227            fidl::decode!(bool, D, &mut self.three_way_calling, decoder, offset + 25, _depth)?;
228            fidl::decode!(bool, D, &mut self.wide_band_speech, decoder, offset + 26, _depth)?;
229            Ok(())
230        }
231    }
232}