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