fidl_fuchsia_netemul_guest_common/
fidl_fuchsia_netemul_guest_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
11pub const MAX_GUEST_NAME_LENGTH: u64 = 32;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
14#[repr(u32)]
15pub enum ControllerCreateGuestError {
16    /// Guest was already running.
17    AlreadyRunning = 1,
18    /// Failed to launch guest.
19    LaunchFailed = 2,
20    /// Failed to attach guest to the provided `fuchsia.netemul.network.Network`.
21    AttachFailed = 3,
22}
23
24impl ControllerCreateGuestError {
25    #[inline]
26    pub fn from_primitive(prim: u32) -> Option<Self> {
27        match prim {
28            1 => Some(Self::AlreadyRunning),
29            2 => Some(Self::LaunchFailed),
30            3 => Some(Self::AttachFailed),
31            _ => None,
32        }
33    }
34
35    #[inline]
36    pub const fn into_primitive(self) -> u32 {
37        self as u32
38    }
39}
40
41mod internal {
42    use super::*;
43    unsafe impl fidl::encoding::TypeMarker for ControllerCreateGuestError {
44        type Owned = Self;
45
46        #[inline(always)]
47        fn inline_align(_context: fidl::encoding::Context) -> usize {
48            std::mem::align_of::<u32>()
49        }
50
51        #[inline(always)]
52        fn inline_size(_context: fidl::encoding::Context) -> usize {
53            std::mem::size_of::<u32>()
54        }
55
56        #[inline(always)]
57        fn encode_is_copy() -> bool {
58            true
59        }
60
61        #[inline(always)]
62        fn decode_is_copy() -> bool {
63            false
64        }
65    }
66
67    impl fidl::encoding::ValueTypeMarker for ControllerCreateGuestError {
68        type Borrowed<'a> = Self;
69        #[inline(always)]
70        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
71            *value
72        }
73    }
74
75    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
76        for ControllerCreateGuestError
77    {
78        #[inline]
79        unsafe fn encode(
80            self,
81            encoder: &mut fidl::encoding::Encoder<'_, D>,
82            offset: usize,
83            _depth: fidl::encoding::Depth,
84        ) -> fidl::Result<()> {
85            encoder.debug_check_bounds::<Self>(offset);
86            encoder.write_num(self.into_primitive(), offset);
87            Ok(())
88        }
89    }
90
91    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
92        for ControllerCreateGuestError
93    {
94        #[inline(always)]
95        fn new_empty() -> Self {
96            Self::AlreadyRunning
97        }
98
99        #[inline]
100        unsafe fn decode(
101            &mut self,
102            decoder: &mut fidl::encoding::Decoder<'_, D>,
103            offset: usize,
104            _depth: fidl::encoding::Depth,
105        ) -> fidl::Result<()> {
106            decoder.debug_check_bounds::<Self>(offset);
107            let prim = decoder.read_num::<u32>(offset);
108
109            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
110            Ok(())
111        }
112    }
113}