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;
17
18#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
20pub enum WakeAlarmsError {
21 Unspecified,
26 Dropped,
28 Internal,
32 InvalidArgs,
35 DriverConnection,
38 Driver,
40 #[doc(hidden)]
41 __SourceBreaking { unknown_ordinal: u32 },
42}
43
44#[macro_export]
46macro_rules! WakeAlarmsErrorUnknown {
47 () => {
48 _
49 };
50}
51
52impl WakeAlarmsError {
53 #[inline]
54 pub fn from_primitive(prim: u32) -> Option<Self> {
55 match prim {
56 1 => Some(Self::Unspecified),
57 2 => Some(Self::Dropped),
58 3 => Some(Self::Internal),
59 4 => Some(Self::InvalidArgs),
60 5 => Some(Self::DriverConnection),
61 6 => Some(Self::Driver),
62 _ => None,
63 }
64 }
65
66 #[inline]
67 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
68 match prim {
69 1 => Self::Unspecified,
70 2 => Self::Dropped,
71 3 => Self::Internal,
72 4 => Self::InvalidArgs,
73 5 => Self::DriverConnection,
74 6 => Self::Driver,
75 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
76 }
77 }
78
79 #[inline]
80 pub fn unknown() -> Self {
81 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
82 }
83
84 #[inline]
85 pub const fn into_primitive(self) -> u32 {
86 match self {
87 Self::Unspecified => 1,
88 Self::Dropped => 2,
89 Self::Internal => 3,
90 Self::InvalidArgs => 4,
91 Self::DriverConnection => 5,
92 Self::Driver => 6,
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(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
108#[repr(C)]
109pub struct InstantUtc {
110 pub timestamp_utc: i64,
129}
130
131impl fidl::Persistable for InstantUtc {}
132
133#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
134pub struct WakeAlarmsCancelRequest {
135 pub alarm_id: String,
145}
146
147impl fidl::Persistable for WakeAlarmsCancelRequest {}
148
149pub mod notifier_ordinals {
150 pub const NOTIFY: u64 = 0x23d11b31ba0d67d4;
151 pub const NOTIFY_ERROR: u64 = 0x62e915191b0113e9;
152}
153
154pub mod wake_alarms_ordinals {
155 pub const SET_AND_WAIT: u64 = 0x57ebd075ce4beba;
156 pub const CANCEL: u64 = 0x7b23a9760115e55c;
157 pub const SET: u64 = 0x1f110857e48fd72c;
158 pub const SET_AND_WAIT_UTC: u64 = 0x4ea69d33af584219;
159}
160
161mod internal {
162 use super::*;
163 unsafe impl fidl::encoding::TypeMarker for WakeAlarmsError {
164 type Owned = Self;
165
166 #[inline(always)]
167 fn inline_align(_context: fidl::encoding::Context) -> usize {
168 std::mem::align_of::<u32>()
169 }
170
171 #[inline(always)]
172 fn inline_size(_context: fidl::encoding::Context) -> usize {
173 std::mem::size_of::<u32>()
174 }
175
176 #[inline(always)]
177 fn encode_is_copy() -> bool {
178 false
179 }
180
181 #[inline(always)]
182 fn decode_is_copy() -> bool {
183 false
184 }
185 }
186
187 impl fidl::encoding::ValueTypeMarker for WakeAlarmsError {
188 type Borrowed<'a> = Self;
189 #[inline(always)]
190 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
191 *value
192 }
193 }
194
195 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D>
196 for WakeAlarmsError
197 {
198 #[inline]
199 unsafe fn encode(
200 self,
201 encoder: &mut fidl::encoding::Encoder<'_, D>,
202 offset: usize,
203 _depth: fidl::encoding::Depth,
204 ) -> fidl::Result<()> {
205 encoder.debug_check_bounds::<Self>(offset);
206 encoder.write_num(self.into_primitive(), offset);
207 Ok(())
208 }
209 }
210
211 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for WakeAlarmsError {
212 #[inline(always)]
213 fn new_empty() -> Self {
214 Self::unknown()
215 }
216
217 #[inline]
218 unsafe fn decode(
219 &mut self,
220 decoder: &mut fidl::encoding::Decoder<'_, D>,
221 offset: usize,
222 _depth: fidl::encoding::Depth,
223 ) -> fidl::Result<()> {
224 decoder.debug_check_bounds::<Self>(offset);
225 let prim = decoder.read_num::<u32>(offset);
226
227 *self = Self::from_primitive_allow_unknown(prim);
228 Ok(())
229 }
230 }
231
232 impl fidl::encoding::ValueTypeMarker for InstantUtc {
233 type Borrowed<'a> = &'a Self;
234 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
235 value
236 }
237 }
238
239 unsafe impl fidl::encoding::TypeMarker for InstantUtc {
240 type Owned = Self;
241
242 #[inline(always)]
243 fn inline_align(_context: fidl::encoding::Context) -> usize {
244 8
245 }
246
247 #[inline(always)]
248 fn inline_size(_context: fidl::encoding::Context) -> usize {
249 8
250 }
251 #[inline(always)]
252 fn encode_is_copy() -> bool {
253 true
254 }
255
256 #[inline(always)]
257 fn decode_is_copy() -> bool {
258 true
259 }
260 }
261
262 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<InstantUtc, D>
263 for &InstantUtc
264 {
265 #[inline]
266 unsafe fn encode(
267 self,
268 encoder: &mut fidl::encoding::Encoder<'_, D>,
269 offset: usize,
270 _depth: fidl::encoding::Depth,
271 ) -> fidl::Result<()> {
272 encoder.debug_check_bounds::<InstantUtc>(offset);
273 unsafe {
274 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
276 (buf_ptr as *mut InstantUtc).write_unaligned((self as *const InstantUtc).read());
277 }
280 Ok(())
281 }
282 }
283 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
284 fidl::encoding::Encode<InstantUtc, D> for (T0,)
285 {
286 #[inline]
287 unsafe fn encode(
288 self,
289 encoder: &mut fidl::encoding::Encoder<'_, D>,
290 offset: usize,
291 depth: fidl::encoding::Depth,
292 ) -> fidl::Result<()> {
293 encoder.debug_check_bounds::<InstantUtc>(offset);
294 self.0.encode(encoder, offset + 0, depth)?;
298 Ok(())
299 }
300 }
301
302 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for InstantUtc {
303 #[inline(always)]
304 fn new_empty() -> Self {
305 Self { timestamp_utc: fidl::new_empty!(i64, D) }
306 }
307
308 #[inline]
309 unsafe fn decode(
310 &mut self,
311 decoder: &mut fidl::encoding::Decoder<'_, D>,
312 offset: usize,
313 _depth: fidl::encoding::Depth,
314 ) -> fidl::Result<()> {
315 decoder.debug_check_bounds::<Self>(offset);
316 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
317 unsafe {
320 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
321 }
322 Ok(())
323 }
324 }
325
326 impl fidl::encoding::ValueTypeMarker for WakeAlarmsCancelRequest {
327 type Borrowed<'a> = &'a Self;
328 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
329 value
330 }
331 }
332
333 unsafe impl fidl::encoding::TypeMarker for WakeAlarmsCancelRequest {
334 type Owned = Self;
335
336 #[inline(always)]
337 fn inline_align(_context: fidl::encoding::Context) -> usize {
338 8
339 }
340
341 #[inline(always)]
342 fn inline_size(_context: fidl::encoding::Context) -> usize {
343 16
344 }
345 }
346
347 unsafe impl<D: fidl::encoding::ResourceDialect>
348 fidl::encoding::Encode<WakeAlarmsCancelRequest, D> for &WakeAlarmsCancelRequest
349 {
350 #[inline]
351 unsafe fn encode(
352 self,
353 encoder: &mut fidl::encoding::Encoder<'_, D>,
354 offset: usize,
355 _depth: fidl::encoding::Depth,
356 ) -> fidl::Result<()> {
357 encoder.debug_check_bounds::<WakeAlarmsCancelRequest>(offset);
358 fidl::encoding::Encode::<WakeAlarmsCancelRequest, D>::encode(
360 (<fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
361 &self.alarm_id,
362 ),),
363 encoder,
364 offset,
365 _depth,
366 )
367 }
368 }
369 unsafe impl<
370 D: fidl::encoding::ResourceDialect,
371 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<128>, D>,
372 > fidl::encoding::Encode<WakeAlarmsCancelRequest, D> for (T0,)
373 {
374 #[inline]
375 unsafe fn encode(
376 self,
377 encoder: &mut fidl::encoding::Encoder<'_, D>,
378 offset: usize,
379 depth: fidl::encoding::Depth,
380 ) -> fidl::Result<()> {
381 encoder.debug_check_bounds::<WakeAlarmsCancelRequest>(offset);
382 self.0.encode(encoder, offset + 0, depth)?;
386 Ok(())
387 }
388 }
389
390 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
391 for WakeAlarmsCancelRequest
392 {
393 #[inline(always)]
394 fn new_empty() -> Self {
395 Self { alarm_id: fidl::new_empty!(fidl::encoding::BoundedString<128>, D) }
396 }
397
398 #[inline]
399 unsafe fn decode(
400 &mut self,
401 decoder: &mut fidl::encoding::Decoder<'_, D>,
402 offset: usize,
403 _depth: fidl::encoding::Depth,
404 ) -> fidl::Result<()> {
405 decoder.debug_check_bounds::<Self>(offset);
406 fidl::decode!(
408 fidl::encoding::BoundedString<128>,
409 D,
410 &mut self.alarm_id,
411 decoder,
412 offset + 0,
413 _depth
414 )?;
415 Ok(())
416 }
417 }
418}