fidl_fuchsia_pkg_resolution__common/
fidl_fuchsia_pkg_resolution__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 ResolveError {
14 Internal,
16 AccessDenied,
18 Io,
20 BlobNotFound,
22 PackageNotFound,
24 RepoNotFound,
26 NoSpace,
28 UnavailableBlob,
30 UnavailableRepoMetadata,
32 InvalidUrl,
34 InvalidContext,
36 #[doc(hidden)]
37 __SourceBreaking { unknown_ordinal: i32 },
38}
39
40#[macro_export]
42macro_rules! ResolveErrorUnknown {
43 () => {
44 _
45 };
46}
47
48impl ResolveError {
49 #[inline]
50 pub fn from_primitive(prim: i32) -> Option<Self> {
51 match prim {
52 1 => Some(Self::Internal),
53 2 => Some(Self::AccessDenied),
54 3 => Some(Self::Io),
55 4 => Some(Self::BlobNotFound),
56 5 => Some(Self::PackageNotFound),
57 6 => Some(Self::RepoNotFound),
58 7 => Some(Self::NoSpace),
59 8 => Some(Self::UnavailableBlob),
60 9 => Some(Self::UnavailableRepoMetadata),
61 10 => Some(Self::InvalidUrl),
62 11 => Some(Self::InvalidContext),
63 _ => None,
64 }
65 }
66
67 #[inline]
68 pub fn from_primitive_allow_unknown(prim: i32) -> Self {
69 match prim {
70 1 => Self::Internal,
71 2 => Self::AccessDenied,
72 3 => Self::Io,
73 4 => Self::BlobNotFound,
74 5 => Self::PackageNotFound,
75 6 => Self::RepoNotFound,
76 7 => Self::NoSpace,
77 8 => Self::UnavailableBlob,
78 9 => Self::UnavailableRepoMetadata,
79 10 => Self::InvalidUrl,
80 11 => Self::InvalidContext,
81 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
82 }
83 }
84
85 #[inline]
86 pub fn unknown() -> Self {
87 Self::__SourceBreaking { unknown_ordinal: 0x7fffffff }
88 }
89
90 #[inline]
91 pub const fn into_primitive(self) -> i32 {
92 match self {
93 Self::Internal => 1,
94 Self::AccessDenied => 2,
95 Self::Io => 3,
96 Self::BlobNotFound => 4,
97 Self::PackageNotFound => 5,
98 Self::RepoNotFound => 6,
99 Self::NoSpace => 7,
100 Self::UnavailableBlob => 8,
101 Self::UnavailableRepoMetadata => 9,
102 Self::InvalidUrl => 10,
103 Self::InvalidContext => 11,
104 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
105 }
106 }
107
108 #[inline]
109 pub fn is_unknown(&self) -> bool {
110 match self {
111 Self::__SourceBreaking { unknown_ordinal: _ } => true,
112 _ => false,
113 }
114 }
115}
116
117pub mod package_resolver_ordinals {
118 pub const RESOLVE: u64 = 0x33e16c815a5aed26;
119}
120
121mod internal {
122 use super::*;
123 unsafe impl fidl::encoding::TypeMarker for ResolveError {
124 type Owned = Self;
125
126 #[inline(always)]
127 fn inline_align(_context: fidl::encoding::Context) -> usize {
128 std::mem::align_of::<i32>()
129 }
130
131 #[inline(always)]
132 fn inline_size(_context: fidl::encoding::Context) -> usize {
133 std::mem::size_of::<i32>()
134 }
135
136 #[inline(always)]
137 fn encode_is_copy() -> bool {
138 false
139 }
140
141 #[inline(always)]
142 fn decode_is_copy() -> bool {
143 false
144 }
145 }
146
147 impl fidl::encoding::ValueTypeMarker for ResolveError {
148 type Borrowed<'a> = Self;
149 #[inline(always)]
150 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
151 *value
152 }
153 }
154
155 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ResolveError {
156 #[inline]
157 unsafe fn encode(
158 self,
159 encoder: &mut fidl::encoding::Encoder<'_, D>,
160 offset: usize,
161 _depth: fidl::encoding::Depth,
162 ) -> fidl::Result<()> {
163 encoder.debug_check_bounds::<Self>(offset);
164 encoder.write_num(self.into_primitive(), offset);
165 Ok(())
166 }
167 }
168
169 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ResolveError {
170 #[inline(always)]
171 fn new_empty() -> Self {
172 Self::unknown()
173 }
174
175 #[inline]
176 unsafe fn decode(
177 &mut self,
178 decoder: &mut fidl::encoding::Decoder<'_, D>,
179 offset: usize,
180 _depth: fidl::encoding::Depth,
181 ) -> fidl::Result<()> {
182 decoder.debug_check_bounds::<Self>(offset);
183 let prim = decoder.read_num::<i32>(offset);
184
185 *self = Self::from_primitive_allow_unknown(prim);
186 Ok(())
187 }
188 }
189}