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    #[deprecated = "Strict enums should not use `is_unknown`"]
34    #[inline]
35    pub fn is_unknown(&self) -> bool {
36        false
37    }
38}
39
40mod internal {
41    use super::*;
42    unsafe impl fidl::encoding::TypeMarker for RebootError {
43        type Owned = Self;
44
45        #[inline(always)]
46        fn inline_align(_context: fidl::encoding::Context) -> usize {
47            std::mem::align_of::<i32>()
48        }
49
50        #[inline(always)]
51        fn inline_size(_context: fidl::encoding::Context) -> usize {
52            std::mem::size_of::<i32>()
53        }
54
55        #[inline(always)]
56        fn encode_is_copy() -> bool {
57            true
58        }
59
60        #[inline(always)]
61        fn decode_is_copy() -> bool {
62            false
63        }
64    }
65
66    impl fidl::encoding::ValueTypeMarker for RebootError {
67        type Borrowed<'a> = Self;
68        #[inline(always)]
69        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
70            *value
71        }
72    }
73
74    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RebootError {
75        #[inline]
76        unsafe fn encode(
77            self,
78            encoder: &mut fidl::encoding::Encoder<'_, D>,
79            offset: usize,
80            _depth: fidl::encoding::Depth,
81        ) -> fidl::Result<()> {
82            encoder.debug_check_bounds::<Self>(offset);
83            encoder.write_num(self.into_primitive(), offset);
84            Ok(())
85        }
86    }
87
88    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RebootError {
89        #[inline(always)]
90        fn new_empty() -> Self {
91            Self::ClientError
92        }
93
94        #[inline]
95        unsafe fn decode(
96            &mut self,
97            decoder: &mut fidl::encoding::Decoder<'_, D>,
98            offset: usize,
99            _depth: fidl::encoding::Depth,
100        ) -> fidl::Result<()> {
101            decoder.debug_check_bounds::<Self>(offset);
102            let prim = decoder.read_num::<i32>(offset);
103
104            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
105            Ok(())
106        }
107    }
108}