Skip to main content

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        Self { client: fidl::client::sync::Client::new(channel) }
226    }
227
228    pub fn into_channel(self) -> fidl::Channel {
229        self.client.into_channel()
230    }
231
232    /// Waits until an event arrives and returns it. It is safe for other
233    /// threads to make concurrent requests while waiting for an event.
234    pub fn wait_for_event(
235        &self,
236        deadline: zx::MonotonicInstant,
237    ) -> Result<NotifierEvent, fidl::Error> {
238        NotifierEvent::decode(self.client.wait_for_event::<NotifierMarker>(deadline)?)
239    }
240
241    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
242    pub fn r#notify(
243        &self,
244        mut alarm_id: &str,
245        mut keep_alive: fidl::EventPair,
246    ) -> Result<(), fidl::Error> {
247        self.client.send::<NotifierNotifyRequest>(
248            (alarm_id, keep_alive),
249            0x23d11b31ba0d67d4,
250            fidl::encoding::DynamicFlags::FLEXIBLE,
251        )
252    }
253
254    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
255    /// fire due to an error.
256    pub fn r#notify_error(
257        &self,
258        mut alarm_id: &str,
259        mut error: WakeAlarmsError,
260    ) -> Result<(), fidl::Error> {
261        self.client.send::<NotifierNotifyErrorRequest>(
262            (alarm_id, error),
263            0x62e915191b0113e9,
264            fidl::encoding::DynamicFlags::FLEXIBLE,
265        )
266    }
267}
268
269#[cfg(target_os = "fuchsia")]
270impl From<NotifierSynchronousProxy> for zx::NullableHandle {
271    fn from(value: NotifierSynchronousProxy) -> Self {
272        value.into_channel().into()
273    }
274}
275
276#[cfg(target_os = "fuchsia")]
277impl From<fidl::Channel> for NotifierSynchronousProxy {
278    fn from(value: fidl::Channel) -> Self {
279        Self::new(value)
280    }
281}
282
283#[cfg(target_os = "fuchsia")]
284impl fidl::endpoints::FromClient for NotifierSynchronousProxy {
285    type Protocol = NotifierMarker;
286
287    fn from_client(value: fidl::endpoints::ClientEnd<NotifierMarker>) -> Self {
288        Self::new(value.into_channel())
289    }
290}
291
292#[derive(Debug, Clone)]
293pub struct NotifierProxy {
294    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
295}
296
297impl fidl::endpoints::Proxy for NotifierProxy {
298    type Protocol = NotifierMarker;
299
300    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
301        Self::new(inner)
302    }
303
304    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
305        self.client.into_channel().map_err(|client| Self { client })
306    }
307
308    fn as_channel(&self) -> &::fidl::AsyncChannel {
309        self.client.as_channel()
310    }
311}
312
313impl NotifierProxy {
314    /// Create a new Proxy for fuchsia.time.alarms/Notifier.
315    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
316        let protocol_name = <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
317        Self { client: fidl::client::Client::new(channel, protocol_name) }
318    }
319
320    /// Get a Stream of events from the remote end of the protocol.
321    ///
322    /// # Panics
323    ///
324    /// Panics if the event stream was already taken.
325    pub fn take_event_stream(&self) -> NotifierEventStream {
326        NotifierEventStream { event_receiver: self.client.take_event_receiver() }
327    }
328
329    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
330    pub fn r#notify(
331        &self,
332        mut alarm_id: &str,
333        mut keep_alive: fidl::EventPair,
334    ) -> Result<(), fidl::Error> {
335        NotifierProxyInterface::r#notify(self, alarm_id, keep_alive)
336    }
337
338    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
339    /// fire due to an error.
340    pub fn r#notify_error(
341        &self,
342        mut alarm_id: &str,
343        mut error: WakeAlarmsError,
344    ) -> Result<(), fidl::Error> {
345        NotifierProxyInterface::r#notify_error(self, alarm_id, error)
346    }
347}
348
349impl NotifierProxyInterface for NotifierProxy {
350    fn r#notify(
351        &self,
352        mut alarm_id: &str,
353        mut keep_alive: fidl::EventPair,
354    ) -> Result<(), fidl::Error> {
355        self.client.send::<NotifierNotifyRequest>(
356            (alarm_id, keep_alive),
357            0x23d11b31ba0d67d4,
358            fidl::encoding::DynamicFlags::FLEXIBLE,
359        )
360    }
361
362    fn r#notify_error(
363        &self,
364        mut alarm_id: &str,
365        mut error: WakeAlarmsError,
366    ) -> Result<(), fidl::Error> {
367        self.client.send::<NotifierNotifyErrorRequest>(
368            (alarm_id, error),
369            0x62e915191b0113e9,
370            fidl::encoding::DynamicFlags::FLEXIBLE,
371        )
372    }
373}
374
375pub struct NotifierEventStream {
376    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
377}
378
379impl std::marker::Unpin for NotifierEventStream {}
380
381impl futures::stream::FusedStream for NotifierEventStream {
382    fn is_terminated(&self) -> bool {
383        self.event_receiver.is_terminated()
384    }
385}
386
387impl futures::Stream for NotifierEventStream {
388    type Item = Result<NotifierEvent, fidl::Error>;
389
390    fn poll_next(
391        mut self: std::pin::Pin<&mut Self>,
392        cx: &mut std::task::Context<'_>,
393    ) -> std::task::Poll<Option<Self::Item>> {
394        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
395            &mut self.event_receiver,
396            cx
397        )?) {
398            Some(buf) => std::task::Poll::Ready(Some(NotifierEvent::decode(buf))),
399            None => std::task::Poll::Ready(None),
400        }
401    }
402}
403
404#[derive(Debug)]
405pub enum NotifierEvent {
406    #[non_exhaustive]
407    _UnknownEvent {
408        /// Ordinal of the event that was sent.
409        ordinal: u64,
410    },
411}
412
413impl NotifierEvent {
414    /// Decodes a message buffer as a [`NotifierEvent`].
415    fn decode(
416        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
417    ) -> Result<NotifierEvent, fidl::Error> {
418        let (bytes, _handles) = buf.split_mut();
419        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
420        debug_assert_eq!(tx_header.tx_id, 0);
421        match tx_header.ordinal {
422            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
423                Ok(NotifierEvent::_UnknownEvent { ordinal: tx_header.ordinal })
424            }
425            _ => Err(fidl::Error::UnknownOrdinal {
426                ordinal: tx_header.ordinal,
427                protocol_name: <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
428            }),
429        }
430    }
431}
432
433/// A Stream of incoming requests for fuchsia.time.alarms/Notifier.
434pub struct NotifierRequestStream {
435    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
436    is_terminated: bool,
437}
438
439impl std::marker::Unpin for NotifierRequestStream {}
440
441impl futures::stream::FusedStream for NotifierRequestStream {
442    fn is_terminated(&self) -> bool {
443        self.is_terminated
444    }
445}
446
447impl fidl::endpoints::RequestStream for NotifierRequestStream {
448    type Protocol = NotifierMarker;
449    type ControlHandle = NotifierControlHandle;
450
451    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
452        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
453    }
454
455    fn control_handle(&self) -> Self::ControlHandle {
456        NotifierControlHandle { inner: self.inner.clone() }
457    }
458
459    fn into_inner(
460        self,
461    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
462    {
463        (self.inner, self.is_terminated)
464    }
465
466    fn from_inner(
467        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
468        is_terminated: bool,
469    ) -> Self {
470        Self { inner, is_terminated }
471    }
472}
473
474impl futures::Stream for NotifierRequestStream {
475    type Item = Result<NotifierRequest, fidl::Error>;
476
477    fn poll_next(
478        mut self: std::pin::Pin<&mut Self>,
479        cx: &mut std::task::Context<'_>,
480    ) -> std::task::Poll<Option<Self::Item>> {
481        let this = &mut *self;
482        if this.inner.check_shutdown(cx) {
483            this.is_terminated = true;
484            return std::task::Poll::Ready(None);
485        }
486        if this.is_terminated {
487            panic!("polled NotifierRequestStream after completion");
488        }
489        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
490            |bytes, handles| {
491                match this.inner.channel().read_etc(cx, bytes, handles) {
492                    std::task::Poll::Ready(Ok(())) => {}
493                    std::task::Poll::Pending => return std::task::Poll::Pending,
494                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
495                        this.is_terminated = true;
496                        return std::task::Poll::Ready(None);
497                    }
498                    std::task::Poll::Ready(Err(e)) => {
499                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
500                            e.into(),
501                        ))));
502                    }
503                }
504
505                // A message has been received from the channel
506                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
507
508                std::task::Poll::Ready(Some(match header.ordinal {
509                    0x23d11b31ba0d67d4 => {
510                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
511                        let mut req = fidl::new_empty!(
512                            NotifierNotifyRequest,
513                            fidl::encoding::DefaultFuchsiaResourceDialect
514                        );
515                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotifierNotifyRequest>(&header, _body_bytes, handles, &mut req)?;
516                        let control_handle = NotifierControlHandle { inner: this.inner.clone() };
517                        Ok(NotifierRequest::Notify {
518                            alarm_id: req.alarm_id,
519                            keep_alive: req.keep_alive,
520
521                            control_handle,
522                        })
523                    }
524                    0x62e915191b0113e9 => {
525                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
526                        let mut req = fidl::new_empty!(
527                            NotifierNotifyErrorRequest,
528                            fidl::encoding::DefaultFuchsiaResourceDialect
529                        );
530                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<NotifierNotifyErrorRequest>(&header, _body_bytes, handles, &mut req)?;
531                        let control_handle = NotifierControlHandle { inner: this.inner.clone() };
532                        Ok(NotifierRequest::NotifyError {
533                            alarm_id: req.alarm_id,
534                            error: req.error,
535
536                            control_handle,
537                        })
538                    }
539                    _ if header.tx_id == 0
540                        && header
541                            .dynamic_flags()
542                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
543                    {
544                        Ok(NotifierRequest::_UnknownMethod {
545                            ordinal: header.ordinal,
546                            control_handle: NotifierControlHandle { inner: this.inner.clone() },
547                            method_type: fidl::MethodType::OneWay,
548                        })
549                    }
550                    _ if header
551                        .dynamic_flags()
552                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
553                    {
554                        this.inner.send_framework_err(
555                            fidl::encoding::FrameworkErr::UnknownMethod,
556                            header.tx_id,
557                            header.ordinal,
558                            header.dynamic_flags(),
559                            (bytes, handles),
560                        )?;
561                        Ok(NotifierRequest::_UnknownMethod {
562                            ordinal: header.ordinal,
563                            control_handle: NotifierControlHandle { inner: this.inner.clone() },
564                            method_type: fidl::MethodType::TwoWay,
565                        })
566                    }
567                    _ => Err(fidl::Error::UnknownOrdinal {
568                        ordinal: header.ordinal,
569                        protocol_name:
570                            <NotifierMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
571                    }),
572                }))
573            },
574        )
575    }
576}
577
578/// [Notifier] is used to notify when a wake alarm fires.
579///
580/// A client-end channel of this protocol will be provided to the implementor of
581/// [WakeAlarms.Set].
582///
583/// Dropping the server-end will cancel all alarms scheduled with [WakeAlarms.Set]
584/// associated with this server instance.
585#[derive(Debug)]
586pub enum NotifierRequest {
587    /// Notifies when an alarm previously set by [WakeAlarms.Set] fires.
588    Notify { alarm_id: String, keep_alive: fidl::EventPair, control_handle: NotifierControlHandle },
589    /// Notifies when an alarm previously set by [WakeAlarms.Set] is unable to
590    /// fire due to an error.
591    NotifyError { alarm_id: String, error: WakeAlarmsError, control_handle: NotifierControlHandle },
592    /// An interaction was received which does not match any known method.
593    #[non_exhaustive]
594    _UnknownMethod {
595        /// Ordinal of the method that was called.
596        ordinal: u64,
597        control_handle: NotifierControlHandle,
598        method_type: fidl::MethodType,
599    },
600}
601
602impl NotifierRequest {
603    #[allow(irrefutable_let_patterns)]
604    pub fn into_notify(self) -> Option<(String, fidl::EventPair, NotifierControlHandle)> {
605        if let NotifierRequest::Notify { alarm_id, keep_alive, control_handle } = self {
606            Some((alarm_id, keep_alive, control_handle))
607        } else {
608            None
609        }
610    }
611
612    #[allow(irrefutable_let_patterns)]
613    pub fn into_notify_error(self) -> Option<(String, WakeAlarmsError, NotifierControlHandle)> {
614        if let NotifierRequest::NotifyError { alarm_id, error, control_handle } = self {
615            Some((alarm_id, error, control_handle))
616        } else {
617            None
618        }
619    }
620
621    /// Name of the method defined in FIDL
622    pub fn method_name(&self) -> &'static str {
623        match *self {
624            NotifierRequest::Notify { .. } => "notify",
625            NotifierRequest::NotifyError { .. } => "notify_error",
626            NotifierRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
627                "unknown one-way method"
628            }
629            NotifierRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
630                "unknown two-way method"
631            }
632        }
633    }
634}
635
636#[derive(Debug, Clone)]
637pub struct NotifierControlHandle {
638    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
639}
640
641impl fidl::endpoints::ControlHandle for NotifierControlHandle {
642    fn shutdown(&self) {
643        self.inner.shutdown()
644    }
645
646    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
647        self.inner.shutdown_with_epitaph(status)
648    }
649
650    fn is_closed(&self) -> bool {
651        self.inner.channel().is_closed()
652    }
653    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
654        self.inner.channel().on_closed()
655    }
656
657    #[cfg(target_os = "fuchsia")]
658    fn signal_peer(
659        &self,
660        clear_mask: zx::Signals,
661        set_mask: zx::Signals,
662    ) -> Result<(), zx_status::Status> {
663        use fidl::Peered;
664        self.inner.channel().signal_peer(clear_mask, set_mask)
665    }
666}
667
668impl NotifierControlHandle {}
669
670#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
671pub struct WakeAlarmsMarker;
672
673impl fidl::endpoints::ProtocolMarker for WakeAlarmsMarker {
674    type Proxy = WakeAlarmsProxy;
675    type RequestStream = WakeAlarmsRequestStream;
676    #[cfg(target_os = "fuchsia")]
677    type SynchronousProxy = WakeAlarmsSynchronousProxy;
678
679    const DEBUG_NAME: &'static str = "fuchsia.time.alarms.WakeAlarms";
680}
681impl fidl::endpoints::DiscoverableProtocolMarker for WakeAlarmsMarker {}
682pub type WakeAlarmsSetAndWaitResult = Result<fidl::EventPair, WakeAlarmsError>;
683pub type WakeAlarmsSetResult = Result<(), WakeAlarmsError>;
684pub type WakeAlarmsSetAndWaitUtcResult = Result<fidl::EventPair, WakeAlarmsError>;
685
686pub trait WakeAlarmsProxyInterface: Send + Sync {
687    type SetAndWaitResponseFut: std::future::Future<Output = Result<WakeAlarmsSetAndWaitResult, fidl::Error>>
688        + Send;
689    fn r#set_and_wait(
690        &self,
691        deadline: fidl::BootInstant,
692        mode: SetMode,
693        alarm_id: &str,
694    ) -> Self::SetAndWaitResponseFut;
695    fn r#cancel(&self, alarm_id: &str) -> Result<(), fidl::Error>;
696    type SetResponseFut: std::future::Future<Output = Result<WakeAlarmsSetResult, fidl::Error>>
697        + Send;
698    fn r#set(
699        &self,
700        notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
701        deadline: fidl::BootInstant,
702        mode: SetMode,
703        alarm_id: &str,
704    ) -> Self::SetResponseFut;
705    type SetAndWaitUtcResponseFut: std::future::Future<Output = Result<WakeAlarmsSetAndWaitUtcResult, fidl::Error>>
706        + Send;
707    fn r#set_and_wait_utc(
708        &self,
709        deadline: &InstantUtc,
710        mode: SetMode,
711        alarm_id: &str,
712    ) -> Self::SetAndWaitUtcResponseFut;
713}
714#[derive(Debug)]
715#[cfg(target_os = "fuchsia")]
716pub struct WakeAlarmsSynchronousProxy {
717    client: fidl::client::sync::Client,
718}
719
720#[cfg(target_os = "fuchsia")]
721impl fidl::endpoints::SynchronousProxy for WakeAlarmsSynchronousProxy {
722    type Proxy = WakeAlarmsProxy;
723    type Protocol = WakeAlarmsMarker;
724
725    fn from_channel(inner: fidl::Channel) -> Self {
726        Self::new(inner)
727    }
728
729    fn into_channel(self) -> fidl::Channel {
730        self.client.into_channel()
731    }
732
733    fn as_channel(&self) -> &fidl::Channel {
734        self.client.as_channel()
735    }
736}
737
738#[cfg(target_os = "fuchsia")]
739impl WakeAlarmsSynchronousProxy {
740    pub fn new(channel: fidl::Channel) -> Self {
741        Self { client: fidl::client::sync::Client::new(channel) }
742    }
743
744    pub fn into_channel(self) -> fidl::Channel {
745        self.client.into_channel()
746    }
747
748    /// Waits until an event arrives and returns it. It is safe for other
749    /// threads to make concurrent requests while waiting for an event.
750    pub fn wait_for_event(
751        &self,
752        deadline: zx::MonotonicInstant,
753    ) -> Result<WakeAlarmsEvent, fidl::Error> {
754        WakeAlarmsEvent::decode(self.client.wait_for_event::<WakeAlarmsMarker>(deadline)?)
755    }
756
757    /// Sets a wake alarm with the provided parameters, and waits for the alarm
758    /// to fire.
759    ///
760    /// The caller may request multiple alarms concurrently. Re-requesting
761    /// an alarm that has the same `alarm_id` as an already scheduled alarm
762    /// causes that scheduled alarm to be canceled before the new alarm is
763    /// scheduled.
764    ///
765    /// ## Return value
766    ///
767    /// * `keep_alive`: A handle that prevents the system from suspending as
768    ///   long as it is held.
769    ///
770    /// The call to `SetAndWait` returns when the alarm fires, an error occurs,
771    /// or the alarm is canceled. This return style is required for some
772    /// clients, such as Starnix, which rely on FIDL response tallying to guide
773    /// their power management strategy.
774    ///
775    /// As an example, under Starnix, a response to this request will cause a
776    /// Starnix container to be unsuspended ("woken up"). This is a critical
777    /// behavior for suspend correctness under Starnix. Using the [Notifier]
778    /// approach would side-step this mechanism and result in incorrect wake
779    /// behavior under Starnix.
780    ///
781    /// ## Protocol Errors
782    ///
783    /// * `DROPPED`: The alarm was canceled by a call to `Cancel`.
784    /// * `UNSPECIFIED`: A new failure mode has been observed that has not
785    ///   yet been assigned an error code. This indicates that the API
786    ///   version may need to be updated.
787    /// * `INTERNAL` is a server-side bug: an internal fallible call (which is
788    ///   expected to be unlikely to fail) has failed somehow. Please report this
789    ///   for investigation.
790    /// * [INVALID_ARGS]: a parameter provided by the user is not valid, such
791    ///   as an empty `alarm_id`.
792    pub fn r#set_and_wait(
793        &self,
794        mut deadline: fidl::BootInstant,
795        mut mode: SetMode,
796        mut alarm_id: &str,
797        ___deadline: zx::MonotonicInstant,
798    ) -> Result<WakeAlarmsSetAndWaitResult, fidl::Error> {
799        let _response = self.client.send_query::<
800            SetAndWaitArgs,
801            fidl::encoding::FlexibleResultType<WakeAlarmsSetAndWaitResponse, WakeAlarmsError>,
802            WakeAlarmsMarker,
803        >(
804            (deadline, &mut mode, alarm_id,),
805            0x57ebd075ce4beba,
806            fidl::encoding::DynamicFlags::FLEXIBLE,
807            ___deadline,
808        )?
809        .into_result::<WakeAlarmsMarker>("set_and_wait")?;
810        Ok(_response.map(|x| x.keep_alive))
811    }
812
813    /// Cancels the alarm specified by `alarm_id`.
814    ///
815    /// Providing an `alarm_id` for an alarm that is not scheduled is a no-op.
816    pub fn r#cancel(&self, mut alarm_id: &str) -> Result<(), fidl::Error> {
817        self.client.send::<WakeAlarmsCancelRequest>(
818            (alarm_id,),
819            0x7b23a9760115e55c,
820            fidl::encoding::DynamicFlags::FLEXIBLE,
821        )
822    }
823
824    /// Sets a wake alarm with the provided parameters.
825    ///
826    /// The caller may request multiple alarms concurrently. Re-requesting
827    /// an alarm that has the same `alarm_id` as an already scheduled alarm
828    /// causes that scheduled alarm to be canceled before the same alarm
829    /// is scheduled again.
830    ///
831    /// ## Return value
832    ///
833    /// This method will return when the alarm is scheduled.
834    ///
835    /// ## Protocol Errors
836    ///
837    /// * [UNSPECIFIED] you are observing a new failure mode which has not
838    ///   been assigned an error code yet. Expect this failure mode to be
839    ///   assigned a more specific error code in future versions of this API.
840    ///   This is not a bug, but an indication that you may need to update the
841    ///   API version.
842    /// * [INTERNAL] is a bug: an internal fallible call (which is expected
843    ///   to be unlikely to fail) has failed somehow. Please report this for
844    ///   investigation.
845    /// * [INVALID_ARGS]: a parameter provided by the user is not valid, such
846    ///   as an empty `alarm_id`.
847    pub fn r#set(
848        &self,
849        mut notifier: fidl::endpoints::ClientEnd<NotifierMarker>,
850        mut deadline: fidl::BootInstant,
851        mut mode: SetMode,
852        mut alarm_id: &str,
853        ___deadline: zx::MonotonicInstant,
854    ) -> Result<WakeAlarmsSetResult, fidl::Error> {
855        let _response = self.client.send_query::<
856            SetArgs,
857            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, WakeAlarmsError>,
858            WakeAlarmsMarker,
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                >, WakeAlarmsMarker>(
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}