Skip to main content

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