fidl_fuchsia_ui_input_internal_common/
fidl_fuchsia_ui_input_internal_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
11bitflags! {
12 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
22 pub struct InputOwnershipSignal: u32 {
23 const DISPLAY_UNOWNED = 16777216;
26 const DISPLAY_PLATFORM_OWNED = 33554432;
29 const INPUT_CLIENT_OWNED = 134217728;
32 const INPUT_PLATFORM_OWNED = 268435456;
35 }
36}
37
38impl InputOwnershipSignal {
39 #[inline(always)]
40 pub fn from_bits_allow_unknown(bits: u32) -> Self {
41 Self::from_bits_retain(bits)
42 }
43
44 #[inline(always)]
45 pub fn has_unknown_bits(&self) -> bool {
46 self.get_unknown_bits() != 0
47 }
48
49 #[inline(always)]
50 pub fn get_unknown_bits(&self) -> u32 {
51 self.bits() & !Self::all().bits()
52 }
53}
54
55#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
57pub enum InputOwnershipError {
58 InvalidTarget,
60 UnknownView,
63 AccessDenied,
65 #[doc(hidden)]
66 __SourceBreaking { unknown_ordinal: u32 },
67}
68
69#[macro_export]
71macro_rules! InputOwnershipErrorUnknown {
72 () => {
73 _
74 };
75}
76
77impl InputOwnershipError {
78 #[inline]
79 pub fn from_primitive(prim: u32) -> Option<Self> {
80 match prim {
81 1 => Some(Self::InvalidTarget),
82 2 => Some(Self::UnknownView),
83 3 => Some(Self::AccessDenied),
84 _ => None,
85 }
86 }
87
88 #[inline]
89 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
90 match prim {
91 1 => Self::InvalidTarget,
92 2 => Self::UnknownView,
93 3 => Self::AccessDenied,
94 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
95 }
96 }
97
98 #[inline]
99 pub fn unknown() -> Self {
100 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
101 }
102
103 #[inline]
104 pub const fn into_primitive(self) -> u32 {
105 match self {
106 Self::InvalidTarget => 1,
107 Self::UnknownView => 2,
108 Self::AccessDenied => 3,
109 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
110 }
111 }
112
113 #[inline]
114 pub fn is_unknown(&self) -> bool {
115 match self {
116 Self::__SourceBreaking { unknown_ordinal: _ } => true,
117 _ => false,
118 }
119 }
120}
121
122#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
123pub struct Platform;
124
125impl fidl::Persistable for Platform {}
126
127#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
128pub struct Virtcon;
129
130impl fidl::Persistable for Virtcon {}
131
132pub mod input_ownership_ordinals {
133 pub const GET_EVENT: u64 = 0x486e6eebf1f00657;
134}
135
136mod internal {
137 use super::*;
138 unsafe impl fidl::encoding::TypeMarker for InputOwnershipSignal {
139 type Owned = Self;
140
141 #[inline(always)]
142 fn inline_align(_context: fidl::encoding::Context) -> usize {
143 4
144 }
145
146 #[inline(always)]
147 fn inline_size(_context: fidl::encoding::Context) -> usize {
148 4
149 }
150 }
151
152 impl fidl::encoding::ValueTypeMarker for InputOwnershipSignal {
153 type Borrowed<'a> = Self;
154 #[inline(always)]
155 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
156 *value
157 }
158 }
159
160 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
161 for InputOwnershipSignal
162 {
163 #[inline]
164 unsafe fn encode(
165 self,
166 encoder: &mut fidl::encoding::Encoder<'_, D>,
167 offset: usize,
168 _depth: fidl::encoding::Depth,
169 ) -> fidl::Result<()> {
170 encoder.debug_check_bounds::<Self>(offset);
171 encoder.write_num(self.bits(), offset);
172 Ok(())
173 }
174 }
175
176 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InputOwnershipSignal {
177 #[inline(always)]
178 fn new_empty() -> Self {
179 Self::empty()
180 }
181
182 #[inline]
183 unsafe fn decode(
184 &mut self,
185 decoder: &mut fidl::encoding::Decoder<'_, D>,
186 offset: usize,
187 _depth: fidl::encoding::Depth,
188 ) -> fidl::Result<()> {
189 decoder.debug_check_bounds::<Self>(offset);
190 let prim = decoder.read_num::<u32>(offset);
191 *self = Self::from_bits_allow_unknown(prim);
192 Ok(())
193 }
194 }
195 unsafe impl fidl::encoding::TypeMarker for InputOwnershipError {
196 type Owned = Self;
197
198 #[inline(always)]
199 fn inline_align(_context: fidl::encoding::Context) -> usize {
200 std::mem::align_of::<u32>()
201 }
202
203 #[inline(always)]
204 fn inline_size(_context: fidl::encoding::Context) -> usize {
205 std::mem::size_of::<u32>()
206 }
207
208 #[inline(always)]
209 fn encode_is_copy() -> bool {
210 false
211 }
212
213 #[inline(always)]
214 fn decode_is_copy() -> bool {
215 false
216 }
217 }
218
219 impl fidl::encoding::ValueTypeMarker for InputOwnershipError {
220 type Borrowed<'a> = Self;
221 #[inline(always)]
222 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
223 *value
224 }
225 }
226
227 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
228 for InputOwnershipError
229 {
230 #[inline]
231 unsafe fn encode(
232 self,
233 encoder: &mut fidl::encoding::Encoder<'_, D>,
234 offset: usize,
235 _depth: fidl::encoding::Depth,
236 ) -> fidl::Result<()> {
237 encoder.debug_check_bounds::<Self>(offset);
238 encoder.write_num(self.into_primitive(), offset);
239 Ok(())
240 }
241 }
242
243 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InputOwnershipError {
244 #[inline(always)]
245 fn new_empty() -> Self {
246 Self::unknown()
247 }
248
249 #[inline]
250 unsafe fn decode(
251 &mut self,
252 decoder: &mut fidl::encoding::Decoder<'_, D>,
253 offset: usize,
254 _depth: fidl::encoding::Depth,
255 ) -> fidl::Result<()> {
256 decoder.debug_check_bounds::<Self>(offset);
257 let prim = decoder.read_num::<u32>(offset);
258
259 *self = Self::from_primitive_allow_unknown(prim);
260 Ok(())
261 }
262 }
263
264 impl fidl::encoding::ValueTypeMarker for Platform {
265 type Borrowed<'a> = &'a Self;
266 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
267 value
268 }
269 }
270
271 unsafe impl fidl::encoding::TypeMarker for Platform {
272 type Owned = Self;
273
274 #[inline(always)]
275 fn inline_align(_context: fidl::encoding::Context) -> usize {
276 1
277 }
278
279 #[inline(always)]
280 fn inline_size(_context: fidl::encoding::Context) -> usize {
281 1
282 }
283 }
284
285 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Platform, D> for &Platform {
286 #[inline]
287 unsafe fn encode(
288 self,
289 encoder: &mut fidl::encoding::Encoder<'_, D>,
290 offset: usize,
291 _depth: fidl::encoding::Depth,
292 ) -> fidl::Result<()> {
293 encoder.debug_check_bounds::<Platform>(offset);
294 encoder.write_num(0u8, offset);
295 Ok(())
296 }
297 }
298
299 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Platform {
300 #[inline(always)]
301 fn new_empty() -> Self {
302 Self
303 }
304
305 #[inline]
306 unsafe fn decode(
307 &mut self,
308 decoder: &mut fidl::encoding::Decoder<'_, D>,
309 offset: usize,
310 _depth: fidl::encoding::Depth,
311 ) -> fidl::Result<()> {
312 decoder.debug_check_bounds::<Self>(offset);
313 match decoder.read_num::<u8>(offset) {
314 0 => Ok(()),
315 _ => Err(fidl::Error::Invalid),
316 }
317 }
318 }
319
320 impl fidl::encoding::ValueTypeMarker for Virtcon {
321 type Borrowed<'a> = &'a Self;
322 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
323 value
324 }
325 }
326
327 unsafe impl fidl::encoding::TypeMarker for Virtcon {
328 type Owned = Self;
329
330 #[inline(always)]
331 fn inline_align(_context: fidl::encoding::Context) -> usize {
332 1
333 }
334
335 #[inline(always)]
336 fn inline_size(_context: fidl::encoding::Context) -> usize {
337 1
338 }
339 }
340
341 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Virtcon, D> for &Virtcon {
342 #[inline]
343 unsafe fn encode(
344 self,
345 encoder: &mut fidl::encoding::Encoder<'_, D>,
346 offset: usize,
347 _depth: fidl::encoding::Depth,
348 ) -> fidl::Result<()> {
349 encoder.debug_check_bounds::<Virtcon>(offset);
350 encoder.write_num(0u8, offset);
351 Ok(())
352 }
353 }
354
355 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Virtcon {
356 #[inline(always)]
357 fn new_empty() -> Self {
358 Self
359 }
360
361 #[inline]
362 unsafe fn decode(
363 &mut self,
364 decoder: &mut fidl::encoding::Decoder<'_, D>,
365 offset: usize,
366 _depth: fidl::encoding::Depth,
367 ) -> fidl::Result<()> {
368 decoder.debug_check_bounds::<Self>(offset);
369 match decoder.read_num::<u8>(offset) {
370 0 => Ok(()),
371 _ => Err(fidl::Error::Invalid),
372 }
373 }
374 }
375}