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