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