fidl_fuchsia_dash__common/
fidl_fuchsia_dash__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
11pub const MAX_URLS: u64 = 20;
13
14#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16#[repr(u32)]
17pub enum DashNamespaceLayout {
18 NestAllInstanceDirs = 1,
21 InstanceNamespaceIsRoot = 2,
26}
27
28impl DashNamespaceLayout {
29 #[inline]
30 pub fn from_primitive(prim: u32) -> Option<Self> {
31 match prim {
32 1 => Some(Self::NestAllInstanceDirs),
33 2 => Some(Self::InstanceNamespaceIsRoot),
34 _ => None,
35 }
36 }
37
38 #[inline]
39 pub const fn into_primitive(self) -> u32 {
40 self as u32
41 }
42}
43
44#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
46pub enum FuchsiaPkgResolver {
47 Base,
49 Full,
52 #[doc(hidden)]
53 __SourceBreaking { unknown_ordinal: u32 },
54}
55
56#[macro_export]
58macro_rules! FuchsiaPkgResolverUnknown {
59 () => {
60 _
61 };
62}
63
64impl FuchsiaPkgResolver {
65 #[inline]
66 pub fn from_primitive(prim: u32) -> Option<Self> {
67 match prim {
68 1 => Some(Self::Base),
69 2 => Some(Self::Full),
70 _ => None,
71 }
72 }
73
74 #[inline]
75 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
76 match prim {
77 1 => Self::Base,
78 2 => Self::Full,
79 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
80 }
81 }
82
83 #[inline]
84 pub fn unknown() -> Self {
85 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
86 }
87
88 #[inline]
89 pub const fn into_primitive(self) -> u32 {
90 match self {
91 Self::Base => 1,
92 Self::Full => 2,
93 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
94 }
95 }
96
97 #[inline]
98 pub fn is_unknown(&self) -> bool {
99 match self {
100 Self::__SourceBreaking { unknown_ordinal: _ } => true,
101 _ => false,
102 }
103 }
104}
105
106#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
108#[repr(u32)]
109pub enum LauncherError {
110 Internal = 1,
112 BadMoniker = 2,
114 InstanceNotFound = 3,
116 RealmQuery = 4,
118 ProcessLauncher = 5,
120 DashBinary = 6,
122 Pty = 7,
124 InstanceNotResolved = 8,
126 PackageResolver = 9,
128 ToolsCannotResolve = 10,
130 BadUrl = 11,
132 ToolsBinaryRead = 12,
134 NonUniqueBinaryName = 13,
136 ProcessResolver = 14,
138 VmexResource = 15,
140 ResolveTargetPackage = 16,
142}
143
144impl LauncherError {
145 #[inline]
146 pub fn from_primitive(prim: u32) -> Option<Self> {
147 match prim {
148 1 => Some(Self::Internal),
149 2 => Some(Self::BadMoniker),
150 3 => Some(Self::InstanceNotFound),
151 4 => Some(Self::RealmQuery),
152 5 => Some(Self::ProcessLauncher),
153 6 => Some(Self::DashBinary),
154 7 => Some(Self::Pty),
155 8 => Some(Self::InstanceNotResolved),
156 9 => Some(Self::PackageResolver),
157 10 => Some(Self::ToolsCannotResolve),
158 11 => Some(Self::BadUrl),
159 12 => Some(Self::ToolsBinaryRead),
160 13 => Some(Self::NonUniqueBinaryName),
161 14 => Some(Self::ProcessResolver),
162 15 => Some(Self::VmexResource),
163 16 => Some(Self::ResolveTargetPackage),
164 _ => None,
165 }
166 }
167
168 #[inline]
169 pub const fn into_primitive(self) -> u32 {
170 self as u32
171 }
172}
173
174#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
175#[repr(C)]
176pub struct LauncherOnTerminatedRequest {
177 pub return_code: i32,
179}
180
181impl fidl::Persistable for LauncherOnTerminatedRequest {}
182
183mod internal {
184 use super::*;
185 unsafe impl fidl::encoding::TypeMarker for DashNamespaceLayout {
186 type Owned = Self;
187
188 #[inline(always)]
189 fn inline_align(_context: fidl::encoding::Context) -> usize {
190 std::mem::align_of::<u32>()
191 }
192
193 #[inline(always)]
194 fn inline_size(_context: fidl::encoding::Context) -> usize {
195 std::mem::size_of::<u32>()
196 }
197
198 #[inline(always)]
199 fn encode_is_copy() -> bool {
200 true
201 }
202
203 #[inline(always)]
204 fn decode_is_copy() -> bool {
205 false
206 }
207 }
208
209 impl fidl::encoding::ValueTypeMarker for DashNamespaceLayout {
210 type Borrowed<'a> = Self;
211 #[inline(always)]
212 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
213 *value
214 }
215 }
216
217 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
218 for DashNamespaceLayout
219 {
220 #[inline]
221 unsafe fn encode(
222 self,
223 encoder: &mut fidl::encoding::Encoder<'_, D>,
224 offset: usize,
225 _depth: fidl::encoding::Depth,
226 ) -> fidl::Result<()> {
227 encoder.debug_check_bounds::<Self>(offset);
228 encoder.write_num(self.into_primitive(), offset);
229 Ok(())
230 }
231 }
232
233 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DashNamespaceLayout {
234 #[inline(always)]
235 fn new_empty() -> Self {
236 Self::NestAllInstanceDirs
237 }
238
239 #[inline]
240 unsafe fn decode(
241 &mut self,
242 decoder: &mut fidl::encoding::Decoder<'_, D>,
243 offset: usize,
244 _depth: fidl::encoding::Depth,
245 ) -> fidl::Result<()> {
246 decoder.debug_check_bounds::<Self>(offset);
247 let prim = decoder.read_num::<u32>(offset);
248
249 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
250 Ok(())
251 }
252 }
253 unsafe impl fidl::encoding::TypeMarker for FuchsiaPkgResolver {
254 type Owned = Self;
255
256 #[inline(always)]
257 fn inline_align(_context: fidl::encoding::Context) -> usize {
258 std::mem::align_of::<u32>()
259 }
260
261 #[inline(always)]
262 fn inline_size(_context: fidl::encoding::Context) -> usize {
263 std::mem::size_of::<u32>()
264 }
265
266 #[inline(always)]
267 fn encode_is_copy() -> bool {
268 false
269 }
270
271 #[inline(always)]
272 fn decode_is_copy() -> bool {
273 false
274 }
275 }
276
277 impl fidl::encoding::ValueTypeMarker for FuchsiaPkgResolver {
278 type Borrowed<'a> = Self;
279 #[inline(always)]
280 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
281 *value
282 }
283 }
284
285 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
286 for FuchsiaPkgResolver
287 {
288 #[inline]
289 unsafe fn encode(
290 self,
291 encoder: &mut fidl::encoding::Encoder<'_, D>,
292 offset: usize,
293 _depth: fidl::encoding::Depth,
294 ) -> fidl::Result<()> {
295 encoder.debug_check_bounds::<Self>(offset);
296 encoder.write_num(self.into_primitive(), offset);
297 Ok(())
298 }
299 }
300
301 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for FuchsiaPkgResolver {
302 #[inline(always)]
303 fn new_empty() -> Self {
304 Self::unknown()
305 }
306
307 #[inline]
308 unsafe fn decode(
309 &mut self,
310 decoder: &mut fidl::encoding::Decoder<'_, D>,
311 offset: usize,
312 _depth: fidl::encoding::Depth,
313 ) -> fidl::Result<()> {
314 decoder.debug_check_bounds::<Self>(offset);
315 let prim = decoder.read_num::<u32>(offset);
316
317 *self = Self::from_primitive_allow_unknown(prim);
318 Ok(())
319 }
320 }
321 unsafe impl fidl::encoding::TypeMarker for LauncherError {
322 type Owned = Self;
323
324 #[inline(always)]
325 fn inline_align(_context: fidl::encoding::Context) -> usize {
326 std::mem::align_of::<u32>()
327 }
328
329 #[inline(always)]
330 fn inline_size(_context: fidl::encoding::Context) -> usize {
331 std::mem::size_of::<u32>()
332 }
333
334 #[inline(always)]
335 fn encode_is_copy() -> bool {
336 true
337 }
338
339 #[inline(always)]
340 fn decode_is_copy() -> bool {
341 false
342 }
343 }
344
345 impl fidl::encoding::ValueTypeMarker for LauncherError {
346 type Borrowed<'a> = Self;
347 #[inline(always)]
348 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
349 *value
350 }
351 }
352
353 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for LauncherError {
354 #[inline]
355 unsafe fn encode(
356 self,
357 encoder: &mut fidl::encoding::Encoder<'_, D>,
358 offset: usize,
359 _depth: fidl::encoding::Depth,
360 ) -> fidl::Result<()> {
361 encoder.debug_check_bounds::<Self>(offset);
362 encoder.write_num(self.into_primitive(), offset);
363 Ok(())
364 }
365 }
366
367 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for LauncherError {
368 #[inline(always)]
369 fn new_empty() -> Self {
370 Self::Internal
371 }
372
373 #[inline]
374 unsafe fn decode(
375 &mut self,
376 decoder: &mut fidl::encoding::Decoder<'_, D>,
377 offset: usize,
378 _depth: fidl::encoding::Depth,
379 ) -> fidl::Result<()> {
380 decoder.debug_check_bounds::<Self>(offset);
381 let prim = decoder.read_num::<u32>(offset);
382
383 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
384 Ok(())
385 }
386 }
387
388 impl fidl::encoding::ValueTypeMarker for LauncherOnTerminatedRequest {
389 type Borrowed<'a> = &'a Self;
390 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
391 value
392 }
393 }
394
395 unsafe impl fidl::encoding::TypeMarker for LauncherOnTerminatedRequest {
396 type Owned = Self;
397
398 #[inline(always)]
399 fn inline_align(_context: fidl::encoding::Context) -> usize {
400 4
401 }
402
403 #[inline(always)]
404 fn inline_size(_context: fidl::encoding::Context) -> usize {
405 4
406 }
407 #[inline(always)]
408 fn encode_is_copy() -> bool {
409 true
410 }
411
412 #[inline(always)]
413 fn decode_is_copy() -> bool {
414 true
415 }
416 }
417
418 unsafe impl<D: fidl::encoding::ResourceDialect>
419 fidl::encoding::Encode<LauncherOnTerminatedRequest, D> for &LauncherOnTerminatedRequest
420 {
421 #[inline]
422 unsafe fn encode(
423 self,
424 encoder: &mut fidl::encoding::Encoder<'_, D>,
425 offset: usize,
426 _depth: fidl::encoding::Depth,
427 ) -> fidl::Result<()> {
428 encoder.debug_check_bounds::<LauncherOnTerminatedRequest>(offset);
429 unsafe {
430 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
432 (buf_ptr as *mut LauncherOnTerminatedRequest)
433 .write_unaligned((self as *const LauncherOnTerminatedRequest).read());
434 }
437 Ok(())
438 }
439 }
440 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
441 fidl::encoding::Encode<LauncherOnTerminatedRequest, D> for (T0,)
442 {
443 #[inline]
444 unsafe fn encode(
445 self,
446 encoder: &mut fidl::encoding::Encoder<'_, D>,
447 offset: usize,
448 depth: fidl::encoding::Depth,
449 ) -> fidl::Result<()> {
450 encoder.debug_check_bounds::<LauncherOnTerminatedRequest>(offset);
451 self.0.encode(encoder, offset + 0, depth)?;
455 Ok(())
456 }
457 }
458
459 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
460 for LauncherOnTerminatedRequest
461 {
462 #[inline(always)]
463 fn new_empty() -> Self {
464 Self { return_code: fidl::new_empty!(i32, D) }
465 }
466
467 #[inline]
468 unsafe fn decode(
469 &mut self,
470 decoder: &mut fidl::encoding::Decoder<'_, D>,
471 offset: usize,
472 _depth: fidl::encoding::Depth,
473 ) -> fidl::Result<()> {
474 decoder.debug_check_bounds::<Self>(offset);
475 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
476 unsafe {
479 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
480 }
481 Ok(())
482 }
483 }
484}