fidl_fuchsia_time_alarms/
fidl_fuchsia_time_alarms.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::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_time_alarms__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct NotifierNotifyErrorRequest {
16    /// Identifier of the alarm that fired.
17    pub alarm_id: String,
18    /// Error preventing the alarm from firing.
19    pub error: WakeAlarmsError,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23    for NotifierNotifyErrorRequest
24{
25}
26
27#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct NotifierNotifyRequest {
29    /// Identifier of the alarm that fired.
30    pub alarm_id: String,
31    /// Used to ensure a minimum time slice for useful work, before the
32    /// system may suspend again.
33    pub keep_alive: fidl::EventPair,
34}
35
36impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for NotifierNotifyRequest {}
37
38#[derive(Debug, PartialEq)]
39pub struct SetAndWaitArgs {
40    /// The deadline at which the timer is supposed to fire. This
41    /// corresponds to a time instant on the boot timeline.
42    pub deadline: fidl::BootInstant,
43    /// Optional mode that allows the API to support a number of use cases.
44    pub mode: SetMode,
45    /// Set to a nonempty value to identify the alarm. A unique value
46    /// of [AlarmId] must be picked per each unique alarm within a
47    /// single FIDL connection's scope.
48    ///
49    /// Supplying an alarm_id for an already scheduled alarm reschedules
50    /// that alarm.
51    pub alarm_id: String,
52}
53
54impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SetAndWaitArgs {}
55
56#[derive(Debug, PartialEq)]
57pub struct SetArgs {
58    /// Notifier to call when the alarm fires. When the server_end to
59    /// this channel is dropped, the alarm will be canceled.
60    pub notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
61    /// The deadline at which the timer is supposed to fire. This
62    /// corresponds to a time instant on the boot timeline.
63    pub deadline: fidl::BootInstant,
64    /// Optional mode that allows the API to support a number of use cases.
65    pub mode: SetMode,
66    /// Set to a nonempty value to identify the alarm. A unique value
67    /// of [AlarmId] must be picked per each unique alarm within a
68    /// single FIDL connection's scope.
69    ///
70    /// Supplying an alarm_id for an already scheduled alarm reschedules
71    /// that alarm.
72    pub alarm_id: String,
73}
74
75impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SetArgs {}
76
77#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
78pub struct WakeAlarmsSetAndWaitResponse {
79    /// Used by the caller to ensure a minimum time slice for useful work,
80    /// before the system may suspend again.
81    pub keep_alive: fidl::EventPair,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
85    for WakeAlarmsSetAndWaitResponse
86{
87}
88
89/// A mode of notification for when an alarm has been scheduled.
90#[derive(Debug)]
91pub enum SetMode {
92    /// This lease is dropped as immediately after the alarm is scheduled
93    /// (or an error occurs during scheduling), thus guaranteeing that the
94    /// alarm is scheduled before the system is suspended.
95    KeepAlive(fidl::EventPair),
96    /// The callee signals this event (with ZX_EVENT_SIGNALED) once the alarm
97    /// is scheduled. This indicates that the caller can drop any pending wake
98    /// leases related to this call.
99    NotifySetupDone(fidl::Event),
100    #[doc(hidden)]
101    __SourceBreaking { unknown_ordinal: u64 },
102}
103
104/// Pattern that matches an unknown `SetMode` member.
105#[macro_export]
106macro_rules! SetModeUnknown {
107    () => {
108        _
109    };
110}
111
112// Custom PartialEq so that unknown variants are not equal to themselves.
113impl PartialEq for SetMode {
114    fn eq(&self, other: &Self) -> bool {
115        match (self, other) {
116            (Self::KeepAlive(x), Self::KeepAlive(y)) => *x == *y,
117            (Self::NotifySetupDone(x), Self::NotifySetupDone(y)) => *x == *y,
118            _ => false,
119        }
120    }
121}
122
123impl SetMode {
124    #[inline]
125    pub fn ordinal(&self) -> u64 {
126        match *self {
127            Self::KeepAlive(_) => 1,
128            Self::NotifySetupDone(_) => 2,
129            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
130        }
131    }
132
133    #[inline]
134    pub fn unknown_variant_for_testing() -> Self {
135        Self::__SourceBreaking { unknown_ordinal: 0 }
136    }
137
138    #[inline]
139    pub fn is_unknown(&self) -> bool {
140        match self {
141            Self::__SourceBreaking { .. } => true,
142            _ => false,
143        }
144    }
145}
146
147impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SetMode {}
148
149#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
150pub struct NotifierMarker;
151
152impl fidl::endpoints::ProtocolMarker for NotifierMarker {
153    type Proxy = NotifierProxy;
154    type RequestStream = NotifierRequestStream;
155    #[cfg(target_os = "fuchsia")]
156    type SynchronousProxy = NotifierSynchronousProxy;
157
158    const DEBUG_NAME: &'static str = "fuchsia.time.alarms.Notifier";
159}
160impl fidl::endpoints::DiscoverableProtocolMarker for NotifierMarker {}
161
162pub trait NotifierProxyInterface: Send + Sync {
163    fn r#notify(&self, alarm_id: &str, keep_alive: fidl::EventPair) -> Result<(), fidl::Error>;
164    fn r#notify_error(&self, alarm_id: &str, error: WakeAlarmsError) -> Result<(), fidl::Error>;
165}
166#[derive(Debug)]
167#[cfg(target_os = "fuchsia")]
168pub struct NotifierSynchronousProxy {
169    client: fidl::client::sync::Client,
170}
171
172#[cfg(target_os = "fuchsia")]
173impl fidl::endpoints::SynchronousProxy for NotifierSynchronousProxy {
174    type Proxy = NotifierProxy;
175    type Protocol = NotifierMarker;
176
177    fn from_channel(inner: fidl::Channel) -> Self {
178        Self::new(inner)
179    }
180
181    fn into_channel(self) -> fidl::Channel {
182        self.client.into_channel()
183    }
184
185    fn as_channel(&self) -> &fidl::Channel {
186        self.client.as_channel()
187    }
188}
189
190#[cfg(target_os = "fuchsia")]
191impl NotifierSynchronousProxy {
192    pub fn new(channel: fidl::Channel) -> Self {
193        let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
194        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
195    }
196
197    pub fn into_channel(self) -> fidl::Channel {
198        self.client.into_channel()
199    }
200
201    /// Waits until an event arrives and returns it. It is safe for other
202    /// threads to make concurrent requests while waiting for an event.
203    pub fn wait_for_event(
204        &self,
205        deadline: zx::MonotonicInstant,
206    ) -> Result<NotifierEvent, fidl::Error> {
207        NotifierEvent::decode(self.client.wait_for_event(deadline)?)
208    }
209
210    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
211    pub fn r#notify(
212        &self,
213        mut alarm_id: &str,
214        mut keep_alive: fidl::EventPair,
215    ) -> Result<(), fidl::Error> {
216        self.client.send::<NotifierNotifyRequest>(
217            (alarm_id, keep_alive),
218            0x23d11b31ba0d67d4,
219            fidl::encoding::DynamicFlags::FLEXIBLE,
220        )
221    }
222
223    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
224    /// fire due to an error.
225    pub fn r#notify_error(
226        &self,
227        mut alarm_id: &str,
228        mut error: WakeAlarmsError,
229    ) -> Result<(), fidl::Error> {
230        self.client.send::<NotifierNotifyErrorRequest>(
231            (alarm_id, error),
232            0x62e915191b0113e9,
233            fidl::encoding::DynamicFlags::FLEXIBLE,
234        )
235    }
236}
237
238#[cfg(target_os = "fuchsia")]
239impl From<NotifierSynchronousProxy> for zx::Handle {
240    fn from(value: NotifierSynchronousProxy) -> Self {
241        value.into_channel().into()
242    }
243}
244
245#[cfg(target_os = "fuchsia")]
246impl From<fidl::Channel> for NotifierSynchronousProxy {
247    fn from(value: fidl::Channel) -> Self {
248        Self::new(value)
249    }
250}
251
252#[cfg(target_os = "fuchsia")]
253impl fidl::endpoints::FromClient for NotifierSynchronousProxy {
254    type Protocol = NotifierMarker;
255
256    fn from_client(value: fidl::endpoints::ClientEnd<NotifierMarker>) -> Self {
257        Self::new(value.into_channel())
258    }
259}
260
261#[derive(Debug, Clone)]
262pub struct NotifierProxy {
263    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
264}
265
266impl fidl::endpoints::Proxy for NotifierProxy {
267    type Protocol = NotifierMarker;
268
269    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
270        Self::new(inner)
271    }
272
273    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
274        self.client.into_channel().map_err(|client| Self { client })
275    }
276
277    fn as_channel(&self) -> &::fidl::AsyncChannel {
278        self.client.as_channel()
279    }
280}
281
282impl NotifierProxy {
283    /// Create a new Proxy for fuchsia.time.alarms/Notifier.
284    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
285        let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
286        Self { client: fidl::client::Client::new(channel, protocol_name) }
287    }
288
289    /// Get a Stream of events from the remote end of the protocol.
290    ///
291    /// # Panics
292    ///
293    /// Panics if the event stream was already taken.
294    pub fn take_event_stream(&self) -> NotifierEventStream {
295        NotifierEventStream { event_receiver: self.client.take_event_receiver() }
296    }
297
298    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
299    pub fn r#notify(
300        &self,
301        mut alarm_id: &str,
302        mut keep_alive: fidl::EventPair,
303    ) -> Result<(), fidl::Error> {
304        NotifierProxyInterface::r#notify(self, alarm_id, keep_alive)
305    }
306
307    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
308    /// fire due to an error.
309    pub fn r#notify_error(
310        &self,
311        mut alarm_id: &str,
312        mut error: WakeAlarmsError,
313    ) -> Result<(), fidl::Error> {
314        NotifierProxyInterface::r#notify_error(self, alarm_id, error)
315    }
316}
317
318impl NotifierProxyInterface for NotifierProxy {
319    fn r#notify(
320        &self,
321        mut alarm_id: &str,
322        mut keep_alive: fidl::EventPair,
323    ) -> Result<(), fidl::Error> {
324        self.client.send::<NotifierNotifyRequest>(
325            (alarm_id, keep_alive),
326            0x23d11b31ba0d67d4,
327            fidl::encoding::DynamicFlags::FLEXIBLE,
328        )
329    }
330
331    fn r#notify_error(
332        &self,
333        mut alarm_id: &str,
334        mut error: WakeAlarmsError,
335    ) -> Result<(), fidl::Error> {
336        self.client.send::<NotifierNotifyErrorRequest>(
337            (alarm_id, error),
338            0x62e915191b0113e9,
339            fidl::encoding::DynamicFlags::FLEXIBLE,
340        )
341    }
342}
343
344pub struct NotifierEventStream {
345    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
346}
347
348impl std::marker::Unpin for NotifierEventStream {}
349
350impl futures::stream::FusedStream for NotifierEventStream {
351    fn is_terminated(&self) -> bool {
352        self.event_receiver.is_terminated()
353    }
354}
355
356impl futures::Stream for NotifierEventStream {
357    type Item = Result<NotifierEvent, fidl::Error>;
358
359    fn poll_next(
360        mut self: std::pin::Pin<&mut Self>,
361        cx: &mut std::task::Context<'_>,
362    ) -> std::task::Poll<Option<Self::Item>> {
363        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
364            &mut self.event_receiver,
365            cx
366        )?) {
367            Some(buf) => std::task::Poll::Ready(Some(NotifierEvent::decode(buf))),
368            None => std::task::Poll::Ready(None),
369        }
370    }
371}
372
373#[derive(Debug)]
374pub enum NotifierEvent {
375    #[non_exhaustive]
376    _UnknownEvent {
377        /// Ordinal of the event that was sent.
378        ordinal: u64,
379    },
380}
381
382impl NotifierEvent {
383    /// Decodes a message buffer as a [`NotifierEvent`].
384    fn decode(
385        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
386    ) -> Result<NotifierEvent, fidl::Error> {
387        let (bytes, _handles) = buf.split_mut();
388        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
389        debug_assert_eq!(tx_header.tx_id, 0);
390        match tx_header.ordinal {
391            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
392                Ok(NotifierEvent::_UnknownEvent { ordinal: tx_header.ordinal })
393            }
394            _ => Err(fidl::Error::UnknownOrdinal {
395                ordinal: tx_header.ordinal,
396                protocol_name: <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
397            }),
398        }
399    }
400}
401
402/// A Stream of incoming requests for fuchsia.time.alarms/Notifier.
403pub struct NotifierRequestStream {
404    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
405    is_terminated: bool,
406}
407
408impl std::marker::Unpin for NotifierRequestStream {}
409
410impl futures::stream::FusedStream for NotifierRequestStream {
411    fn is_terminated(&self) -> bool {
412        self.is_terminated
413    }
414}
415
416impl fidl::endpoints::RequestStream for NotifierRequestStream {
417    type Protocol = NotifierMarker;
418    type ControlHandle = NotifierControlHandle;
419
420    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
421        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
422    }
423
424    fn control_handle(&self) -> Self::ControlHandle {
425        NotifierControlHandle { inner: self.inner.clone() }
426    }
427
428    fn into_inner(
429        self,
430    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
431    {
432        (self.inner, self.is_terminated)
433    }
434
435    fn from_inner(
436        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
437        is_terminated: bool,
438    ) -> Self {
439        Self { inner, is_terminated }
440    }
441}
442
443impl futures::Stream for NotifierRequestStream {
444    type Item = Result<NotifierRequest, fidl::Error>;
445
446    fn poll_next(
447        mut self: std::pin::Pin<&mut Self>,
448        cx: &mut std::task::Context<'_>,
449    ) -> std::task::Poll<Option<Self::Item>> {
450        let this = &mut *self;
451        if this.inner.check_shutdown(cx) {
452            this.is_terminated = true;
453            return std::task::Poll::Ready(None);
454        }
455        if this.is_terminated {
456            panic!("polled NotifierRequestStream after completion");
457        }
458        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
459            |bytes, handles| {
460                match this.inner.channel().read_etc(cx, bytes, handles) {
461                    std::task::Poll::Ready(Ok(())) => {}
462                    std::task::Poll::Pending => return std::task::Poll::Pending,
463                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
464                        this.is_terminated = true;
465                        return std::task::Poll::Ready(None);
466                    }
467                    std::task::Poll::Ready(Err(e)) => {
468                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
469                            e.into(),
470                        ))))
471                    }
472                }
473
474                // A message has been received from the channel
475                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
476
477                std::task::Poll::Ready(Some(match header.ordinal {
478                    0x23d11b31ba0d67d4 => {
479                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
480                        let mut req = fidl::new_empty!(
481                            NotifierNotifyRequest,
482                            fidl::encoding::DefaultFuchsiaResourceDialect
483                        );
484                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotifierNotifyRequest>(&header, _body_bytes, handles, &mut req)?;
485                        let control_handle = NotifierControlHandle { inner: this.inner.clone() };
486                        Ok(NotifierRequest::Notify {
487                            alarm_id: req.alarm_id,
488                            keep_alive: req.keep_alive,
489
490                            control_handle,
491                        })
492                    }
493                    0x62e915191b0113e9 => {
494                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
495                        let mut req = fidl::new_empty!(
496                            NotifierNotifyErrorRequest,
497                            fidl::encoding::DefaultFuchsiaResourceDialect
498                        );
499                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotifierNotifyErrorRequest>(&header, _body_bytes, handles, &mut req)?;
500                        let control_handle = NotifierControlHandle { inner: this.inner.clone() };
501                        Ok(NotifierRequest::NotifyError {
502                            alarm_id: req.alarm_id,
503                            error: req.error,
504
505                            control_handle,
506                        })
507                    }
508                    _ if header.tx_id == 0
509                        && header
510                            .dynamic_flags()
511                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
512                    {
513                        Ok(NotifierRequest::_UnknownMethod {
514                            ordinal: header.ordinal,
515                            control_handle: NotifierControlHandle { inner: this.inner.clone() },
516                            method_type: fidl::MethodType::OneWay,
517                        })
518                    }
519                    _ if header
520                        .dynamic_flags()
521                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
522                    {
523                        this.inner.send_framework_err(
524                            fidl::encoding::FrameworkErr::UnknownMethod,
525                            header.tx_id,
526                            header.ordinal,
527                            header.dynamic_flags(),
528                            (bytes, handles),
529                        )?;
530                        Ok(NotifierRequest::_UnknownMethod {
531                            ordinal: header.ordinal,
532                            control_handle: NotifierControlHandle { inner: this.inner.clone() },
533                            method_type: fidl::MethodType::TwoWay,
534                        })
535                    }
536                    _ => Err(fidl::Error::UnknownOrdinal {
537                        ordinal: header.ordinal,
538                        protocol_name:
539                            <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
540                    }),
541                }))
542            },
543        )
544    }
545}
546
547/// [Notifier] is used to notify when a wake alarm fires.
548///
549/// A client-end channel of this protocol will be provided to the implementor of
550/// [WakeAlarms.Set].
551///
552/// Dropping the server-end will cancel all alarms scheduled with [WakeAlarms.Set]
553/// associated with this server instance.
554#[derive(Debug)]
555pub enum NotifierRequest {
556    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
557    Notify { alarm_id: String, keep_alive: fidl::EventPair, control_handle: NotifierControlHandle },
558    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
559    /// fire due to an error.
560    NotifyError { alarm_id: String, error: WakeAlarmsError, control_handle: NotifierControlHandle },
561    /// An interaction was received which does not match any known method.
562    #[non_exhaustive]
563    _UnknownMethod {
564        /// Ordinal of the method that was called.
565        ordinal: u64,
566        control_handle: NotifierControlHandle,
567        method_type: fidl::MethodType,
568    },
569}
570
571impl NotifierRequest {
572    #[allow(irrefutable_let_patterns)]
573    pub fn into_notify(self) -> Option<(String, fidl::EventPair, NotifierControlHandle)> {
574        if let NotifierRequest::Notify { alarm_id, keep_alive, control_handle } = self {
575            Some((alarm_id, keep_alive, control_handle))
576        } else {
577            None
578        }
579    }
580
581    #[allow(irrefutable_let_patterns)]
582    pub fn into_notify_error(self) -> Option<(String, WakeAlarmsError, NotifierControlHandle)> {
583        if let NotifierRequest::NotifyError { alarm_id, error, control_handle } = self {
584            Some((alarm_id, error, control_handle))
585        } else {
586            None
587        }
588    }
589
590    /// Name of the method defined in FIDL
591    pub fn method_name(&self) -> &'static str {
592        match *self {
593            NotifierRequest::Notify { .. } => "notify",
594            NotifierRequest::NotifyError { .. } => "notify_error",
595            NotifierRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
596                "unknown one-way method"
597            }
598            NotifierRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
599                "unknown two-way method"
600            }
601        }
602    }
603}
604
605#[derive(Debug, Clone)]
606pub struct NotifierControlHandle {
607    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
608}
609
610impl fidl::endpoints::ControlHandle for NotifierControlHandle {
611    fn shutdown(&self) {
612        self.inner.shutdown()
613    }
614    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
615        self.inner.shutdown_with_epitaph(status)
616    }
617
618    fn is_closed(&self) -> bool {
619        self.inner.channel().is_closed()
620    }
621    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
622        self.inner.channel().on_closed()
623    }
624
625    #[cfg(target_os = "fuchsia")]
626    fn signal_peer(
627        &self,
628        clear_mask: zx::Signals,
629        set_mask: zx::Signals,
630    ) -> Result<(), zx_status::Status> {
631        use fidl::Peered;
632        self.inner.channel().signal_peer(clear_mask, set_mask)
633    }
634}
635
636impl NotifierControlHandle {}
637
638#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
639pub struct WakeAlarmsMarker;
640
641impl fidl::endpoints::ProtocolMarker for WakeAlarmsMarker {
642    type Proxy = WakeAlarmsProxy;
643    type RequestStream = WakeAlarmsRequestStream;
644    #[cfg(target_os = "fuchsia")]
645    type SynchronousProxy = WakeAlarmsSynchronousProxy;
646
647    const DEBUG_NAME: &'static str = "fuchsia.time.alarms.WakeAlarms";
648}
649impl fidl::endpoints::DiscoverableProtocolMarker for WakeAlarmsMarker {}
650pub type WakeAlarmsSetAndWaitResult = Result<fidl::EventPair, WakeAlarmsError>;
651pub type WakeAlarmsSetResult = Result<(), WakeAlarmsError>;
652
653pub trait WakeAlarmsProxyInterface: Send + Sync {
654    type SetAndWaitResponseFut: std::future::Future<Output = Result<WakeAlarmsSetAndWaitResult, fidl::Error>>
655        + Send;
656    fn r#set_and_wait(
657        &self,
658        deadline: fidl::BootInstant,
659        mode: SetMode,
660        alarm_id: &str,
661    ) -> Self::SetAndWaitResponseFut;
662    fn r#cancel(&self, alarm_id: &str) -> Result<(), fidl::Error>;
663    type SetResponseFut: std::future::Future<Output = Result<WakeAlarmsSetResult, fidl::Error>>
664        + Send;
665    fn r#set(
666        &self,
667        notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
668        deadline: fidl::BootInstant,
669        mode: SetMode,
670        alarm_id: &str,
671    ) -> Self::SetResponseFut;
672}
673#[derive(Debug)]
674#[cfg(target_os = "fuchsia")]
675pub struct WakeAlarmsSynchronousProxy {
676    client: fidl::client::sync::Client,
677}
678
679#[cfg(target_os = "fuchsia")]
680impl fidl::endpoints::SynchronousProxy for WakeAlarmsSynchronousProxy {
681    type Proxy = WakeAlarmsProxy;
682    type Protocol = WakeAlarmsMarker;
683
684    fn from_channel(inner: fidl::Channel) -> Self {
685        Self::new(inner)
686    }
687
688    fn into_channel(self) -> fidl::Channel {
689        self.client.into_channel()
690    }
691
692    fn as_channel(&self) -> &fidl::Channel {
693        self.client.as_channel()
694    }
695}
696
697#[cfg(target_os = "fuchsia")]
698impl WakeAlarmsSynchronousProxy {
699    pub fn new(channel: fidl::Channel) -> Self {
700        let protocol_name = <WakeAlarmsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
701        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
702    }
703
704    pub fn into_channel(self) -> fidl::Channel {
705        self.client.into_channel()
706    }
707
708    /// Waits until an event arrives and returns it. It is safe for other
709    /// threads to make concurrent requests while waiting for an event.
710    pub fn wait_for_event(
711        &self,
712        deadline: zx::MonotonicInstant,
713    ) -> Result<WakeAlarmsEvent, fidl::Error> {
714        WakeAlarmsEvent::decode(self.client.wait_for_event(deadline)?)
715    }
716
717    /// Sets a wake alarm with the provided parameters, and waits for the alarm
718    /// to fire.
719    ///
720    /// The caller may request multiple alarms concurrently. Re-requesting
721    /// an alarm that has the same `alarm_id` as an already scheduled alarm
722    /// causes that scheduled alarm to be canceled before the same alarm
723    /// is scheduled again.
724    ///
725    /// The call to `SetAndWait` returns when the alarm fires, or an error
726    /// occurs, or the alarm is canceled.
727    ///
728    /// ## Return value
729    ///
730    /// * `keep_alive`: a handle which prevents system suspend so long as
731    ///   it is held alive.
732    ///
733    /// ## Protocol Errors
734    ///
735    /// * [DROPPED] if the alarm has been canceled by using
736    ///   [Cancel].
737    /// * [UNSPECIFIED] you are observing a new failure mode which has not
738    ///   been assigned an error code yet. Expect this failure mode to be
739    ///   assigned a more specific error code in future versions of this API.
740    ///   This is not a bug, but an indication that you may need to update the
741    ///   API version.
742    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
743    ///   to be unlikely to fail) has failed somehow. Please report this for
744    ///   investigation.
745    pub fn r#set_and_wait(
746        &self,
747        mut deadline: fidl::BootInstant,
748        mut mode: SetMode,
749        mut alarm_id: &str,
750        ___deadline: zx::MonotonicInstant,
751    ) -> Result<WakeAlarmsSetAndWaitResult, fidl::Error> {
752        let _response = self.client.send_query::<
753            SetAndWaitArgs,
754            fidl::encoding::FlexibleResultType<WakeAlarmsSetAndWaitResponse, WakeAlarmsError>,
755        >(
756            (deadline, &mut mode, alarm_id,),
757            0x57ebd075ce4beba,
758            fidl::encoding::DynamicFlags::FLEXIBLE,
759            ___deadline,
760        )?
761        .into_result::<WakeAlarmsMarker>("set_and_wait")?;
762        Ok(_response.map(|x| x.keep_alive))
763    }
764
765    /// Cancels the alarm specified by `alarm_id`.
766    ///
767    /// Providing an `alarm_id` of an alarm that is not scheduled quietly
768    /// succeeds.
769    pub fn r#cancel(&self, mut alarm_id: &str) -> Result<(), fidl::Error> {
770        self.client.send::<WakeAlarmsCancelRequest>(
771            (alarm_id,),
772            0x7b23a9760115e55c,
773            fidl::encoding::DynamicFlags::FLEXIBLE,
774        )
775    }
776
777    /// Sets a wake alarm with the provided parameters.
778    ///
779    /// The caller may request multiple alarms concurrently. Re-requesting
780    /// an alarm that has the same `alarm_id` as an already scheduled alarm
781    /// causes that scheduled alarm to be canceled before the same alarm
782    /// is scheduled again.
783    ///
784    /// ## Return value
785    ///
786    /// This method will return when the alarm is scheduled.
787    ///
788    /// ## Protocol Errors
789    ///
790    /// * [UNSPECIFIED] you are observing a new failure mode which has not
791    ///   been assigned an error code yet. Expect this failure mode to be
792    ///   assigned a more specific error code in future versions of this API.
793    ///   This is not a bug, but an indication that you may need to update the
794    ///   API version.
795    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
796    ///   to be unlikely to fail) has failed somehow. Please report this for
797    ///   investigation.
798    pub fn r#set(
799        &self,
800        mut notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
801        mut deadline: fidl::BootInstant,
802        mut mode: SetMode,
803        mut alarm_id: &str,
804        ___deadline: zx::MonotonicInstant,
805    ) -> Result<WakeAlarmsSetResult, fidl::Error> {
806        let _response = self.client.send_query::<
807            SetArgs,
808            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WakeAlarmsError>,
809        >(
810            (notifier, deadline, &mut mode, alarm_id,),
811            0x1f110857e48fd72c,
812            fidl::encoding::DynamicFlags::FLEXIBLE,
813            ___deadline,
814        )?
815        .into_result::<WakeAlarmsMarker>("set")?;
816        Ok(_response.map(|x| x))
817    }
818}
819
820#[cfg(target_os = "fuchsia")]
821impl From<WakeAlarmsSynchronousProxy> for zx::Handle {
822    fn from(value: WakeAlarmsSynchronousProxy) -> Self {
823        value.into_channel().into()
824    }
825}
826
827#[cfg(target_os = "fuchsia")]
828impl From<fidl::Channel> for WakeAlarmsSynchronousProxy {
829    fn from(value: fidl::Channel) -> Self {
830        Self::new(value)
831    }
832}
833
834#[cfg(target_os = "fuchsia")]
835impl fidl::endpoints::FromClient for WakeAlarmsSynchronousProxy {
836    type Protocol = WakeAlarmsMarker;
837
838    fn from_client(value: fidl::endpoints::ClientEnd<WakeAlarmsMarker>) -> Self {
839        Self::new(value.into_channel())
840    }
841}
842
843#[derive(Debug, Clone)]
844pub struct WakeAlarmsProxy {
845    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
846}
847
848impl fidl::endpoints::Proxy for WakeAlarmsProxy {
849    type Protocol = WakeAlarmsMarker;
850
851    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
852        Self::new(inner)
853    }
854
855    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
856        self.client.into_channel().map_err(|client| Self { client })
857    }
858
859    fn as_channel(&self) -> &::fidl::AsyncChannel {
860        self.client.as_channel()
861    }
862}
863
864impl WakeAlarmsProxy {
865    /// Create a new Proxy for fuchsia.time.alarms/WakeAlarms.
866    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
867        let protocol_name = <WakeAlarmsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
868        Self { client: fidl::client::Client::new(channel, protocol_name) }
869    }
870
871    /// Get a Stream of events from the remote end of the protocol.
872    ///
873    /// # Panics
874    ///
875    /// Panics if the event stream was already taken.
876    pub fn take_event_stream(&self) -> WakeAlarmsEventStream {
877        WakeAlarmsEventStream { event_receiver: self.client.take_event_receiver() }
878    }
879
880    /// Sets a wake alarm with the provided parameters, and waits for the alarm
881    /// to fire.
882    ///
883    /// The caller may request multiple alarms concurrently. Re-requesting
884    /// an alarm that has the same `alarm_id` as an already scheduled alarm
885    /// causes that scheduled alarm to be canceled before the same alarm
886    /// is scheduled again.
887    ///
888    /// The call to `SetAndWait` returns when the alarm fires, or an error
889    /// occurs, or the alarm is canceled.
890    ///
891    /// ## Return value
892    ///
893    /// * `keep_alive`: a handle which prevents system suspend so long as
894    ///   it is held alive.
895    ///
896    /// ## Protocol Errors
897    ///
898    /// * [DROPPED] if the alarm has been canceled by using
899    ///   [Cancel].
900    /// * [UNSPECIFIED] you are observing a new failure mode which has not
901    ///   been assigned an error code yet. Expect this failure mode to be
902    ///   assigned a more specific error code in future versions of this API.
903    ///   This is not a bug, but an indication that you may need to update the
904    ///   API version.
905    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
906    ///   to be unlikely to fail) has failed somehow. Please report this for
907    ///   investigation.
908    pub fn r#set_and_wait(
909        &self,
910        mut deadline: fidl::BootInstant,
911        mut mode: SetMode,
912        mut alarm_id: &str,
913    ) -> fidl::client::QueryResponseFut<
914        WakeAlarmsSetAndWaitResult,
915        fidl::encoding::DefaultFuchsiaResourceDialect,
916    > {
917        WakeAlarmsProxyInterface::r#set_and_wait(self, deadline, mode, alarm_id)
918    }
919
920    /// Cancels the alarm specified by `alarm_id`.
921    ///
922    /// Providing an `alarm_id` of an alarm that is not scheduled quietly
923    /// succeeds.
924    pub fn r#cancel(&self, mut alarm_id: &str) -> Result<(), fidl::Error> {
925        WakeAlarmsProxyInterface::r#cancel(self, alarm_id)
926    }
927
928    /// Sets a wake alarm with the provided parameters.
929    ///
930    /// The caller may request multiple alarms concurrently. Re-requesting
931    /// an alarm that has the same `alarm_id` as an already scheduled alarm
932    /// causes that scheduled alarm to be canceled before the same alarm
933    /// is scheduled again.
934    ///
935    /// ## Return value
936    ///
937    /// This method will return when the alarm is scheduled.
938    ///
939    /// ## Protocol Errors
940    ///
941    /// * [UNSPECIFIED] you are observing a new failure mode which has not
942    ///   been assigned an error code yet. Expect this failure mode to be
943    ///   assigned a more specific error code in future versions of this API.
944    ///   This is not a bug, but an indication that you may need to update the
945    ///   API version.
946    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
947    ///   to be unlikely to fail) has failed somehow. Please report this for
948    ///   investigation.
949    pub fn r#set(
950        &self,
951        mut notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
952        mut deadline: fidl::BootInstant,
953        mut mode: SetMode,
954        mut alarm_id: &str,
955    ) -> fidl::client::QueryResponseFut<
956        WakeAlarmsSetResult,
957        fidl::encoding::DefaultFuchsiaResourceDialect,
958    > {
959        WakeAlarmsProxyInterface::r#set(self, notifier, deadline, mode, alarm_id)
960    }
961}
962
963impl WakeAlarmsProxyInterface for WakeAlarmsProxy {
964    type SetAndWaitResponseFut = fidl::client::QueryResponseFut<
965        WakeAlarmsSetAndWaitResult,
966        fidl::encoding::DefaultFuchsiaResourceDialect,
967    >;
968    fn r#set_and_wait(
969        &self,
970        mut deadline: fidl::BootInstant,
971        mut mode: SetMode,
972        mut alarm_id: &str,
973    ) -> Self::SetAndWaitResponseFut {
974        fn _decode(
975            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
976        ) -> Result<WakeAlarmsSetAndWaitResult, fidl::Error> {
977            let _response = fidl::client::decode_transaction_body::<
978                fidl::encoding::FlexibleResultType<WakeAlarmsSetAndWaitResponse, WakeAlarmsError>,
979                fidl::encoding::DefaultFuchsiaResourceDialect,
980                0x57ebd075ce4beba,
981            >(_buf?)?
982            .into_result::<WakeAlarmsMarker>("set_and_wait")?;
983            Ok(_response.map(|x| x.keep_alive))
984        }
985        self.client.send_query_and_decode::<SetAndWaitArgs, WakeAlarmsSetAndWaitResult>(
986            (deadline, &mut mode, alarm_id),
987            0x57ebd075ce4beba,
988            fidl::encoding::DynamicFlags::FLEXIBLE,
989            _decode,
990        )
991    }
992
993    fn r#cancel(&self, mut alarm_id: &str) -> Result<(), fidl::Error> {
994        self.client.send::<WakeAlarmsCancelRequest>(
995            (alarm_id,),
996            0x7b23a9760115e55c,
997            fidl::encoding::DynamicFlags::FLEXIBLE,
998        )
999    }
1000
1001    type SetResponseFut = fidl::client::QueryResponseFut<
1002        WakeAlarmsSetResult,
1003        fidl::encoding::DefaultFuchsiaResourceDialect,
1004    >;
1005    fn r#set(
1006        &self,
1007        mut notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
1008        mut deadline: fidl::BootInstant,
1009        mut mode: SetMode,
1010        mut alarm_id: &str,
1011    ) -> Self::SetResponseFut {
1012        fn _decode(
1013            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1014        ) -> Result<WakeAlarmsSetResult, fidl::Error> {
1015            let _response = fidl::client::decode_transaction_body::<
1016                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WakeAlarmsError>,
1017                fidl::encoding::DefaultFuchsiaResourceDialect,
1018                0x1f110857e48fd72c,
1019            >(_buf?)?
1020            .into_result::<WakeAlarmsMarker>("set")?;
1021            Ok(_response.map(|x| x))
1022        }
1023        self.client.send_query_and_decode::<SetArgs, WakeAlarmsSetResult>(
1024            (notifier, deadline, &mut mode, alarm_id),
1025            0x1f110857e48fd72c,
1026            fidl::encoding::DynamicFlags::FLEXIBLE,
1027            _decode,
1028        )
1029    }
1030}
1031
1032pub struct WakeAlarmsEventStream {
1033    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1034}
1035
1036impl std::marker::Unpin for WakeAlarmsEventStream {}
1037
1038impl futures::stream::FusedStream for WakeAlarmsEventStream {
1039    fn is_terminated(&self) -> bool {
1040        self.event_receiver.is_terminated()
1041    }
1042}
1043
1044impl futures::Stream for WakeAlarmsEventStream {
1045    type Item = Result<WakeAlarmsEvent, fidl::Error>;
1046
1047    fn poll_next(
1048        mut self: std::pin::Pin<&mut Self>,
1049        cx: &mut std::task::Context<'_>,
1050    ) -> std::task::Poll<Option<Self::Item>> {
1051        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1052            &mut self.event_receiver,
1053            cx
1054        )?) {
1055            Some(buf) => std::task::Poll::Ready(Some(WakeAlarmsEvent::decode(buf))),
1056            None => std::task::Poll::Ready(None),
1057        }
1058    }
1059}
1060
1061#[derive(Debug)]
1062pub enum WakeAlarmsEvent {
1063    #[non_exhaustive]
1064    _UnknownEvent {
1065        /// Ordinal of the event that was sent.
1066        ordinal: u64,
1067    },
1068}
1069
1070impl WakeAlarmsEvent {
1071    /// Decodes a message buffer as a [`WakeAlarmsEvent`].
1072    fn decode(
1073        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1074    ) -> Result<WakeAlarmsEvent, fidl::Error> {
1075        let (bytes, _handles) = buf.split_mut();
1076        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1077        debug_assert_eq!(tx_header.tx_id, 0);
1078        match tx_header.ordinal {
1079            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1080                Ok(WakeAlarmsEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1081            }
1082            _ => Err(fidl::Error::UnknownOrdinal {
1083                ordinal: tx_header.ordinal,
1084                protocol_name: <WakeAlarmsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1085            }),
1086        }
1087    }
1088}
1089
1090/// A Stream of incoming requests for fuchsia.time.alarms/WakeAlarms.
1091pub struct WakeAlarmsRequestStream {
1092    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1093    is_terminated: bool,
1094}
1095
1096impl std::marker::Unpin for WakeAlarmsRequestStream {}
1097
1098impl futures::stream::FusedStream for WakeAlarmsRequestStream {
1099    fn is_terminated(&self) -> bool {
1100        self.is_terminated
1101    }
1102}
1103
1104impl fidl::endpoints::RequestStream for WakeAlarmsRequestStream {
1105    type Protocol = WakeAlarmsMarker;
1106    type ControlHandle = WakeAlarmsControlHandle;
1107
1108    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1109        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1110    }
1111
1112    fn control_handle(&self) -> Self::ControlHandle {
1113        WakeAlarmsControlHandle { inner: self.inner.clone() }
1114    }
1115
1116    fn into_inner(
1117        self,
1118    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1119    {
1120        (self.inner, self.is_terminated)
1121    }
1122
1123    fn from_inner(
1124        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1125        is_terminated: bool,
1126    ) -> Self {
1127        Self { inner, is_terminated }
1128    }
1129}
1130
1131impl futures::Stream for WakeAlarmsRequestStream {
1132    type Item = Result<WakeAlarmsRequest, fidl::Error>;
1133
1134    fn poll_next(
1135        mut self: std::pin::Pin<&mut Self>,
1136        cx: &mut std::task::Context<'_>,
1137    ) -> std::task::Poll<Option<Self::Item>> {
1138        let this = &mut *self;
1139        if this.inner.check_shutdown(cx) {
1140            this.is_terminated = true;
1141            return std::task::Poll::Ready(None);
1142        }
1143        if this.is_terminated {
1144            panic!("polled WakeAlarmsRequestStream after completion");
1145        }
1146        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1147            |bytes, handles| {
1148                match this.inner.channel().read_etc(cx, bytes, handles) {
1149                    std::task::Poll::Ready(Ok(())) => {}
1150                    std::task::Poll::Pending => return std::task::Poll::Pending,
1151                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1152                        this.is_terminated = true;
1153                        return std::task::Poll::Ready(None);
1154                    }
1155                    std::task::Poll::Ready(Err(e)) => {
1156                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1157                            e.into(),
1158                        ))))
1159                    }
1160                }
1161
1162                // A message has been received from the channel
1163                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1164
1165                std::task::Poll::Ready(Some(match header.ordinal {
1166                    0x57ebd075ce4beba => {
1167                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1168                        let mut req = fidl::new_empty!(
1169                            SetAndWaitArgs,
1170                            fidl::encoding::DefaultFuchsiaResourceDialect
1171                        );
1172                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SetAndWaitArgs>(&header, _body_bytes, handles, &mut req)?;
1173                        let control_handle = WakeAlarmsControlHandle { inner: this.inner.clone() };
1174                        Ok(WakeAlarmsRequest::SetAndWait {
1175                            deadline: req.deadline,
1176                            mode: req.mode,
1177                            alarm_id: req.alarm_id,
1178
1179                            responder: WakeAlarmsSetAndWaitResponder {
1180                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1181                                tx_id: header.tx_id,
1182                            },
1183                        })
1184                    }
1185                    0x7b23a9760115e55c => {
1186                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1187                        let mut req = fidl::new_empty!(
1188                            WakeAlarmsCancelRequest,
1189                            fidl::encoding::DefaultFuchsiaResourceDialect
1190                        );
1191                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<WakeAlarmsCancelRequest>(&header, _body_bytes, handles, &mut req)?;
1192                        let control_handle = WakeAlarmsControlHandle { inner: this.inner.clone() };
1193                        Ok(WakeAlarmsRequest::Cancel { alarm_id: req.alarm_id, control_handle })
1194                    }
1195                    0x1f110857e48fd72c => {
1196                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1197                        let mut req = fidl::new_empty!(
1198                            SetArgs,
1199                            fidl::encoding::DefaultFuchsiaResourceDialect
1200                        );
1201                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SetArgs>(&header, _body_bytes, handles, &mut req)?;
1202                        let control_handle = WakeAlarmsControlHandle { inner: this.inner.clone() };
1203                        Ok(WakeAlarmsRequest::Set {
1204                            notifier: req.notifier,
1205                            deadline: req.deadline,
1206                            mode: req.mode,
1207                            alarm_id: req.alarm_id,
1208
1209                            responder: WakeAlarmsSetResponder {
1210                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1211                                tx_id: header.tx_id,
1212                            },
1213                        })
1214                    }
1215                    _ if header.tx_id == 0
1216                        && header
1217                            .dynamic_flags()
1218                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1219                    {
1220                        Ok(WakeAlarmsRequest::_UnknownMethod {
1221                            ordinal: header.ordinal,
1222                            control_handle: WakeAlarmsControlHandle { inner: this.inner.clone() },
1223                            method_type: fidl::MethodType::OneWay,
1224                        })
1225                    }
1226                    _ if header
1227                        .dynamic_flags()
1228                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1229                    {
1230                        this.inner.send_framework_err(
1231                            fidl::encoding::FrameworkErr::UnknownMethod,
1232                            header.tx_id,
1233                            header.ordinal,
1234                            header.dynamic_flags(),
1235                            (bytes, handles),
1236                        )?;
1237                        Ok(WakeAlarmsRequest::_UnknownMethod {
1238                            ordinal: header.ordinal,
1239                            control_handle: WakeAlarmsControlHandle { inner: this.inner.clone() },
1240                            method_type: fidl::MethodType::TwoWay,
1241                        })
1242                    }
1243                    _ => Err(fidl::Error::UnknownOrdinal {
1244                        ordinal: header.ordinal,
1245                        protocol_name:
1246                            <WakeAlarmsMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1247                    }),
1248                }))
1249            },
1250        )
1251    }
1252}
1253
1254/// [WakeAlarms] provides setting up platform-wide wake alarms.
1255///
1256/// An alarm is a promise made by the system to the caller of the API to notify
1257/// the caller that AT LEAST a certain amount of time has expired. The alarm
1258/// may fire later than the requested amount of time at the discretion of the
1259/// server implementing this API.
1260///
1261/// When this notification happens, we say that the wake alarm has "fired".
1262///
1263/// A "wake" alarm firing also ensures that the system comes back from a reduced
1264/// power state if needed, so that it can notify the caller.
1265///
1266/// The general shape of a wake alarm API has three parts:
1267/// * A specification of when a wake alarm is supposed to fire,
1268/// * A way to notify the caller of an alarm that fired, and
1269/// * A way to keep the system awake until both the caller and the callee have
1270///   completed work associated with the alarm.
1271#[derive(Debug)]
1272pub enum WakeAlarmsRequest {
1273    /// Sets a wake alarm with the provided parameters, and waits for the alarm
1274    /// to fire.
1275    ///
1276    /// The caller may request multiple alarms concurrently. Re-requesting
1277    /// an alarm that has the same `alarm_id` as an already scheduled alarm
1278    /// causes that scheduled alarm to be canceled before the same alarm
1279    /// is scheduled again.
1280    ///
1281    /// The call to `SetAndWait` returns when the alarm fires, or an error
1282    /// occurs, or the alarm is canceled.
1283    ///
1284    /// ## Return value
1285    ///
1286    /// * `keep_alive`: a handle which prevents system suspend so long as
1287    ///   it is held alive.
1288    ///
1289    /// ## Protocol Errors
1290    ///
1291    /// * [DROPPED] if the alarm has been canceled by using
1292    ///   [Cancel].
1293    /// * [UNSPECIFIED] you are observing a new failure mode which has not
1294    ///   been assigned an error code yet. Expect this failure mode to be
1295    ///   assigned a more specific error code in future versions of this API.
1296    ///   This is not a bug, but an indication that you may need to update the
1297    ///   API version.
1298    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
1299    ///   to be unlikely to fail) has failed somehow. Please report this for
1300    ///   investigation.
1301    SetAndWait {
1302        deadline: fidl::BootInstant,
1303        mode: SetMode,
1304        alarm_id: String,
1305        responder: WakeAlarmsSetAndWaitResponder,
1306    },
1307    /// Cancels the alarm specified by `alarm_id`.
1308    ///
1309    /// Providing an `alarm_id` of an alarm that is not scheduled quietly
1310    /// succeeds.
1311    Cancel { alarm_id: String, control_handle: WakeAlarmsControlHandle },
1312    /// Sets a wake alarm with the provided parameters.
1313    ///
1314    /// The caller may request multiple alarms concurrently. Re-requesting
1315    /// an alarm that has the same `alarm_id` as an already scheduled alarm
1316    /// causes that scheduled alarm to be canceled before the same alarm
1317    /// is scheduled again.
1318    ///
1319    /// ## Return value
1320    ///
1321    /// This method will return when the alarm is scheduled.
1322    ///
1323    /// ## Protocol Errors
1324    ///
1325    /// * [UNSPECIFIED] you are observing a new failure mode which has not
1326    ///   been assigned an error code yet. Expect this failure mode to be
1327    ///   assigned a more specific error code in future versions of this API.
1328    ///   This is not a bug, but an indication that you may need to update the
1329    ///   API version.
1330    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
1331    ///   to be unlikely to fail) has failed somehow. Please report this for
1332    ///   investigation.
1333    Set {
1334        notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
1335        deadline: fidl::BootInstant,
1336        mode: SetMode,
1337        alarm_id: String,
1338        responder: WakeAlarmsSetResponder,
1339    },
1340    /// An interaction was received which does not match any known method.
1341    #[non_exhaustive]
1342    _UnknownMethod {
1343        /// Ordinal of the method that was called.
1344        ordinal: u64,
1345        control_handle: WakeAlarmsControlHandle,
1346        method_type: fidl::MethodType,
1347    },
1348}
1349
1350impl WakeAlarmsRequest {
1351    #[allow(irrefutable_let_patterns)]
1352    pub fn into_set_and_wait(
1353        self,
1354    ) -> Option<(fidl::BootInstant, SetMode, String, WakeAlarmsSetAndWaitResponder)> {
1355        if let WakeAlarmsRequest::SetAndWait { deadline, mode, alarm_id, responder } = self {
1356            Some((deadline, mode, alarm_id, responder))
1357        } else {
1358            None
1359        }
1360    }
1361
1362    #[allow(irrefutable_let_patterns)]
1363    pub fn into_cancel(self) -> Option<(String, WakeAlarmsControlHandle)> {
1364        if let WakeAlarmsRequest::Cancel { alarm_id, control_handle } = self {
1365            Some((alarm_id, control_handle))
1366        } else {
1367            None
1368        }
1369    }
1370
1371    #[allow(irrefutable_let_patterns)]
1372    pub fn into_set(
1373        self,
1374    ) -> Option<(
1375        fidl::endpoints::ClientEnd<NotifierMarker>,
1376        fidl::BootInstant,
1377        SetMode,
1378        String,
1379        WakeAlarmsSetResponder,
1380    )> {
1381        if let WakeAlarmsRequest::Set { notifier, deadline, mode, alarm_id, responder } = self {
1382            Some((notifier, deadline, mode, alarm_id, responder))
1383        } else {
1384            None
1385        }
1386    }
1387
1388    /// Name of the method defined in FIDL
1389    pub fn method_name(&self) -> &'static str {
1390        match *self {
1391            WakeAlarmsRequest::SetAndWait { .. } => "set_and_wait",
1392            WakeAlarmsRequest::Cancel { .. } => "cancel",
1393            WakeAlarmsRequest::Set { .. } => "set",
1394            WakeAlarmsRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1395                "unknown one-way method"
1396            }
1397            WakeAlarmsRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1398                "unknown two-way method"
1399            }
1400        }
1401    }
1402}
1403
1404#[derive(Debug, Clone)]
1405pub struct WakeAlarmsControlHandle {
1406    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1407}
1408
1409impl fidl::endpoints::ControlHandle for WakeAlarmsControlHandle {
1410    fn shutdown(&self) {
1411        self.inner.shutdown()
1412    }
1413    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1414        self.inner.shutdown_with_epitaph(status)
1415    }
1416
1417    fn is_closed(&self) -> bool {
1418        self.inner.channel().is_closed()
1419    }
1420    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1421        self.inner.channel().on_closed()
1422    }
1423
1424    #[cfg(target_os = "fuchsia")]
1425    fn signal_peer(
1426        &self,
1427        clear_mask: zx::Signals,
1428        set_mask: zx::Signals,
1429    ) -> Result<(), zx_status::Status> {
1430        use fidl::Peered;
1431        self.inner.channel().signal_peer(clear_mask, set_mask)
1432    }
1433}
1434
1435impl WakeAlarmsControlHandle {}
1436
1437#[must_use = "FIDL methods require a response to be sent"]
1438#[derive(Debug)]
1439pub struct WakeAlarmsSetAndWaitResponder {
1440    control_handle: std::mem::ManuallyDrop<WakeAlarmsControlHandle>,
1441    tx_id: u32,
1442}
1443
1444/// Set the the channel to be shutdown (see [`WakeAlarmsControlHandle::shutdown`])
1445/// if the responder is dropped without sending a response, so that the client
1446/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1447impl std::ops::Drop for WakeAlarmsSetAndWaitResponder {
1448    fn drop(&mut self) {
1449        self.control_handle.shutdown();
1450        // Safety: drops once, never accessed again
1451        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1452    }
1453}
1454
1455impl fidl::endpoints::Responder for WakeAlarmsSetAndWaitResponder {
1456    type ControlHandle = WakeAlarmsControlHandle;
1457
1458    fn control_handle(&self) -> &WakeAlarmsControlHandle {
1459        &self.control_handle
1460    }
1461
1462    fn drop_without_shutdown(mut self) {
1463        // Safety: drops once, never accessed again due to mem::forget
1464        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1465        // Prevent Drop from running (which would shut down the channel)
1466        std::mem::forget(self);
1467    }
1468}
1469
1470impl WakeAlarmsSetAndWaitResponder {
1471    /// Sends a response to the FIDL transaction.
1472    ///
1473    /// Sets the channel to shutdown if an error occurs.
1474    pub fn send(
1475        self,
1476        mut result: Result<fidl::EventPair, WakeAlarmsError>,
1477    ) -> Result<(), fidl::Error> {
1478        let _result = self.send_raw(result);
1479        if _result.is_err() {
1480            self.control_handle.shutdown();
1481        }
1482        self.drop_without_shutdown();
1483        _result
1484    }
1485
1486    /// Similar to "send" but does not shutdown the channel if an error occurs.
1487    pub fn send_no_shutdown_on_err(
1488        self,
1489        mut result: Result<fidl::EventPair, WakeAlarmsError>,
1490    ) -> Result<(), fidl::Error> {
1491        let _result = self.send_raw(result);
1492        self.drop_without_shutdown();
1493        _result
1494    }
1495
1496    fn send_raw(
1497        &self,
1498        mut result: Result<fidl::EventPair, WakeAlarmsError>,
1499    ) -> Result<(), fidl::Error> {
1500        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1501            WakeAlarmsSetAndWaitResponse,
1502            WakeAlarmsError,
1503        >>(
1504            fidl::encoding::FlexibleResult::new(result.map(|keep_alive| (keep_alive,))),
1505            self.tx_id,
1506            0x57ebd075ce4beba,
1507            fidl::encoding::DynamicFlags::FLEXIBLE,
1508        )
1509    }
1510}
1511
1512#[must_use = "FIDL methods require a response to be sent"]
1513#[derive(Debug)]
1514pub struct WakeAlarmsSetResponder {
1515    control_handle: std::mem::ManuallyDrop<WakeAlarmsControlHandle>,
1516    tx_id: u32,
1517}
1518
1519/// Set the the channel to be shutdown (see [`WakeAlarmsControlHandle::shutdown`])
1520/// if the responder is dropped without sending a response, so that the client
1521/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1522impl std::ops::Drop for WakeAlarmsSetResponder {
1523    fn drop(&mut self) {
1524        self.control_handle.shutdown();
1525        // Safety: drops once, never accessed again
1526        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1527    }
1528}
1529
1530impl fidl::endpoints::Responder for WakeAlarmsSetResponder {
1531    type ControlHandle = WakeAlarmsControlHandle;
1532
1533    fn control_handle(&self) -> &WakeAlarmsControlHandle {
1534        &self.control_handle
1535    }
1536
1537    fn drop_without_shutdown(mut self) {
1538        // Safety: drops once, never accessed again due to mem::forget
1539        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1540        // Prevent Drop from running (which would shut down the channel)
1541        std::mem::forget(self);
1542    }
1543}
1544
1545impl WakeAlarmsSetResponder {
1546    /// Sends a response to the FIDL transaction.
1547    ///
1548    /// Sets the channel to shutdown if an error occurs.
1549    pub fn send(self, mut result: Result<(), WakeAlarmsError>) -> Result<(), fidl::Error> {
1550        let _result = self.send_raw(result);
1551        if _result.is_err() {
1552            self.control_handle.shutdown();
1553        }
1554        self.drop_without_shutdown();
1555        _result
1556    }
1557
1558    /// Similar to "send" but does not shutdown the channel if an error occurs.
1559    pub fn send_no_shutdown_on_err(
1560        self,
1561        mut result: Result<(), WakeAlarmsError>,
1562    ) -> Result<(), fidl::Error> {
1563        let _result = self.send_raw(result);
1564        self.drop_without_shutdown();
1565        _result
1566    }
1567
1568    fn send_raw(&self, mut result: Result<(), WakeAlarmsError>) -> Result<(), fidl::Error> {
1569        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1570            fidl::encoding::EmptyStruct,
1571            WakeAlarmsError,
1572        >>(
1573            fidl::encoding::FlexibleResult::new(result),
1574            self.tx_id,
1575            0x1f110857e48fd72c,
1576            fidl::encoding::DynamicFlags::FLEXIBLE,
1577        )
1578    }
1579}
1580
1581mod internal {
1582    use super::*;
1583
1584    impl fidl::encoding::ResourceTypeMarker for NotifierNotifyErrorRequest {
1585        type Borrowed<'a> = &'a mut Self;
1586        fn take_or_borrow<'a>(
1587            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1588        ) -> Self::Borrowed<'a> {
1589            value
1590        }
1591    }
1592
1593    unsafe impl fidl::encoding::TypeMarker for NotifierNotifyErrorRequest {
1594        type Owned = Self;
1595
1596        #[inline(always)]
1597        fn inline_align(_context: fidl::encoding::Context) -> usize {
1598            8
1599        }
1600
1601        #[inline(always)]
1602        fn inline_size(_context: fidl::encoding::Context) -> usize {
1603            24
1604        }
1605    }
1606
1607    unsafe impl
1608        fidl::encoding::Encode<
1609            NotifierNotifyErrorRequest,
1610            fidl::encoding::DefaultFuchsiaResourceDialect,
1611        > for &mut NotifierNotifyErrorRequest
1612    {
1613        #[inline]
1614        unsafe fn encode(
1615            self,
1616            encoder: &mut fidl::encoding::Encoder<
1617                '_,
1618                fidl::encoding::DefaultFuchsiaResourceDialect,
1619            >,
1620            offset: usize,
1621            _depth: fidl::encoding::Depth,
1622        ) -> fidl::Result<()> {
1623            encoder.debug_check_bounds::<NotifierNotifyErrorRequest>(offset);
1624            // Delegate to tuple encoding.
1625            fidl::encoding::Encode::<
1626                NotifierNotifyErrorRequest,
1627                fidl::encoding::DefaultFuchsiaResourceDialect,
1628            >::encode(
1629                (
1630                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
1631                        &self.alarm_id,
1632                    ),
1633                    <WakeAlarmsError as fidl::encoding::ValueTypeMarker>::borrow(&self.error),
1634                ),
1635                encoder,
1636                offset,
1637                _depth,
1638            )
1639        }
1640    }
1641    unsafe impl<
1642            T0: fidl::encoding::Encode<
1643                fidl::encoding::BoundedString<128>,
1644                fidl::encoding::DefaultFuchsiaResourceDialect,
1645            >,
1646            T1: fidl::encoding::Encode<WakeAlarmsError, fidl::encoding::DefaultFuchsiaResourceDialect>,
1647        >
1648        fidl::encoding::Encode<
1649            NotifierNotifyErrorRequest,
1650            fidl::encoding::DefaultFuchsiaResourceDialect,
1651        > for (T0, T1)
1652    {
1653        #[inline]
1654        unsafe fn encode(
1655            self,
1656            encoder: &mut fidl::encoding::Encoder<
1657                '_,
1658                fidl::encoding::DefaultFuchsiaResourceDialect,
1659            >,
1660            offset: usize,
1661            depth: fidl::encoding::Depth,
1662        ) -> fidl::Result<()> {
1663            encoder.debug_check_bounds::<NotifierNotifyErrorRequest>(offset);
1664            // Zero out padding regions. There's no need to apply masks
1665            // because the unmasked parts will be overwritten by fields.
1666            unsafe {
1667                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1668                (ptr as *mut u64).write_unaligned(0);
1669            }
1670            // Write the fields.
1671            self.0.encode(encoder, offset + 0, depth)?;
1672            self.1.encode(encoder, offset + 16, depth)?;
1673            Ok(())
1674        }
1675    }
1676
1677    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1678        for NotifierNotifyErrorRequest
1679    {
1680        #[inline(always)]
1681        fn new_empty() -> Self {
1682            Self {
1683                alarm_id: fidl::new_empty!(
1684                    fidl::encoding::BoundedString<128>,
1685                    fidl::encoding::DefaultFuchsiaResourceDialect
1686                ),
1687                error: fidl::new_empty!(
1688                    WakeAlarmsError,
1689                    fidl::encoding::DefaultFuchsiaResourceDialect
1690                ),
1691            }
1692        }
1693
1694        #[inline]
1695        unsafe fn decode(
1696            &mut self,
1697            decoder: &mut fidl::encoding::Decoder<
1698                '_,
1699                fidl::encoding::DefaultFuchsiaResourceDialect,
1700            >,
1701            offset: usize,
1702            _depth: fidl::encoding::Depth,
1703        ) -> fidl::Result<()> {
1704            decoder.debug_check_bounds::<Self>(offset);
1705            // Verify that padding bytes are zero.
1706            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1707            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1708            let mask = 0xffffffff00000000u64;
1709            let maskedval = padval & mask;
1710            if maskedval != 0 {
1711                return Err(fidl::Error::NonZeroPadding {
1712                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1713                });
1714            }
1715            fidl::decode!(
1716                fidl::encoding::BoundedString<128>,
1717                fidl::encoding::DefaultFuchsiaResourceDialect,
1718                &mut self.alarm_id,
1719                decoder,
1720                offset + 0,
1721                _depth
1722            )?;
1723            fidl::decode!(
1724                WakeAlarmsError,
1725                fidl::encoding::DefaultFuchsiaResourceDialect,
1726                &mut self.error,
1727                decoder,
1728                offset + 16,
1729                _depth
1730            )?;
1731            Ok(())
1732        }
1733    }
1734
1735    impl fidl::encoding::ResourceTypeMarker for NotifierNotifyRequest {
1736        type Borrowed<'a> = &'a mut Self;
1737        fn take_or_borrow<'a>(
1738            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1739        ) -> Self::Borrowed<'a> {
1740            value
1741        }
1742    }
1743
1744    unsafe impl fidl::encoding::TypeMarker for NotifierNotifyRequest {
1745        type Owned = Self;
1746
1747        #[inline(always)]
1748        fn inline_align(_context: fidl::encoding::Context) -> usize {
1749            8
1750        }
1751
1752        #[inline(always)]
1753        fn inline_size(_context: fidl::encoding::Context) -> usize {
1754            24
1755        }
1756    }
1757
1758    unsafe impl
1759        fidl::encoding::Encode<NotifierNotifyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1760        for &mut NotifierNotifyRequest
1761    {
1762        #[inline]
1763        unsafe fn encode(
1764            self,
1765            encoder: &mut fidl::encoding::Encoder<
1766                '_,
1767                fidl::encoding::DefaultFuchsiaResourceDialect,
1768            >,
1769            offset: usize,
1770            _depth: fidl::encoding::Depth,
1771        ) -> fidl::Result<()> {
1772            encoder.debug_check_bounds::<NotifierNotifyRequest>(offset);
1773            // Delegate to tuple encoding.
1774            fidl::encoding::Encode::<
1775                NotifierNotifyRequest,
1776                fidl::encoding::DefaultFuchsiaResourceDialect,
1777            >::encode(
1778                (
1779                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(
1780                        &self.alarm_id,
1781                    ),
1782                    <fidl::encoding::HandleType<
1783                        fidl::EventPair,
1784                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1785                        16387,
1786                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1787                        &mut self.keep_alive
1788                    ),
1789                ),
1790                encoder,
1791                offset,
1792                _depth,
1793            )
1794        }
1795    }
1796    unsafe impl<
1797            T0: fidl::encoding::Encode<
1798                fidl::encoding::BoundedString<128>,
1799                fidl::encoding::DefaultFuchsiaResourceDialect,
1800            >,
1801            T1: fidl::encoding::Encode<
1802                fidl::encoding::HandleType<
1803                    fidl::EventPair,
1804                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1805                    16387,
1806                >,
1807                fidl::encoding::DefaultFuchsiaResourceDialect,
1808            >,
1809        >
1810        fidl::encoding::Encode<NotifierNotifyRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1811        for (T0, T1)
1812    {
1813        #[inline]
1814        unsafe fn encode(
1815            self,
1816            encoder: &mut fidl::encoding::Encoder<
1817                '_,
1818                fidl::encoding::DefaultFuchsiaResourceDialect,
1819            >,
1820            offset: usize,
1821            depth: fidl::encoding::Depth,
1822        ) -> fidl::Result<()> {
1823            encoder.debug_check_bounds::<NotifierNotifyRequest>(offset);
1824            // Zero out padding regions. There's no need to apply masks
1825            // because the unmasked parts will be overwritten by fields.
1826            unsafe {
1827                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1828                (ptr as *mut u64).write_unaligned(0);
1829            }
1830            // Write the fields.
1831            self.0.encode(encoder, offset + 0, depth)?;
1832            self.1.encode(encoder, offset + 16, depth)?;
1833            Ok(())
1834        }
1835    }
1836
1837    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1838        for NotifierNotifyRequest
1839    {
1840        #[inline(always)]
1841        fn new_empty() -> Self {
1842            Self {
1843                alarm_id: fidl::new_empty!(
1844                    fidl::encoding::BoundedString<128>,
1845                    fidl::encoding::DefaultFuchsiaResourceDialect
1846                ),
1847                keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
1848            }
1849        }
1850
1851        #[inline]
1852        unsafe fn decode(
1853            &mut self,
1854            decoder: &mut fidl::encoding::Decoder<
1855                '_,
1856                fidl::encoding::DefaultFuchsiaResourceDialect,
1857            >,
1858            offset: usize,
1859            _depth: fidl::encoding::Depth,
1860        ) -> fidl::Result<()> {
1861            decoder.debug_check_bounds::<Self>(offset);
1862            // Verify that padding bytes are zero.
1863            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1864            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1865            let mask = 0xffffffff00000000u64;
1866            let maskedval = padval & mask;
1867            if maskedval != 0 {
1868                return Err(fidl::Error::NonZeroPadding {
1869                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1870                });
1871            }
1872            fidl::decode!(
1873                fidl::encoding::BoundedString<128>,
1874                fidl::encoding::DefaultFuchsiaResourceDialect,
1875                &mut self.alarm_id,
1876                decoder,
1877                offset + 0,
1878                _depth
1879            )?;
1880            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.keep_alive, decoder, offset + 16, _depth)?;
1881            Ok(())
1882        }
1883    }
1884
1885    impl fidl::encoding::ResourceTypeMarker for SetAndWaitArgs {
1886        type Borrowed<'a> = &'a mut Self;
1887        fn take_or_borrow<'a>(
1888            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1889        ) -> Self::Borrowed<'a> {
1890            value
1891        }
1892    }
1893
1894    unsafe impl fidl::encoding::TypeMarker for SetAndWaitArgs {
1895        type Owned = Self;
1896
1897        #[inline(always)]
1898        fn inline_align(_context: fidl::encoding::Context) -> usize {
1899            8
1900        }
1901
1902        #[inline(always)]
1903        fn inline_size(_context: fidl::encoding::Context) -> usize {
1904            40
1905        }
1906    }
1907
1908    unsafe impl
1909        fidl::encoding::Encode<SetAndWaitArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
1910        for &mut SetAndWaitArgs
1911    {
1912        #[inline]
1913        unsafe fn encode(
1914            self,
1915            encoder: &mut fidl::encoding::Encoder<
1916                '_,
1917                fidl::encoding::DefaultFuchsiaResourceDialect,
1918            >,
1919            offset: usize,
1920            _depth: fidl::encoding::Depth,
1921        ) -> fidl::Result<()> {
1922            encoder.debug_check_bounds::<SetAndWaitArgs>(offset);
1923            // Delegate to tuple encoding.
1924            fidl::encoding::Encode::<SetAndWaitArgs, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1925                (
1926                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline),
1927                    <SetMode as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mode),
1928                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.alarm_id),
1929                ),
1930                encoder, offset, _depth
1931            )
1932        }
1933    }
1934    unsafe impl<
1935            T0: fidl::encoding::Encode<
1936                fidl::BootInstant,
1937                fidl::encoding::DefaultFuchsiaResourceDialect,
1938            >,
1939            T1: fidl::encoding::Encode<SetMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
1940            T2: fidl::encoding::Encode<
1941                fidl::encoding::BoundedString<128>,
1942                fidl::encoding::DefaultFuchsiaResourceDialect,
1943            >,
1944        > fidl::encoding::Encode<SetAndWaitArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
1945        for (T0, T1, T2)
1946    {
1947        #[inline]
1948        unsafe fn encode(
1949            self,
1950            encoder: &mut fidl::encoding::Encoder<
1951                '_,
1952                fidl::encoding::DefaultFuchsiaResourceDialect,
1953            >,
1954            offset: usize,
1955            depth: fidl::encoding::Depth,
1956        ) -> fidl::Result<()> {
1957            encoder.debug_check_bounds::<SetAndWaitArgs>(offset);
1958            // Zero out padding regions. There's no need to apply masks
1959            // because the unmasked parts will be overwritten by fields.
1960            // Write the fields.
1961            self.0.encode(encoder, offset + 0, depth)?;
1962            self.1.encode(encoder, offset + 8, depth)?;
1963            self.2.encode(encoder, offset + 24, depth)?;
1964            Ok(())
1965        }
1966    }
1967
1968    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1969        for SetAndWaitArgs
1970    {
1971        #[inline(always)]
1972        fn new_empty() -> Self {
1973            Self {
1974                deadline: fidl::new_empty!(
1975                    fidl::BootInstant,
1976                    fidl::encoding::DefaultFuchsiaResourceDialect
1977                ),
1978                mode: fidl::new_empty!(SetMode, fidl::encoding::DefaultFuchsiaResourceDialect),
1979                alarm_id: fidl::new_empty!(
1980                    fidl::encoding::BoundedString<128>,
1981                    fidl::encoding::DefaultFuchsiaResourceDialect
1982                ),
1983            }
1984        }
1985
1986        #[inline]
1987        unsafe fn decode(
1988            &mut self,
1989            decoder: &mut fidl::encoding::Decoder<
1990                '_,
1991                fidl::encoding::DefaultFuchsiaResourceDialect,
1992            >,
1993            offset: usize,
1994            _depth: fidl::encoding::Depth,
1995        ) -> fidl::Result<()> {
1996            decoder.debug_check_bounds::<Self>(offset);
1997            // Verify that padding bytes are zero.
1998            fidl::decode!(
1999                fidl::BootInstant,
2000                fidl::encoding::DefaultFuchsiaResourceDialect,
2001                &mut self.deadline,
2002                decoder,
2003                offset + 0,
2004                _depth
2005            )?;
2006            fidl::decode!(
2007                SetMode,
2008                fidl::encoding::DefaultFuchsiaResourceDialect,
2009                &mut self.mode,
2010                decoder,
2011                offset + 8,
2012                _depth
2013            )?;
2014            fidl::decode!(
2015                fidl::encoding::BoundedString<128>,
2016                fidl::encoding::DefaultFuchsiaResourceDialect,
2017                &mut self.alarm_id,
2018                decoder,
2019                offset + 24,
2020                _depth
2021            )?;
2022            Ok(())
2023        }
2024    }
2025
2026    impl fidl::encoding::ResourceTypeMarker for SetArgs {
2027        type Borrowed<'a> = &'a mut Self;
2028        fn take_or_borrow<'a>(
2029            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2030        ) -> Self::Borrowed<'a> {
2031            value
2032        }
2033    }
2034
2035    unsafe impl fidl::encoding::TypeMarker for SetArgs {
2036        type Owned = Self;
2037
2038        #[inline(always)]
2039        fn inline_align(_context: fidl::encoding::Context) -> usize {
2040            8
2041        }
2042
2043        #[inline(always)]
2044        fn inline_size(_context: fidl::encoding::Context) -> usize {
2045            48
2046        }
2047    }
2048
2049    unsafe impl fidl::encoding::Encode<SetArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
2050        for &mut SetArgs
2051    {
2052        #[inline]
2053        unsafe fn encode(
2054            self,
2055            encoder: &mut fidl::encoding::Encoder<
2056                '_,
2057                fidl::encoding::DefaultFuchsiaResourceDialect,
2058            >,
2059            offset: usize,
2060            _depth: fidl::encoding::Depth,
2061        ) -> fidl::Result<()> {
2062            encoder.debug_check_bounds::<SetArgs>(offset);
2063            // Delegate to tuple encoding.
2064            fidl::encoding::Encode::<SetArgs, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2065                (
2066                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.notifier),
2067                    <fidl::BootInstant as fidl::encoding::ValueTypeMarker>::borrow(&self.deadline),
2068                    <SetMode as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.mode),
2069                    <fidl::encoding::BoundedString<128> as fidl::encoding::ValueTypeMarker>::borrow(&self.alarm_id),
2070                ),
2071                encoder, offset, _depth
2072            )
2073        }
2074    }
2075    unsafe impl<
2076            T0: fidl::encoding::Encode<
2077                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>,
2078                fidl::encoding::DefaultFuchsiaResourceDialect,
2079            >,
2080            T1: fidl::encoding::Encode<
2081                fidl::BootInstant,
2082                fidl::encoding::DefaultFuchsiaResourceDialect,
2083            >,
2084            T2: fidl::encoding::Encode<SetMode, fidl::encoding::DefaultFuchsiaResourceDialect>,
2085            T3: fidl::encoding::Encode<
2086                fidl::encoding::BoundedString<128>,
2087                fidl::encoding::DefaultFuchsiaResourceDialect,
2088            >,
2089        > fidl::encoding::Encode<SetArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
2090        for (T0, T1, T2, T3)
2091    {
2092        #[inline]
2093        unsafe fn encode(
2094            self,
2095            encoder: &mut fidl::encoding::Encoder<
2096                '_,
2097                fidl::encoding::DefaultFuchsiaResourceDialect,
2098            >,
2099            offset: usize,
2100            depth: fidl::encoding::Depth,
2101        ) -> fidl::Result<()> {
2102            encoder.debug_check_bounds::<SetArgs>(offset);
2103            // Zero out padding regions. There's no need to apply masks
2104            // because the unmasked parts will be overwritten by fields.
2105            unsafe {
2106                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2107                (ptr as *mut u64).write_unaligned(0);
2108            }
2109            // Write the fields.
2110            self.0.encode(encoder, offset + 0, depth)?;
2111            self.1.encode(encoder, offset + 8, depth)?;
2112            self.2.encode(encoder, offset + 16, depth)?;
2113            self.3.encode(encoder, offset + 32, depth)?;
2114            Ok(())
2115        }
2116    }
2117
2118    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SetArgs {
2119        #[inline(always)]
2120        fn new_empty() -> Self {
2121            Self {
2122                notifier: fidl::new_empty!(
2123                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>,
2124                    fidl::encoding::DefaultFuchsiaResourceDialect
2125                ),
2126                deadline: fidl::new_empty!(
2127                    fidl::BootInstant,
2128                    fidl::encoding::DefaultFuchsiaResourceDialect
2129                ),
2130                mode: fidl::new_empty!(SetMode, fidl::encoding::DefaultFuchsiaResourceDialect),
2131                alarm_id: fidl::new_empty!(
2132                    fidl::encoding::BoundedString<128>,
2133                    fidl::encoding::DefaultFuchsiaResourceDialect
2134                ),
2135            }
2136        }
2137
2138        #[inline]
2139        unsafe fn decode(
2140            &mut self,
2141            decoder: &mut fidl::encoding::Decoder<
2142                '_,
2143                fidl::encoding::DefaultFuchsiaResourceDialect,
2144            >,
2145            offset: usize,
2146            _depth: fidl::encoding::Depth,
2147        ) -> fidl::Result<()> {
2148            decoder.debug_check_bounds::<Self>(offset);
2149            // Verify that padding bytes are zero.
2150            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2151            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2152            let mask = 0xffffffff00000000u64;
2153            let maskedval = padval & mask;
2154            if maskedval != 0 {
2155                return Err(fidl::Error::NonZeroPadding {
2156                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2157                });
2158            }
2159            fidl::decode!(
2160                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<NotifierMarker>>,
2161                fidl::encoding::DefaultFuchsiaResourceDialect,
2162                &mut self.notifier,
2163                decoder,
2164                offset + 0,
2165                _depth
2166            )?;
2167            fidl::decode!(
2168                fidl::BootInstant,
2169                fidl::encoding::DefaultFuchsiaResourceDialect,
2170                &mut self.deadline,
2171                decoder,
2172                offset + 8,
2173                _depth
2174            )?;
2175            fidl::decode!(
2176                SetMode,
2177                fidl::encoding::DefaultFuchsiaResourceDialect,
2178                &mut self.mode,
2179                decoder,
2180                offset + 16,
2181                _depth
2182            )?;
2183            fidl::decode!(
2184                fidl::encoding::BoundedString<128>,
2185                fidl::encoding::DefaultFuchsiaResourceDialect,
2186                &mut self.alarm_id,
2187                decoder,
2188                offset + 32,
2189                _depth
2190            )?;
2191            Ok(())
2192        }
2193    }
2194
2195    impl fidl::encoding::ResourceTypeMarker for WakeAlarmsSetAndWaitResponse {
2196        type Borrowed<'a> = &'a mut Self;
2197        fn take_or_borrow<'a>(
2198            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2199        ) -> Self::Borrowed<'a> {
2200            value
2201        }
2202    }
2203
2204    unsafe impl fidl::encoding::TypeMarker for WakeAlarmsSetAndWaitResponse {
2205        type Owned = Self;
2206
2207        #[inline(always)]
2208        fn inline_align(_context: fidl::encoding::Context) -> usize {
2209            4
2210        }
2211
2212        #[inline(always)]
2213        fn inline_size(_context: fidl::encoding::Context) -> usize {
2214            4
2215        }
2216    }
2217
2218    unsafe impl
2219        fidl::encoding::Encode<
2220            WakeAlarmsSetAndWaitResponse,
2221            fidl::encoding::DefaultFuchsiaResourceDialect,
2222        > for &mut WakeAlarmsSetAndWaitResponse
2223    {
2224        #[inline]
2225        unsafe fn encode(
2226            self,
2227            encoder: &mut fidl::encoding::Encoder<
2228                '_,
2229                fidl::encoding::DefaultFuchsiaResourceDialect,
2230            >,
2231            offset: usize,
2232            _depth: fidl::encoding::Depth,
2233        ) -> fidl::Result<()> {
2234            encoder.debug_check_bounds::<WakeAlarmsSetAndWaitResponse>(offset);
2235            // Delegate to tuple encoding.
2236            fidl::encoding::Encode::<
2237                WakeAlarmsSetAndWaitResponse,
2238                fidl::encoding::DefaultFuchsiaResourceDialect,
2239            >::encode(
2240                (<fidl::encoding::HandleType<
2241                    fidl::EventPair,
2242                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2243                    16387,
2244                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2245                    &mut self.keep_alive
2246                ),),
2247                encoder,
2248                offset,
2249                _depth,
2250            )
2251        }
2252    }
2253    unsafe impl<
2254            T0: fidl::encoding::Encode<
2255                fidl::encoding::HandleType<
2256                    fidl::EventPair,
2257                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2258                    16387,
2259                >,
2260                fidl::encoding::DefaultFuchsiaResourceDialect,
2261            >,
2262        >
2263        fidl::encoding::Encode<
2264            WakeAlarmsSetAndWaitResponse,
2265            fidl::encoding::DefaultFuchsiaResourceDialect,
2266        > for (T0,)
2267    {
2268        #[inline]
2269        unsafe fn encode(
2270            self,
2271            encoder: &mut fidl::encoding::Encoder<
2272                '_,
2273                fidl::encoding::DefaultFuchsiaResourceDialect,
2274            >,
2275            offset: usize,
2276            depth: fidl::encoding::Depth,
2277        ) -> fidl::Result<()> {
2278            encoder.debug_check_bounds::<WakeAlarmsSetAndWaitResponse>(offset);
2279            // Zero out padding regions. There's no need to apply masks
2280            // because the unmasked parts will be overwritten by fields.
2281            // Write the fields.
2282            self.0.encode(encoder, offset + 0, depth)?;
2283            Ok(())
2284        }
2285    }
2286
2287    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2288        for WakeAlarmsSetAndWaitResponse
2289    {
2290        #[inline(always)]
2291        fn new_empty() -> Self {
2292            Self {
2293                keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
2294            }
2295        }
2296
2297        #[inline]
2298        unsafe fn decode(
2299            &mut self,
2300            decoder: &mut fidl::encoding::Decoder<
2301                '_,
2302                fidl::encoding::DefaultFuchsiaResourceDialect,
2303            >,
2304            offset: usize,
2305            _depth: fidl::encoding::Depth,
2306        ) -> fidl::Result<()> {
2307            decoder.debug_check_bounds::<Self>(offset);
2308            // Verify that padding bytes are zero.
2309            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.keep_alive, decoder, offset + 0, _depth)?;
2310            Ok(())
2311        }
2312    }
2313
2314    impl fidl::encoding::ResourceTypeMarker for SetMode {
2315        type Borrowed<'a> = &'a mut Self;
2316        fn take_or_borrow<'a>(
2317            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2318        ) -> Self::Borrowed<'a> {
2319            value
2320        }
2321    }
2322
2323    unsafe impl fidl::encoding::TypeMarker for SetMode {
2324        type Owned = Self;
2325
2326        #[inline(always)]
2327        fn inline_align(_context: fidl::encoding::Context) -> usize {
2328            8
2329        }
2330
2331        #[inline(always)]
2332        fn inline_size(_context: fidl::encoding::Context) -> usize {
2333            16
2334        }
2335    }
2336
2337    unsafe impl fidl::encoding::Encode<SetMode, fidl::encoding::DefaultFuchsiaResourceDialect>
2338        for &mut SetMode
2339    {
2340        #[inline]
2341        unsafe fn encode(
2342            self,
2343            encoder: &mut fidl::encoding::Encoder<
2344                '_,
2345                fidl::encoding::DefaultFuchsiaResourceDialect,
2346            >,
2347            offset: usize,
2348            _depth: fidl::encoding::Depth,
2349        ) -> fidl::Result<()> {
2350            encoder.debug_check_bounds::<SetMode>(offset);
2351            encoder.write_num::<u64>(self.ordinal(), offset);
2352            match self {
2353                SetMode::KeepAlive(ref mut val) => fidl::encoding::encode_in_envelope::<
2354                    fidl::encoding::HandleType<
2355                        fidl::EventPair,
2356                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2357                        16387,
2358                    >,
2359                    fidl::encoding::DefaultFuchsiaResourceDialect,
2360                >(
2361                    <fidl::encoding::HandleType<
2362                        fidl::EventPair,
2363                        { fidl::ObjectType::EVENTPAIR.into_raw() },
2364                        16387,
2365                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2366                        val
2367                    ),
2368                    encoder,
2369                    offset + 8,
2370                    _depth,
2371                ),
2372                SetMode::NotifySetupDone(ref mut val) => fidl::encoding::encode_in_envelope::<
2373                    fidl::encoding::HandleType<
2374                        fidl::Event,
2375                        { fidl::ObjectType::EVENT.into_raw() },
2376                        2147483648,
2377                    >,
2378                    fidl::encoding::DefaultFuchsiaResourceDialect,
2379                >(
2380                    <fidl::encoding::HandleType<
2381                        fidl::Event,
2382                        { fidl::ObjectType::EVENT.into_raw() },
2383                        2147483648,
2384                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2385                        val
2386                    ),
2387                    encoder,
2388                    offset + 8,
2389                    _depth,
2390                ),
2391                SetMode::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
2392            }
2393        }
2394    }
2395
2396    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for SetMode {
2397        #[inline(always)]
2398        fn new_empty() -> Self {
2399            Self::__SourceBreaking { unknown_ordinal: 0 }
2400        }
2401
2402        #[inline]
2403        unsafe fn decode(
2404            &mut self,
2405            decoder: &mut fidl::encoding::Decoder<
2406                '_,
2407                fidl::encoding::DefaultFuchsiaResourceDialect,
2408            >,
2409            offset: usize,
2410            mut depth: fidl::encoding::Depth,
2411        ) -> fidl::Result<()> {
2412            decoder.debug_check_bounds::<Self>(offset);
2413            #[allow(unused_variables)]
2414            let next_out_of_line = decoder.next_out_of_line();
2415            let handles_before = decoder.remaining_handles();
2416            let (ordinal, inlined, num_bytes, num_handles) =
2417                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2418
2419            let member_inline_size = match ordinal {
2420                1 => <fidl::encoding::HandleType<
2421                    fidl::EventPair,
2422                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2423                    16387,
2424                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2425                2 => <fidl::encoding::HandleType<
2426                    fidl::Event,
2427                    { fidl::ObjectType::EVENT.into_raw() },
2428                    2147483648,
2429                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2430                0 => return Err(fidl::Error::UnknownUnionTag),
2431                _ => num_bytes as usize,
2432            };
2433
2434            if inlined != (member_inline_size <= 4) {
2435                return Err(fidl::Error::InvalidInlineBitInEnvelope);
2436            }
2437            let _inner_offset;
2438            if inlined {
2439                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2440                _inner_offset = offset + 8;
2441            } else {
2442                depth.increment()?;
2443                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2444            }
2445            match ordinal {
2446                1 => {
2447                    #[allow(irrefutable_let_patterns)]
2448                    if let SetMode::KeepAlive(_) = self {
2449                        // Do nothing, read the value into the object
2450                    } else {
2451                        // Initialize `self` to the right variant
2452                        *self = SetMode::KeepAlive(
2453                            fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
2454                        );
2455                    }
2456                    #[allow(irrefutable_let_patterns)]
2457                    if let SetMode::KeepAlive(ref mut val) = self {
2458                        fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2459                    } else {
2460                        unreachable!()
2461                    }
2462                }
2463                2 => {
2464                    #[allow(irrefutable_let_patterns)]
2465                    if let SetMode::NotifySetupDone(_) = self {
2466                        // Do nothing, read the value into the object
2467                    } else {
2468                        // Initialize `self` to the right variant
2469                        *self = SetMode::NotifySetupDone(
2470                            fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2471                        );
2472                    }
2473                    #[allow(irrefutable_let_patterns)]
2474                    if let SetMode::NotifySetupDone(ref mut val) = self {
2475                        fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
2476                    } else {
2477                        unreachable!()
2478                    }
2479                }
2480                #[allow(deprecated)]
2481                ordinal => {
2482                    for _ in 0..num_handles {
2483                        decoder.drop_next_handle()?;
2484                    }
2485                    *self = SetMode::__SourceBreaking { unknown_ordinal: ordinal };
2486                }
2487            }
2488            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2489                return Err(fidl::Error::InvalidNumBytesInEnvelope);
2490            }
2491            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2492                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2493            }
2494            Ok(())
2495        }
2496    }
2497}