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