fidl_fdf_common/
fidl_fdf_common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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
32mod internal {
33    use super::*;
34    unsafe impl fidl::encoding::TypeMarker for ObjType {
35        type Owned = Self;
36
37        #[inline(always)]
38        fn inline_align(_context: fidl::encoding::Context) -> usize {
39            std::mem::align_of::<u32>()
40        }
41
42        #[inline(always)]
43        fn inline_size(_context: fidl::encoding::Context) -> usize {
44            std::mem::size_of::<u32>()
45        }
46
47        #[inline(always)]
48        fn encode_is_copy() -> bool {
49            true
50        }
51
52        #[inline(always)]
53        fn decode_is_copy() -> bool {
54            false
55        }
56    }
57
58    impl fidl::encoding::ValueTypeMarker for ObjType {
59        type Borrowed<'a> = Self;
60        #[inline(always)]
61        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
62            *value
63        }
64    }
65
66    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ObjType {
67        #[inline]
68        unsafe fn encode(
69            self,
70            encoder: &mut fidl::encoding::Encoder<'_, D>,
71            offset: usize,
72            _depth: fidl::encoding::Depth,
73        ) -> fidl::Result<()> {
74            encoder.debug_check_bounds::<Self>(offset);
75            encoder.write_num(self.into_primitive(), offset);
76            Ok(())
77        }
78    }
79
80    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ObjType {
81        #[inline(always)]
82        fn new_empty() -> Self {
83            Self::Channel
84        }
85
86        #[inline]
87        unsafe fn decode(
88            &mut self,
89            decoder: &mut fidl::encoding::Decoder<'_, D>,
90            offset: usize,
91            _depth: fidl::encoding::Depth,
92        ) -> fidl::Result<()> {
93            decoder.debug_check_bounds::<Self>(offset);
94            let prim = decoder.read_num::<u32>(offset);
95
96            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
97            Ok(())
98        }
99    }
100}