fidl_fuchsia_power_manager_debug_common/
fidl_fuchsia_power_manager_debug_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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
13pub enum MessageError {
14 Generic,
15 InvalidNodeName,
16 UnsupportedCommand,
17 InvalidCommandArgs,
18 #[doc(hidden)]
19 __SourceBreaking {
20 unknown_ordinal: u32,
21 },
22}
23
24#[macro_export]
26macro_rules! MessageErrorUnknown {
27 () => {
28 _
29 };
30}
31
32impl MessageError {
33 #[inline]
34 pub fn from_primitive(prim: u32) -> Option<Self> {
35 match prim {
36 0 => Some(Self::Generic),
37 1 => Some(Self::InvalidNodeName),
38 2 => Some(Self::UnsupportedCommand),
39 3 => Some(Self::InvalidCommandArgs),
40 _ => None,
41 }
42 }
43
44 #[inline]
45 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
46 match prim {
47 0 => Self::Generic,
48 1 => Self::InvalidNodeName,
49 2 => Self::UnsupportedCommand,
50 3 => Self::InvalidCommandArgs,
51 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
52 }
53 }
54
55 #[inline]
56 pub fn unknown() -> Self {
57 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
58 }
59
60 #[inline]
61 pub const fn into_primitive(self) -> u32 {
62 match self {
63 Self::Generic => 0,
64 Self::InvalidNodeName => 1,
65 Self::UnsupportedCommand => 2,
66 Self::InvalidCommandArgs => 3,
67 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
68 }
69 }
70
71 #[inline]
72 pub fn is_unknown(&self) -> bool {
73 match self {
74 Self::__SourceBreaking { unknown_ordinal: _ } => true,
75 _ => false,
76 }
77 }
78}
79
80#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
81pub struct DebugMessageRequest {
82 pub node_name: String,
83 pub command: String,
84 pub args: Vec<String>,
85}
86
87impl fidl::Persistable for DebugMessageRequest {}
88
89mod internal {
90 use super::*;
91 unsafe impl fidl::encoding::TypeMarker for MessageError {
92 type Owned = Self;
93
94 #[inline(always)]
95 fn inline_align(_context: fidl::encoding::Context) -> usize {
96 std::mem::align_of::<u32>()
97 }
98
99 #[inline(always)]
100 fn inline_size(_context: fidl::encoding::Context) -> usize {
101 std::mem::size_of::<u32>()
102 }
103
104 #[inline(always)]
105 fn encode_is_copy() -> bool {
106 false
107 }
108
109 #[inline(always)]
110 fn decode_is_copy() -> bool {
111 false
112 }
113 }
114
115 impl fidl::encoding::ValueTypeMarker for MessageError {
116 type Borrowed<'a> = Self;
117 #[inline(always)]
118 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
119 *value
120 }
121 }
122
123 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for MessageError {
124 #[inline]
125 unsafe fn encode(
126 self,
127 encoder: &mut fidl::encoding::Encoder<'_, D>,
128 offset: usize,
129 _depth: fidl::encoding::Depth,
130 ) -> fidl::Result<()> {
131 encoder.debug_check_bounds::<Self>(offset);
132 encoder.write_num(self.into_primitive(), offset);
133 Ok(())
134 }
135 }
136
137 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for MessageError {
138 #[inline(always)]
139 fn new_empty() -> Self {
140 Self::unknown()
141 }
142
143 #[inline]
144 unsafe fn decode(
145 &mut self,
146 decoder: &mut fidl::encoding::Decoder<'_, D>,
147 offset: usize,
148 _depth: fidl::encoding::Depth,
149 ) -> fidl::Result<()> {
150 decoder.debug_check_bounds::<Self>(offset);
151 let prim = decoder.read_num::<u32>(offset);
152
153 *self = Self::from_primitive_allow_unknown(prim);
154 Ok(())
155 }
156 }
157
158 impl fidl::encoding::ValueTypeMarker for DebugMessageRequest {
159 type Borrowed<'a> = &'a Self;
160 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
161 value
162 }
163 }
164
165 unsafe impl fidl::encoding::TypeMarker for DebugMessageRequest {
166 type Owned = Self;
167
168 #[inline(always)]
169 fn inline_align(_context: fidl::encoding::Context) -> usize {
170 8
171 }
172
173 #[inline(always)]
174 fn inline_size(_context: fidl::encoding::Context) -> usize {
175 48
176 }
177 }
178
179 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DebugMessageRequest, D>
180 for &DebugMessageRequest
181 {
182 #[inline]
183 unsafe fn encode(
184 self,
185 encoder: &mut fidl::encoding::Encoder<'_, D>,
186 offset: usize,
187 _depth: fidl::encoding::Depth,
188 ) -> fidl::Result<()> {
189 encoder.debug_check_bounds::<DebugMessageRequest>(offset);
190 fidl::encoding::Encode::<DebugMessageRequest, D>::encode(
192 (
193 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.node_name),
194 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(&self.command),
195 <fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.args),
196 ),
197 encoder, offset, _depth
198 )
199 }
200 }
201 unsafe impl<
202 D: fidl::encoding::ResourceDialect,
203 T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
204 T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
205 T2: fidl::encoding::Encode<
206 fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
207 D,
208 >,
209 > fidl::encoding::Encode<DebugMessageRequest, D> for (T0, T1, T2)
210 {
211 #[inline]
212 unsafe fn encode(
213 self,
214 encoder: &mut fidl::encoding::Encoder<'_, D>,
215 offset: usize,
216 depth: fidl::encoding::Depth,
217 ) -> fidl::Result<()> {
218 encoder.debug_check_bounds::<DebugMessageRequest>(offset);
219 self.0.encode(encoder, offset + 0, depth)?;
223 self.1.encode(encoder, offset + 16, depth)?;
224 self.2.encode(encoder, offset + 32, depth)?;
225 Ok(())
226 }
227 }
228
229 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DebugMessageRequest {
230 #[inline(always)]
231 fn new_empty() -> Self {
232 Self {
233 node_name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
234 command: fidl::new_empty!(fidl::encoding::UnboundedString, D),
235 args: fidl::new_empty!(
236 fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
237 D
238 ),
239 }
240 }
241
242 #[inline]
243 unsafe fn decode(
244 &mut self,
245 decoder: &mut fidl::encoding::Decoder<'_, D>,
246 offset: usize,
247 _depth: fidl::encoding::Depth,
248 ) -> fidl::Result<()> {
249 decoder.debug_check_bounds::<Self>(offset);
250 fidl::decode!(
252 fidl::encoding::UnboundedString,
253 D,
254 &mut self.node_name,
255 decoder,
256 offset + 0,
257 _depth
258 )?;
259 fidl::decode!(
260 fidl::encoding::UnboundedString,
261 D,
262 &mut self.command,
263 decoder,
264 offset + 16,
265 _depth
266 )?;
267 fidl::decode!(
268 fidl::encoding::UnboundedVector<fidl::encoding::UnboundedString>,
269 D,
270 &mut self.args,
271 decoder,
272 offset + 32,
273 _depth
274 )?;
275 Ok(())
276 }
277 }
278}