fidl_fuchsia_developer_console__common/
fidl_fuchsia_developer_console__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 LauncherError {
14 Internal,
16 NotSupported,
18 InvalidNamespacePath,
20 DuplicateNamespacePath,
22 ProgramLoadFailed,
24 ProcessLaunchFailed,
26 PtyFailed,
28 #[doc(hidden)]
29 __SourceBreaking { unknown_ordinal: u32 },
30}
31
32#[macro_export]
34macro_rules! LauncherErrorUnknown {
35 () => {
36 _
37 };
38}
39
40impl LauncherError {
41 #[inline]
42 pub fn from_primitive(prim: u32) -> Option<Self> {
43 match prim {
44 1 => Some(Self::Internal),
45 2 => Some(Self::NotSupported),
46 3 => Some(Self::InvalidNamespacePath),
47 4 => Some(Self::DuplicateNamespacePath),
48 5 => Some(Self::ProgramLoadFailed),
49 6 => Some(Self::ProcessLaunchFailed),
50 7 => Some(Self::PtyFailed),
51 _ => None,
52 }
53 }
54
55 #[inline]
56 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
57 match prim {
58 1 => Self::Internal,
59 2 => Self::NotSupported,
60 3 => Self::InvalidNamespacePath,
61 4 => Self::DuplicateNamespacePath,
62 5 => Self::ProgramLoadFailed,
63 6 => Self::ProcessLaunchFailed,
64 7 => Self::PtyFailed,
65 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
66 }
67 }
68
69 #[inline]
70 pub fn unknown() -> Self {
71 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
72 }
73
74 #[inline]
75 pub const fn into_primitive(self) -> u32 {
76 match self {
77 Self::Internal => 1,
78 Self::NotSupported => 2,
79 Self::InvalidNamespacePath => 3,
80 Self::DuplicateNamespacePath => 4,
81 Self::ProgramLoadFailed => 5,
82 Self::ProcessLaunchFailed => 6,
83 Self::PtyFailed => 7,
84 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
85 }
86 }
87
88 #[inline]
89 pub fn is_unknown(&self) -> bool {
90 match self {
91 Self::__SourceBreaking { unknown_ordinal: _ } => true,
92 _ => false,
93 }
94 }
95}
96
97#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
98pub struct Empty;
99
100impl fidl::Persistable for Empty {}
101
102#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
103#[repr(C)]
104pub struct LauncherLaunchResponse {
105 pub return_code: i64,
106}
107
108impl fidl::Persistable for LauncherLaunchResponse {}
109
110pub mod launcher_ordinals {
111 pub const LAUNCH: u64 = 0x54051bc8d2beffac;
112}
113
114mod internal {
115 use super::*;
116 unsafe impl fidl::encoding::TypeMarker for LauncherError {
117 type Owned = Self;
118
119 #[inline(always)]
120 fn inline_align(_context: fidl::encoding::Context) -> usize {
121 std::mem::align_of::<u32>()
122 }
123
124 #[inline(always)]
125 fn inline_size(_context: fidl::encoding::Context) -> usize {
126 std::mem::size_of::<u32>()
127 }
128
129 #[inline(always)]
130 fn encode_is_copy() -> bool {
131 false
132 }
133
134 #[inline(always)]
135 fn decode_is_copy() -> bool {
136 false
137 }
138 }
139
140 impl fidl::encoding::ValueTypeMarker for LauncherError {
141 type Borrowed<'a> = Self;
142 #[inline(always)]
143 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
144 *value
145 }
146 }
147
148 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LauncherError {
149 #[inline]
150 unsafe fn encode(
151 self,
152 encoder: &mut fidl::encoding::Encoder<'_, D>,
153 offset: usize,
154 _depth: fidl::encoding::Depth,
155 ) -> fidl::Result<()> {
156 encoder.debug_check_bounds::<Self>(offset);
157 encoder.write_num(self.into_primitive(), offset);
158 Ok(())
159 }
160 }
161
162 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LauncherError {
163 #[inline(always)]
164 fn new_empty() -> Self {
165 Self::unknown()
166 }
167
168 #[inline]
169 unsafe fn decode(
170 &mut self,
171 decoder: &mut fidl::encoding::Decoder<'_, D>,
172 offset: usize,
173 _depth: fidl::encoding::Depth,
174 ) -> fidl::Result<()> {
175 decoder.debug_check_bounds::<Self>(offset);
176 let prim = decoder.read_num::<u32>(offset);
177
178 *self = Self::from_primitive_allow_unknown(prim);
179 Ok(())
180 }
181 }
182
183 impl fidl::encoding::ValueTypeMarker for Empty {
184 type Borrowed<'a> = &'a Self;
185 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
186 value
187 }
188 }
189
190 unsafe impl fidl::encoding::TypeMarker for Empty {
191 type Owned = Self;
192
193 #[inline(always)]
194 fn inline_align(_context: fidl::encoding::Context) -> usize {
195 1
196 }
197
198 #[inline(always)]
199 fn inline_size(_context: fidl::encoding::Context) -> usize {
200 1
201 }
202 }
203
204 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Empty, D> for &Empty {
205 #[inline]
206 unsafe fn encode(
207 self,
208 encoder: &mut fidl::encoding::Encoder<'_, D>,
209 offset: usize,
210 _depth: fidl::encoding::Depth,
211 ) -> fidl::Result<()> {
212 encoder.debug_check_bounds::<Empty>(offset);
213 encoder.write_num(0u8, offset);
214 Ok(())
215 }
216 }
217
218 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Empty {
219 #[inline(always)]
220 fn new_empty() -> Self {
221 Self
222 }
223
224 #[inline]
225 unsafe fn decode(
226 &mut self,
227 decoder: &mut fidl::encoding::Decoder<'_, D>,
228 offset: usize,
229 _depth: fidl::encoding::Depth,
230 ) -> fidl::Result<()> {
231 decoder.debug_check_bounds::<Self>(offset);
232 match decoder.read_num::<u8>(offset) {
233 0 => Ok(()),
234 _ => Err(fidl::Error::Invalid),
235 }
236 }
237 }
238
239 impl fidl::encoding::ValueTypeMarker for LauncherLaunchResponse {
240 type Borrowed<'a> = &'a Self;
241 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
242 value
243 }
244 }
245
246 unsafe impl fidl::encoding::TypeMarker for LauncherLaunchResponse {
247 type Owned = Self;
248
249 #[inline(always)]
250 fn inline_align(_context: fidl::encoding::Context) -> usize {
251 8
252 }
253
254 #[inline(always)]
255 fn inline_size(_context: fidl::encoding::Context) -> usize {
256 8
257 }
258 #[inline(always)]
259 fn encode_is_copy() -> bool {
260 true
261 }
262
263 #[inline(always)]
264 fn decode_is_copy() -> bool {
265 true
266 }
267 }
268
269 unsafe impl<D: fidl::encoding::ResourceDialect>
270 fidl::encoding::Encode<LauncherLaunchResponse, D> for &LauncherLaunchResponse
271 {
272 #[inline]
273 unsafe fn encode(
274 self,
275 encoder: &mut fidl::encoding::Encoder<'_, D>,
276 offset: usize,
277 _depth: fidl::encoding::Depth,
278 ) -> fidl::Result<()> {
279 encoder.debug_check_bounds::<LauncherLaunchResponse>(offset);
280 unsafe {
281 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
283 (buf_ptr as *mut LauncherLaunchResponse)
284 .write_unaligned((self as *const LauncherLaunchResponse).read());
285 }
288 Ok(())
289 }
290 }
291 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
292 fidl::encoding::Encode<LauncherLaunchResponse, D> for (T0,)
293 {
294 #[inline]
295 unsafe fn encode(
296 self,
297 encoder: &mut fidl::encoding::Encoder<'_, D>,
298 offset: usize,
299 depth: fidl::encoding::Depth,
300 ) -> fidl::Result<()> {
301 encoder.debug_check_bounds::<LauncherLaunchResponse>(offset);
302 self.0.encode(encoder, offset + 0, depth)?;
306 Ok(())
307 }
308 }
309
310 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
311 for LauncherLaunchResponse
312 {
313 #[inline(always)]
314 fn new_empty() -> Self {
315 Self { return_code: fidl::new_empty!(i64, D) }
316 }
317
318 #[inline]
319 unsafe fn decode(
320 &mut self,
321 decoder: &mut fidl::encoding::Decoder<'_, D>,
322 offset: usize,
323 _depth: fidl::encoding::Depth,
324 ) -> fidl::Result<()> {
325 decoder.debug_check_bounds::<Self>(offset);
326 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
327 unsafe {
330 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
331 }
332 Ok(())
333 }
334 }
335}