fidl_fuchsia_net_power/
fidl_fuchsia_net_power.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_net_power__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct CreateWakeGroupRequest {
16    pub options: WakeGroupOptions,
17    pub request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CreateWakeGroupRequest {}
21
22#[derive(Debug, Default, PartialEq)]
23pub struct CreateWakeGroupResponse {
24    /// A token that can be used to identify this wake group when adding
25    /// networking resources (such as sockets) to the group.
26    ///
27    /// Always present.
28    pub token: Option<fidl_fuchsia_net_resources::WakeGroupToken>,
29    #[doc(hidden)]
30    pub __source_breaking: fidl::marker::SourceBreaking,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for CreateWakeGroupResponse {}
34
35#[derive(Debug, Default, PartialEq)]
36pub struct WakeGroupWaitForDataResponse {
37    /// The source of the wakeup.
38    ///
39    /// Always present.
40    pub source: Option<WakeSource>,
41    #[doc(hidden)]
42    pub __source_breaking: fidl::marker::SourceBreaking,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
46    for WakeGroupWaitForDataResponse
47{
48}
49
50#[derive(Debug)]
51pub enum WakeSource {
52    /// The caller is being notified of data to be processed.
53    Data(Empty),
54    /// The caller is being notified of a lease delegated from the
55    /// network driver.
56    ///
57    /// The caller should retain the lease until it is ready to allow
58    /// the system to suspend.
59    Lease(fidl::EventPair),
60    #[doc(hidden)]
61    __SourceBreaking { unknown_ordinal: u64 },
62}
63
64/// Pattern that matches an unknown `WakeSource` member.
65#[macro_export]
66macro_rules! WakeSourceUnknown {
67    () => {
68        _
69    };
70}
71
72// Custom PartialEq so that unknown variants are not equal to themselves.
73impl PartialEq for WakeSource {
74    fn eq(&self, other: &Self) -> bool {
75        match (self, other) {
76            (Self::Data(x), Self::Data(y)) => *x == *y,
77            (Self::Lease(x), Self::Lease(y)) => *x == *y,
78            _ => false,
79        }
80    }
81}
82
83impl WakeSource {
84    #[inline]
85    pub fn ordinal(&self) -> u64 {
86        match *self {
87            Self::Data(_) => 1,
88            Self::Lease(_) => 2,
89            Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
90        }
91    }
92
93    #[inline]
94    pub fn unknown_variant_for_testing() -> Self {
95        Self::__SourceBreaking { unknown_ordinal: 0 }
96    }
97
98    #[inline]
99    pub fn is_unknown(&self) -> bool {
100        match self {
101            Self::__SourceBreaking { .. } => true,
102            _ => false,
103        }
104    }
105}
106
107impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for WakeSource {}
108
109#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
110pub struct WakeGroupMarker;
111
112impl fidl::endpoints::ProtocolMarker for WakeGroupMarker {
113    type Proxy = WakeGroupProxy;
114    type RequestStream = WakeGroupRequestStream;
115    #[cfg(target_os = "fuchsia")]
116    type SynchronousProxy = WakeGroupSynchronousProxy;
117
118    const DEBUG_NAME: &'static str = "(anonymous) WakeGroup";
119}
120
121pub trait WakeGroupProxyInterface: Send + Sync {
122    type WaitForDataResponseFut: std::future::Future<Output = Result<WakeGroupWaitForDataResponse, fidl::Error>>
123        + Send;
124    fn r#wait_for_data(&self) -> Self::WaitForDataResponseFut;
125    type ArmResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
126    fn r#arm(&self) -> Self::ArmResponseFut;
127}
128#[derive(Debug)]
129#[cfg(target_os = "fuchsia")]
130pub struct WakeGroupSynchronousProxy {
131    client: fidl::client::sync::Client,
132}
133
134#[cfg(target_os = "fuchsia")]
135impl fidl::endpoints::SynchronousProxy for WakeGroupSynchronousProxy {
136    type Proxy = WakeGroupProxy;
137    type Protocol = WakeGroupMarker;
138
139    fn from_channel(inner: fidl::Channel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> fidl::Channel {
144        self.client.into_channel()
145    }
146
147    fn as_channel(&self) -> &fidl::Channel {
148        self.client.as_channel()
149    }
150}
151
152#[cfg(target_os = "fuchsia")]
153impl WakeGroupSynchronousProxy {
154    pub fn new(channel: fidl::Channel) -> Self {
155        let protocol_name = <WakeGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
157    }
158
159    pub fn into_channel(self) -> fidl::Channel {
160        self.client.into_channel()
161    }
162
163    /// Waits until an event arrives and returns it. It is safe for other
164    /// threads to make concurrent requests while waiting for an event.
165    pub fn wait_for_event(
166        &self,
167        deadline: zx::MonotonicInstant,
168    ) -> Result<WakeGroupEvent, fidl::Error> {
169        WakeGroupEvent::decode(self.client.wait_for_event(deadline)?)
170    }
171
172    /// Registers the client to be woken up (in the form of a response) when
173    /// there is incoming data available for any of the resources registered
174    /// with this wake group.
175    ///
176    /// Note that the client is required to "arm" this hanging get by calling
177    /// `Arm` in order to ensure a response. Once the `WaitForData` call has
178    /// returned, the next call to the method will hang until `Arm` has been
179    /// called again *and* new data has arrived. In other words, `Arm` re-arms
180    /// the hanging get and should be called when a response is required in
181    /// order to be woken up.
182    ///
183    /// If the caller is responsible for keeping the system awake while handling
184    /// the incoming data, the netstack will delegate (baton-pass) a lease to
185    /// the caller that it can retain until it is ready to allow the system to
186    /// suspend.
187    pub fn r#wait_for_data(
188        &self,
189        ___deadline: zx::MonotonicInstant,
190    ) -> Result<WakeGroupWaitForDataResponse, fidl::Error> {
191        let _response =
192            self.client.send_query::<fidl::encoding::EmptyPayload, WakeGroupWaitForDataResponse>(
193                (),
194                0x1b9ea0f8e92c2e79,
195                fidl::encoding::DynamicFlags::empty(),
196                ___deadline,
197            )?;
198        Ok(_response)
199    }
200
201    /// Notifies the netstack that the client has handled any previous
202    /// `WaitForData` response that has arrived on the channel, and expects to
203    /// be woken up again when data arrives, in the form of a response to the
204    /// pending `WaitForData` call.
205    ///
206    /// In other words, calling this method "re-arms" the hanging get.
207    ///
208    /// `Arm` must be called *after* a `WaitForData` hanging get has been
209    /// posted. Calling `Arm` when there is no hanging get is a no-op.
210    pub fn r#arm(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
211        let _response =
212            self.client.send_query::<fidl::encoding::EmptyPayload, WakeGroupArmResponse>(
213                (),
214                0x4339c3052501e712,
215                fidl::encoding::DynamicFlags::empty(),
216                ___deadline,
217            )?;
218        Ok(_response.armed)
219    }
220}
221
222#[cfg(target_os = "fuchsia")]
223impl From<WakeGroupSynchronousProxy> for zx::NullableHandle {
224    fn from(value: WakeGroupSynchronousProxy) -> Self {
225        value.into_channel().into()
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl From<fidl::Channel> for WakeGroupSynchronousProxy {
231    fn from(value: fidl::Channel) -> Self {
232        Self::new(value)
233    }
234}
235
236#[cfg(target_os = "fuchsia")]
237impl fidl::endpoints::FromClient for WakeGroupSynchronousProxy {
238    type Protocol = WakeGroupMarker;
239
240    fn from_client(value: fidl::endpoints::ClientEnd<WakeGroupMarker>) -> Self {
241        Self::new(value.into_channel())
242    }
243}
244
245#[derive(Debug, Clone)]
246pub struct WakeGroupProxy {
247    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
248}
249
250impl fidl::endpoints::Proxy for WakeGroupProxy {
251    type Protocol = WakeGroupMarker;
252
253    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
254        Self::new(inner)
255    }
256
257    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
258        self.client.into_channel().map_err(|client| Self { client })
259    }
260
261    fn as_channel(&self) -> &::fidl::AsyncChannel {
262        self.client.as_channel()
263    }
264}
265
266impl WakeGroupProxy {
267    /// Create a new Proxy for fuchsia.net.power/WakeGroup.
268    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
269        let protocol_name = <WakeGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
270        Self { client: fidl::client::Client::new(channel, protocol_name) }
271    }
272
273    /// Get a Stream of events from the remote end of the protocol.
274    ///
275    /// # Panics
276    ///
277    /// Panics if the event stream was already taken.
278    pub fn take_event_stream(&self) -> WakeGroupEventStream {
279        WakeGroupEventStream { event_receiver: self.client.take_event_receiver() }
280    }
281
282    /// Registers the client to be woken up (in the form of a response) when
283    /// there is incoming data available for any of the resources registered
284    /// with this wake group.
285    ///
286    /// Note that the client is required to "arm" this hanging get by calling
287    /// `Arm` in order to ensure a response. Once the `WaitForData` call has
288    /// returned, the next call to the method will hang until `Arm` has been
289    /// called again *and* new data has arrived. In other words, `Arm` re-arms
290    /// the hanging get and should be called when a response is required in
291    /// order to be woken up.
292    ///
293    /// If the caller is responsible for keeping the system awake while handling
294    /// the incoming data, the netstack will delegate (baton-pass) a lease to
295    /// the caller that it can retain until it is ready to allow the system to
296    /// suspend.
297    pub fn r#wait_for_data(
298        &self,
299    ) -> fidl::client::QueryResponseFut<
300        WakeGroupWaitForDataResponse,
301        fidl::encoding::DefaultFuchsiaResourceDialect,
302    > {
303        WakeGroupProxyInterface::r#wait_for_data(self)
304    }
305
306    /// Notifies the netstack that the client has handled any previous
307    /// `WaitForData` response that has arrived on the channel, and expects to
308    /// be woken up again when data arrives, in the form of a response to the
309    /// pending `WaitForData` call.
310    ///
311    /// In other words, calling this method "re-arms" the hanging get.
312    ///
313    /// `Arm` must be called *after* a `WaitForData` hanging get has been
314    /// posted. Calling `Arm` when there is no hanging get is a no-op.
315    pub fn r#arm(
316        &self,
317    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
318        WakeGroupProxyInterface::r#arm(self)
319    }
320}
321
322impl WakeGroupProxyInterface for WakeGroupProxy {
323    type WaitForDataResponseFut = fidl::client::QueryResponseFut<
324        WakeGroupWaitForDataResponse,
325        fidl::encoding::DefaultFuchsiaResourceDialect,
326    >;
327    fn r#wait_for_data(&self) -> Self::WaitForDataResponseFut {
328        fn _decode(
329            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
330        ) -> Result<WakeGroupWaitForDataResponse, fidl::Error> {
331            let _response = fidl::client::decode_transaction_body::<
332                WakeGroupWaitForDataResponse,
333                fidl::encoding::DefaultFuchsiaResourceDialect,
334                0x1b9ea0f8e92c2e79,
335            >(_buf?)?;
336            Ok(_response)
337        }
338        self.client
339            .send_query_and_decode::<fidl::encoding::EmptyPayload, WakeGroupWaitForDataResponse>(
340                (),
341                0x1b9ea0f8e92c2e79,
342                fidl::encoding::DynamicFlags::empty(),
343                _decode,
344            )
345    }
346
347    type ArmResponseFut =
348        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
349    fn r#arm(&self) -> Self::ArmResponseFut {
350        fn _decode(
351            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
352        ) -> Result<bool, fidl::Error> {
353            let _response = fidl::client::decode_transaction_body::<
354                WakeGroupArmResponse,
355                fidl::encoding::DefaultFuchsiaResourceDialect,
356                0x4339c3052501e712,
357            >(_buf?)?;
358            Ok(_response.armed)
359        }
360        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
361            (),
362            0x4339c3052501e712,
363            fidl::encoding::DynamicFlags::empty(),
364            _decode,
365        )
366    }
367}
368
369pub struct WakeGroupEventStream {
370    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
371}
372
373impl std::marker::Unpin for WakeGroupEventStream {}
374
375impl futures::stream::FusedStream for WakeGroupEventStream {
376    fn is_terminated(&self) -> bool {
377        self.event_receiver.is_terminated()
378    }
379}
380
381impl futures::Stream for WakeGroupEventStream {
382    type Item = Result<WakeGroupEvent, fidl::Error>;
383
384    fn poll_next(
385        mut self: std::pin::Pin<&mut Self>,
386        cx: &mut std::task::Context<'_>,
387    ) -> std::task::Poll<Option<Self::Item>> {
388        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
389            &mut self.event_receiver,
390            cx
391        )?) {
392            Some(buf) => std::task::Poll::Ready(Some(WakeGroupEvent::decode(buf))),
393            None => std::task::Poll::Ready(None),
394        }
395    }
396}
397
398#[derive(Debug)]
399pub enum WakeGroupEvent {}
400
401impl WakeGroupEvent {
402    /// Decodes a message buffer as a [`WakeGroupEvent`].
403    fn decode(
404        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
405    ) -> Result<WakeGroupEvent, fidl::Error> {
406        let (bytes, _handles) = buf.split_mut();
407        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
408        debug_assert_eq!(tx_header.tx_id, 0);
409        match tx_header.ordinal {
410            _ => Err(fidl::Error::UnknownOrdinal {
411                ordinal: tx_header.ordinal,
412                protocol_name: <WakeGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
413            }),
414        }
415    }
416}
417
418/// A Stream of incoming requests for fuchsia.net.power/WakeGroup.
419pub struct WakeGroupRequestStream {
420    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
421    is_terminated: bool,
422}
423
424impl std::marker::Unpin for WakeGroupRequestStream {}
425
426impl futures::stream::FusedStream for WakeGroupRequestStream {
427    fn is_terminated(&self) -> bool {
428        self.is_terminated
429    }
430}
431
432impl fidl::endpoints::RequestStream for WakeGroupRequestStream {
433    type Protocol = WakeGroupMarker;
434    type ControlHandle = WakeGroupControlHandle;
435
436    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
437        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
438    }
439
440    fn control_handle(&self) -> Self::ControlHandle {
441        WakeGroupControlHandle { inner: self.inner.clone() }
442    }
443
444    fn into_inner(
445        self,
446    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
447    {
448        (self.inner, self.is_terminated)
449    }
450
451    fn from_inner(
452        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
453        is_terminated: bool,
454    ) -> Self {
455        Self { inner, is_terminated }
456    }
457}
458
459impl futures::Stream for WakeGroupRequestStream {
460    type Item = Result<WakeGroupRequest, fidl::Error>;
461
462    fn poll_next(
463        mut self: std::pin::Pin<&mut Self>,
464        cx: &mut std::task::Context<'_>,
465    ) -> std::task::Poll<Option<Self::Item>> {
466        let this = &mut *self;
467        if this.inner.check_shutdown(cx) {
468            this.is_terminated = true;
469            return std::task::Poll::Ready(None);
470        }
471        if this.is_terminated {
472            panic!("polled WakeGroupRequestStream after completion");
473        }
474        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
475            |bytes, handles| {
476                match this.inner.channel().read_etc(cx, bytes, handles) {
477                    std::task::Poll::Ready(Ok(())) => {}
478                    std::task::Poll::Pending => return std::task::Poll::Pending,
479                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
480                        this.is_terminated = true;
481                        return std::task::Poll::Ready(None);
482                    }
483                    std::task::Poll::Ready(Err(e)) => {
484                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
485                            e.into(),
486                        ))));
487                    }
488                }
489
490                // A message has been received from the channel
491                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
492
493                std::task::Poll::Ready(Some(match header.ordinal {
494                    0x1b9ea0f8e92c2e79 => {
495                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
496                        let mut req = fidl::new_empty!(
497                            fidl::encoding::EmptyPayload,
498                            fidl::encoding::DefaultFuchsiaResourceDialect
499                        );
500                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
501                        let control_handle = WakeGroupControlHandle { inner: this.inner.clone() };
502                        Ok(WakeGroupRequest::WaitForData {
503                            responder: WakeGroupWaitForDataResponder {
504                                control_handle: std::mem::ManuallyDrop::new(control_handle),
505                                tx_id: header.tx_id,
506                            },
507                        })
508                    }
509                    0x4339c3052501e712 => {
510                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
511                        let mut req = fidl::new_empty!(
512                            fidl::encoding::EmptyPayload,
513                            fidl::encoding::DefaultFuchsiaResourceDialect
514                        );
515                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
516                        let control_handle = WakeGroupControlHandle { inner: this.inner.clone() };
517                        Ok(WakeGroupRequest::Arm {
518                            responder: WakeGroupArmResponder {
519                                control_handle: std::mem::ManuallyDrop::new(control_handle),
520                                tx_id: header.tx_id,
521                            },
522                        })
523                    }
524                    _ => Err(fidl::Error::UnknownOrdinal {
525                        ordinal: header.ordinal,
526                        protocol_name:
527                            <WakeGroupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
528                    }),
529                }))
530            },
531        )
532    }
533}
534
535/// A group of networking resources, such as sockets, for which the client
536/// wishes to receive a notification when data is available.
537///
538/// This may be useful to, for example, allow a client to suspend execution
539/// until it is notified that some data is available to be processed.
540///
541/// Each connection to this protocol represents a distinct wake group. Closing
542/// the connection to the protocol results in removal of the wake group.
543#[derive(Debug)]
544pub enum WakeGroupRequest {
545    /// Registers the client to be woken up (in the form of a response) when
546    /// there is incoming data available for any of the resources registered
547    /// with this wake group.
548    ///
549    /// Note that the client is required to "arm" this hanging get by calling
550    /// `Arm` in order to ensure a response. Once the `WaitForData` call has
551    /// returned, the next call to the method will hang until `Arm` has been
552    /// called again *and* new data has arrived. In other words, `Arm` re-arms
553    /// the hanging get and should be called when a response is required in
554    /// order to be woken up.
555    ///
556    /// If the caller is responsible for keeping the system awake while handling
557    /// the incoming data, the netstack will delegate (baton-pass) a lease to
558    /// the caller that it can retain until it is ready to allow the system to
559    /// suspend.
560    WaitForData { responder: WakeGroupWaitForDataResponder },
561    /// Notifies the netstack that the client has handled any previous
562    /// `WaitForData` response that has arrived on the channel, and expects to
563    /// be woken up again when data arrives, in the form of a response to the
564    /// pending `WaitForData` call.
565    ///
566    /// In other words, calling this method "re-arms" the hanging get.
567    ///
568    /// `Arm` must be called *after* a `WaitForData` hanging get has been
569    /// posted. Calling `Arm` when there is no hanging get is a no-op.
570    Arm { responder: WakeGroupArmResponder },
571}
572
573impl WakeGroupRequest {
574    #[allow(irrefutable_let_patterns)]
575    pub fn into_wait_for_data(self) -> Option<(WakeGroupWaitForDataResponder)> {
576        if let WakeGroupRequest::WaitForData { responder } = self {
577            Some((responder))
578        } else {
579            None
580        }
581    }
582
583    #[allow(irrefutable_let_patterns)]
584    pub fn into_arm(self) -> Option<(WakeGroupArmResponder)> {
585        if let WakeGroupRequest::Arm { responder } = self { Some((responder)) } else { None }
586    }
587
588    /// Name of the method defined in FIDL
589    pub fn method_name(&self) -> &'static str {
590        match *self {
591            WakeGroupRequest::WaitForData { .. } => "wait_for_data",
592            WakeGroupRequest::Arm { .. } => "arm",
593        }
594    }
595}
596
597#[derive(Debug, Clone)]
598pub struct WakeGroupControlHandle {
599    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
600}
601
602impl fidl::endpoints::ControlHandle for WakeGroupControlHandle {
603    fn shutdown(&self) {
604        self.inner.shutdown()
605    }
606
607    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
608        self.inner.shutdown_with_epitaph(status)
609    }
610
611    fn is_closed(&self) -> bool {
612        self.inner.channel().is_closed()
613    }
614    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
615        self.inner.channel().on_closed()
616    }
617
618    #[cfg(target_os = "fuchsia")]
619    fn signal_peer(
620        &self,
621        clear_mask: zx::Signals,
622        set_mask: zx::Signals,
623    ) -> Result<(), zx_status::Status> {
624        use fidl::Peered;
625        self.inner.channel().signal_peer(clear_mask, set_mask)
626    }
627}
628
629impl WakeGroupControlHandle {}
630
631#[must_use = "FIDL methods require a response to be sent"]
632#[derive(Debug)]
633pub struct WakeGroupWaitForDataResponder {
634    control_handle: std::mem::ManuallyDrop<WakeGroupControlHandle>,
635    tx_id: u32,
636}
637
638/// Set the the channel to be shutdown (see [`WakeGroupControlHandle::shutdown`])
639/// if the responder is dropped without sending a response, so that the client
640/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
641impl std::ops::Drop for WakeGroupWaitForDataResponder {
642    fn drop(&mut self) {
643        self.control_handle.shutdown();
644        // Safety: drops once, never accessed again
645        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
646    }
647}
648
649impl fidl::endpoints::Responder for WakeGroupWaitForDataResponder {
650    type ControlHandle = WakeGroupControlHandle;
651
652    fn control_handle(&self) -> &WakeGroupControlHandle {
653        &self.control_handle
654    }
655
656    fn drop_without_shutdown(mut self) {
657        // Safety: drops once, never accessed again due to mem::forget
658        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
659        // Prevent Drop from running (which would shut down the channel)
660        std::mem::forget(self);
661    }
662}
663
664impl WakeGroupWaitForDataResponder {
665    /// Sends a response to the FIDL transaction.
666    ///
667    /// Sets the channel to shutdown if an error occurs.
668    pub fn send(self, mut payload: WakeGroupWaitForDataResponse) -> Result<(), fidl::Error> {
669        let _result = self.send_raw(payload);
670        if _result.is_err() {
671            self.control_handle.shutdown();
672        }
673        self.drop_without_shutdown();
674        _result
675    }
676
677    /// Similar to "send" but does not shutdown the channel if an error occurs.
678    pub fn send_no_shutdown_on_err(
679        self,
680        mut payload: WakeGroupWaitForDataResponse,
681    ) -> Result<(), fidl::Error> {
682        let _result = self.send_raw(payload);
683        self.drop_without_shutdown();
684        _result
685    }
686
687    fn send_raw(&self, mut payload: WakeGroupWaitForDataResponse) -> Result<(), fidl::Error> {
688        self.control_handle.inner.send::<WakeGroupWaitForDataResponse>(
689            &mut payload,
690            self.tx_id,
691            0x1b9ea0f8e92c2e79,
692            fidl::encoding::DynamicFlags::empty(),
693        )
694    }
695}
696
697#[must_use = "FIDL methods require a response to be sent"]
698#[derive(Debug)]
699pub struct WakeGroupArmResponder {
700    control_handle: std::mem::ManuallyDrop<WakeGroupControlHandle>,
701    tx_id: u32,
702}
703
704/// Set the the channel to be shutdown (see [`WakeGroupControlHandle::shutdown`])
705/// if the responder is dropped without sending a response, so that the client
706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
707impl std::ops::Drop for WakeGroupArmResponder {
708    fn drop(&mut self) {
709        self.control_handle.shutdown();
710        // Safety: drops once, never accessed again
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712    }
713}
714
715impl fidl::endpoints::Responder for WakeGroupArmResponder {
716    type ControlHandle = WakeGroupControlHandle;
717
718    fn control_handle(&self) -> &WakeGroupControlHandle {
719        &self.control_handle
720    }
721
722    fn drop_without_shutdown(mut self) {
723        // Safety: drops once, never accessed again due to mem::forget
724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
725        // Prevent Drop from running (which would shut down the channel)
726        std::mem::forget(self);
727    }
728}
729
730impl WakeGroupArmResponder {
731    /// Sends a response to the FIDL transaction.
732    ///
733    /// Sets the channel to shutdown if an error occurs.
734    pub fn send(self, mut armed: bool) -> Result<(), fidl::Error> {
735        let _result = self.send_raw(armed);
736        if _result.is_err() {
737            self.control_handle.shutdown();
738        }
739        self.drop_without_shutdown();
740        _result
741    }
742
743    /// Similar to "send" but does not shutdown the channel if an error occurs.
744    pub fn send_no_shutdown_on_err(self, mut armed: bool) -> Result<(), fidl::Error> {
745        let _result = self.send_raw(armed);
746        self.drop_without_shutdown();
747        _result
748    }
749
750    fn send_raw(&self, mut armed: bool) -> Result<(), fidl::Error> {
751        self.control_handle.inner.send::<WakeGroupArmResponse>(
752            (armed,),
753            self.tx_id,
754            0x4339c3052501e712,
755            fidl::encoding::DynamicFlags::empty(),
756        )
757    }
758}
759
760#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
761pub struct WakeGroupProviderMarker;
762
763impl fidl::endpoints::ProtocolMarker for WakeGroupProviderMarker {
764    type Proxy = WakeGroupProviderProxy;
765    type RequestStream = WakeGroupProviderRequestStream;
766    #[cfg(target_os = "fuchsia")]
767    type SynchronousProxy = WakeGroupProviderSynchronousProxy;
768
769    const DEBUG_NAME: &'static str = "fuchsia.net.power.WakeGroupProvider";
770}
771impl fidl::endpoints::DiscoverableProtocolMarker for WakeGroupProviderMarker {}
772
773pub trait WakeGroupProviderProxyInterface: Send + Sync {
774    type CreateWakeGroupResponseFut: std::future::Future<Output = Result<CreateWakeGroupResponse, fidl::Error>>
775        + Send;
776    fn r#create_wake_group(
777        &self,
778        options: &WakeGroupOptions,
779        request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
780    ) -> Self::CreateWakeGroupResponseFut;
781}
782#[derive(Debug)]
783#[cfg(target_os = "fuchsia")]
784pub struct WakeGroupProviderSynchronousProxy {
785    client: fidl::client::sync::Client,
786}
787
788#[cfg(target_os = "fuchsia")]
789impl fidl::endpoints::SynchronousProxy for WakeGroupProviderSynchronousProxy {
790    type Proxy = WakeGroupProviderProxy;
791    type Protocol = WakeGroupProviderMarker;
792
793    fn from_channel(inner: fidl::Channel) -> Self {
794        Self::new(inner)
795    }
796
797    fn into_channel(self) -> fidl::Channel {
798        self.client.into_channel()
799    }
800
801    fn as_channel(&self) -> &fidl::Channel {
802        self.client.as_channel()
803    }
804}
805
806#[cfg(target_os = "fuchsia")]
807impl WakeGroupProviderSynchronousProxy {
808    pub fn new(channel: fidl::Channel) -> Self {
809        let protocol_name =
810            <WakeGroupProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
811        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
812    }
813
814    pub fn into_channel(self) -> fidl::Channel {
815        self.client.into_channel()
816    }
817
818    /// Waits until an event arrives and returns it. It is safe for other
819    /// threads to make concurrent requests while waiting for an event.
820    pub fn wait_for_event(
821        &self,
822        deadline: zx::MonotonicInstant,
823    ) -> Result<WakeGroupProviderEvent, fidl::Error> {
824        WakeGroupProviderEvent::decode(self.client.wait_for_event(deadline)?)
825    }
826
827    /// Creates a new wake group with the provided options.
828    pub fn r#create_wake_group(
829        &self,
830        mut options: &WakeGroupOptions,
831        mut request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
832        ___deadline: zx::MonotonicInstant,
833    ) -> Result<CreateWakeGroupResponse, fidl::Error> {
834        let _response = self.client.send_query::<CreateWakeGroupRequest, CreateWakeGroupResponse>(
835            (options, request),
836            0x3c6a15f6c6b1447f,
837            fidl::encoding::DynamicFlags::empty(),
838            ___deadline,
839        )?;
840        Ok(_response)
841    }
842}
843
844#[cfg(target_os = "fuchsia")]
845impl From<WakeGroupProviderSynchronousProxy> for zx::NullableHandle {
846    fn from(value: WakeGroupProviderSynchronousProxy) -> Self {
847        value.into_channel().into()
848    }
849}
850
851#[cfg(target_os = "fuchsia")]
852impl From<fidl::Channel> for WakeGroupProviderSynchronousProxy {
853    fn from(value: fidl::Channel) -> Self {
854        Self::new(value)
855    }
856}
857
858#[cfg(target_os = "fuchsia")]
859impl fidl::endpoints::FromClient for WakeGroupProviderSynchronousProxy {
860    type Protocol = WakeGroupProviderMarker;
861
862    fn from_client(value: fidl::endpoints::ClientEnd<WakeGroupProviderMarker>) -> Self {
863        Self::new(value.into_channel())
864    }
865}
866
867#[derive(Debug, Clone)]
868pub struct WakeGroupProviderProxy {
869    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
870}
871
872impl fidl::endpoints::Proxy for WakeGroupProviderProxy {
873    type Protocol = WakeGroupProviderMarker;
874
875    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
876        Self::new(inner)
877    }
878
879    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
880        self.client.into_channel().map_err(|client| Self { client })
881    }
882
883    fn as_channel(&self) -> &::fidl::AsyncChannel {
884        self.client.as_channel()
885    }
886}
887
888impl WakeGroupProviderProxy {
889    /// Create a new Proxy for fuchsia.net.power/WakeGroupProvider.
890    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
891        let protocol_name =
892            <WakeGroupProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
893        Self { client: fidl::client::Client::new(channel, protocol_name) }
894    }
895
896    /// Get a Stream of events from the remote end of the protocol.
897    ///
898    /// # Panics
899    ///
900    /// Panics if the event stream was already taken.
901    pub fn take_event_stream(&self) -> WakeGroupProviderEventStream {
902        WakeGroupProviderEventStream { event_receiver: self.client.take_event_receiver() }
903    }
904
905    /// Creates a new wake group with the provided options.
906    pub fn r#create_wake_group(
907        &self,
908        mut options: &WakeGroupOptions,
909        mut request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
910    ) -> fidl::client::QueryResponseFut<
911        CreateWakeGroupResponse,
912        fidl::encoding::DefaultFuchsiaResourceDialect,
913    > {
914        WakeGroupProviderProxyInterface::r#create_wake_group(self, options, request)
915    }
916}
917
918impl WakeGroupProviderProxyInterface for WakeGroupProviderProxy {
919    type CreateWakeGroupResponseFut = fidl::client::QueryResponseFut<
920        CreateWakeGroupResponse,
921        fidl::encoding::DefaultFuchsiaResourceDialect,
922    >;
923    fn r#create_wake_group(
924        &self,
925        mut options: &WakeGroupOptions,
926        mut request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
927    ) -> Self::CreateWakeGroupResponseFut {
928        fn _decode(
929            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
930        ) -> Result<CreateWakeGroupResponse, fidl::Error> {
931            let _response = fidl::client::decode_transaction_body::<
932                CreateWakeGroupResponse,
933                fidl::encoding::DefaultFuchsiaResourceDialect,
934                0x3c6a15f6c6b1447f,
935            >(_buf?)?;
936            Ok(_response)
937        }
938        self.client.send_query_and_decode::<CreateWakeGroupRequest, CreateWakeGroupResponse>(
939            (options, request),
940            0x3c6a15f6c6b1447f,
941            fidl::encoding::DynamicFlags::empty(),
942            _decode,
943        )
944    }
945}
946
947pub struct WakeGroupProviderEventStream {
948    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
949}
950
951impl std::marker::Unpin for WakeGroupProviderEventStream {}
952
953impl futures::stream::FusedStream for WakeGroupProviderEventStream {
954    fn is_terminated(&self) -> bool {
955        self.event_receiver.is_terminated()
956    }
957}
958
959impl futures::Stream for WakeGroupProviderEventStream {
960    type Item = Result<WakeGroupProviderEvent, fidl::Error>;
961
962    fn poll_next(
963        mut self: std::pin::Pin<&mut Self>,
964        cx: &mut std::task::Context<'_>,
965    ) -> std::task::Poll<Option<Self::Item>> {
966        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
967            &mut self.event_receiver,
968            cx
969        )?) {
970            Some(buf) => std::task::Poll::Ready(Some(WakeGroupProviderEvent::decode(buf))),
971            None => std::task::Poll::Ready(None),
972        }
973    }
974}
975
976#[derive(Debug)]
977pub enum WakeGroupProviderEvent {}
978
979impl WakeGroupProviderEvent {
980    /// Decodes a message buffer as a [`WakeGroupProviderEvent`].
981    fn decode(
982        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
983    ) -> Result<WakeGroupProviderEvent, fidl::Error> {
984        let (bytes, _handles) = buf.split_mut();
985        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
986        debug_assert_eq!(tx_header.tx_id, 0);
987        match tx_header.ordinal {
988            _ => Err(fidl::Error::UnknownOrdinal {
989                ordinal: tx_header.ordinal,
990                protocol_name:
991                    <WakeGroupProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
992            }),
993        }
994    }
995}
996
997/// A Stream of incoming requests for fuchsia.net.power/WakeGroupProvider.
998pub struct WakeGroupProviderRequestStream {
999    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1000    is_terminated: bool,
1001}
1002
1003impl std::marker::Unpin for WakeGroupProviderRequestStream {}
1004
1005impl futures::stream::FusedStream for WakeGroupProviderRequestStream {
1006    fn is_terminated(&self) -> bool {
1007        self.is_terminated
1008    }
1009}
1010
1011impl fidl::endpoints::RequestStream for WakeGroupProviderRequestStream {
1012    type Protocol = WakeGroupProviderMarker;
1013    type ControlHandle = WakeGroupProviderControlHandle;
1014
1015    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1016        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1017    }
1018
1019    fn control_handle(&self) -> Self::ControlHandle {
1020        WakeGroupProviderControlHandle { inner: self.inner.clone() }
1021    }
1022
1023    fn into_inner(
1024        self,
1025    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1026    {
1027        (self.inner, self.is_terminated)
1028    }
1029
1030    fn from_inner(
1031        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1032        is_terminated: bool,
1033    ) -> Self {
1034        Self { inner, is_terminated }
1035    }
1036}
1037
1038impl futures::Stream for WakeGroupProviderRequestStream {
1039    type Item = Result<WakeGroupProviderRequest, fidl::Error>;
1040
1041    fn poll_next(
1042        mut self: std::pin::Pin<&mut Self>,
1043        cx: &mut std::task::Context<'_>,
1044    ) -> std::task::Poll<Option<Self::Item>> {
1045        let this = &mut *self;
1046        if this.inner.check_shutdown(cx) {
1047            this.is_terminated = true;
1048            return std::task::Poll::Ready(None);
1049        }
1050        if this.is_terminated {
1051            panic!("polled WakeGroupProviderRequestStream after completion");
1052        }
1053        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1054            |bytes, handles| {
1055                match this.inner.channel().read_etc(cx, bytes, handles) {
1056                    std::task::Poll::Ready(Ok(())) => {}
1057                    std::task::Poll::Pending => return std::task::Poll::Pending,
1058                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1059                        this.is_terminated = true;
1060                        return std::task::Poll::Ready(None);
1061                    }
1062                    std::task::Poll::Ready(Err(e)) => {
1063                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1064                            e.into(),
1065                        ))));
1066                    }
1067                }
1068
1069                // A message has been received from the channel
1070                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1071
1072                std::task::Poll::Ready(Some(match header.ordinal {
1073                    0x3c6a15f6c6b1447f => {
1074                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1075                        let mut req = fidl::new_empty!(
1076                            CreateWakeGroupRequest,
1077                            fidl::encoding::DefaultFuchsiaResourceDialect
1078                        );
1079                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CreateWakeGroupRequest>(&header, _body_bytes, handles, &mut req)?;
1080                        let control_handle =
1081                            WakeGroupProviderControlHandle { inner: this.inner.clone() };
1082                        Ok(WakeGroupProviderRequest::CreateWakeGroup {
1083                            options: req.options,
1084                            request: req.request,
1085
1086                            responder: WakeGroupProviderCreateWakeGroupResponder {
1087                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1088                                tx_id: header.tx_id,
1089                            },
1090                        })
1091                    }
1092                    _ => Err(fidl::Error::UnknownOrdinal {
1093                        ordinal: header.ordinal,
1094                        protocol_name:
1095                            <WakeGroupProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1096                    }),
1097                }))
1098            },
1099        )
1100    }
1101}
1102
1103/// A provider of `WakeGroup`s.
1104#[derive(Debug)]
1105pub enum WakeGroupProviderRequest {
1106    /// Creates a new wake group with the provided options.
1107    CreateWakeGroup {
1108        options: WakeGroupOptions,
1109        request: fidl::endpoints::ServerEnd<WakeGroupMarker>,
1110        responder: WakeGroupProviderCreateWakeGroupResponder,
1111    },
1112}
1113
1114impl WakeGroupProviderRequest {
1115    #[allow(irrefutable_let_patterns)]
1116    pub fn into_create_wake_group(
1117        self,
1118    ) -> Option<(
1119        WakeGroupOptions,
1120        fidl::endpoints::ServerEnd<WakeGroupMarker>,
1121        WakeGroupProviderCreateWakeGroupResponder,
1122    )> {
1123        if let WakeGroupProviderRequest::CreateWakeGroup { options, request, responder } = self {
1124            Some((options, request, responder))
1125        } else {
1126            None
1127        }
1128    }
1129
1130    /// Name of the method defined in FIDL
1131    pub fn method_name(&self) -> &'static str {
1132        match *self {
1133            WakeGroupProviderRequest::CreateWakeGroup { .. } => "create_wake_group",
1134        }
1135    }
1136}
1137
1138#[derive(Debug, Clone)]
1139pub struct WakeGroupProviderControlHandle {
1140    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1141}
1142
1143impl fidl::endpoints::ControlHandle for WakeGroupProviderControlHandle {
1144    fn shutdown(&self) {
1145        self.inner.shutdown()
1146    }
1147
1148    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1149        self.inner.shutdown_with_epitaph(status)
1150    }
1151
1152    fn is_closed(&self) -> bool {
1153        self.inner.channel().is_closed()
1154    }
1155    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1156        self.inner.channel().on_closed()
1157    }
1158
1159    #[cfg(target_os = "fuchsia")]
1160    fn signal_peer(
1161        &self,
1162        clear_mask: zx::Signals,
1163        set_mask: zx::Signals,
1164    ) -> Result<(), zx_status::Status> {
1165        use fidl::Peered;
1166        self.inner.channel().signal_peer(clear_mask, set_mask)
1167    }
1168}
1169
1170impl WakeGroupProviderControlHandle {}
1171
1172#[must_use = "FIDL methods require a response to be sent"]
1173#[derive(Debug)]
1174pub struct WakeGroupProviderCreateWakeGroupResponder {
1175    control_handle: std::mem::ManuallyDrop<WakeGroupProviderControlHandle>,
1176    tx_id: u32,
1177}
1178
1179/// Set the the channel to be shutdown (see [`WakeGroupProviderControlHandle::shutdown`])
1180/// if the responder is dropped without sending a response, so that the client
1181/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1182impl std::ops::Drop for WakeGroupProviderCreateWakeGroupResponder {
1183    fn drop(&mut self) {
1184        self.control_handle.shutdown();
1185        // Safety: drops once, never accessed again
1186        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1187    }
1188}
1189
1190impl fidl::endpoints::Responder for WakeGroupProviderCreateWakeGroupResponder {
1191    type ControlHandle = WakeGroupProviderControlHandle;
1192
1193    fn control_handle(&self) -> &WakeGroupProviderControlHandle {
1194        &self.control_handle
1195    }
1196
1197    fn drop_without_shutdown(mut self) {
1198        // Safety: drops once, never accessed again due to mem::forget
1199        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1200        // Prevent Drop from running (which would shut down the channel)
1201        std::mem::forget(self);
1202    }
1203}
1204
1205impl WakeGroupProviderCreateWakeGroupResponder {
1206    /// Sends a response to the FIDL transaction.
1207    ///
1208    /// Sets the channel to shutdown if an error occurs.
1209    pub fn send(self, mut payload: CreateWakeGroupResponse) -> Result<(), fidl::Error> {
1210        let _result = self.send_raw(payload);
1211        if _result.is_err() {
1212            self.control_handle.shutdown();
1213        }
1214        self.drop_without_shutdown();
1215        _result
1216    }
1217
1218    /// Similar to "send" but does not shutdown the channel if an error occurs.
1219    pub fn send_no_shutdown_on_err(
1220        self,
1221        mut payload: CreateWakeGroupResponse,
1222    ) -> Result<(), fidl::Error> {
1223        let _result = self.send_raw(payload);
1224        self.drop_without_shutdown();
1225        _result
1226    }
1227
1228    fn send_raw(&self, mut payload: CreateWakeGroupResponse) -> Result<(), fidl::Error> {
1229        self.control_handle.inner.send::<CreateWakeGroupResponse>(
1230            &mut payload,
1231            self.tx_id,
1232            0x3c6a15f6c6b1447f,
1233            fidl::encoding::DynamicFlags::empty(),
1234        )
1235    }
1236}
1237
1238mod internal {
1239    use super::*;
1240
1241    impl fidl::encoding::ResourceTypeMarker for CreateWakeGroupRequest {
1242        type Borrowed<'a> = &'a mut Self;
1243        fn take_or_borrow<'a>(
1244            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1245        ) -> Self::Borrowed<'a> {
1246            value
1247        }
1248    }
1249
1250    unsafe impl fidl::encoding::TypeMarker for CreateWakeGroupRequest {
1251        type Owned = Self;
1252
1253        #[inline(always)]
1254        fn inline_align(_context: fidl::encoding::Context) -> usize {
1255            8
1256        }
1257
1258        #[inline(always)]
1259        fn inline_size(_context: fidl::encoding::Context) -> usize {
1260            24
1261        }
1262    }
1263
1264    unsafe impl
1265        fidl::encoding::Encode<
1266            CreateWakeGroupRequest,
1267            fidl::encoding::DefaultFuchsiaResourceDialect,
1268        > for &mut CreateWakeGroupRequest
1269    {
1270        #[inline]
1271        unsafe fn encode(
1272            self,
1273            encoder: &mut fidl::encoding::Encoder<
1274                '_,
1275                fidl::encoding::DefaultFuchsiaResourceDialect,
1276            >,
1277            offset: usize,
1278            _depth: fidl::encoding::Depth,
1279        ) -> fidl::Result<()> {
1280            encoder.debug_check_bounds::<CreateWakeGroupRequest>(offset);
1281            // Delegate to tuple encoding.
1282            fidl::encoding::Encode::<CreateWakeGroupRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1283                (
1284                    <WakeGroupOptions as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
1285                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WakeGroupMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.request),
1286                ),
1287                encoder, offset, _depth
1288            )
1289        }
1290    }
1291    unsafe impl<
1292        T0: fidl::encoding::Encode<WakeGroupOptions, fidl::encoding::DefaultFuchsiaResourceDialect>,
1293        T1: fidl::encoding::Encode<
1294                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WakeGroupMarker>>,
1295                fidl::encoding::DefaultFuchsiaResourceDialect,
1296            >,
1297    >
1298        fidl::encoding::Encode<
1299            CreateWakeGroupRequest,
1300            fidl::encoding::DefaultFuchsiaResourceDialect,
1301        > for (T0, T1)
1302    {
1303        #[inline]
1304        unsafe fn encode(
1305            self,
1306            encoder: &mut fidl::encoding::Encoder<
1307                '_,
1308                fidl::encoding::DefaultFuchsiaResourceDialect,
1309            >,
1310            offset: usize,
1311            depth: fidl::encoding::Depth,
1312        ) -> fidl::Result<()> {
1313            encoder.debug_check_bounds::<CreateWakeGroupRequest>(offset);
1314            // Zero out padding regions. There's no need to apply masks
1315            // because the unmasked parts will be overwritten by fields.
1316            unsafe {
1317                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1318                (ptr as *mut u64).write_unaligned(0);
1319            }
1320            // Write the fields.
1321            self.0.encode(encoder, offset + 0, depth)?;
1322            self.1.encode(encoder, offset + 16, depth)?;
1323            Ok(())
1324        }
1325    }
1326
1327    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1328        for CreateWakeGroupRequest
1329    {
1330        #[inline(always)]
1331        fn new_empty() -> Self {
1332            Self {
1333                options: fidl::new_empty!(
1334                    WakeGroupOptions,
1335                    fidl::encoding::DefaultFuchsiaResourceDialect
1336                ),
1337                request: fidl::new_empty!(
1338                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WakeGroupMarker>>,
1339                    fidl::encoding::DefaultFuchsiaResourceDialect
1340                ),
1341            }
1342        }
1343
1344        #[inline]
1345        unsafe fn decode(
1346            &mut self,
1347            decoder: &mut fidl::encoding::Decoder<
1348                '_,
1349                fidl::encoding::DefaultFuchsiaResourceDialect,
1350            >,
1351            offset: usize,
1352            _depth: fidl::encoding::Depth,
1353        ) -> fidl::Result<()> {
1354            decoder.debug_check_bounds::<Self>(offset);
1355            // Verify that padding bytes are zero.
1356            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1357            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1358            let mask = 0xffffffff00000000u64;
1359            let maskedval = padval & mask;
1360            if maskedval != 0 {
1361                return Err(fidl::Error::NonZeroPadding {
1362                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1363                });
1364            }
1365            fidl::decode!(
1366                WakeGroupOptions,
1367                fidl::encoding::DefaultFuchsiaResourceDialect,
1368                &mut self.options,
1369                decoder,
1370                offset + 0,
1371                _depth
1372            )?;
1373            fidl::decode!(
1374                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<WakeGroupMarker>>,
1375                fidl::encoding::DefaultFuchsiaResourceDialect,
1376                &mut self.request,
1377                decoder,
1378                offset + 16,
1379                _depth
1380            )?;
1381            Ok(())
1382        }
1383    }
1384
1385    impl CreateWakeGroupResponse {
1386        #[inline(always)]
1387        fn max_ordinal_present(&self) -> u64 {
1388            if let Some(_) = self.token {
1389                return 1;
1390            }
1391            0
1392        }
1393    }
1394
1395    impl fidl::encoding::ResourceTypeMarker for CreateWakeGroupResponse {
1396        type Borrowed<'a> = &'a mut Self;
1397        fn take_or_borrow<'a>(
1398            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1399        ) -> Self::Borrowed<'a> {
1400            value
1401        }
1402    }
1403
1404    unsafe impl fidl::encoding::TypeMarker for CreateWakeGroupResponse {
1405        type Owned = Self;
1406
1407        #[inline(always)]
1408        fn inline_align(_context: fidl::encoding::Context) -> usize {
1409            8
1410        }
1411
1412        #[inline(always)]
1413        fn inline_size(_context: fidl::encoding::Context) -> usize {
1414            16
1415        }
1416    }
1417
1418    unsafe impl
1419        fidl::encoding::Encode<
1420            CreateWakeGroupResponse,
1421            fidl::encoding::DefaultFuchsiaResourceDialect,
1422        > for &mut CreateWakeGroupResponse
1423    {
1424        unsafe fn encode(
1425            self,
1426            encoder: &mut fidl::encoding::Encoder<
1427                '_,
1428                fidl::encoding::DefaultFuchsiaResourceDialect,
1429            >,
1430            offset: usize,
1431            mut depth: fidl::encoding::Depth,
1432        ) -> fidl::Result<()> {
1433            encoder.debug_check_bounds::<CreateWakeGroupResponse>(offset);
1434            // Vector header
1435            let max_ordinal: u64 = self.max_ordinal_present();
1436            encoder.write_num(max_ordinal, offset);
1437            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1438            // Calling encoder.out_of_line_offset(0) is not allowed.
1439            if max_ordinal == 0 {
1440                return Ok(());
1441            }
1442            depth.increment()?;
1443            let envelope_size = 8;
1444            let bytes_len = max_ordinal as usize * envelope_size;
1445            #[allow(unused_variables)]
1446            let offset = encoder.out_of_line_offset(bytes_len);
1447            let mut _prev_end_offset: usize = 0;
1448            if 1 > max_ordinal {
1449                return Ok(());
1450            }
1451
1452            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1453            // are envelope_size bytes.
1454            let cur_offset: usize = (1 - 1) * envelope_size;
1455
1456            // Zero reserved fields.
1457            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1458
1459            // Safety:
1460            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1461            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1462            //   envelope_size bytes, there is always sufficient room.
1463            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_net_resources::WakeGroupToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
1464            self.token.as_mut().map(<fidl_fuchsia_net_resources::WakeGroupToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1465            encoder, offset + cur_offset, depth
1466        )?;
1467
1468            _prev_end_offset = cur_offset + envelope_size;
1469
1470            Ok(())
1471        }
1472    }
1473
1474    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1475        for CreateWakeGroupResponse
1476    {
1477        #[inline(always)]
1478        fn new_empty() -> Self {
1479            Self::default()
1480        }
1481
1482        unsafe fn decode(
1483            &mut self,
1484            decoder: &mut fidl::encoding::Decoder<
1485                '_,
1486                fidl::encoding::DefaultFuchsiaResourceDialect,
1487            >,
1488            offset: usize,
1489            mut depth: fidl::encoding::Depth,
1490        ) -> fidl::Result<()> {
1491            decoder.debug_check_bounds::<Self>(offset);
1492            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1493                None => return Err(fidl::Error::NotNullable),
1494                Some(len) => len,
1495            };
1496            // Calling decoder.out_of_line_offset(0) is not allowed.
1497            if len == 0 {
1498                return Ok(());
1499            };
1500            depth.increment()?;
1501            let envelope_size = 8;
1502            let bytes_len = len * envelope_size;
1503            let offset = decoder.out_of_line_offset(bytes_len)?;
1504            // Decode the envelope for each type.
1505            let mut _next_ordinal_to_read = 0;
1506            let mut next_offset = offset;
1507            let end_offset = offset + bytes_len;
1508            _next_ordinal_to_read += 1;
1509            if next_offset >= end_offset {
1510                return Ok(());
1511            }
1512
1513            // Decode unknown envelopes for gaps in ordinals.
1514            while _next_ordinal_to_read < 1 {
1515                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1516                _next_ordinal_to_read += 1;
1517                next_offset += envelope_size;
1518            }
1519
1520            let next_out_of_line = decoder.next_out_of_line();
1521            let handles_before = decoder.remaining_handles();
1522            if let Some((inlined, num_bytes, num_handles)) =
1523                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1524            {
1525                let member_inline_size = <fidl_fuchsia_net_resources::WakeGroupToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1526                if inlined != (member_inline_size <= 4) {
1527                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1528                }
1529                let inner_offset;
1530                let mut inner_depth = depth.clone();
1531                if inlined {
1532                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1533                    inner_offset = next_offset;
1534                } else {
1535                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1536                    inner_depth.increment()?;
1537                }
1538                let val_ref = self.token.get_or_insert_with(|| {
1539                    fidl::new_empty!(
1540                        fidl_fuchsia_net_resources::WakeGroupToken,
1541                        fidl::encoding::DefaultFuchsiaResourceDialect
1542                    )
1543                });
1544                fidl::decode!(
1545                    fidl_fuchsia_net_resources::WakeGroupToken,
1546                    fidl::encoding::DefaultFuchsiaResourceDialect,
1547                    val_ref,
1548                    decoder,
1549                    inner_offset,
1550                    inner_depth
1551                )?;
1552                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1553                {
1554                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1555                }
1556                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1557                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1558                }
1559            }
1560
1561            next_offset += envelope_size;
1562
1563            // Decode the remaining unknown envelopes.
1564            while next_offset < end_offset {
1565                _next_ordinal_to_read += 1;
1566                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1567                next_offset += envelope_size;
1568            }
1569
1570            Ok(())
1571        }
1572    }
1573
1574    impl WakeGroupWaitForDataResponse {
1575        #[inline(always)]
1576        fn max_ordinal_present(&self) -> u64 {
1577            if let Some(_) = self.source {
1578                return 1;
1579            }
1580            0
1581        }
1582    }
1583
1584    impl fidl::encoding::ResourceTypeMarker for WakeGroupWaitForDataResponse {
1585        type Borrowed<'a> = &'a mut Self;
1586        fn take_or_borrow<'a>(
1587            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1588        ) -> Self::Borrowed<'a> {
1589            value
1590        }
1591    }
1592
1593    unsafe impl fidl::encoding::TypeMarker for WakeGroupWaitForDataResponse {
1594        type Owned = Self;
1595
1596        #[inline(always)]
1597        fn inline_align(_context: fidl::encoding::Context) -> usize {
1598            8
1599        }
1600
1601        #[inline(always)]
1602        fn inline_size(_context: fidl::encoding::Context) -> usize {
1603            16
1604        }
1605    }
1606
1607    unsafe impl
1608        fidl::encoding::Encode<
1609            WakeGroupWaitForDataResponse,
1610            fidl::encoding::DefaultFuchsiaResourceDialect,
1611        > for &mut WakeGroupWaitForDataResponse
1612    {
1613        unsafe fn encode(
1614            self,
1615            encoder: &mut fidl::encoding::Encoder<
1616                '_,
1617                fidl::encoding::DefaultFuchsiaResourceDialect,
1618            >,
1619            offset: usize,
1620            mut depth: fidl::encoding::Depth,
1621        ) -> fidl::Result<()> {
1622            encoder.debug_check_bounds::<WakeGroupWaitForDataResponse>(offset);
1623            // Vector header
1624            let max_ordinal: u64 = self.max_ordinal_present();
1625            encoder.write_num(max_ordinal, offset);
1626            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1627            // Calling encoder.out_of_line_offset(0) is not allowed.
1628            if max_ordinal == 0 {
1629                return Ok(());
1630            }
1631            depth.increment()?;
1632            let envelope_size = 8;
1633            let bytes_len = max_ordinal as usize * envelope_size;
1634            #[allow(unused_variables)]
1635            let offset = encoder.out_of_line_offset(bytes_len);
1636            let mut _prev_end_offset: usize = 0;
1637            if 1 > max_ordinal {
1638                return Ok(());
1639            }
1640
1641            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1642            // are envelope_size bytes.
1643            let cur_offset: usize = (1 - 1) * envelope_size;
1644
1645            // Zero reserved fields.
1646            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1647
1648            // Safety:
1649            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1650            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1651            //   envelope_size bytes, there is always sufficient room.
1652            fidl::encoding::encode_in_envelope_optional::<
1653                WakeSource,
1654                fidl::encoding::DefaultFuchsiaResourceDialect,
1655            >(
1656                self.source
1657                    .as_mut()
1658                    .map(<WakeSource as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1659                encoder,
1660                offset + cur_offset,
1661                depth,
1662            )?;
1663
1664            _prev_end_offset = cur_offset + envelope_size;
1665
1666            Ok(())
1667        }
1668    }
1669
1670    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1671        for WakeGroupWaitForDataResponse
1672    {
1673        #[inline(always)]
1674        fn new_empty() -> Self {
1675            Self::default()
1676        }
1677
1678        unsafe fn decode(
1679            &mut self,
1680            decoder: &mut fidl::encoding::Decoder<
1681                '_,
1682                fidl::encoding::DefaultFuchsiaResourceDialect,
1683            >,
1684            offset: usize,
1685            mut depth: fidl::encoding::Depth,
1686        ) -> fidl::Result<()> {
1687            decoder.debug_check_bounds::<Self>(offset);
1688            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1689                None => return Err(fidl::Error::NotNullable),
1690                Some(len) => len,
1691            };
1692            // Calling decoder.out_of_line_offset(0) is not allowed.
1693            if len == 0 {
1694                return Ok(());
1695            };
1696            depth.increment()?;
1697            let envelope_size = 8;
1698            let bytes_len = len * envelope_size;
1699            let offset = decoder.out_of_line_offset(bytes_len)?;
1700            // Decode the envelope for each type.
1701            let mut _next_ordinal_to_read = 0;
1702            let mut next_offset = offset;
1703            let end_offset = offset + bytes_len;
1704            _next_ordinal_to_read += 1;
1705            if next_offset >= end_offset {
1706                return Ok(());
1707            }
1708
1709            // Decode unknown envelopes for gaps in ordinals.
1710            while _next_ordinal_to_read < 1 {
1711                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1712                _next_ordinal_to_read += 1;
1713                next_offset += envelope_size;
1714            }
1715
1716            let next_out_of_line = decoder.next_out_of_line();
1717            let handles_before = decoder.remaining_handles();
1718            if let Some((inlined, num_bytes, num_handles)) =
1719                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1720            {
1721                let member_inline_size =
1722                    <WakeSource as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1723                if inlined != (member_inline_size <= 4) {
1724                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1725                }
1726                let inner_offset;
1727                let mut inner_depth = depth.clone();
1728                if inlined {
1729                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1730                    inner_offset = next_offset;
1731                } else {
1732                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1733                    inner_depth.increment()?;
1734                }
1735                let val_ref = self.source.get_or_insert_with(|| {
1736                    fidl::new_empty!(WakeSource, fidl::encoding::DefaultFuchsiaResourceDialect)
1737                });
1738                fidl::decode!(
1739                    WakeSource,
1740                    fidl::encoding::DefaultFuchsiaResourceDialect,
1741                    val_ref,
1742                    decoder,
1743                    inner_offset,
1744                    inner_depth
1745                )?;
1746                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1747                {
1748                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1749                }
1750                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1751                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1752                }
1753            }
1754
1755            next_offset += envelope_size;
1756
1757            // Decode the remaining unknown envelopes.
1758            while next_offset < end_offset {
1759                _next_ordinal_to_read += 1;
1760                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1761                next_offset += envelope_size;
1762            }
1763
1764            Ok(())
1765        }
1766    }
1767
1768    impl fidl::encoding::ResourceTypeMarker for WakeSource {
1769        type Borrowed<'a> = &'a mut Self;
1770        fn take_or_borrow<'a>(
1771            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1772        ) -> Self::Borrowed<'a> {
1773            value
1774        }
1775    }
1776
1777    unsafe impl fidl::encoding::TypeMarker for WakeSource {
1778        type Owned = Self;
1779
1780        #[inline(always)]
1781        fn inline_align(_context: fidl::encoding::Context) -> usize {
1782            8
1783        }
1784
1785        #[inline(always)]
1786        fn inline_size(_context: fidl::encoding::Context) -> usize {
1787            16
1788        }
1789    }
1790
1791    unsafe impl fidl::encoding::Encode<WakeSource, fidl::encoding::DefaultFuchsiaResourceDialect>
1792        for &mut WakeSource
1793    {
1794        #[inline]
1795        unsafe fn encode(
1796            self,
1797            encoder: &mut fidl::encoding::Encoder<
1798                '_,
1799                fidl::encoding::DefaultFuchsiaResourceDialect,
1800            >,
1801            offset: usize,
1802            _depth: fidl::encoding::Depth,
1803        ) -> fidl::Result<()> {
1804            encoder.debug_check_bounds::<WakeSource>(offset);
1805            encoder.write_num::<u64>(self.ordinal(), offset);
1806            match self {
1807                WakeSource::Data(ref val) => fidl::encoding::encode_in_envelope::<
1808                    Empty,
1809                    fidl::encoding::DefaultFuchsiaResourceDialect,
1810                >(
1811                    <Empty as fidl::encoding::ValueTypeMarker>::borrow(val),
1812                    encoder,
1813                    offset + 8,
1814                    _depth,
1815                ),
1816                WakeSource::Lease(ref mut val) => fidl::encoding::encode_in_envelope::<
1817                    fidl::encoding::HandleType<
1818                        fidl::EventPair,
1819                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1820                        16387,
1821                    >,
1822                    fidl::encoding::DefaultFuchsiaResourceDialect,
1823                >(
1824                    <fidl::encoding::HandleType<
1825                        fidl::EventPair,
1826                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1827                        16387,
1828                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1829                        val
1830                    ),
1831                    encoder,
1832                    offset + 8,
1833                    _depth,
1834                ),
1835                WakeSource::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
1836            }
1837        }
1838    }
1839
1840    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for WakeSource {
1841        #[inline(always)]
1842        fn new_empty() -> Self {
1843            Self::__SourceBreaking { unknown_ordinal: 0 }
1844        }
1845
1846        #[inline]
1847        unsafe fn decode(
1848            &mut self,
1849            decoder: &mut fidl::encoding::Decoder<
1850                '_,
1851                fidl::encoding::DefaultFuchsiaResourceDialect,
1852            >,
1853            offset: usize,
1854            mut depth: fidl::encoding::Depth,
1855        ) -> fidl::Result<()> {
1856            decoder.debug_check_bounds::<Self>(offset);
1857            #[allow(unused_variables)]
1858            let next_out_of_line = decoder.next_out_of_line();
1859            let handles_before = decoder.remaining_handles();
1860            let (ordinal, inlined, num_bytes, num_handles) =
1861                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
1862
1863            let member_inline_size = match ordinal {
1864                1 => <Empty as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1865                2 => <fidl::encoding::HandleType<
1866                    fidl::EventPair,
1867                    { fidl::ObjectType::EVENTPAIR.into_raw() },
1868                    16387,
1869                > as fidl::encoding::TypeMarker>::inline_size(decoder.context),
1870                0 => return Err(fidl::Error::UnknownUnionTag),
1871                _ => num_bytes as usize,
1872            };
1873
1874            if inlined != (member_inline_size <= 4) {
1875                return Err(fidl::Error::InvalidInlineBitInEnvelope);
1876            }
1877            let _inner_offset;
1878            if inlined {
1879                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
1880                _inner_offset = offset + 8;
1881            } else {
1882                depth.increment()?;
1883                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1884            }
1885            match ordinal {
1886                1 => {
1887                    #[allow(irrefutable_let_patterns)]
1888                    if let WakeSource::Data(_) = self {
1889                        // Do nothing, read the value into the object
1890                    } else {
1891                        // Initialize `self` to the right variant
1892                        *self = WakeSource::Data(fidl::new_empty!(
1893                            Empty,
1894                            fidl::encoding::DefaultFuchsiaResourceDialect
1895                        ));
1896                    }
1897                    #[allow(irrefutable_let_patterns)]
1898                    if let WakeSource::Data(ref mut val) = self {
1899                        fidl::decode!(
1900                            Empty,
1901                            fidl::encoding::DefaultFuchsiaResourceDialect,
1902                            val,
1903                            decoder,
1904                            _inner_offset,
1905                            depth
1906                        )?;
1907                    } else {
1908                        unreachable!()
1909                    }
1910                }
1911                2 => {
1912                    #[allow(irrefutable_let_patterns)]
1913                    if let WakeSource::Lease(_) = self {
1914                        // Do nothing, read the value into the object
1915                    } else {
1916                        // Initialize `self` to the right variant
1917                        *self = WakeSource::Lease(
1918                            fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
1919                        );
1920                    }
1921                    #[allow(irrefutable_let_patterns)]
1922                    if let WakeSource::Lease(ref mut val) = self {
1923                        fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, val, decoder, _inner_offset, depth)?;
1924                    } else {
1925                        unreachable!()
1926                    }
1927                }
1928                #[allow(deprecated)]
1929                ordinal => {
1930                    for _ in 0..num_handles {
1931                        decoder.drop_next_handle()?;
1932                    }
1933                    *self = WakeSource::__SourceBreaking { unknown_ordinal: ordinal };
1934                }
1935            }
1936            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
1937                return Err(fidl::Error::InvalidNumBytesInEnvelope);
1938            }
1939            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1940                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1941            }
1942            Ok(())
1943        }
1944    }
1945}