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