fidl_fuchsia_ui_test_context__common/
fidl_fuchsia_ui_test_context__common.rs
1#![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
77pub mod realm_factory_ordinals {
78 pub const CREATE_REALM: u64 = 0x6e1c904f44c7d0fc;
79}
80
81pub mod scenic_realm_factory_ordinals {
82 pub const CREATE_REALM: u64 = 0x11f2157d1648e6ba;
83}
84
85mod internal {
86 use super::*;
87 unsafe impl fidl::encoding::TypeMarker for RendererType {
88 type Owned = Self;
89
90 #[inline(always)]
91 fn inline_align(_context: fidl::encoding::Context) -> usize {
92 std::mem::align_of::<u32>()
93 }
94
95 #[inline(always)]
96 fn inline_size(_context: fidl::encoding::Context) -> usize {
97 std::mem::size_of::<u32>()
98 }
99
100 #[inline(always)]
101 fn encode_is_copy() -> bool {
102 false
103 }
104
105 #[inline(always)]
106 fn decode_is_copy() -> bool {
107 false
108 }
109 }
110
111 impl fidl::encoding::ValueTypeMarker for RendererType {
112 type Borrowed<'a> = Self;
113 #[inline(always)]
114 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
115 *value
116 }
117 }
118
119 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RendererType {
120 #[inline]
121 unsafe fn encode(
122 self,
123 encoder: &mut fidl::encoding::Encoder<'_, D>,
124 offset: usize,
125 _depth: fidl::encoding::Depth,
126 ) -> fidl::Result<()> {
127 encoder.debug_check_bounds::<Self>(offset);
128 encoder.write_num(self.into_primitive(), offset);
129 Ok(())
130 }
131 }
132
133 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RendererType {
134 #[inline(always)]
135 fn new_empty() -> Self {
136 Self::unknown()
137 }
138
139 #[inline]
140 unsafe fn decode(
141 &mut self,
142 decoder: &mut fidl::encoding::Decoder<'_, D>,
143 offset: usize,
144 _depth: fidl::encoding::Depth,
145 ) -> fidl::Result<()> {
146 decoder.debug_check_bounds::<Self>(offset);
147 let prim = decoder.read_num::<u32>(offset);
148
149 *self = Self::from_primitive_allow_unknown(prim);
150 Ok(())
151 }
152 }
153}