fidl_cf_sc_internal_brightnessmanagerconfig_common/
fidl_cf_sc_internal_brightnessmanagerconfig_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 manage_display_power: bool,
14 pub power_off_delay_millis: u16,
15 pub power_on_delay_millis: u16,
16}
17
18impl fidl::Persistable for Config {}
19
20mod internal {
21 use super::*;
22
23 impl fidl::encoding::ValueTypeMarker for Config {
24 type Borrowed<'a> = &'a Self;
25 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
26 value
27 }
28 }
29
30 unsafe impl fidl::encoding::TypeMarker for Config {
31 type Owned = Self;
32
33 #[inline(always)]
34 fn inline_align(_context: fidl::encoding::Context) -> usize {
35 2
36 }
37
38 #[inline(always)]
39 fn inline_size(_context: fidl::encoding::Context) -> usize {
40 6
41 }
42 }
43
44 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
45 #[inline]
46 unsafe fn encode(
47 self,
48 encoder: &mut fidl::encoding::Encoder<'_, D>,
49 offset: usize,
50 _depth: fidl::encoding::Depth,
51 ) -> fidl::Result<()> {
52 encoder.debug_check_bounds::<Config>(offset);
53 fidl::encoding::Encode::<Config, D>::encode(
55 (
56 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.manage_display_power),
57 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.power_off_delay_millis),
58 <u16 as fidl::encoding::ValueTypeMarker>::borrow(&self.power_on_delay_millis),
59 ),
60 encoder,
61 offset,
62 _depth,
63 )
64 }
65 }
66 unsafe impl<
67 D: fidl::encoding::ResourceDialect,
68 T0: fidl::encoding::Encode<bool, D>,
69 T1: fidl::encoding::Encode<u16, D>,
70 T2: fidl::encoding::Encode<u16, D>,
71 > fidl::encoding::Encode<Config, D> for (T0, T1, T2)
72 {
73 #[inline]
74 unsafe fn encode(
75 self,
76 encoder: &mut fidl::encoding::Encoder<'_, D>,
77 offset: usize,
78 depth: fidl::encoding::Depth,
79 ) -> fidl::Result<()> {
80 encoder.debug_check_bounds::<Config>(offset);
81 unsafe {
84 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
85 (ptr as *mut u16).write_unaligned(0);
86 }
87 self.0.encode(encoder, offset + 0, depth)?;
89 self.1.encode(encoder, offset + 2, depth)?;
90 self.2.encode(encoder, offset + 4, depth)?;
91 Ok(())
92 }
93 }
94
95 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
96 #[inline(always)]
97 fn new_empty() -> Self {
98 Self {
99 manage_display_power: fidl::new_empty!(bool, D),
100 power_off_delay_millis: fidl::new_empty!(u16, D),
101 power_on_delay_millis: fidl::new_empty!(u16, D),
102 }
103 }
104
105 #[inline]
106 unsafe fn decode(
107 &mut self,
108 decoder: &mut fidl::encoding::Decoder<'_, D>,
109 offset: usize,
110 _depth: fidl::encoding::Depth,
111 ) -> fidl::Result<()> {
112 decoder.debug_check_bounds::<Self>(offset);
113 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
115 let padval = unsafe { (ptr as *const u16).read_unaligned() };
116 let mask = 0xff00u16;
117 let maskedval = padval & mask;
118 if maskedval != 0 {
119 return Err(fidl::Error::NonZeroPadding {
120 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
121 });
122 }
123 fidl::decode!(bool, D, &mut self.manage_display_power, decoder, offset + 0, _depth)?;
124 fidl::decode!(u16, D, &mut self.power_off_delay_millis, decoder, offset + 2, _depth)?;
125 fidl::decode!(u16, D, &mut self.power_on_delay_millis, decoder, offset + 4, _depth)?;
126 Ok(())
127 }
128 }
129}