fidl_test_powerelementrunner_common/
fidl_test_powerelementrunner_common.rs
1#![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)]
12pub enum StartPowerElementError {
13 Internal,
14 InvalidClientEnd,
15 #[doc(hidden)]
16 __SourceBreaking {
17 unknown_ordinal: u32,
18 },
19}
20
21#[macro_export]
23macro_rules! StartPowerElementErrorUnknown {
24 () => {
25 _
26 };
27}
28
29impl StartPowerElementError {
30 #[inline]
31 pub fn from_primitive(prim: u32) -> Option<Self> {
32 match prim {
33 1 => Some(Self::Internal),
34 2 => Some(Self::InvalidClientEnd),
35 _ => None,
36 }
37 }
38
39 #[inline]
40 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
41 match prim {
42 1 => Self::Internal,
43 2 => Self::InvalidClientEnd,
44 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
45 }
46 }
47
48 #[inline]
49 pub fn unknown() -> Self {
50 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
51 }
52
53 #[inline]
54 pub const fn into_primitive(self) -> u32 {
55 match self {
56 Self::Internal => 1,
57 Self::InvalidClientEnd => 2,
58 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
59 }
60 }
61
62 #[inline]
63 pub fn is_unknown(&self) -> bool {
64 match self {
65 Self::__SourceBreaking { unknown_ordinal: _ } => true,
66 _ => false,
67 }
68 }
69}
70
71mod internal {
72 use super::*;
73 unsafe impl fidl::encoding::TypeMarker for StartPowerElementError {
74 type Owned = Self;
75
76 #[inline(always)]
77 fn inline_align(_context: fidl::encoding::Context) -> usize {
78 std::mem::align_of::<u32>()
79 }
80
81 #[inline(always)]
82 fn inline_size(_context: fidl::encoding::Context) -> usize {
83 std::mem::size_of::<u32>()
84 }
85
86 #[inline(always)]
87 fn encode_is_copy() -> bool {
88 false
89 }
90
91 #[inline(always)]
92 fn decode_is_copy() -> bool {
93 false
94 }
95 }
96
97 impl fidl::encoding::ValueTypeMarker for StartPowerElementError {
98 type Borrowed<'a> = Self;
99 #[inline(always)]
100 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
101 *value
102 }
103 }
104
105 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
106 for StartPowerElementError
107 {
108 #[inline]
109 unsafe fn encode(
110 self,
111 encoder: &mut fidl::encoding::Encoder<'_, D>,
112 offset: usize,
113 _depth: fidl::encoding::Depth,
114 ) -> fidl::Result<()> {
115 encoder.debug_check_bounds::<Self>(offset);
116 encoder.write_num(self.into_primitive(), offset);
117 Ok(())
118 }
119 }
120
121 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
122 for StartPowerElementError
123 {
124 #[inline(always)]
125 fn new_empty() -> Self {
126 Self::unknown()
127 }
128
129 #[inline]
130 unsafe fn decode(
131 &mut self,
132 decoder: &mut fidl::encoding::Decoder<'_, D>,
133 offset: usize,
134 _depth: fidl::encoding::Depth,
135 ) -> fidl::Result<()> {
136 decoder.debug_check_bounds::<Self>(offset);
137 let prim = decoder.read_num::<u32>(offset);
138
139 *self = Self::from_primitive_allow_unknown(prim);
140 Ok(())
141 }
142 }
143}