fidl_fuchsia_pkg_garbagecollector__common/
fidl_fuchsia_pkg_garbagecollector__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)]
13pub enum GcError {
14 Internal,
15 PendingCommit,
21 #[doc(hidden)]
22 __SourceBreaking {
23 unknown_ordinal: u32,
24 },
25}
26
27#[macro_export]
29macro_rules! GcErrorUnknown {
30 () => {
31 _
32 };
33}
34
35impl GcError {
36 #[inline]
37 pub fn from_primitive(prim: u32) -> Option<Self> {
38 match prim {
39 1 => Some(Self::Internal),
40 2 => Some(Self::PendingCommit),
41 _ => None,
42 }
43 }
44
45 #[inline]
46 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
47 match prim {
48 1 => Self::Internal,
49 2 => Self::PendingCommit,
50 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
51 }
52 }
53
54 #[inline]
55 pub fn unknown() -> Self {
56 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
57 }
58
59 #[inline]
60 pub const fn into_primitive(self) -> u32 {
61 match self {
62 Self::Internal => 1,
63 Self::PendingCommit => 2,
64 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
65 }
66 }
67
68 #[inline]
69 pub fn is_unknown(&self) -> bool {
70 match self {
71 Self::__SourceBreaking { unknown_ordinal: _ } => true,
72 _ => false,
73 }
74 }
75}
76
77pub mod manager_ordinals {
78 pub const GC: u64 = 0x68a3c8b241ab99ce;
79}
80
81mod internal {
82 use super::*;
83 unsafe impl fidl::encoding::TypeMarker for GcError {
84 type Owned = Self;
85
86 #[inline(always)]
87 fn inline_align(_context: fidl::encoding::Context) -> usize {
88 std::mem::align_of::<u32>()
89 }
90
91 #[inline(always)]
92 fn inline_size(_context: fidl::encoding::Context) -> usize {
93 std::mem::size_of::<u32>()
94 }
95
96 #[inline(always)]
97 fn encode_is_copy() -> bool {
98 false
99 }
100
101 #[inline(always)]
102 fn decode_is_copy() -> bool {
103 false
104 }
105 }
106
107 impl fidl::encoding::ValueTypeMarker for GcError {
108 type Borrowed<'a> = Self;
109 #[inline(always)]
110 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
111 *value
112 }
113 }
114
115 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for GcError {
116 #[inline]
117 unsafe fn encode(
118 self,
119 encoder: &mut fidl::encoding::Encoder<'_, D>,
120 offset: usize,
121 _depth: fidl::encoding::Depth,
122 ) -> fidl::Result<()> {
123 encoder.debug_check_bounds::<Self>(offset);
124 encoder.write_num(self.into_primitive(), offset);
125 Ok(())
126 }
127 }
128
129 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GcError {
130 #[inline(always)]
131 fn new_empty() -> Self {
132 Self::unknown()
133 }
134
135 #[inline]
136 unsafe fn decode(
137 &mut self,
138 decoder: &mut fidl::encoding::Decoder<'_, D>,
139 offset: usize,
140 _depth: fidl::encoding::Depth,
141 ) -> fidl::Result<()> {
142 decoder.debug_check_bounds::<Self>(offset);
143 let prim = decoder.read_num::<u32>(offset);
144
145 *self = Self::from_primitive_allow_unknown(prim);
146 Ok(())
147 }
148 }
149}