fidl_cf_sc_internal_httpsdateconfig_common/
fidl_cf_sc_internal_httpsdateconfig_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 first_rtt_time_factor: u16,
14    pub https_timeout_sec: u8,
15    pub max_attempts_urgency_high: u32,
16    pub max_attempts_urgency_low: u32,
17    pub max_attempts_urgency_medium: u32,
18    pub num_polls_urgency_high: u32,
19    pub num_polls_urgency_low: u32,
20    pub num_polls_urgency_medium: u32,
21    pub standard_deviation_bound_percentage: u8,
22    pub time_source_endpoint_url: String,
23    pub use_pull_api: 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            56
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                    <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.first_rtt_time_factor),
65                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.https_timeout_sec),
66                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_attempts_urgency_high),
67                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_attempts_urgency_low),
68                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_attempts_urgency_medium),
69                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_polls_urgency_high),
70                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_polls_urgency_low),
71                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.num_polls_urgency_medium),
72                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.standard_deviation_bound_percentage),
73                    <fidl::encoding::BoundedString<1024> as fidl::encoding::ValueTypeMarker>::borrow(&self.time_source_endpoint_url),
74                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.use_pull_api),
75                ),
76                encoder, offset, _depth
77            )
78        }
79    }
80    unsafe impl<
81            D: fidl::encoding::ResourceDialect,
82            T0: fidl::encoding::Encode<u16, D>,
83            T1: fidl::encoding::Encode<u8, D>,
84            T2: fidl::encoding::Encode<u32, D>,
85            T3: fidl::encoding::Encode<u32, D>,
86            T4: fidl::encoding::Encode<u32, D>,
87            T5: fidl::encoding::Encode<u32, D>,
88            T6: fidl::encoding::Encode<u32, D>,
89            T7: fidl::encoding::Encode<u32, D>,
90            T8: fidl::encoding::Encode<u8, D>,
91            T9: fidl::encoding::Encode<fidl::encoding::BoundedString<1024>, D>,
92            T10: fidl::encoding::Encode<bool, D>,
93        > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
94    {
95        #[inline]
96        unsafe fn encode(
97            self,
98            encoder: &mut fidl::encoding::Encoder<'_, D>,
99            offset: usize,
100            depth: fidl::encoding::Depth,
101        ) -> fidl::Result<()> {
102            encoder.debug_check_bounds::<Config>(offset);
103            // Zero out padding regions. There's no need to apply masks
104            // because the unmasked parts will be overwritten by fields.
105            unsafe {
106                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
107                (ptr as *mut u64).write_unaligned(0);
108            }
109            unsafe {
110                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
111                (ptr as *mut u64).write_unaligned(0);
112            }
113            unsafe {
114                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
115                (ptr as *mut u64).write_unaligned(0);
116            }
117            // Write the fields.
118            self.0.encode(encoder, offset + 0, depth)?;
119            self.1.encode(encoder, offset + 2, depth)?;
120            self.2.encode(encoder, offset + 4, depth)?;
121            self.3.encode(encoder, offset + 8, depth)?;
122            self.4.encode(encoder, offset + 12, depth)?;
123            self.5.encode(encoder, offset + 16, depth)?;
124            self.6.encode(encoder, offset + 20, depth)?;
125            self.7.encode(encoder, offset + 24, depth)?;
126            self.8.encode(encoder, offset + 28, depth)?;
127            self.9.encode(encoder, offset + 32, depth)?;
128            self.10.encode(encoder, offset + 48, depth)?;
129            Ok(())
130        }
131    }
132
133    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
134        #[inline(always)]
135        fn new_empty() -> Self {
136            Self {
137                first_rtt_time_factor: fidl::new_empty!(u16, D),
138                https_timeout_sec: fidl::new_empty!(u8, D),
139                max_attempts_urgency_high: fidl::new_empty!(u32, D),
140                max_attempts_urgency_low: fidl::new_empty!(u32, D),
141                max_attempts_urgency_medium: fidl::new_empty!(u32, D),
142                num_polls_urgency_high: fidl::new_empty!(u32, D),
143                num_polls_urgency_low: fidl::new_empty!(u32, D),
144                num_polls_urgency_medium: fidl::new_empty!(u32, D),
145                standard_deviation_bound_percentage: fidl::new_empty!(u8, D),
146                time_source_endpoint_url: fidl::new_empty!(fidl::encoding::BoundedString<1024>, D),
147                use_pull_api: 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 = 0xff000000u64;
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 = 0xffffff0000000000u64;
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            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
179            let padval = unsafe { (ptr as *const u64).read_unaligned() };
180            let mask = 0xffffffffffffff00u64;
181            let maskedval = padval & mask;
182            if maskedval != 0 {
183                return Err(fidl::Error::NonZeroPadding {
184                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
185                });
186            }
187            fidl::decode!(u16, D, &mut self.first_rtt_time_factor, decoder, offset + 0, _depth)?;
188            fidl::decode!(u8, D, &mut self.https_timeout_sec, decoder, offset + 2, _depth)?;
189            fidl::decode!(
190                u32,
191                D,
192                &mut self.max_attempts_urgency_high,
193                decoder,
194                offset + 4,
195                _depth
196            )?;
197            fidl::decode!(u32, D, &mut self.max_attempts_urgency_low, decoder, offset + 8, _depth)?;
198            fidl::decode!(
199                u32,
200                D,
201                &mut self.max_attempts_urgency_medium,
202                decoder,
203                offset + 12,
204                _depth
205            )?;
206            fidl::decode!(u32, D, &mut self.num_polls_urgency_high, decoder, offset + 16, _depth)?;
207            fidl::decode!(u32, D, &mut self.num_polls_urgency_low, decoder, offset + 20, _depth)?;
208            fidl::decode!(
209                u32,
210                D,
211                &mut self.num_polls_urgency_medium,
212                decoder,
213                offset + 24,
214                _depth
215            )?;
216            fidl::decode!(
217                u8,
218                D,
219                &mut self.standard_deviation_bound_percentage,
220                decoder,
221                offset + 28,
222                _depth
223            )?;
224            fidl::decode!(
225                fidl::encoding::BoundedString<1024>,
226                D,
227                &mut self.time_source_endpoint_url,
228                decoder,
229                offset + 32,
230                _depth
231            )?;
232            fidl::decode!(bool, D, &mut self.use_pull_api, decoder, offset + 48, _depth)?;
233            Ok(())
234        }
235    }
236}