fidl_fuchsia_time_alarms__common/
fidl_fuchsia_time_alarms__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 type AlarmId = String;
12
13#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
16pub enum WakeAlarmsError {
17 Unspecified,
23 Dropped,
25 Internal,
29 #[doc(hidden)]
30 __SourceBreaking { unknown_ordinal: u32 },
31}
32
33#[macro_export]
35macro_rules! WakeAlarmsErrorUnknown {
36 () => {
37 _
38 };
39}
40
41impl WakeAlarmsError {
42 #[inline]
43 pub fn from_primitive(prim: u32) -> Option<Self> {
44 match prim {
45 1 => Some(Self::Unspecified),
46 2 => Some(Self::Dropped),
47 3 => Some(Self::Internal),
48 _ => None,
49 }
50 }
51
52 #[inline]
53 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
54 match prim {
55 1 => Self::Unspecified,
56 2 => Self::Dropped,
57 3 => Self::Internal,
58 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
59 }
60 }
61
62 #[inline]
63 pub fn unknown() -> Self {
64 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
65 }
66
67 #[inline]
68 pub const fn into_primitive(self) -> u32 {
69 match self {
70 Self::Unspecified => 1,
71 Self::Dropped => 2,
72 Self::Internal => 3,
73 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
74 }
75 }
76
77 #[inline]
78 pub fn is_unknown(&self) -> bool {
79 match self {
80 Self::__SourceBreaking { unknown_ordinal: _ } => true,
81 _ => false,
82 }
83 }
84}
85
86#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
87pub struct WakeAlarmsCancelRequest {
88 pub alarm_id: String,
98}
99
100impl fidl::Persistable for WakeAlarmsCancelRequest {}
101
102pub mod wake_alarms_ordinals {
103 pub const SET_AND_WAIT: u64 = 0x57ebd075ce4beba;
104 pub const CANCEL: u64 = 0x7b23a9760115e55c;
105}
106
107mod internal {
108 use super::*;
109 unsafe impl fidl::encoding::TypeMarker for WakeAlarmsError {
110 type Owned = Self;
111
112 #[inline(always)]
113 fn inline_align(_context: fidl::encoding::Context) -> usize {
114 std::mem::align_of::<u32>()
115 }
116
117 #[inline(always)]
118 fn inline_size(_context: fidl::encoding::Context) -> usize {
119 std::mem::size_of::<u32>()
120 }
121
122 #[inline(always)]
123 fn encode_is_copy() -> bool {
124 false
125 }
126
127 #[inline(always)]
128 fn decode_is_copy() -> bool {
129 false
130 }
131 }
132
133 impl fidl::encoding::ValueTypeMarker for WakeAlarmsError {
134 type Borrowed<'a> = Self;
135 #[inline(always)]
136 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
137 *value
138 }
139 }
140
141 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
142 for WakeAlarmsError
143 {
144 #[inline]
145 unsafe fn encode(
146 self,
147 encoder: &mut fidl::encoding::Encoder<'_, D>,
148 offset: usize,
149 _depth: fidl::encoding::Depth,
150 ) -> fidl::Result<()> {
151 encoder.debug_check_bounds::<Self>(offset);
152 encoder.write_num(self.into_primitive(), offset);
153 Ok(())
154 }
155 }
156
157 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WakeAlarmsError {
158 #[inline(always)]
159 fn new_empty() -> Self {
160 Self::unknown()
161 }
162
163 #[inline]
164 unsafe fn decode(
165 &mut self,
166 decoder: &mut fidl::encoding::Decoder<'_, D>,
167 offset: usize,
168 _depth: fidl::encoding::Depth,
169 ) -> fidl::Result<()> {
170 decoder.debug_check_bounds::<Self>(offset);
171 let prim = decoder.read_num::<u32>(offset);
172
173 *self = Self::from_primitive_allow_unknown(prim);
174 Ok(())
175 }
176 }
177
178 impl fidl::encoding::ValueTypeMarker for WakeAlarmsCancelRequest {
179 type Borrowed<'a> = &'a Self;
180 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
181 value
182 }
183 }
184
185 unsafe impl fidl::encoding::TypeMarker for WakeAlarmsCancelRequest {
186 type Owned = Self;
187
188 #[inline(always)]
189 fn inline_align(_context: fidl::encoding::Context) -> usize {
190 8
191 }
192
193 #[inline(always)]
194 fn inline_size(_context: fidl::encoding::Context) -> usize {
195 16
196 }
197 }
198
199 unsafe impl<D: fidl::encoding::ResourceDialect>
200 fidl::encoding::Encode<WakeAlarmsCancelRequest, D> for &WakeAlarmsCancelRequest
201 {
202 #[inline]
203 unsafe fn encode(
204 self,
205 encoder: &mut fidl::encoding::Encoder<'_, D>,
206 offset: usize,
207 _depth: fidl::encoding::Depth,
208 ) -> fidl::Result<()> {
209 encoder.debug_check_bounds::<WakeAlarmsCancelRequest>(offset);
210 fidl::encoding::Encode::<WakeAlarmsCancelRequest, D>::encode(
212 (<fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
213 &self.alarm_id,
214 ),),
215 encoder,
216 offset,
217 _depth,
218 )
219 }
220 }
221 unsafe impl<
222 D: fidl::encoding::ResourceDialect,
223 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
224 > fidl::encoding::Encode<WakeAlarmsCancelRequest, D> for (T0,)
225 {
226 #[inline]
227 unsafe fn encode(
228 self,
229 encoder: &mut fidl::encoding::Encoder<'_, D>,
230 offset: usize,
231 depth: fidl::encoding::Depth,
232 ) -> fidl::Result<()> {
233 encoder.debug_check_bounds::<WakeAlarmsCancelRequest>(offset);
234 self.0.encode(encoder, offset + 0, depth)?;
238 Ok(())
239 }
240 }
241
242 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
243 for WakeAlarmsCancelRequest
244 {
245 #[inline(always)]
246 fn new_empty() -> Self {
247 Self { alarm_id: fidl::new_empty!(fidl::encoding::BoundedString<128>, D) }
248 }
249
250 #[inline]
251 unsafe fn decode(
252 &mut self,
253 decoder: &mut fidl::encoding::Decoder<'_, D>,
254 offset: usize,
255 _depth: fidl::encoding::Depth,
256 ) -> fidl::Result<()> {
257 decoder.debug_check_bounds::<Self>(offset);
258 fidl::decode!(
260 fidl::encoding::BoundedString<128>,
261 D,
262 &mut self.alarm_id,
263 decoder,
264 offset + 0,
265 _depth
266 )?;
267 Ok(())
268 }
269 }
270}