fidl_fuchsia_starnix_gralloc_common/
fidl_fuchsia_starnix_gralloc_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)]
12pub enum VulkanMode {
13 NotYetSet,
14 Swiftshader,
15 Magma,
16 #[doc(hidden)]
17 __SourceBreaking {
18 unknown_ordinal: u32,
19 },
20}
21
22#[macro_export]
24macro_rules! VulkanModeUnknown {
25 () => {
26 _
27 };
28}
29
30impl VulkanMode {
31 #[inline]
32 pub fn from_primitive(prim: u32) -> Option<Self> {
33 match prim {
34 0 => Some(Self::NotYetSet),
35 1 => Some(Self::Swiftshader),
36 2 => Some(Self::Magma),
37 _ => None,
38 }
39 }
40
41 #[inline]
42 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
43 match prim {
44 0 => Self::NotYetSet,
45 1 => Self::Swiftshader,
46 2 => Self::Magma,
47 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
48 }
49 }
50
51 #[inline]
52 pub fn unknown() -> Self {
53 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
54 }
55
56 #[inline]
57 pub const fn into_primitive(self) -> u32 {
58 match self {
59 Self::NotYetSet => 0,
60 Self::Swiftshader => 1,
61 Self::Magma => 2,
62 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
63 }
64 }
65
66 #[inline]
67 pub fn is_unknown(&self) -> bool {
68 match self {
69 Self::__SourceBreaking { unknown_ordinal: _ } => true,
70 _ => false,
71 }
72 }
73}
74
75#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
76pub enum VulkanModeSetterError {
77 InvalidArgs,
78 #[doc(hidden)]
79 __SourceBreaking {
80 unknown_ordinal: u32,
81 },
82}
83
84#[macro_export]
86macro_rules! VulkanModeSetterErrorUnknown {
87 () => {
88 _
89 };
90}
91
92impl VulkanModeSetterError {
93 #[inline]
94 pub fn from_primitive(prim: u32) -> Option<Self> {
95 match prim {
96 1 => Some(Self::InvalidArgs),
97 _ => None,
98 }
99 }
100
101 #[inline]
102 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
103 match prim {
104 1 => Self::InvalidArgs,
105 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
106 }
107 }
108
109 #[inline]
110 pub fn unknown() -> Self {
111 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
112 }
113
114 #[inline]
115 pub const fn into_primitive(self) -> u32 {
116 match self {
117 Self::InvalidArgs => 1,
118 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
119 }
120 }
121
122 #[inline]
123 pub fn is_unknown(&self) -> bool {
124 match self {
125 Self::__SourceBreaking { unknown_ordinal: _ } => true,
126 _ => false,
127 }
128 }
129}
130
131#[derive(Clone, Debug, Default, PartialEq)]
132pub struct VulkanModeSetterSetVulkanModeRequest {
133 pub vulkan_mode: Option<VulkanMode>,
134 #[doc(hidden)]
135 pub __source_breaking: fidl::marker::SourceBreaking,
136}
137
138impl fidl::Persistable for VulkanModeSetterSetVulkanModeRequest {}
139
140mod internal {
141 use super::*;
142 unsafe impl fidl::encoding::TypeMarker for VulkanMode {
143 type Owned = Self;
144
145 #[inline(always)]
146 fn inline_align(_context: fidl::encoding::Context) -> usize {
147 std::mem::align_of::<u32>()
148 }
149
150 #[inline(always)]
151 fn inline_size(_context: fidl::encoding::Context) -> usize {
152 std::mem::size_of::<u32>()
153 }
154
155 #[inline(always)]
156 fn encode_is_copy() -> bool {
157 false
158 }
159
160 #[inline(always)]
161 fn decode_is_copy() -> bool {
162 false
163 }
164 }
165
166 impl fidl::encoding::ValueTypeMarker for VulkanMode {
167 type Borrowed<'a> = Self;
168 #[inline(always)]
169 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
170 *value
171 }
172 }
173
174 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for VulkanMode {
175 #[inline]
176 unsafe fn encode(
177 self,
178 encoder: &mut fidl::encoding::Encoder<'_, D>,
179 offset: usize,
180 _depth: fidl::encoding::Depth,
181 ) -> fidl::Result<()> {
182 encoder.debug_check_bounds::<Self>(offset);
183 encoder.write_num(self.into_primitive(), offset);
184 Ok(())
185 }
186 }
187
188 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VulkanMode {
189 #[inline(always)]
190 fn new_empty() -> Self {
191 Self::unknown()
192 }
193
194 #[inline]
195 unsafe fn decode(
196 &mut self,
197 decoder: &mut fidl::encoding::Decoder<'_, D>,
198 offset: usize,
199 _depth: fidl::encoding::Depth,
200 ) -> fidl::Result<()> {
201 decoder.debug_check_bounds::<Self>(offset);
202 let prim = decoder.read_num::<u32>(offset);
203
204 *self = Self::from_primitive_allow_unknown(prim);
205 Ok(())
206 }
207 }
208 unsafe impl fidl::encoding::TypeMarker for VulkanModeSetterError {
209 type Owned = Self;
210
211 #[inline(always)]
212 fn inline_align(_context: fidl::encoding::Context) -> usize {
213 std::mem::align_of::<u32>()
214 }
215
216 #[inline(always)]
217 fn inline_size(_context: fidl::encoding::Context) -> usize {
218 std::mem::size_of::<u32>()
219 }
220
221 #[inline(always)]
222 fn encode_is_copy() -> bool {
223 false
224 }
225
226 #[inline(always)]
227 fn decode_is_copy() -> bool {
228 false
229 }
230 }
231
232 impl fidl::encoding::ValueTypeMarker for VulkanModeSetterError {
233 type Borrowed<'a> = Self;
234 #[inline(always)]
235 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
236 *value
237 }
238 }
239
240 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
241 for VulkanModeSetterError
242 {
243 #[inline]
244 unsafe fn encode(
245 self,
246 encoder: &mut fidl::encoding::Encoder<'_, D>,
247 offset: usize,
248 _depth: fidl::encoding::Depth,
249 ) -> fidl::Result<()> {
250 encoder.debug_check_bounds::<Self>(offset);
251 encoder.write_num(self.into_primitive(), offset);
252 Ok(())
253 }
254 }
255
256 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VulkanModeSetterError {
257 #[inline(always)]
258 fn new_empty() -> Self {
259 Self::unknown()
260 }
261
262 #[inline]
263 unsafe fn decode(
264 &mut self,
265 decoder: &mut fidl::encoding::Decoder<'_, D>,
266 offset: usize,
267 _depth: fidl::encoding::Depth,
268 ) -> fidl::Result<()> {
269 decoder.debug_check_bounds::<Self>(offset);
270 let prim = decoder.read_num::<u32>(offset);
271
272 *self = Self::from_primitive_allow_unknown(prim);
273 Ok(())
274 }
275 }
276
277 impl VulkanModeSetterSetVulkanModeRequest {
278 #[inline(always)]
279 fn max_ordinal_present(&self) -> u64 {
280 if let Some(_) = self.vulkan_mode {
281 return 1;
282 }
283 0
284 }
285 }
286
287 impl fidl::encoding::ValueTypeMarker for VulkanModeSetterSetVulkanModeRequest {
288 type Borrowed<'a> = &'a Self;
289 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
290 value
291 }
292 }
293
294 unsafe impl fidl::encoding::TypeMarker for VulkanModeSetterSetVulkanModeRequest {
295 type Owned = Self;
296
297 #[inline(always)]
298 fn inline_align(_context: fidl::encoding::Context) -> usize {
299 8
300 }
301
302 #[inline(always)]
303 fn inline_size(_context: fidl::encoding::Context) -> usize {
304 16
305 }
306 }
307
308 unsafe impl<D: fidl::encoding::ResourceDialect>
309 fidl::encoding::Encode<VulkanModeSetterSetVulkanModeRequest, D>
310 for &VulkanModeSetterSetVulkanModeRequest
311 {
312 unsafe fn encode(
313 self,
314 encoder: &mut fidl::encoding::Encoder<'_, D>,
315 offset: usize,
316 mut depth: fidl::encoding::Depth,
317 ) -> fidl::Result<()> {
318 encoder.debug_check_bounds::<VulkanModeSetterSetVulkanModeRequest>(offset);
319 let max_ordinal: u64 = self.max_ordinal_present();
321 encoder.write_num(max_ordinal, offset);
322 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
323 if max_ordinal == 0 {
325 return Ok(());
326 }
327 depth.increment()?;
328 let envelope_size = 8;
329 let bytes_len = max_ordinal as usize * envelope_size;
330 #[allow(unused_variables)]
331 let offset = encoder.out_of_line_offset(bytes_len);
332 let mut _prev_end_offset: usize = 0;
333 if 1 > max_ordinal {
334 return Ok(());
335 }
336
337 let cur_offset: usize = (1 - 1) * envelope_size;
340
341 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
343
344 fidl::encoding::encode_in_envelope_optional::<VulkanMode, D>(
349 self.vulkan_mode
350 .as_ref()
351 .map(<VulkanMode as fidl::encoding::ValueTypeMarker>::borrow),
352 encoder,
353 offset + cur_offset,
354 depth,
355 )?;
356
357 _prev_end_offset = cur_offset + envelope_size;
358
359 Ok(())
360 }
361 }
362
363 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
364 for VulkanModeSetterSetVulkanModeRequest
365 {
366 #[inline(always)]
367 fn new_empty() -> Self {
368 Self::default()
369 }
370
371 unsafe fn decode(
372 &mut self,
373 decoder: &mut fidl::encoding::Decoder<'_, D>,
374 offset: usize,
375 mut depth: fidl::encoding::Depth,
376 ) -> fidl::Result<()> {
377 decoder.debug_check_bounds::<Self>(offset);
378 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
379 None => return Err(fidl::Error::NotNullable),
380 Some(len) => len,
381 };
382 if len == 0 {
384 return Ok(());
385 };
386 depth.increment()?;
387 let envelope_size = 8;
388 let bytes_len = len * envelope_size;
389 let offset = decoder.out_of_line_offset(bytes_len)?;
390 let mut _next_ordinal_to_read = 0;
392 let mut next_offset = offset;
393 let end_offset = offset + bytes_len;
394 _next_ordinal_to_read += 1;
395 if next_offset >= end_offset {
396 return Ok(());
397 }
398
399 while _next_ordinal_to_read < 1 {
401 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
402 _next_ordinal_to_read += 1;
403 next_offset += envelope_size;
404 }
405
406 let next_out_of_line = decoder.next_out_of_line();
407 let handles_before = decoder.remaining_handles();
408 if let Some((inlined, num_bytes, num_handles)) =
409 fidl::encoding::decode_envelope_header(decoder, next_offset)?
410 {
411 let member_inline_size =
412 <VulkanMode as fidl::encoding::TypeMarker>::inline_size(decoder.context);
413 if inlined != (member_inline_size <= 4) {
414 return Err(fidl::Error::InvalidInlineBitInEnvelope);
415 }
416 let inner_offset;
417 let mut inner_depth = depth.clone();
418 if inlined {
419 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
420 inner_offset = next_offset;
421 } else {
422 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
423 inner_depth.increment()?;
424 }
425 let val_ref =
426 self.vulkan_mode.get_or_insert_with(|| fidl::new_empty!(VulkanMode, D));
427 fidl::decode!(VulkanMode, D, val_ref, decoder, inner_offset, inner_depth)?;
428 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
429 {
430 return Err(fidl::Error::InvalidNumBytesInEnvelope);
431 }
432 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
433 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
434 }
435 }
436
437 next_offset += envelope_size;
438
439 while next_offset < end_offset {
441 _next_ordinal_to_read += 1;
442 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
443 next_offset += envelope_size;
444 }
445
446 Ok(())
447 }
448 }
449}