fidl_fuchsia_ui_composition_internal_common/
fidl_fuchsia_ui_composition_internal_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
11pub const SIGNAL_DISPLAY_NOT_OWNED: u32 = 16777216;
12
13pub const SIGNAL_DISPLAY_OWNED: u32 = 33554432;
14
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
17pub enum ScreenCaptureError {
18 MissingArgs,
20 InvalidArgs,
22 BadHangingGet,
24 #[doc(hidden)]
25 __SourceBreaking { unknown_ordinal: u32 },
26}
27
28#[macro_export]
30macro_rules! ScreenCaptureErrorUnknown {
31 () => {
32 _
33 };
34}
35
36impl ScreenCaptureError {
37 #[inline]
38 pub fn from_primitive(prim: u32) -> Option<Self> {
39 match prim {
40 1 => Some(Self::MissingArgs),
41 2 => Some(Self::InvalidArgs),
42 3 => Some(Self::BadHangingGet),
43 _ => None,
44 }
45 }
46
47 #[inline]
48 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
49 match prim {
50 1 => Self::MissingArgs,
51 2 => Self::InvalidArgs,
52 3 => Self::BadHangingGet,
53 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
54 }
55 }
56
57 #[inline]
58 pub fn unknown() -> Self {
59 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
60 }
61
62 #[inline]
63 pub const fn into_primitive(self) -> u32 {
64 match self {
65 Self::MissingArgs => 1,
66 Self::InvalidArgs => 2,
67 Self::BadHangingGet => 3,
68 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
69 }
70 }
71
72 #[inline]
73 pub fn is_unknown(&self) -> bool {
74 match self {
75 Self::__SourceBreaking { unknown_ordinal: _ } => true,
76 _ => false,
77 }
78 }
79}
80
81#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
86#[repr(u32)]
87pub enum ScreenCaptureRotation {
88 Cw0Degrees = 0,
89 Cw90Degrees = 1,
90 Cw180Degrees = 2,
91 Cw270Degrees = 3,
92}
93
94impl ScreenCaptureRotation {
95 #[inline]
96 pub fn from_primitive(prim: u32) -> Option<Self> {
97 match prim {
98 0 => Some(Self::Cw0Degrees),
99 1 => Some(Self::Cw90Degrees),
100 2 => Some(Self::Cw180Degrees),
101 3 => Some(Self::Cw270Degrees),
102 _ => None,
103 }
104 }
105
106 #[inline]
107 pub const fn into_primitive(self) -> u32 {
108 self as u32
109 }
110}
111
112mod internal {
113 use super::*;
114 unsafe impl fidl::encoding::TypeMarker for ScreenCaptureError {
115 type Owned = Self;
116
117 #[inline(always)]
118 fn inline_align(_context: fidl::encoding::Context) -> usize {
119 std::mem::align_of::<u32>()
120 }
121
122 #[inline(always)]
123 fn inline_size(_context: fidl::encoding::Context) -> usize {
124 std::mem::size_of::<u32>()
125 }
126
127 #[inline(always)]
128 fn encode_is_copy() -> bool {
129 false
130 }
131
132 #[inline(always)]
133 fn decode_is_copy() -> bool {
134 false
135 }
136 }
137
138 impl fidl::encoding::ValueTypeMarker for ScreenCaptureError {
139 type Borrowed<'a> = Self;
140 #[inline(always)]
141 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
142 *value
143 }
144 }
145
146 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
147 for ScreenCaptureError
148 {
149 #[inline]
150 unsafe fn encode(
151 self,
152 encoder: &mut fidl::encoding::Encoder<'_, D>,
153 offset: usize,
154 _depth: fidl::encoding::Depth,
155 ) -> fidl::Result<()> {
156 encoder.debug_check_bounds::<Self>(offset);
157 encoder.write_num(self.into_primitive(), offset);
158 Ok(())
159 }
160 }
161
162 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ScreenCaptureError {
163 #[inline(always)]
164 fn new_empty() -> Self {
165 Self::unknown()
166 }
167
168 #[inline]
169 unsafe fn decode(
170 &mut self,
171 decoder: &mut fidl::encoding::Decoder<'_, D>,
172 offset: usize,
173 _depth: fidl::encoding::Depth,
174 ) -> fidl::Result<()> {
175 decoder.debug_check_bounds::<Self>(offset);
176 let prim = decoder.read_num::<u32>(offset);
177
178 *self = Self::from_primitive_allow_unknown(prim);
179 Ok(())
180 }
181 }
182 unsafe impl fidl::encoding::TypeMarker for ScreenCaptureRotation {
183 type Owned = Self;
184
185 #[inline(always)]
186 fn inline_align(_context: fidl::encoding::Context) -> usize {
187 std::mem::align_of::<u32>()
188 }
189
190 #[inline(always)]
191 fn inline_size(_context: fidl::encoding::Context) -> usize {
192 std::mem::size_of::<u32>()
193 }
194
195 #[inline(always)]
196 fn encode_is_copy() -> bool {
197 true
198 }
199
200 #[inline(always)]
201 fn decode_is_copy() -> bool {
202 false
203 }
204 }
205
206 impl fidl::encoding::ValueTypeMarker for ScreenCaptureRotation {
207 type Borrowed<'a> = Self;
208 #[inline(always)]
209 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
210 *value
211 }
212 }
213
214 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
215 for ScreenCaptureRotation
216 {
217 #[inline]
218 unsafe fn encode(
219 self,
220 encoder: &mut fidl::encoding::Encoder<'_, D>,
221 offset: usize,
222 _depth: fidl::encoding::Depth,
223 ) -> fidl::Result<()> {
224 encoder.debug_check_bounds::<Self>(offset);
225 encoder.write_num(self.into_primitive(), offset);
226 Ok(())
227 }
228 }
229
230 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ScreenCaptureRotation {
231 #[inline(always)]
232 fn new_empty() -> Self {
233 Self::Cw0Degrees
234 }
235
236 #[inline]
237 unsafe fn decode(
238 &mut self,
239 decoder: &mut fidl::encoding::Decoder<'_, D>,
240 offset: usize,
241 _depth: fidl::encoding::Depth,
242 ) -> fidl::Result<()> {
243 decoder.debug_check_bounds::<Self>(offset);
244 let prim = decoder.read_num::<u32>(offset);
245
246 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
247 Ok(())
248 }
249 }
250}