fidl_cf_sc_internal_persistencebuildconfig_common/
fidl_cf_sc_internal_persistencebuildconfig_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, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
12pub struct Config {
13 pub enable_shutdown_snapshot: bool,
14 pub low_battery_threshold_percent: u64,
15 pub persistence_period_seconds: i64,
16 pub skip_update_check: bool,
17 pub stop_on_idle_timeout_millis: i64,
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 40
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(
59 &self.enable_shutdown_snapshot,
60 ),
61 <u64 as fidl::encoding::ValueTypeMarker>::borrow(
62 &self.low_battery_threshold_percent,
63 ),
64 <i64 as fidl::encoding::ValueTypeMarker>::borrow(
65 &self.persistence_period_seconds,
66 ),
67 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.skip_update_check),
68 <i64 as fidl::encoding::ValueTypeMarker>::borrow(
69 &self.stop_on_idle_timeout_millis,
70 ),
71 ),
72 encoder,
73 offset,
74 _depth,
75 )
76 }
77 }
78 unsafe impl<
79 D: fidl::encoding::ResourceDialect,
80 T0: fidl::encoding::Encode<bool, D>,
81 T1: fidl::encoding::Encode<u64, D>,
82 T2: fidl::encoding::Encode<i64, D>,
83 T3: fidl::encoding::Encode<bool, D>,
84 T4: fidl::encoding::Encode<i64, D>,
85 > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3, T4)
86 {
87 #[inline]
88 unsafe fn encode(
89 self,
90 encoder: &mut fidl::encoding::Encoder<'_, D>,
91 offset: usize,
92 depth: fidl::encoding::Depth,
93 ) -> fidl::Result<()> {
94 encoder.debug_check_bounds::<Config>(offset);
95 unsafe {
98 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
99 (ptr as *mut u64).write_unaligned(0);
100 }
101 unsafe {
102 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
103 (ptr as *mut u64).write_unaligned(0);
104 }
105 self.0.encode(encoder, offset + 0, depth)?;
107 self.1.encode(encoder, offset + 8, depth)?;
108 self.2.encode(encoder, offset + 16, depth)?;
109 self.3.encode(encoder, offset + 24, depth)?;
110 self.4.encode(encoder, offset + 32, depth)?;
111 Ok(())
112 }
113 }
114
115 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
116 #[inline(always)]
117 fn new_empty() -> Self {
118 Self {
119 enable_shutdown_snapshot: fidl::new_empty!(bool, D),
120 low_battery_threshold_percent: fidl::new_empty!(u64, D),
121 persistence_period_seconds: fidl::new_empty!(i64, D),
122 skip_update_check: fidl::new_empty!(bool, D),
123 stop_on_idle_timeout_millis: fidl::new_empty!(i64, D),
124 }
125 }
126
127 #[inline]
128 unsafe fn decode(
129 &mut self,
130 decoder: &mut fidl::encoding::Decoder<'_, D>,
131 offset: usize,
132 _depth: fidl::encoding::Depth,
133 ) -> fidl::Result<()> {
134 decoder.debug_check_bounds::<Self>(offset);
135 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
137 let padval = unsafe { (ptr as *const u64).read_unaligned() };
138 let mask = 0xffffffffffffff00u64;
139 let maskedval = padval & mask;
140 if maskedval != 0 {
141 return Err(fidl::Error::NonZeroPadding {
142 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
143 });
144 }
145 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
146 let padval = unsafe { (ptr as *const u64).read_unaligned() };
147 let mask = 0xffffffffffffff00u64;
148 let maskedval = padval & mask;
149 if maskedval != 0 {
150 return Err(fidl::Error::NonZeroPadding {
151 padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
152 });
153 }
154 fidl::decode!(
155 bool,
156 D,
157 &mut self.enable_shutdown_snapshot,
158 decoder,
159 offset + 0,
160 _depth
161 )?;
162 fidl::decode!(
163 u64,
164 D,
165 &mut self.low_battery_threshold_percent,
166 decoder,
167 offset + 8,
168 _depth
169 )?;
170 fidl::decode!(
171 i64,
172 D,
173 &mut self.persistence_period_seconds,
174 decoder,
175 offset + 16,
176 _depth
177 )?;
178 fidl::decode!(bool, D, &mut self.skip_update_check, decoder, offset + 24, _depth)?;
179 fidl::decode!(
180 i64,
181 D,
182 &mut self.stop_on_idle_timeout_millis,
183 decoder,
184 offset + 32,
185 _depth
186 )?;
187 Ok(())
188 }
189 }
190}