fidl_fuchsia_dash__common/
fidl_fuchsia_dash__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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/// Maximum number of URLs allowed to be sent to the launcher.
12pub const MAX_URLS: u64 = 20;
13
14/// The namespace layout to create for the dash process.
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum DashNamespaceLayout {
18    /// All instance directories are nested under subdirectories.
19    /// e.g - namespace is under /ns, outgoing dir is under /out, etc.
20    NestAllInstanceDirs = 1,
21    /// The instance namespace is the root of the dash shell.
22    /// Several ELF binaries and libraries in Fuchsia assume that directories like
23    /// `svc` and `dev` will be at the root. As a result, this layout should be
24    /// more compatible than nesting for running Fuchsia ELF binaries in the shell.
25    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/// The package resolvers available for resolving package URLs with the `fuchsia-pkg` scheme.
45#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
46pub enum FuchsiaPkgResolver {
47    /// Resolves base packages from blobfs.
48    Base,
49    /// Resolves base, cache, or universe packages from blobfs and any configured remote
50    /// repositories.
51    Full,
52    #[doc(hidden)]
53    __SourceBreaking { unknown_ordinal: u32 },
54}
55
56/// Pattern that matches an unknown `FuchsiaPkgResolver` member.
57#[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/// Standard errors for the Launcher protocol
107#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
108#[repr(u32)]
109pub enum LauncherError {
110    /// Launcher encountered an unspecified error
111    Internal = 1,
112    /// Moniker could not be parsed by launcher
113    BadMoniker = 2,
114    /// No instance was found matching the moniker
115    InstanceNotFound = 3,
116    /// Error occurred using fuchsia.sys2.RealmQuery
117    RealmQuery = 4,
118    /// Error occurred using fuchsia.process.Launcher
119    ProcessLauncher = 5,
120    /// Error loading dash binary
121    DashBinary = 6,
122    /// Error occurred involving the PTY
123    Pty = 7,
124    /// Instance is not in a resolved state, so there is nothing to explore
125    InstanceNotResolved = 8,
126    /// Error occurred using fuchsia.pkg.PackageResolver
127    PackageResolver = 9,
128    /// Error resolving tools package
129    ToolsCannotResolve = 10,
130    /// URL could not be parsed by launcher
131    BadUrl = 11,
132    /// Error reading a binary from a tools package
133    ToolsBinaryRead = 12,
134    /// A binary name was repeated
135    NonUniqueBinaryName = 13,
136    /// Error occurred using fuchsia.process.Resolver
137    ProcessResolver = 14,
138    /// Error occurred using fuchsia.kernel.VmexResource
139    VmexResource = 15,
140    /// Error resolving the package that is to be explored.
141    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    /// The process exit code of the shell.
178    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                // Copy the object into the buffer.
439                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                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
443                // done second because the memcpy will write garbage to these bytes.
444            }
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            // Zero out padding regions. There's no need to apply masks
460            // because the unmasked parts will be overwritten by fields.
461            // Write the fields.
462            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            // Verify that padding bytes are zero.
485            // Copy from the buffer into the object.
486            unsafe {
487                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
488            }
489            Ok(())
490        }
491    }
492}