Skip to main content

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