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