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