fidl_fuchsia_dash_common/
fidl_fuchsia_dash_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
11pub const MAX_URLS: u64 = 20;
13
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum DashNamespaceLayout {
18 NestAllInstanceDirs = 1,
21 InstanceNamespaceIsRoot = 2,
26}
27
28impl DashNamespaceLayout {
29 #[inline]
30 pub fn from_primitive(prim: u32) -> Option<Self> {
31 match prim {
32 1 => Some(Self::NestAllInstanceDirs),
33 2 => Some(Self::InstanceNamespaceIsRoot),
34 _ => None,
35 }
36 }
37
38 #[inline]
39 pub const fn into_primitive(self) -> u32 {
40 self as u32
41 }
42
43 #[deprecated = "Strict enums should not use `is_unknown`"]
44 #[inline]
45 pub fn is_unknown(&self) -> bool {
46 false
47 }
48}
49
50#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
52pub enum FuchsiaPkgResolver {
53 Base,
55 Full,
58 #[doc(hidden)]
59 __SourceBreaking { unknown_ordinal: u32 },
60}
61
62#[macro_export]
64macro_rules! FuchsiaPkgResolverUnknown {
65 () => {
66 _
67 };
68}
69
70impl FuchsiaPkgResolver {
71 #[inline]
72 pub fn from_primitive(prim: u32) -> Option<Self> {
73 match prim {
74 1 => Some(Self::Base),
75 2 => Some(Self::Full),
76 _ => None,
77 }
78 }
79
80 #[inline]
81 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
82 match prim {
83 1 => Self::Base,
84 2 => Self::Full,
85 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
86 }
87 }
88
89 #[inline]
90 pub fn unknown() -> Self {
91 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
92 }
93
94 #[inline]
95 pub const fn into_primitive(self) -> u32 {
96 match self {
97 Self::Base => 1,
98 Self::Full => 2,
99 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
100 }
101 }
102
103 #[inline]
104 pub fn is_unknown(&self) -> bool {
105 match self {
106 Self::__SourceBreaking { unknown_ordinal: _ } => true,
107 _ => false,
108 }
109 }
110}
111
112#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
114#[repr(u32)]
115pub enum LauncherError {
116 Internal = 1,
118 BadMoniker = 2,
120 InstanceNotFound = 3,
122 RealmQuery = 4,
124 ProcessLauncher = 5,
126 DashBinary = 6,
128 Pty = 7,
130 InstanceNotResolved = 8,
132 PackageResolver = 9,
134 ToolsCannotResolve = 10,
136 BadUrl = 11,
138 ToolsBinaryRead = 12,
140 NonUniqueBinaryName = 13,
142 ProcessResolver = 14,
144 VmexResource = 15,
146 ResolveTargetPackage = 16,
148}
149
150impl LauncherError {
151 #[inline]
152 pub fn from_primitive(prim: u32) -> Option<Self> {
153 match prim {
154 1 => Some(Self::Internal),
155 2 => Some(Self::BadMoniker),
156 3 => Some(Self::InstanceNotFound),
157 4 => Some(Self::RealmQuery),
158 5 => Some(Self::ProcessLauncher),
159 6 => Some(Self::DashBinary),
160 7 => Some(Self::Pty),
161 8 => Some(Self::InstanceNotResolved),
162 9 => Some(Self::PackageResolver),
163 10 => Some(Self::ToolsCannotResolve),
164 11 => Some(Self::BadUrl),
165 12 => Some(Self::ToolsBinaryRead),
166 13 => Some(Self::NonUniqueBinaryName),
167 14 => Some(Self::ProcessResolver),
168 15 => Some(Self::VmexResource),
169 16 => Some(Self::ResolveTargetPackage),
170 _ => None,
171 }
172 }
173
174 #[inline]
175 pub const fn into_primitive(self) -> u32 {
176 self as u32
177 }
178
179 #[deprecated = "Strict enums should not use `is_unknown`"]
180 #[inline]
181 pub fn is_unknown(&self) -> bool {
182 false
183 }
184}
185
186#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
187#[repr(C)]
188pub struct LauncherOnTerminatedRequest {
189 pub return_code: i32,
191}
192
193impl fidl::Persistable for LauncherOnTerminatedRequest {}
194
195mod internal {
196 use super::*;
197 unsafe impl fidl::encoding::TypeMarker for DashNamespaceLayout {
198 type Owned = Self;
199
200 #[inline(always)]
201 fn inline_align(_context: fidl::encoding::Context) -> usize {
202 std::mem::align_of::<u32>()
203 }
204
205 #[inline(always)]
206 fn inline_size(_context: fidl::encoding::Context) -> usize {
207 std::mem::size_of::<u32>()
208 }
209
210 #[inline(always)]
211 fn encode_is_copy() -> bool {
212 true
213 }
214
215 #[inline(always)]
216 fn decode_is_copy() -> bool {
217 false
218 }
219 }
220
221 impl fidl::encoding::ValueTypeMarker for DashNamespaceLayout {
222 type Borrowed<'a> = Self;
223 #[inline(always)]
224 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
225 *value
226 }
227 }
228
229 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
230 for DashNamespaceLayout
231 {
232 #[inline]
233 unsafe fn encode(
234 self,
235 encoder: &mut fidl::encoding::Encoder<'_, D>,
236 offset: usize,
237 _depth: fidl::encoding::Depth,
238 ) -> fidl::Result<()> {
239 encoder.debug_check_bounds::<Self>(offset);
240 encoder.write_num(self.into_primitive(), offset);
241 Ok(())
242 }
243 }
244
245 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DashNamespaceLayout {
246 #[inline(always)]
247 fn new_empty() -> Self {
248 Self::NestAllInstanceDirs
249 }
250
251 #[inline]
252 unsafe fn decode(
253 &mut self,
254 decoder: &mut fidl::encoding::Decoder<'_, D>,
255 offset: usize,
256 _depth: fidl::encoding::Depth,
257 ) -> fidl::Result<()> {
258 decoder.debug_check_bounds::<Self>(offset);
259 let prim = decoder.read_num::<u32>(offset);
260
261 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
262 Ok(())
263 }
264 }
265 unsafe impl fidl::encoding::TypeMarker for FuchsiaPkgResolver {
266 type Owned = Self;
267
268 #[inline(always)]
269 fn inline_align(_context: fidl::encoding::Context) -> usize {
270 std::mem::align_of::<u32>()
271 }
272
273 #[inline(always)]
274 fn inline_size(_context: fidl::encoding::Context) -> usize {
275 std::mem::size_of::<u32>()
276 }
277
278 #[inline(always)]
279 fn encode_is_copy() -> bool {
280 false
281 }
282
283 #[inline(always)]
284 fn decode_is_copy() -> bool {
285 false
286 }
287 }
288
289 impl fidl::encoding::ValueTypeMarker for FuchsiaPkgResolver {
290 type Borrowed<'a> = Self;
291 #[inline(always)]
292 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
293 *value
294 }
295 }
296
297 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
298 for FuchsiaPkgResolver
299 {
300 #[inline]
301 unsafe fn encode(
302 self,
303 encoder: &mut fidl::encoding::Encoder<'_, D>,
304 offset: usize,
305 _depth: fidl::encoding::Depth,
306 ) -> fidl::Result<()> {
307 encoder.debug_check_bounds::<Self>(offset);
308 encoder.write_num(self.into_primitive(), offset);
309 Ok(())
310 }
311 }
312
313 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FuchsiaPkgResolver {
314 #[inline(always)]
315 fn new_empty() -> Self {
316 Self::unknown()
317 }
318
319 #[inline]
320 unsafe fn decode(
321 &mut self,
322 decoder: &mut fidl::encoding::Decoder<'_, D>,
323 offset: usize,
324 _depth: fidl::encoding::Depth,
325 ) -> fidl::Result<()> {
326 decoder.debug_check_bounds::<Self>(offset);
327 let prim = decoder.read_num::<u32>(offset);
328
329 *self = Self::from_primitive_allow_unknown(prim);
330 Ok(())
331 }
332 }
333 unsafe impl fidl::encoding::TypeMarker for LauncherError {
334 type Owned = Self;
335
336 #[inline(always)]
337 fn inline_align(_context: fidl::encoding::Context) -> usize {
338 std::mem::align_of::<u32>()
339 }
340
341 #[inline(always)]
342 fn inline_size(_context: fidl::encoding::Context) -> usize {
343 std::mem::size_of::<u32>()
344 }
345
346 #[inline(always)]
347 fn encode_is_copy() -> bool {
348 true
349 }
350
351 #[inline(always)]
352 fn decode_is_copy() -> bool {
353 false
354 }
355 }
356
357 impl fidl::encoding::ValueTypeMarker for LauncherError {
358 type Borrowed<'a> = Self;
359 #[inline(always)]
360 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
361 *value
362 }
363 }
364
365 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LauncherError {
366 #[inline]
367 unsafe fn encode(
368 self,
369 encoder: &mut fidl::encoding::Encoder<'_, D>,
370 offset: usize,
371 _depth: fidl::encoding::Depth,
372 ) -> fidl::Result<()> {
373 encoder.debug_check_bounds::<Self>(offset);
374 encoder.write_num(self.into_primitive(), offset);
375 Ok(())
376 }
377 }
378
379 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LauncherError {
380 #[inline(always)]
381 fn new_empty() -> Self {
382 Self::Internal
383 }
384
385 #[inline]
386 unsafe fn decode(
387 &mut self,
388 decoder: &mut fidl::encoding::Decoder<'_, D>,
389 offset: usize,
390 _depth: fidl::encoding::Depth,
391 ) -> fidl::Result<()> {
392 decoder.debug_check_bounds::<Self>(offset);
393 let prim = decoder.read_num::<u32>(offset);
394
395 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
396 Ok(())
397 }
398 }
399
400 impl fidl::encoding::ValueTypeMarker for LauncherOnTerminatedRequest {
401 type Borrowed<'a> = &'a Self;
402 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
403 value
404 }
405 }
406
407 unsafe impl fidl::encoding::TypeMarker for LauncherOnTerminatedRequest {
408 type Owned = Self;
409
410 #[inline(always)]
411 fn inline_align(_context: fidl::encoding::Context) -> usize {
412 4
413 }
414
415 #[inline(always)]
416 fn inline_size(_context: fidl::encoding::Context) -> usize {
417 4
418 }
419 #[inline(always)]
420 fn encode_is_copy() -> bool {
421 true
422 }
423
424 #[inline(always)]
425 fn decode_is_copy() -> bool {
426 true
427 }
428 }
429
430 unsafe impl<D: fidl::encoding::ResourceDialect>
431 fidl::encoding::Encode<LauncherOnTerminatedRequest, D> for &LauncherOnTerminatedRequest
432 {
433 #[inline]
434 unsafe fn encode(
435 self,
436 encoder: &mut fidl::encoding::Encoder<'_, D>,
437 offset: usize,
438 _depth: fidl::encoding::Depth,
439 ) -> fidl::Result<()> {
440 encoder.debug_check_bounds::<LauncherOnTerminatedRequest>(offset);
441 unsafe {
442 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
444 (buf_ptr as *mut LauncherOnTerminatedRequest)
445 .write_unaligned((self as *const LauncherOnTerminatedRequest).read());
446 }
449 Ok(())
450 }
451 }
452 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
453 fidl::encoding::Encode<LauncherOnTerminatedRequest, D> for (T0,)
454 {
455 #[inline]
456 unsafe fn encode(
457 self,
458 encoder: &mut fidl::encoding::Encoder<'_, D>,
459 offset: usize,
460 depth: fidl::encoding::Depth,
461 ) -> fidl::Result<()> {
462 encoder.debug_check_bounds::<LauncherOnTerminatedRequest>(offset);
463 self.0.encode(encoder, offset + 0, depth)?;
467 Ok(())
468 }
469 }
470
471 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
472 for LauncherOnTerminatedRequest
473 {
474 #[inline(always)]
475 fn new_empty() -> Self {
476 Self { return_code: fidl::new_empty!(i32, D) }
477 }
478
479 #[inline]
480 unsafe fn decode(
481 &mut self,
482 decoder: &mut fidl::encoding::Decoder<'_, D>,
483 offset: usize,
484 _depth: fidl::encoding::Depth,
485 ) -> fidl::Result<()> {
486 decoder.debug_check_bounds::<Self>(offset);
487 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
488 unsafe {
491 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
492 }
493 Ok(())
494 }
495 }
496}