fidl_fdf_common/
fidl_fdf_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)]
12#[repr(u32)]
13pub enum ObjType {
14 Channel = 4,
15}
16
17impl ObjType {
18 #[inline]
19 pub fn from_primitive(prim: u32) -> Option<Self> {
20 match prim {
21 4 => Some(Self::Channel),
22 _ => None,
23 }
24 }
25
26 #[inline]
27 pub const fn into_primitive(self) -> u32 {
28 self as u32
29 }
30
31 #[deprecated = "Strict enums should not use `is_unknown`"]
32 #[inline]
33 pub fn is_unknown(&self) -> bool {
34 false
35 }
36}
37
38mod internal {
39 use super::*;
40 unsafe impl fidl::encoding::TypeMarker for ObjType {
41 type Owned = Self;
42
43 #[inline(always)]
44 fn inline_align(_context: fidl::encoding::Context) -> usize {
45 std::mem::align_of::<u32>()
46 }
47
48 #[inline(always)]
49 fn inline_size(_context: fidl::encoding::Context) -> usize {
50 std::mem::size_of::<u32>()
51 }
52
53 #[inline(always)]
54 fn encode_is_copy() -> bool {
55 true
56 }
57
58 #[inline(always)]
59 fn decode_is_copy() -> bool {
60 false
61 }
62 }
63
64 impl fidl::encoding::ValueTypeMarker for ObjType {
65 type Borrowed<'a> = Self;
66 #[inline(always)]
67 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
68 *value
69 }
70 }
71
72 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ObjType {
73 #[inline]
74 unsafe fn encode(
75 self,
76 encoder: &mut fidl::encoding::Encoder<'_, D>,
77 offset: usize,
78 _depth: fidl::encoding::Depth,
79 ) -> fidl::Result<()> {
80 encoder.debug_check_bounds::<Self>(offset);
81 encoder.write_num(self.into_primitive(), offset);
82 Ok(())
83 }
84 }
85
86 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ObjType {
87 #[inline(always)]
88 fn new_empty() -> Self {
89 Self::Channel
90 }
91
92 #[inline]
93 unsafe fn decode(
94 &mut self,
95 decoder: &mut fidl::encoding::Decoder<'_, D>,
96 offset: usize,
97 _depth: fidl::encoding::Depth,
98 ) -> fidl::Result<()> {
99 decoder.debug_check_bounds::<Self>(offset);
100 let prim = decoder.read_num::<u32>(offset);
101
102 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
103 Ok(())
104 }
105 }
106}