fidl_fuchsia_testing_harness__common/
fidl_fuchsia_testing_harness__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
11pub const MAX_PROTOCOL_LEN: u64 = fidl_fuchsia_io__common::MAX_NAME_LENGTH as u64;
15
16#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21pub enum OperationError {
22 Invalid,
32 Failed,
44 Unsupported,
59 #[doc(hidden)]
60 __SourceBreaking { unknown_ordinal: u32 },
61}
62
63#[macro_export]
65macro_rules! OperationErrorUnknown {
66 () => {
67 _
68 };
69}
70
71impl OperationError {
72 #[inline]
73 pub fn from_primitive(prim: u32) -> Option<Self> {
74 match prim {
75 0 => Some(Self::Invalid),
76 1 => Some(Self::Failed),
77 2 => Some(Self::Unsupported),
78 _ => None,
79 }
80 }
81
82 #[inline]
83 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
84 match prim {
85 0 => Self::Invalid,
86 1 => Self::Failed,
87 2 => Self::Unsupported,
88 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
89 }
90 }
91
92 #[inline]
93 pub fn unknown() -> Self {
94 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
95 }
96
97 #[inline]
98 pub const fn into_primitive(self) -> u32 {
99 match self {
100 Self::Invalid => 0,
101 Self::Failed => 1,
102 Self::Unsupported => 2,
103 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
104 }
105 }
106
107 #[inline]
108 pub fn is_unknown(&self) -> bool {
109 match self {
110 Self::__SourceBreaking { unknown_ordinal: _ } => true,
111 _ => false,
112 }
113 }
114}
115
116pub mod realm_proxy__ordinals {
117 pub const CONNECT_TO_NAMED_PROTOCOL: u64 = 0x159b4ba0b614ecc4;
118 pub const OPEN_SERVICE: u64 = 0x7e4f670a6ec5986a;
119 pub const CONNECT_TO_SERVICE_INSTANCE: u64 = 0x39111e790d55bbf;
120}
121
122mod internal {
123 use super::*;
124 unsafe impl fidl::encoding::TypeMarker for OperationError {
125 type Owned = Self;
126
127 #[inline(always)]
128 fn inline_align(_context: fidl::encoding::Context) -> usize {
129 std::mem::align_of::<u32>()
130 }
131
132 #[inline(always)]
133 fn inline_size(_context: fidl::encoding::Context) -> usize {
134 std::mem::size_of::<u32>()
135 }
136
137 #[inline(always)]
138 fn encode_is_copy() -> bool {
139 false
140 }
141
142 #[inline(always)]
143 fn decode_is_copy() -> bool {
144 false
145 }
146 }
147
148 impl fidl::encoding::ValueTypeMarker for OperationError {
149 type Borrowed<'a> = Self;
150 #[inline(always)]
151 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
152 *value
153 }
154 }
155
156 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for OperationError {
157 #[inline]
158 unsafe fn encode(
159 self,
160 encoder: &mut fidl::encoding::Encoder<'_, D>,
161 offset: usize,
162 _depth: fidl::encoding::Depth,
163 ) -> fidl::Result<()> {
164 encoder.debug_check_bounds::<Self>(offset);
165 encoder.write_num(self.into_primitive(), offset);
166 Ok(())
167 }
168 }
169
170 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for OperationError {
171 #[inline(always)]
172 fn new_empty() -> Self {
173 Self::unknown()
174 }
175
176 #[inline]
177 unsafe fn decode(
178 &mut self,
179 decoder: &mut fidl::encoding::Decoder<'_, D>,
180 offset: usize,
181 _depth: fidl::encoding::Depth,
182 ) -> fidl::Result<()> {
183 decoder.debug_check_bounds::<Self>(offset);
184 let prim = decoder.read_num::<u32>(offset);
185
186 *self = Self::from_primitive_allow_unknown(prim);
187 Ok(())
188 }
189 }
190}