fidl_fuchsia_space__common/
fidl_fuchsia_space__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 ErrorCode {
14    Internal = 1,
15    /// The system is in the process of being updated, and the current system version has not yet
16    /// been committed. GC is blocked to protect the blobs required by the previous system version.
17    /// Consumers may use [`fuchsia.update/CommitStatusProvider.IsCurrentSystemCommitted`] to track
18    /// when the commit completes.
19    PendingCommit = 2,
20}
21
22impl ErrorCode {
23    #[inline]
24    pub fn from_primitive(prim: u32) -> Option<Self> {
25        match prim {
26            1 => Some(Self::Internal),
27            2 => Some(Self::PendingCommit),
28            _ => None,
29        }
30    }
31
32    #[inline]
33    pub const fn into_primitive(self) -> u32 {
34        self as u32
35    }
36}
37
38mod internal {
39    use super::*;
40    unsafe impl fidl::encoding::TypeMarker for ErrorCode {
41        type Owned = Self;
42
43        #[inline(always)]
44        fn inline_align(_context: fidl::encoding::Context) -> usize {
45            std::mem::align_of::<u32>()
46        }
47
48        #[inline(always)]
49        fn inline_size(_context: fidl::encoding::Context) -> usize {
50            std::mem::size_of::<u32>()
51        }
52
53        #[inline(always)]
54        fn encode_is_copy() -> bool {
55            true
56        }
57
58        #[inline(always)]
59        fn decode_is_copy() -> bool {
60            false
61        }
62    }
63
64    impl fidl::encoding::ValueTypeMarker for ErrorCode {
65        type Borrowed<'a> = Self;
66        #[inline(always)]
67        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
68            *value
69        }
70    }
71
72    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for ErrorCode {
73        #[inline]
74        unsafe fn encode(
75            self,
76            encoder: &mut fidl::encoding::Encoder<'_, D>,
77            offset: usize,
78            _depth: fidl::encoding::Depth,
79        ) -> fidl::Result<()> {
80            encoder.debug_check_bounds::<Self>(offset);
81            encoder.write_num(self.into_primitive(), offset);
82            Ok(())
83        }
84    }
85
86    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ErrorCode {
87        #[inline(always)]
88        fn new_empty() -> Self {
89            Self::Internal
90        }
91
92        #[inline]
93        unsafe fn decode(
94            &mut self,
95            decoder: &mut fidl::encoding::Decoder<'_, D>,
96            offset: usize,
97            _depth: fidl::encoding::Depth,
98        ) -> fidl::Result<()> {
99            decoder.debug_check_bounds::<Self>(offset);
100            let prim = decoder.read_num::<u32>(offset);
101
102            *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
103            Ok(())
104        }
105    }
106}