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