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