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