Skip to main content

fidl_fuchsia_hardware_power_source/
fidl_fuchsia_hardware_power_source.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_hardware_power_source_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct SourceWatchRequest {
16    pub interest: Status,
17    pub wake_on: Status,
18    pub lease: Option<fidl::EventPair>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SourceWatchRequest {}
22
23#[derive(Debug, PartialEq)]
24pub struct SourceWatchResponse {
25    pub status: Status,
26    pub wake_lease: Option<fidl::EventPair>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SourceWatchResponse {}
30
31#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
32pub struct SourceMarker;
33
34impl fidl::endpoints::ProtocolMarker for SourceMarker {
35    type Proxy = SourceProxy;
36    type RequestStream = SourceRequestStream;
37    #[cfg(target_os = "fuchsia")]
38    type SynchronousProxy = SourceSynchronousProxy;
39
40    const DEBUG_NAME: &'static str = "(anonymous) Source";
41}
42pub type SourceGetSpecResult = Result<Spec, Error>;
43pub type SourceGetStatusResult = Result<Status, Error>;
44pub type SourceSetRoleResult = Result<(), Error>;
45
46pub trait SourceProxyInterface: Send + Sync {
47    type GetSpecResponseFut: std::future::Future<Output = Result<SourceGetSpecResult, fidl::Error>>
48        + Send;
49    fn r#get_spec(&self) -> Self::GetSpecResponseFut;
50    type GetStatusResponseFut: std::future::Future<Output = Result<SourceGetStatusResult, fidl::Error>>
51        + Send;
52    fn r#get_status(&self) -> Self::GetStatusResponseFut;
53    type SetRoleResponseFut: std::future::Future<Output = Result<SourceSetRoleResult, fidl::Error>>
54        + Send;
55    fn r#set_role(&self, role: &Role) -> Self::SetRoleResponseFut;
56    type WatchResponseFut: std::future::Future<Output = Result<(Status, Option<fidl::EventPair>), fidl::Error>>
57        + Send;
58    fn r#watch(
59        &self,
60        interest: &Status,
61        wake_on: &Status,
62        lease: Option<fidl::EventPair>,
63    ) -> Self::WatchResponseFut;
64}
65#[derive(Debug)]
66#[cfg(target_os = "fuchsia")]
67pub struct SourceSynchronousProxy {
68    client: fidl::client::sync::Client,
69}
70
71#[cfg(target_os = "fuchsia")]
72impl fidl::endpoints::SynchronousProxy for SourceSynchronousProxy {
73    type Proxy = SourceProxy;
74    type Protocol = SourceMarker;
75
76    fn from_channel(inner: fidl::Channel) -> Self {
77        Self::new(inner)
78    }
79
80    fn into_channel(self) -> fidl::Channel {
81        self.client.into_channel()
82    }
83
84    fn as_channel(&self) -> &fidl::Channel {
85        self.client.as_channel()
86    }
87}
88
89#[cfg(target_os = "fuchsia")]
90impl SourceSynchronousProxy {
91    pub fn new(channel: fidl::Channel) -> Self {
92        Self { client: fidl::client::sync::Client::new(channel) }
93    }
94
95    pub fn into_channel(self) -> fidl::Channel {
96        self.client.into_channel()
97    }
98
99    /// Waits until an event arrives and returns it. It is safe for other
100    /// threads to make concurrent requests while waiting for an event.
101    pub fn wait_for_event(
102        &self,
103        deadline: zx::MonotonicInstant,
104    ) -> Result<SourceEvent, fidl::Error> {
105        SourceEvent::decode(self.client.wait_for_event::<SourceMarker>(deadline)?)
106    }
107
108    /// Returns static hardware characteristics that do not change during operation.
109    pub fn r#get_spec(
110        &self,
111        ___deadline: zx::MonotonicInstant,
112    ) -> Result<SourceGetSpecResult, fidl::Error> {
113        let _response = self.client.send_query::<
114            fidl::encoding::EmptyPayload,
115            fidl::encoding::FlexibleResultType<SourceGetSpecResponse, Error>,
116            SourceMarker,
117        >(
118            (),
119            0x7f756685c3daa1ac,
120            fidl::encoding::DynamicFlags::FLEXIBLE,
121            ___deadline,
122        )?
123        .into_result::<SourceMarker>("get_spec")?;
124        Ok(_response.map(|x| x.spec))
125    }
126
127    /// Returns dynamic status of the source immediately.
128    pub fn r#get_status(
129        &self,
130        ___deadline: zx::MonotonicInstant,
131    ) -> Result<SourceGetStatusResult, fidl::Error> {
132        let _response = self.client.send_query::<
133            fidl::encoding::EmptyPayload,
134            fidl::encoding::FlexibleResultType<SourceGetStatusResponse, Error>,
135            SourceMarker,
136        >(
137            (),
138            0x121659a401919be7,
139            fidl::encoding::DynamicFlags::FLEXIBLE,
140            ___deadline,
141        )?
142        .into_result::<SourceMarker>("get_status")?;
143        Ok(_response.map(|x| x.status))
144    }
145
146    /// Set the role of this specific node.
147    ///
148    /// Errors:
149    /// + `INVALID_ARGS`: If the provided role is invalid.
150    /// + `NOT_SUPPORTED`: If the requested role is not supported by the hardware.
151    /// + `INTERNAL`: If an unexpected error occurred.
152    pub fn r#set_role(
153        &self,
154        mut role: &Role,
155        ___deadline: zx::MonotonicInstant,
156    ) -> Result<SourceSetRoleResult, fidl::Error> {
157        let _response = self.client.send_query::<
158            SourceSetRoleRequest,
159            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
160            SourceMarker,
161        >(
162            (role,),
163            0x2a0b0990da5f4ae1,
164            fidl::encoding::DynamicFlags::FLEXIBLE,
165            ___deadline,
166        )?
167        .into_result::<SourceMarker>("set_role")?;
168        Ok(_response.map(|x| x))
169    }
170
171    /// Change notification for power source state using a "hanging-get" pattern.
172    ///
173    /// The first call to this method returns the current hardware state immediately.
174    /// Subsequent calls block until a change occurs that matches the provided masks.
175    ///
176    /// At most one `Watch` call may be outstanding at a time per connection.
177    /// Completing a call acknowledges that the client has received the previous update.
178    ///
179    /// ### Power Management and Suspend
180    /// To prevent lost wakeups, the server (driver) must ensure that the `Watch` call
181    /// remains active (and hardware interrupts armed) while the system is suspended.
182    ///
183    /// + **Interest Triggers**: If a change in the `interest` mask occurs while the
184    ///   system is suspended, the server MUST NOT complete the `Watch` call until
185    ///   the system wakes for another reason (e.g., a `wake_on` event or external trigger).
186    ///   This ensures the CPU remains asleep for non-critical updates.
187    /// + **Wake-On Triggers**: If a change in the `wake_on` mask occurs, the server
188    ///   MUST wake the system and complete the call immediately with a `wake_lease`.
189    ///
190    /// As a result of this queuing behavior, if multiple changes occur while the
191    /// system is suspended, they may be merged into a single returned `status` table,
192    /// and intermediate state transitions may be lost.
193    ///
194    /// + `interest`: The client wants to be notified if any of the fields present
195    ///   in this table change. If any field in `interest` changes, the method returns.
196    /// + `wake_on`: Similar to `interest`, but if a change occurs in these fields,
197    ///   the server will attempt to keep the system awake using the provided `lease`
198    ///   (or by returning a `wake_lease`) until the client acknowledges the update.
199    /// + `lease`: A power lease token used to coordinate handoff between the server
200    ///   and client, ensuring the system does not suspend before the client can
201    ///   process a critical power event.
202    ///
203    /// Returns:
204    /// + `status`: The updated status table containing the fields that changed.
205    /// + `wake_lease`: An optional lease token provided if the change triggered
206    ///   a `wake_on` condition and the server is maintaining system state.
207    pub fn r#watch(
208        &self,
209        mut interest: &Status,
210        mut wake_on: &Status,
211        mut lease: Option<fidl::EventPair>,
212        ___deadline: zx::MonotonicInstant,
213    ) -> Result<(Status, Option<fidl::EventPair>), fidl::Error> {
214        let _response = self.client.send_query::<
215            SourceWatchRequest,
216            fidl::encoding::FlexibleType<SourceWatchResponse>,
217            SourceMarker,
218        >(
219            (interest, wake_on, lease,),
220            0x15f6187735c58e1,
221            fidl::encoding::DynamicFlags::FLEXIBLE,
222            ___deadline,
223        )?
224        .into_result::<SourceMarker>("watch")?;
225        Ok((_response.status, _response.wake_lease))
226    }
227}
228
229#[cfg(target_os = "fuchsia")]
230impl From<SourceSynchronousProxy> for zx::NullableHandle {
231    fn from(value: SourceSynchronousProxy) -> Self {
232        value.into_channel().into()
233    }
234}
235
236#[cfg(target_os = "fuchsia")]
237impl From<fidl::Channel> for SourceSynchronousProxy {
238    fn from(value: fidl::Channel) -> Self {
239        Self::new(value)
240    }
241}
242
243#[cfg(target_os = "fuchsia")]
244impl fidl::endpoints::FromClient for SourceSynchronousProxy {
245    type Protocol = SourceMarker;
246
247    fn from_client(value: fidl::endpoints::ClientEnd<SourceMarker>) -> Self {
248        Self::new(value.into_channel())
249    }
250}
251
252#[derive(Debug, Clone)]
253pub struct SourceProxy {
254    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
255}
256
257impl fidl::endpoints::Proxy for SourceProxy {
258    type Protocol = SourceMarker;
259
260    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
261        Self::new(inner)
262    }
263
264    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
265        self.client.into_channel().map_err(|client| Self { client })
266    }
267
268    fn as_channel(&self) -> &::fidl::AsyncChannel {
269        self.client.as_channel()
270    }
271}
272
273impl SourceProxy {
274    /// Create a new Proxy for fuchsia.hardware.power.source/Source.
275    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
276        let protocol_name = <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
277        Self { client: fidl::client::Client::new(channel, protocol_name) }
278    }
279
280    /// Get a Stream of events from the remote end of the protocol.
281    ///
282    /// # Panics
283    ///
284    /// Panics if the event stream was already taken.
285    pub fn take_event_stream(&self) -> SourceEventStream {
286        SourceEventStream { event_receiver: self.client.take_event_receiver() }
287    }
288
289    /// Returns static hardware characteristics that do not change during operation.
290    pub fn r#get_spec(
291        &self,
292    ) -> fidl::client::QueryResponseFut<
293        SourceGetSpecResult,
294        fidl::encoding::DefaultFuchsiaResourceDialect,
295    > {
296        SourceProxyInterface::r#get_spec(self)
297    }
298
299    /// Returns dynamic status of the source immediately.
300    pub fn r#get_status(
301        &self,
302    ) -> fidl::client::QueryResponseFut<
303        SourceGetStatusResult,
304        fidl::encoding::DefaultFuchsiaResourceDialect,
305    > {
306        SourceProxyInterface::r#get_status(self)
307    }
308
309    /// Set the role of this specific node.
310    ///
311    /// Errors:
312    /// + `INVALID_ARGS`: If the provided role is invalid.
313    /// + `NOT_SUPPORTED`: If the requested role is not supported by the hardware.
314    /// + `INTERNAL`: If an unexpected error occurred.
315    pub fn r#set_role(
316        &self,
317        mut role: &Role,
318    ) -> fidl::client::QueryResponseFut<
319        SourceSetRoleResult,
320        fidl::encoding::DefaultFuchsiaResourceDialect,
321    > {
322        SourceProxyInterface::r#set_role(self, role)
323    }
324
325    /// Change notification for power source state using a "hanging-get" pattern.
326    ///
327    /// The first call to this method returns the current hardware state immediately.
328    /// Subsequent calls block until a change occurs that matches the provided masks.
329    ///
330    /// At most one `Watch` call may be outstanding at a time per connection.
331    /// Completing a call acknowledges that the client has received the previous update.
332    ///
333    /// ### Power Management and Suspend
334    /// To prevent lost wakeups, the server (driver) must ensure that the `Watch` call
335    /// remains active (and hardware interrupts armed) while the system is suspended.
336    ///
337    /// + **Interest Triggers**: If a change in the `interest` mask occurs while the
338    ///   system is suspended, the server MUST NOT complete the `Watch` call until
339    ///   the system wakes for another reason (e.g., a `wake_on` event or external trigger).
340    ///   This ensures the CPU remains asleep for non-critical updates.
341    /// + **Wake-On Triggers**: If a change in the `wake_on` mask occurs, the server
342    ///   MUST wake the system and complete the call immediately with a `wake_lease`.
343    ///
344    /// As a result of this queuing behavior, if multiple changes occur while the
345    /// system is suspended, they may be merged into a single returned `status` table,
346    /// and intermediate state transitions may be lost.
347    ///
348    /// + `interest`: The client wants to be notified if any of the fields present
349    ///   in this table change. If any field in `interest` changes, the method returns.
350    /// + `wake_on`: Similar to `interest`, but if a change occurs in these fields,
351    ///   the server will attempt to keep the system awake using the provided `lease`
352    ///   (or by returning a `wake_lease`) until the client acknowledges the update.
353    /// + `lease`: A power lease token used to coordinate handoff between the server
354    ///   and client, ensuring the system does not suspend before the client can
355    ///   process a critical power event.
356    ///
357    /// Returns:
358    /// + `status`: The updated status table containing the fields that changed.
359    /// + `wake_lease`: An optional lease token provided if the change triggered
360    ///   a `wake_on` condition and the server is maintaining system state.
361    pub fn r#watch(
362        &self,
363        mut interest: &Status,
364        mut wake_on: &Status,
365        mut lease: Option<fidl::EventPair>,
366    ) -> fidl::client::QueryResponseFut<
367        (Status, Option<fidl::EventPair>),
368        fidl::encoding::DefaultFuchsiaResourceDialect,
369    > {
370        SourceProxyInterface::r#watch(self, interest, wake_on, lease)
371    }
372}
373
374impl SourceProxyInterface for SourceProxy {
375    type GetSpecResponseFut = fidl::client::QueryResponseFut<
376        SourceGetSpecResult,
377        fidl::encoding::DefaultFuchsiaResourceDialect,
378    >;
379    fn r#get_spec(&self) -> Self::GetSpecResponseFut {
380        fn _decode(
381            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
382        ) -> Result<SourceGetSpecResult, fidl::Error> {
383            let _response = fidl::client::decode_transaction_body::<
384                fidl::encoding::FlexibleResultType<SourceGetSpecResponse, Error>,
385                fidl::encoding::DefaultFuchsiaResourceDialect,
386                0x7f756685c3daa1ac,
387            >(_buf?)?
388            .into_result::<SourceMarker>("get_spec")?;
389            Ok(_response.map(|x| x.spec))
390        }
391        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SourceGetSpecResult>(
392            (),
393            0x7f756685c3daa1ac,
394            fidl::encoding::DynamicFlags::FLEXIBLE,
395            _decode,
396        )
397    }
398
399    type GetStatusResponseFut = fidl::client::QueryResponseFut<
400        SourceGetStatusResult,
401        fidl::encoding::DefaultFuchsiaResourceDialect,
402    >;
403    fn r#get_status(&self) -> Self::GetStatusResponseFut {
404        fn _decode(
405            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
406        ) -> Result<SourceGetStatusResult, fidl::Error> {
407            let _response = fidl::client::decode_transaction_body::<
408                fidl::encoding::FlexibleResultType<SourceGetStatusResponse, Error>,
409                fidl::encoding::DefaultFuchsiaResourceDialect,
410                0x121659a401919be7,
411            >(_buf?)?
412            .into_result::<SourceMarker>("get_status")?;
413            Ok(_response.map(|x| x.status))
414        }
415        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, SourceGetStatusResult>(
416            (),
417            0x121659a401919be7,
418            fidl::encoding::DynamicFlags::FLEXIBLE,
419            _decode,
420        )
421    }
422
423    type SetRoleResponseFut = fidl::client::QueryResponseFut<
424        SourceSetRoleResult,
425        fidl::encoding::DefaultFuchsiaResourceDialect,
426    >;
427    fn r#set_role(&self, mut role: &Role) -> Self::SetRoleResponseFut {
428        fn _decode(
429            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
430        ) -> Result<SourceSetRoleResult, fidl::Error> {
431            let _response = fidl::client::decode_transaction_body::<
432                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, Error>,
433                fidl::encoding::DefaultFuchsiaResourceDialect,
434                0x2a0b0990da5f4ae1,
435            >(_buf?)?
436            .into_result::<SourceMarker>("set_role")?;
437            Ok(_response.map(|x| x))
438        }
439        self.client.send_query_and_decode::<SourceSetRoleRequest, SourceSetRoleResult>(
440            (role,),
441            0x2a0b0990da5f4ae1,
442            fidl::encoding::DynamicFlags::FLEXIBLE,
443            _decode,
444        )
445    }
446
447    type WatchResponseFut = fidl::client::QueryResponseFut<
448        (Status, Option<fidl::EventPair>),
449        fidl::encoding::DefaultFuchsiaResourceDialect,
450    >;
451    fn r#watch(
452        &self,
453        mut interest: &Status,
454        mut wake_on: &Status,
455        mut lease: Option<fidl::EventPair>,
456    ) -> Self::WatchResponseFut {
457        fn _decode(
458            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
459        ) -> Result<(Status, Option<fidl::EventPair>), fidl::Error> {
460            let _response = fidl::client::decode_transaction_body::<
461                fidl::encoding::FlexibleType<SourceWatchResponse>,
462                fidl::encoding::DefaultFuchsiaResourceDialect,
463                0x15f6187735c58e1,
464            >(_buf?)?
465            .into_result::<SourceMarker>("watch")?;
466            Ok((_response.status, _response.wake_lease))
467        }
468        self.client.send_query_and_decode::<SourceWatchRequest, (Status, Option<fidl::EventPair>)>(
469            (interest, wake_on, lease),
470            0x15f6187735c58e1,
471            fidl::encoding::DynamicFlags::FLEXIBLE,
472            _decode,
473        )
474    }
475}
476
477pub struct SourceEventStream {
478    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
479}
480
481impl std::marker::Unpin for SourceEventStream {}
482
483impl futures::stream::FusedStream for SourceEventStream {
484    fn is_terminated(&self) -> bool {
485        self.event_receiver.is_terminated()
486    }
487}
488
489impl futures::Stream for SourceEventStream {
490    type Item = Result<SourceEvent, fidl::Error>;
491
492    fn poll_next(
493        mut self: std::pin::Pin<&mut Self>,
494        cx: &mut std::task::Context<'_>,
495    ) -> std::task::Poll<Option<Self::Item>> {
496        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
497            &mut self.event_receiver,
498            cx
499        )?) {
500            Some(buf) => std::task::Poll::Ready(Some(SourceEvent::decode(buf))),
501            None => std::task::Poll::Ready(None),
502        }
503    }
504}
505
506#[derive(Debug)]
507pub enum SourceEvent {
508    #[non_exhaustive]
509    _UnknownEvent {
510        /// Ordinal of the event that was sent.
511        ordinal: u64,
512    },
513}
514
515impl SourceEvent {
516    /// Decodes a message buffer as a [`SourceEvent`].
517    fn decode(
518        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
519    ) -> Result<SourceEvent, fidl::Error> {
520        let (bytes, _handles) = buf.split_mut();
521        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
522        debug_assert_eq!(tx_header.tx_id, 0);
523        match tx_header.ordinal {
524            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
525                Ok(SourceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
526            }
527            _ => Err(fidl::Error::UnknownOrdinal {
528                ordinal: tx_header.ordinal,
529                protocol_name: <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
530            }),
531        }
532    }
533}
534
535/// A Stream of incoming requests for fuchsia.hardware.power.source/Source.
536pub struct SourceRequestStream {
537    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
538    is_terminated: bool,
539}
540
541impl std::marker::Unpin for SourceRequestStream {}
542
543impl futures::stream::FusedStream for SourceRequestStream {
544    fn is_terminated(&self) -> bool {
545        self.is_terminated
546    }
547}
548
549impl fidl::endpoints::RequestStream for SourceRequestStream {
550    type Protocol = SourceMarker;
551    type ControlHandle = SourceControlHandle;
552
553    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
554        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
555    }
556
557    fn control_handle(&self) -> Self::ControlHandle {
558        SourceControlHandle { inner: self.inner.clone() }
559    }
560
561    fn into_inner(
562        self,
563    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
564    {
565        (self.inner, self.is_terminated)
566    }
567
568    fn from_inner(
569        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
570        is_terminated: bool,
571    ) -> Self {
572        Self { inner, is_terminated }
573    }
574}
575
576impl futures::Stream for SourceRequestStream {
577    type Item = Result<SourceRequest, fidl::Error>;
578
579    fn poll_next(
580        mut self: std::pin::Pin<&mut Self>,
581        cx: &mut std::task::Context<'_>,
582    ) -> std::task::Poll<Option<Self::Item>> {
583        let this = &mut *self;
584        if this.inner.check_shutdown(cx) {
585            this.is_terminated = true;
586            return std::task::Poll::Ready(None);
587        }
588        if this.is_terminated {
589            panic!("polled SourceRequestStream after completion");
590        }
591        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
592            |bytes, handles| {
593                match this.inner.channel().read_etc(cx, bytes, handles) {
594                    std::task::Poll::Ready(Ok(())) => {}
595                    std::task::Poll::Pending => return std::task::Poll::Pending,
596                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
597                        this.is_terminated = true;
598                        return std::task::Poll::Ready(None);
599                    }
600                    std::task::Poll::Ready(Err(e)) => {
601                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
602                            e.into(),
603                        ))));
604                    }
605                }
606
607                // A message has been received from the channel
608                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
609
610                std::task::Poll::Ready(Some(match header.ordinal {
611                    0x7f756685c3daa1ac => {
612                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
613                        let mut req = fidl::new_empty!(
614                            fidl::encoding::EmptyPayload,
615                            fidl::encoding::DefaultFuchsiaResourceDialect
616                        );
617                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
618                        let control_handle = SourceControlHandle { inner: this.inner.clone() };
619                        Ok(SourceRequest::GetSpec {
620                            responder: SourceGetSpecResponder {
621                                control_handle: std::mem::ManuallyDrop::new(control_handle),
622                                tx_id: header.tx_id,
623                            },
624                        })
625                    }
626                    0x121659a401919be7 => {
627                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
628                        let mut req = fidl::new_empty!(
629                            fidl::encoding::EmptyPayload,
630                            fidl::encoding::DefaultFuchsiaResourceDialect
631                        );
632                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
633                        let control_handle = SourceControlHandle { inner: this.inner.clone() };
634                        Ok(SourceRequest::GetStatus {
635                            responder: SourceGetStatusResponder {
636                                control_handle: std::mem::ManuallyDrop::new(control_handle),
637                                tx_id: header.tx_id,
638                            },
639                        })
640                    }
641                    0x2a0b0990da5f4ae1 => {
642                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
643                        let mut req = fidl::new_empty!(
644                            SourceSetRoleRequest,
645                            fidl::encoding::DefaultFuchsiaResourceDialect
646                        );
647                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SourceSetRoleRequest>(&header, _body_bytes, handles, &mut req)?;
648                        let control_handle = SourceControlHandle { inner: this.inner.clone() };
649                        Ok(SourceRequest::SetRole {
650                            role: req.role,
651
652                            responder: SourceSetRoleResponder {
653                                control_handle: std::mem::ManuallyDrop::new(control_handle),
654                                tx_id: header.tx_id,
655                            },
656                        })
657                    }
658                    0x15f6187735c58e1 => {
659                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
660                        let mut req = fidl::new_empty!(
661                            SourceWatchRequest,
662                            fidl::encoding::DefaultFuchsiaResourceDialect
663                        );
664                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SourceWatchRequest>(&header, _body_bytes, handles, &mut req)?;
665                        let control_handle = SourceControlHandle { inner: this.inner.clone() };
666                        Ok(SourceRequest::Watch {
667                            interest: req.interest,
668                            wake_on: req.wake_on,
669                            lease: req.lease,
670
671                            responder: SourceWatchResponder {
672                                control_handle: std::mem::ManuallyDrop::new(control_handle),
673                                tx_id: header.tx_id,
674                            },
675                        })
676                    }
677                    _ if header.tx_id == 0
678                        && header
679                            .dynamic_flags()
680                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
681                    {
682                        Ok(SourceRequest::_UnknownMethod {
683                            ordinal: header.ordinal,
684                            control_handle: SourceControlHandle { inner: this.inner.clone() },
685                            method_type: fidl::MethodType::OneWay,
686                        })
687                    }
688                    _ if header
689                        .dynamic_flags()
690                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
691                    {
692                        this.inner.send_framework_err(
693                            fidl::encoding::FrameworkErr::UnknownMethod,
694                            header.tx_id,
695                            header.ordinal,
696                            header.dynamic_flags(),
697                            (bytes, handles),
698                        )?;
699                        Ok(SourceRequest::_UnknownMethod {
700                            ordinal: header.ordinal,
701                            control_handle: SourceControlHandle { inner: this.inner.clone() },
702                            method_type: fidl::MethodType::TwoWay,
703                        })
704                    }
705                    _ => Err(fidl::Error::UnknownOrdinal {
706                        ordinal: header.ordinal,
707                        protocol_name:
708                            <SourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
709                    }),
710                }))
711            },
712        )
713    }
714}
715
716#[derive(Debug)]
717pub enum SourceRequest {
718    /// Returns static hardware characteristics that do not change during operation.
719    GetSpec { responder: SourceGetSpecResponder },
720    /// Returns dynamic status of the source immediately.
721    GetStatus { responder: SourceGetStatusResponder },
722    /// Set the role of this specific node.
723    ///
724    /// Errors:
725    /// + `INVALID_ARGS`: If the provided role is invalid.
726    /// + `NOT_SUPPORTED`: If the requested role is not supported by the hardware.
727    /// + `INTERNAL`: If an unexpected error occurred.
728    SetRole { role: Role, responder: SourceSetRoleResponder },
729    /// Change notification for power source state using a "hanging-get" pattern.
730    ///
731    /// The first call to this method returns the current hardware state immediately.
732    /// Subsequent calls block until a change occurs that matches the provided masks.
733    ///
734    /// At most one `Watch` call may be outstanding at a time per connection.
735    /// Completing a call acknowledges that the client has received the previous update.
736    ///
737    /// ### Power Management and Suspend
738    /// To prevent lost wakeups, the server (driver) must ensure that the `Watch` call
739    /// remains active (and hardware interrupts armed) while the system is suspended.
740    ///
741    /// + **Interest Triggers**: If a change in the `interest` mask occurs while the
742    ///   system is suspended, the server MUST NOT complete the `Watch` call until
743    ///   the system wakes for another reason (e.g., a `wake_on` event or external trigger).
744    ///   This ensures the CPU remains asleep for non-critical updates.
745    /// + **Wake-On Triggers**: If a change in the `wake_on` mask occurs, the server
746    ///   MUST wake the system and complete the call immediately with a `wake_lease`.
747    ///
748    /// As a result of this queuing behavior, if multiple changes occur while the
749    /// system is suspended, they may be merged into a single returned `status` table,
750    /// and intermediate state transitions may be lost.
751    ///
752    /// + `interest`: The client wants to be notified if any of the fields present
753    ///   in this table change. If any field in `interest` changes, the method returns.
754    /// + `wake_on`: Similar to `interest`, but if a change occurs in these fields,
755    ///   the server will attempt to keep the system awake using the provided `lease`
756    ///   (or by returning a `wake_lease`) until the client acknowledges the update.
757    /// + `lease`: A power lease token used to coordinate handoff between the server
758    ///   and client, ensuring the system does not suspend before the client can
759    ///   process a critical power event.
760    ///
761    /// Returns:
762    /// + `status`: The updated status table containing the fields that changed.
763    /// + `wake_lease`: An optional lease token provided if the change triggered
764    ///   a `wake_on` condition and the server is maintaining system state.
765    Watch {
766        interest: Status,
767        wake_on: Status,
768        lease: Option<fidl::EventPair>,
769        responder: SourceWatchResponder,
770    },
771    /// An interaction was received which does not match any known method.
772    #[non_exhaustive]
773    _UnknownMethod {
774        /// Ordinal of the method that was called.
775        ordinal: u64,
776        control_handle: SourceControlHandle,
777        method_type: fidl::MethodType,
778    },
779}
780
781impl SourceRequest {
782    #[allow(irrefutable_let_patterns)]
783    pub fn into_get_spec(self) -> Option<(SourceGetSpecResponder)> {
784        if let SourceRequest::GetSpec { responder } = self { Some((responder)) } else { None }
785    }
786
787    #[allow(irrefutable_let_patterns)]
788    pub fn into_get_status(self) -> Option<(SourceGetStatusResponder)> {
789        if let SourceRequest::GetStatus { responder } = self { Some((responder)) } else { None }
790    }
791
792    #[allow(irrefutable_let_patterns)]
793    pub fn into_set_role(self) -> Option<(Role, SourceSetRoleResponder)> {
794        if let SourceRequest::SetRole { role, responder } = self {
795            Some((role, responder))
796        } else {
797            None
798        }
799    }
800
801    #[allow(irrefutable_let_patterns)]
802    pub fn into_watch(
803        self,
804    ) -> Option<(Status, Status, Option<fidl::EventPair>, SourceWatchResponder)> {
805        if let SourceRequest::Watch { interest, wake_on, lease, responder } = self {
806            Some((interest, wake_on, lease, responder))
807        } else {
808            None
809        }
810    }
811
812    /// Name of the method defined in FIDL
813    pub fn method_name(&self) -> &'static str {
814        match *self {
815            SourceRequest::GetSpec { .. } => "get_spec",
816            SourceRequest::GetStatus { .. } => "get_status",
817            SourceRequest::SetRole { .. } => "set_role",
818            SourceRequest::Watch { .. } => "watch",
819            SourceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
820                "unknown one-way method"
821            }
822            SourceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
823                "unknown two-way method"
824            }
825        }
826    }
827}
828
829#[derive(Debug, Clone)]
830pub struct SourceControlHandle {
831    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
832}
833
834impl fidl::endpoints::ControlHandle for SourceControlHandle {
835    fn shutdown(&self) {
836        self.inner.shutdown()
837    }
838
839    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
840        self.inner.shutdown_with_epitaph(status)
841    }
842
843    fn is_closed(&self) -> bool {
844        self.inner.channel().is_closed()
845    }
846    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
847        self.inner.channel().on_closed()
848    }
849
850    #[cfg(target_os = "fuchsia")]
851    fn signal_peer(
852        &self,
853        clear_mask: zx::Signals,
854        set_mask: zx::Signals,
855    ) -> Result<(), zx_status::Status> {
856        use fidl::Peered;
857        self.inner.channel().signal_peer(clear_mask, set_mask)
858    }
859}
860
861impl SourceControlHandle {}
862
863#[must_use = "FIDL methods require a response to be sent"]
864#[derive(Debug)]
865pub struct SourceGetSpecResponder {
866    control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
867    tx_id: u32,
868}
869
870/// Set the the channel to be shutdown (see [`SourceControlHandle::shutdown`])
871/// if the responder is dropped without sending a response, so that the client
872/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
873impl std::ops::Drop for SourceGetSpecResponder {
874    fn drop(&mut self) {
875        self.control_handle.shutdown();
876        // Safety: drops once, never accessed again
877        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
878    }
879}
880
881impl fidl::endpoints::Responder for SourceGetSpecResponder {
882    type ControlHandle = SourceControlHandle;
883
884    fn control_handle(&self) -> &SourceControlHandle {
885        &self.control_handle
886    }
887
888    fn drop_without_shutdown(mut self) {
889        // Safety: drops once, never accessed again due to mem::forget
890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
891        // Prevent Drop from running (which would shut down the channel)
892        std::mem::forget(self);
893    }
894}
895
896impl SourceGetSpecResponder {
897    /// Sends a response to the FIDL transaction.
898    ///
899    /// Sets the channel to shutdown if an error occurs.
900    pub fn send(self, mut result: Result<&Spec, Error>) -> Result<(), fidl::Error> {
901        let _result = self.send_raw(result);
902        if _result.is_err() {
903            self.control_handle.shutdown();
904        }
905        self.drop_without_shutdown();
906        _result
907    }
908
909    /// Similar to "send" but does not shutdown the channel if an error occurs.
910    pub fn send_no_shutdown_on_err(
911        self,
912        mut result: Result<&Spec, Error>,
913    ) -> Result<(), fidl::Error> {
914        let _result = self.send_raw(result);
915        self.drop_without_shutdown();
916        _result
917    }
918
919    fn send_raw(&self, mut result: Result<&Spec, Error>) -> Result<(), fidl::Error> {
920        self.control_handle
921            .inner
922            .send::<fidl::encoding::FlexibleResultType<SourceGetSpecResponse, Error>>(
923                fidl::encoding::FlexibleResult::new(result.map(|spec| (spec,))),
924                self.tx_id,
925                0x7f756685c3daa1ac,
926                fidl::encoding::DynamicFlags::FLEXIBLE,
927            )
928    }
929}
930
931#[must_use = "FIDL methods require a response to be sent"]
932#[derive(Debug)]
933pub struct SourceGetStatusResponder {
934    control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
935    tx_id: u32,
936}
937
938/// Set the the channel to be shutdown (see [`SourceControlHandle::shutdown`])
939/// if the responder is dropped without sending a response, so that the client
940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
941impl std::ops::Drop for SourceGetStatusResponder {
942    fn drop(&mut self) {
943        self.control_handle.shutdown();
944        // Safety: drops once, never accessed again
945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
946    }
947}
948
949impl fidl::endpoints::Responder for SourceGetStatusResponder {
950    type ControlHandle = SourceControlHandle;
951
952    fn control_handle(&self) -> &SourceControlHandle {
953        &self.control_handle
954    }
955
956    fn drop_without_shutdown(mut self) {
957        // Safety: drops once, never accessed again due to mem::forget
958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
959        // Prevent Drop from running (which would shut down the channel)
960        std::mem::forget(self);
961    }
962}
963
964impl SourceGetStatusResponder {
965    /// Sends a response to the FIDL transaction.
966    ///
967    /// Sets the channel to shutdown if an error occurs.
968    pub fn send(self, mut result: Result<&Status, Error>) -> Result<(), fidl::Error> {
969        let _result = self.send_raw(result);
970        if _result.is_err() {
971            self.control_handle.shutdown();
972        }
973        self.drop_without_shutdown();
974        _result
975    }
976
977    /// Similar to "send" but does not shutdown the channel if an error occurs.
978    pub fn send_no_shutdown_on_err(
979        self,
980        mut result: Result<&Status, Error>,
981    ) -> Result<(), fidl::Error> {
982        let _result = self.send_raw(result);
983        self.drop_without_shutdown();
984        _result
985    }
986
987    fn send_raw(&self, mut result: Result<&Status, Error>) -> Result<(), fidl::Error> {
988        self.control_handle
989            .inner
990            .send::<fidl::encoding::FlexibleResultType<SourceGetStatusResponse, Error>>(
991                fidl::encoding::FlexibleResult::new(result.map(|status| (status,))),
992                self.tx_id,
993                0x121659a401919be7,
994                fidl::encoding::DynamicFlags::FLEXIBLE,
995            )
996    }
997}
998
999#[must_use = "FIDL methods require a response to be sent"]
1000#[derive(Debug)]
1001pub struct SourceSetRoleResponder {
1002    control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
1003    tx_id: u32,
1004}
1005
1006/// Set the the channel to be shutdown (see [`SourceControlHandle::shutdown`])
1007/// if the responder is dropped without sending a response, so that the client
1008/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1009impl std::ops::Drop for SourceSetRoleResponder {
1010    fn drop(&mut self) {
1011        self.control_handle.shutdown();
1012        // Safety: drops once, never accessed again
1013        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1014    }
1015}
1016
1017impl fidl::endpoints::Responder for SourceSetRoleResponder {
1018    type ControlHandle = SourceControlHandle;
1019
1020    fn control_handle(&self) -> &SourceControlHandle {
1021        &self.control_handle
1022    }
1023
1024    fn drop_without_shutdown(mut self) {
1025        // Safety: drops once, never accessed again due to mem::forget
1026        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1027        // Prevent Drop from running (which would shut down the channel)
1028        std::mem::forget(self);
1029    }
1030}
1031
1032impl SourceSetRoleResponder {
1033    /// Sends a response to the FIDL transaction.
1034    ///
1035    /// Sets the channel to shutdown if an error occurs.
1036    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1037        let _result = self.send_raw(result);
1038        if _result.is_err() {
1039            self.control_handle.shutdown();
1040        }
1041        self.drop_without_shutdown();
1042        _result
1043    }
1044
1045    /// Similar to "send" but does not shutdown the channel if an error occurs.
1046    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1047        let _result = self.send_raw(result);
1048        self.drop_without_shutdown();
1049        _result
1050    }
1051
1052    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
1053        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1054            fidl::encoding::EmptyStruct,
1055            Error,
1056        >>(
1057            fidl::encoding::FlexibleResult::new(result),
1058            self.tx_id,
1059            0x2a0b0990da5f4ae1,
1060            fidl::encoding::DynamicFlags::FLEXIBLE,
1061        )
1062    }
1063}
1064
1065#[must_use = "FIDL methods require a response to be sent"]
1066#[derive(Debug)]
1067pub struct SourceWatchResponder {
1068    control_handle: std::mem::ManuallyDrop<SourceControlHandle>,
1069    tx_id: u32,
1070}
1071
1072/// Set the the channel to be shutdown (see [`SourceControlHandle::shutdown`])
1073/// if the responder is dropped without sending a response, so that the client
1074/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1075impl std::ops::Drop for SourceWatchResponder {
1076    fn drop(&mut self) {
1077        self.control_handle.shutdown();
1078        // Safety: drops once, never accessed again
1079        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1080    }
1081}
1082
1083impl fidl::endpoints::Responder for SourceWatchResponder {
1084    type ControlHandle = SourceControlHandle;
1085
1086    fn control_handle(&self) -> &SourceControlHandle {
1087        &self.control_handle
1088    }
1089
1090    fn drop_without_shutdown(mut self) {
1091        // Safety: drops once, never accessed again due to mem::forget
1092        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1093        // Prevent Drop from running (which would shut down the channel)
1094        std::mem::forget(self);
1095    }
1096}
1097
1098impl SourceWatchResponder {
1099    /// Sends a response to the FIDL transaction.
1100    ///
1101    /// Sets the channel to shutdown if an error occurs.
1102    pub fn send(
1103        self,
1104        mut status: &Status,
1105        mut wake_lease: Option<fidl::EventPair>,
1106    ) -> Result<(), fidl::Error> {
1107        let _result = self.send_raw(status, wake_lease);
1108        if _result.is_err() {
1109            self.control_handle.shutdown();
1110        }
1111        self.drop_without_shutdown();
1112        _result
1113    }
1114
1115    /// Similar to "send" but does not shutdown the channel if an error occurs.
1116    pub fn send_no_shutdown_on_err(
1117        self,
1118        mut status: &Status,
1119        mut wake_lease: Option<fidl::EventPair>,
1120    ) -> Result<(), fidl::Error> {
1121        let _result = self.send_raw(status, wake_lease);
1122        self.drop_without_shutdown();
1123        _result
1124    }
1125
1126    fn send_raw(
1127        &self,
1128        mut status: &Status,
1129        mut wake_lease: Option<fidl::EventPair>,
1130    ) -> Result<(), fidl::Error> {
1131        self.control_handle.inner.send::<fidl::encoding::FlexibleType<SourceWatchResponse>>(
1132            fidl::encoding::Flexible::new((status, wake_lease)),
1133            self.tx_id,
1134            0x15f6187735c58e1,
1135            fidl::encoding::DynamicFlags::FLEXIBLE,
1136        )
1137    }
1138}
1139
1140#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1141pub struct ServiceMarker;
1142
1143#[cfg(target_os = "fuchsia")]
1144impl fidl::endpoints::ServiceMarker for ServiceMarker {
1145    type Proxy = ServiceProxy;
1146    type Request = ServiceRequest;
1147    const SERVICE_NAME: &'static str = "fuchsia.hardware.power.source.Service";
1148}
1149
1150/// A request for one of the member protocols of Service.
1151///
1152#[cfg(target_os = "fuchsia")]
1153pub enum ServiceRequest {
1154    Source(SourceRequestStream),
1155}
1156
1157#[cfg(target_os = "fuchsia")]
1158impl fidl::endpoints::ServiceRequest for ServiceRequest {
1159    type Service = ServiceMarker;
1160
1161    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1162        match name {
1163            "source" => Self::Source(
1164                <SourceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1165            ),
1166            _ => panic!("no such member protocol name for service Service"),
1167        }
1168    }
1169
1170    fn member_names() -> &'static [&'static str] {
1171        &["source"]
1172    }
1173}
1174#[cfg(target_os = "fuchsia")]
1175pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1176
1177#[cfg(target_os = "fuchsia")]
1178impl fidl::endpoints::ServiceProxy for ServiceProxy {
1179    type Service = ServiceMarker;
1180
1181    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1182        Self(opener)
1183    }
1184}
1185
1186#[cfg(target_os = "fuchsia")]
1187impl ServiceProxy {
1188    pub fn connect_to_source(&self) -> Result<SourceProxy, fidl::Error> {
1189        let (proxy, server_end) = fidl::endpoints::create_proxy::<SourceMarker>();
1190        self.connect_channel_to_source(server_end)?;
1191        Ok(proxy)
1192    }
1193
1194    /// Like `connect_to_source`, but returns a sync proxy.
1195    /// See [`Self::connect_to_source`] for more details.
1196    pub fn connect_to_source_sync(&self) -> Result<SourceSynchronousProxy, fidl::Error> {
1197        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<SourceMarker>();
1198        self.connect_channel_to_source(server_end)?;
1199        Ok(proxy)
1200    }
1201
1202    /// Like `connect_to_source`, but accepts a server end.
1203    /// See [`Self::connect_to_source`] for more details.
1204    pub fn connect_channel_to_source(
1205        &self,
1206        server_end: fidl::endpoints::ServerEnd<SourceMarker>,
1207    ) -> Result<(), fidl::Error> {
1208        self.0.open_member("source", server_end.into_channel())
1209    }
1210
1211    pub fn instance_name(&self) -> &str {
1212        self.0.instance_name()
1213    }
1214}
1215
1216mod internal {
1217    use super::*;
1218
1219    impl fidl::encoding::ResourceTypeMarker for SourceWatchRequest {
1220        type Borrowed<'a> = &'a mut Self;
1221        fn take_or_borrow<'a>(
1222            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1223        ) -> Self::Borrowed<'a> {
1224            value
1225        }
1226    }
1227
1228    unsafe impl fidl::encoding::TypeMarker for SourceWatchRequest {
1229        type Owned = Self;
1230
1231        #[inline(always)]
1232        fn inline_align(_context: fidl::encoding::Context) -> usize {
1233            8
1234        }
1235
1236        #[inline(always)]
1237        fn inline_size(_context: fidl::encoding::Context) -> usize {
1238            40
1239        }
1240    }
1241
1242    unsafe impl
1243        fidl::encoding::Encode<SourceWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1244        for &mut SourceWatchRequest
1245    {
1246        #[inline]
1247        unsafe fn encode(
1248            self,
1249            encoder: &mut fidl::encoding::Encoder<
1250                '_,
1251                fidl::encoding::DefaultFuchsiaResourceDialect,
1252            >,
1253            offset: usize,
1254            _depth: fidl::encoding::Depth,
1255        ) -> fidl::Result<()> {
1256            encoder.debug_check_bounds::<SourceWatchRequest>(offset);
1257            // Delegate to tuple encoding.
1258            fidl::encoding::Encode::<
1259                SourceWatchRequest,
1260                fidl::encoding::DefaultFuchsiaResourceDialect,
1261            >::encode(
1262                (
1263                    <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.interest),
1264                    <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.wake_on),
1265                    <fidl::encoding::Optional<
1266                        fidl::encoding::HandleType<
1267                            fidl::EventPair,
1268                            { fidl::ObjectType::EVENTPAIR.into_raw() },
1269                            16387,
1270                        >,
1271                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1272                        &mut self.lease
1273                    ),
1274                ),
1275                encoder,
1276                offset,
1277                _depth,
1278            )
1279        }
1280    }
1281    unsafe impl<
1282        T0: fidl::encoding::Encode<Status, fidl::encoding::DefaultFuchsiaResourceDialect>,
1283        T1: fidl::encoding::Encode<Status, fidl::encoding::DefaultFuchsiaResourceDialect>,
1284        T2: fidl::encoding::Encode<
1285                fidl::encoding::Optional<
1286                    fidl::encoding::HandleType<
1287                        fidl::EventPair,
1288                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1289                        16387,
1290                    >,
1291                >,
1292                fidl::encoding::DefaultFuchsiaResourceDialect,
1293            >,
1294    > fidl::encoding::Encode<SourceWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
1295        for (T0, T1, T2)
1296    {
1297        #[inline]
1298        unsafe fn encode(
1299            self,
1300            encoder: &mut fidl::encoding::Encoder<
1301                '_,
1302                fidl::encoding::DefaultFuchsiaResourceDialect,
1303            >,
1304            offset: usize,
1305            depth: fidl::encoding::Depth,
1306        ) -> fidl::Result<()> {
1307            encoder.debug_check_bounds::<SourceWatchRequest>(offset);
1308            // Zero out padding regions. There's no need to apply masks
1309            // because the unmasked parts will be overwritten by fields.
1310            unsafe {
1311                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1312                (ptr as *mut u64).write_unaligned(0);
1313            }
1314            // Write the fields.
1315            self.0.encode(encoder, offset + 0, depth)?;
1316            self.1.encode(encoder, offset + 16, depth)?;
1317            self.2.encode(encoder, offset + 32, depth)?;
1318            Ok(())
1319        }
1320    }
1321
1322    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1323        for SourceWatchRequest
1324    {
1325        #[inline(always)]
1326        fn new_empty() -> Self {
1327            Self {
1328                interest: fidl::new_empty!(Status, fidl::encoding::DefaultFuchsiaResourceDialect),
1329                wake_on: fidl::new_empty!(Status, fidl::encoding::DefaultFuchsiaResourceDialect),
1330                lease: fidl::new_empty!(
1331                    fidl::encoding::Optional<
1332                        fidl::encoding::HandleType<
1333                            fidl::EventPair,
1334                            { fidl::ObjectType::EVENTPAIR.into_raw() },
1335                            16387,
1336                        >,
1337                    >,
1338                    fidl::encoding::DefaultFuchsiaResourceDialect
1339                ),
1340            }
1341        }
1342
1343        #[inline]
1344        unsafe fn decode(
1345            &mut self,
1346            decoder: &mut fidl::encoding::Decoder<
1347                '_,
1348                fidl::encoding::DefaultFuchsiaResourceDialect,
1349            >,
1350            offset: usize,
1351            _depth: fidl::encoding::Depth,
1352        ) -> fidl::Result<()> {
1353            decoder.debug_check_bounds::<Self>(offset);
1354            // Verify that padding bytes are zero.
1355            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1356            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1357            let mask = 0xffffffff00000000u64;
1358            let maskedval = padval & mask;
1359            if maskedval != 0 {
1360                return Err(fidl::Error::NonZeroPadding {
1361                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1362                });
1363            }
1364            fidl::decode!(
1365                Status,
1366                fidl::encoding::DefaultFuchsiaResourceDialect,
1367                &mut self.interest,
1368                decoder,
1369                offset + 0,
1370                _depth
1371            )?;
1372            fidl::decode!(
1373                Status,
1374                fidl::encoding::DefaultFuchsiaResourceDialect,
1375                &mut self.wake_on,
1376                decoder,
1377                offset + 16,
1378                _depth
1379            )?;
1380            fidl::decode!(
1381                fidl::encoding::Optional<
1382                    fidl::encoding::HandleType<
1383                        fidl::EventPair,
1384                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1385                        16387,
1386                    >,
1387                >,
1388                fidl::encoding::DefaultFuchsiaResourceDialect,
1389                &mut self.lease,
1390                decoder,
1391                offset + 32,
1392                _depth
1393            )?;
1394            Ok(())
1395        }
1396    }
1397
1398    impl fidl::encoding::ResourceTypeMarker for SourceWatchResponse {
1399        type Borrowed<'a> = &'a mut Self;
1400        fn take_or_borrow<'a>(
1401            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1402        ) -> Self::Borrowed<'a> {
1403            value
1404        }
1405    }
1406
1407    unsafe impl fidl::encoding::TypeMarker for SourceWatchResponse {
1408        type Owned = Self;
1409
1410        #[inline(always)]
1411        fn inline_align(_context: fidl::encoding::Context) -> usize {
1412            8
1413        }
1414
1415        #[inline(always)]
1416        fn inline_size(_context: fidl::encoding::Context) -> usize {
1417            24
1418        }
1419    }
1420
1421    unsafe impl
1422        fidl::encoding::Encode<SourceWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1423        for &mut SourceWatchResponse
1424    {
1425        #[inline]
1426        unsafe fn encode(
1427            self,
1428            encoder: &mut fidl::encoding::Encoder<
1429                '_,
1430                fidl::encoding::DefaultFuchsiaResourceDialect,
1431            >,
1432            offset: usize,
1433            _depth: fidl::encoding::Depth,
1434        ) -> fidl::Result<()> {
1435            encoder.debug_check_bounds::<SourceWatchResponse>(offset);
1436            // Delegate to tuple encoding.
1437            fidl::encoding::Encode::<
1438                SourceWatchResponse,
1439                fidl::encoding::DefaultFuchsiaResourceDialect,
1440            >::encode(
1441                (
1442                    <Status as fidl::encoding::ValueTypeMarker>::borrow(&self.status),
1443                    <fidl::encoding::Optional<
1444                        fidl::encoding::HandleType<
1445                            fidl::EventPair,
1446                            { fidl::ObjectType::EVENTPAIR.into_raw() },
1447                            16387,
1448                        >,
1449                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1450                        &mut self.wake_lease
1451                    ),
1452                ),
1453                encoder,
1454                offset,
1455                _depth,
1456            )
1457        }
1458    }
1459    unsafe impl<
1460        T0: fidl::encoding::Encode<Status, fidl::encoding::DefaultFuchsiaResourceDialect>,
1461        T1: fidl::encoding::Encode<
1462                fidl::encoding::Optional<
1463                    fidl::encoding::HandleType<
1464                        fidl::EventPair,
1465                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1466                        16387,
1467                    >,
1468                >,
1469                fidl::encoding::DefaultFuchsiaResourceDialect,
1470            >,
1471    > fidl::encoding::Encode<SourceWatchResponse, fidl::encoding::DefaultFuchsiaResourceDialect>
1472        for (T0, T1)
1473    {
1474        #[inline]
1475        unsafe fn encode(
1476            self,
1477            encoder: &mut fidl::encoding::Encoder<
1478                '_,
1479                fidl::encoding::DefaultFuchsiaResourceDialect,
1480            >,
1481            offset: usize,
1482            depth: fidl::encoding::Depth,
1483        ) -> fidl::Result<()> {
1484            encoder.debug_check_bounds::<SourceWatchResponse>(offset);
1485            // Zero out padding regions. There's no need to apply masks
1486            // because the unmasked parts will be overwritten by fields.
1487            unsafe {
1488                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1489                (ptr as *mut u64).write_unaligned(0);
1490            }
1491            // Write the fields.
1492            self.0.encode(encoder, offset + 0, depth)?;
1493            self.1.encode(encoder, offset + 16, depth)?;
1494            Ok(())
1495        }
1496    }
1497
1498    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1499        for SourceWatchResponse
1500    {
1501        #[inline(always)]
1502        fn new_empty() -> Self {
1503            Self {
1504                status: fidl::new_empty!(Status, fidl::encoding::DefaultFuchsiaResourceDialect),
1505                wake_lease: fidl::new_empty!(
1506                    fidl::encoding::Optional<
1507                        fidl::encoding::HandleType<
1508                            fidl::EventPair,
1509                            { fidl::ObjectType::EVENTPAIR.into_raw() },
1510                            16387,
1511                        >,
1512                    >,
1513                    fidl::encoding::DefaultFuchsiaResourceDialect
1514                ),
1515            }
1516        }
1517
1518        #[inline]
1519        unsafe fn decode(
1520            &mut self,
1521            decoder: &mut fidl::encoding::Decoder<
1522                '_,
1523                fidl::encoding::DefaultFuchsiaResourceDialect,
1524            >,
1525            offset: usize,
1526            _depth: fidl::encoding::Depth,
1527        ) -> fidl::Result<()> {
1528            decoder.debug_check_bounds::<Self>(offset);
1529            // Verify that padding bytes are zero.
1530            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1531            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1532            let mask = 0xffffffff00000000u64;
1533            let maskedval = padval & mask;
1534            if maskedval != 0 {
1535                return Err(fidl::Error::NonZeroPadding {
1536                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1537                });
1538            }
1539            fidl::decode!(
1540                Status,
1541                fidl::encoding::DefaultFuchsiaResourceDialect,
1542                &mut self.status,
1543                decoder,
1544                offset + 0,
1545                _depth
1546            )?;
1547            fidl::decode!(
1548                fidl::encoding::Optional<
1549                    fidl::encoding::HandleType<
1550                        fidl::EventPair,
1551                        { fidl::ObjectType::EVENTPAIR.into_raw() },
1552                        16387,
1553                    >,
1554                >,
1555                fidl::encoding::DefaultFuchsiaResourceDialect,
1556                &mut self.wake_lease,
1557                decoder,
1558                offset + 16,
1559                _depth
1560            )?;
1561            Ok(())
1562        }
1563    }
1564}