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