fidl_cf_sc_internal_configlib/
fidl_cf_sc_internal_configlib.rs1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct Config {
15 pub echo_bool: bool,
16 pub echo_num: u64,
17 pub echo_string: String,
18 pub echo_string_vector: Vec<String>,
19}
20
21impl fidl::Persistable for Config {}
22
23mod internal {
24 use super::*;
25
26 impl fidl::encoding::ValueTypeMarker for Config {
27 type Borrowed<'a> = &'a Self;
28 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
29 value
30 }
31 }
32
33 unsafe impl fidl::encoding::TypeMarker for Config {
34 type Owned = Self;
35
36 #[inline(always)]
37 fn inline_align(_context: fidl::encoding::Context) -> usize {
38 8
39 }
40
41 #[inline(always)]
42 fn inline_size(_context: fidl::encoding::Context) -> usize {
43 48
44 }
45 }
46
47 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Config, D> for &Config {
48 #[inline]
49 unsafe fn encode(
50 self,
51 encoder: &mut fidl::encoding::Encoder<'_, D>,
52 offset: usize,
53 _depth: fidl::encoding::Depth,
54 ) -> fidl::Result<()> {
55 encoder.debug_check_bounds::<Config>(offset);
56 fidl::encoding::Encode::<Config, D>::encode(
58 (
59 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.echo_bool),
60 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.echo_num),
61 <fidl::encoding::BoundedString<15> as fidl::encoding::ValueTypeMarker>::borrow(&self.echo_string),
62 <fidl::encoding::Vector<fidl::encoding::BoundedString<10>, 2> as fidl::encoding::ValueTypeMarker>::borrow(&self.echo_string_vector),
63 ),
64 encoder, offset, _depth
65 )
66 }
67 }
68 unsafe impl<
69 D: fidl::encoding::ResourceDialect,
70 T0: fidl::encoding::Encode<bool, D>,
71 T1: fidl::encoding::Encode<u64, D>,
72 T2: fidl::encoding::Encode<fidl::encoding::BoundedString<15>, D>,
73 T3: fidl::encoding::Encode<fidl::encoding::Vector<fidl::encoding::BoundedString<10>, 2>, D>,
74 > fidl::encoding::Encode<Config, D> for (T0, T1, T2, T3)
75 {
76 #[inline]
77 unsafe fn encode(
78 self,
79 encoder: &mut fidl::encoding::Encoder<'_, D>,
80 offset: usize,
81 depth: fidl::encoding::Depth,
82 ) -> fidl::Result<()> {
83 encoder.debug_check_bounds::<Config>(offset);
84 unsafe {
87 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
88 (ptr as *mut u64).write_unaligned(0);
89 }
90 self.0.encode(encoder, offset + 0, depth)?;
92 self.1.encode(encoder, offset + 8, depth)?;
93 self.2.encode(encoder, offset + 16, depth)?;
94 self.3.encode(encoder, offset + 32, depth)?;
95 Ok(())
96 }
97 }
98
99 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Config {
100 #[inline(always)]
101 fn new_empty() -> Self {
102 Self {
103 echo_bool: fidl::new_empty!(bool, D),
104 echo_num: fidl::new_empty!(u64, D),
105 echo_string: fidl::new_empty!(fidl::encoding::BoundedString<15>, D),
106 echo_string_vector: fidl::new_empty!(
107 fidl::encoding::Vector<fidl::encoding::BoundedString<10>, 2>,
108 D
109 ),
110 }
111 }
112
113 #[inline]
114 unsafe fn decode(
115 &mut self,
116 decoder: &mut fidl::encoding::Decoder<'_, D>,
117 offset: usize,
118 _depth: fidl::encoding::Depth,
119 ) -> fidl::Result<()> {
120 decoder.debug_check_bounds::<Self>(offset);
121 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
123 let padval = unsafe { (ptr as *const u64).read_unaligned() };
124 let mask = 0xffffffffffffff00u64;
125 let maskedval = padval & mask;
126 if maskedval != 0 {
127 return Err(fidl::Error::NonZeroPadding {
128 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
129 });
130 }
131 fidl::decode!(bool, D, &mut self.echo_bool, decoder, offset + 0, _depth)?;
132 fidl::decode!(u64, D, &mut self.echo_num, decoder, offset + 8, _depth)?;
133 fidl::decode!(
134 fidl::encoding::BoundedString<15>,
135 D,
136 &mut self.echo_string,
137 decoder,
138 offset + 16,
139 _depth
140 )?;
141 fidl::decode!(
142 fidl::encoding::Vector<fidl::encoding::BoundedString<10>, 2>,
143 D,
144 &mut self.echo_string_vector,
145 decoder,
146 offset + 32,
147 _depth
148 )?;
149 Ok(())
150 }
151 }
152}