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