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