fidl_fuchsia_power_system/
fidl_fuchsia_power_system.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_power_system__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14pub type LeaseToken = fidl::EventPair;
15
16#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
17pub struct ActivityGovernorAcquireWakeLeaseResponse {
18    /// The token that blocks hardware platform suspension.
19    pub token: fidl::EventPair,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23    for ActivityGovernorAcquireWakeLeaseResponse
24{
25}
26
27#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
28pub struct ActivityGovernorRegisterSuspendBlockerResponse {
29    /// The token that blocks hardware platform suspension.
30    pub token: fidl::EventPair,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for ActivityGovernorRegisterSuspendBlockerResponse
35{
36}
37
38#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
39pub struct ActivityGovernorTakeApplicationActivityLeaseResponse {
40    /// The token that blocks application activity from dropping below the
41    /// 'Active' state.
42    pub token: fidl::EventPair,
43}
44
45impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
46    for ActivityGovernorTakeApplicationActivityLeaseResponse
47{
48}
49
50#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
51pub struct ActivityGovernorTakeWakeLeaseResponse {
52    /// The token that blocks hardware platform suspension.
53    pub token: fidl::EventPair,
54}
55
56impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
57    for ActivityGovernorTakeWakeLeaseResponse
58{
59}
60
61#[derive(Debug, Default, PartialEq)]
62pub struct ActivityGovernorRegisterListenerRequest {
63    /// The client end of the service that receives activity governor events.
64    ///
65    /// Required.
66    pub listener: Option<fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>>,
67    #[doc(hidden)]
68    pub __source_breaking: fidl::marker::SourceBreaking,
69}
70
71impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
72    for ActivityGovernorRegisterListenerRequest
73{
74}
75
76#[derive(Debug, Default, PartialEq)]
77pub struct ActivityGovernorRegisterSuspendBlockerRequest {
78    /// The client end of the SuspendBlocker service.
79    ///
80    /// Required.
81    pub suspend_blocker: Option<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
82    /// The name of the suspend blocker.
83    ///
84    /// Required.
85    ///
86    /// The name cannot be empty but is not required to be globally unique.
87    pub name: Option<String>,
88    #[doc(hidden)]
89    pub __source_breaking: fidl::marker::SourceBreaking,
90}
91
92impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
93    for ActivityGovernorRegisterSuspendBlockerRequest
94{
95}
96
97/// Holds tokens to the application activity power element.
98///
99/// [`fuchsia.power.system/ApplicationActivityLevel`] defines the power levels supported by this power element.
100#[derive(Debug, Default, PartialEq)]
101pub struct ApplicationActivity {
102    pub assertive_dependency_token: Option<fidl::Event>,
103    #[doc(hidden)]
104    pub __source_breaking: fidl::marker::SourceBreaking,
105}
106
107impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ApplicationActivity {}
108
109/// Holds tokens to the CPU power element.
110///
111/// [`fuchsia.power.system/CpuLevel`] defines the power levels supported by this power element.
112#[derive(Debug, Default, PartialEq)]
113pub struct Cpu {
114    pub assertive_dependency_token: Option<fidl::Event>,
115    #[doc(hidden)]
116    pub __source_breaking: fidl::marker::SourceBreaking,
117}
118
119impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {}
120
121#[derive(Debug, Default, PartialEq)]
122pub struct CpuElementManagerAddExecutionStateDependencyRequest {
123    /// The assertive dependency token representing the target power element
124    /// of the dependency.
125    /// Required.
126    pub dependency_token: Option<fidl::Event>,
127    /// The power level of the target power element.
128    /// Required.
129    pub power_level: Option<u8>,
130    #[doc(hidden)]
131    pub __source_breaking: fidl::marker::SourceBreaking,
132}
133
134impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
135    for CpuElementManagerAddExecutionStateDependencyRequest
136{
137}
138
139/// Holds a token to the execution state power element.
140///
141/// Power elements intentionally cannot take assertive dependencies on this power
142/// element. Elements that need to force the execution state to ACTIVE can use
143/// ApplicationActivity which provides more semantic meaning to the
144/// dependencies.
145///
146/// [`fuchsia.power.system/ExecutionStateLevel`] defines the power levels supported by this power element.
147#[derive(Debug, Default, PartialEq)]
148pub struct ExecutionState {
149    pub opportunistic_dependency_token: Option<fidl::Event>,
150    #[doc(hidden)]
151    pub __source_breaking: fidl::marker::SourceBreaking,
152}
153
154impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ExecutionState {}
155
156/// A collection of power elements that are managed by the activity governor.
157#[derive(Debug, Default, PartialEq)]
158pub struct PowerElements {
159    pub execution_state: Option<ExecutionState>,
160    pub application_activity: Option<ApplicationActivity>,
161    #[doc(hidden)]
162    pub __source_breaking: fidl::marker::SourceBreaking,
163}
164
165impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {}
166
167#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
168pub struct ActivityGovernorMarker;
169
170impl fidl::endpoints::ProtocolMarker for ActivityGovernorMarker {
171    type Proxy = ActivityGovernorProxy;
172    type RequestStream = ActivityGovernorRequestStream;
173    #[cfg(target_os = "fuchsia")]
174    type SynchronousProxy = ActivityGovernorSynchronousProxy;
175
176    const DEBUG_NAME: &'static str = "fuchsia.power.system.ActivityGovernor";
177}
178impl fidl::endpoints::DiscoverableProtocolMarker for ActivityGovernorMarker {}
179pub type ActivityGovernorAcquireWakeLeaseResult = Result<fidl::EventPair, AcquireWakeLeaseError>;
180pub type ActivityGovernorRegisterSuspendBlockerResult =
181    Result<fidl::EventPair, RegisterSuspendBlockerError>;
182
183pub trait ActivityGovernorProxyInterface: Send + Sync {
184    type GetPowerElementsResponseFut: std::future::Future<Output = Result<PowerElements, fidl::Error>>
185        + Send;
186    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut;
187    type TakeWakeLeaseResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
188        + Send;
189    fn r#take_wake_lease(&self, name: &str) -> Self::TakeWakeLeaseResponseFut;
190    type AcquireWakeLeaseResponseFut: std::future::Future<Output = Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error>>
191        + Send;
192    fn r#acquire_wake_lease(&self, name: &str) -> Self::AcquireWakeLeaseResponseFut;
193    type TakeApplicationActivityLeaseResponseFut: std::future::Future<Output = Result<fidl::EventPair, fidl::Error>>
194        + Send;
195    fn r#take_application_activity_lease(
196        &self,
197        name: &str,
198    ) -> Self::TakeApplicationActivityLeaseResponseFut;
199    type RegisterListenerResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
200    fn r#register_listener(
201        &self,
202        payload: ActivityGovernorRegisterListenerRequest,
203    ) -> Self::RegisterListenerResponseFut;
204    type RegisterSuspendBlockerResponseFut: std::future::Future<
205            Output = Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error>,
206        > + Send;
207    fn r#register_suspend_blocker(
208        &self,
209        payload: ActivityGovernorRegisterSuspendBlockerRequest,
210    ) -> Self::RegisterSuspendBlockerResponseFut;
211}
212#[derive(Debug)]
213#[cfg(target_os = "fuchsia")]
214pub struct ActivityGovernorSynchronousProxy {
215    client: fidl::client::sync::Client,
216}
217
218#[cfg(target_os = "fuchsia")]
219impl fidl::endpoints::SynchronousProxy for ActivityGovernorSynchronousProxy {
220    type Proxy = ActivityGovernorProxy;
221    type Protocol = ActivityGovernorMarker;
222
223    fn from_channel(inner: fidl::Channel) -> Self {
224        Self::new(inner)
225    }
226
227    fn into_channel(self) -> fidl::Channel {
228        self.client.into_channel()
229    }
230
231    fn as_channel(&self) -> &fidl::Channel {
232        self.client.as_channel()
233    }
234}
235
236#[cfg(target_os = "fuchsia")]
237impl ActivityGovernorSynchronousProxy {
238    pub fn new(channel: fidl::Channel) -> Self {
239        let protocol_name = <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
240        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
241    }
242
243    pub fn into_channel(self) -> fidl::Channel {
244        self.client.into_channel()
245    }
246
247    /// Waits until an event arrives and returns it. It is safe for other
248    /// threads to make concurrent requests while waiting for an event.
249    pub fn wait_for_event(
250        &self,
251        deadline: zx::MonotonicInstant,
252    ) -> Result<ActivityGovernorEvent, fidl::Error> {
253        ActivityGovernorEvent::decode(self.client.wait_for_event(deadline)?)
254    }
255
256    /// Gets the power elements owned by the activity governor.
257    ///
258    /// If an error occurs while the server is registering a power element with
259    /// the power broker or an error occurs while creating a token for a power
260    /// element, then the channel to `ActivityGovernor` will be closed by the
261    /// server and no response will be returned.
262    pub fn r#get_power_elements(
263        &self,
264        ___deadline: zx::MonotonicInstant,
265    ) -> Result<PowerElements, fidl::Error> {
266        let _response = self.client.send_query::<
267            fidl::encoding::EmptyPayload,
268            fidl::encoding::FlexibleType<PowerElements>,
269        >(
270            (),
271            0x798003259dfb5672,
272            fidl::encoding::DynamicFlags::FLEXIBLE,
273            ___deadline,
274        )?
275        .into_result::<ActivityGovernorMarker>("get_power_elements")?;
276        Ok(_response)
277    }
278
279    /// Creates a lease that blocks suspension of the hardware platform.
280    ///
281    /// The hardware platform will not suspend as long as a valid
282    /// [`LeaseToken`] exists.
283    ///
284    /// If an error occurs while creating a token for the wake lease, then the
285    /// channel to `ActivityGovernor` will be closed by the server and no
286    /// response will be returned.
287    pub fn r#take_wake_lease(
288        &self,
289        mut name: &str,
290        ___deadline: zx::MonotonicInstant,
291    ) -> Result<fidl::EventPair, fidl::Error> {
292        let _response = self.client.send_query::<
293            ActivityGovernorTakeWakeLeaseRequest,
294            fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>,
295        >(
296            (name,),
297            0x291cfb42b2d3bf69,
298            fidl::encoding::DynamicFlags::FLEXIBLE,
299            ___deadline,
300        )?
301        .into_result::<ActivityGovernorMarker>("take_wake_lease")?;
302        Ok(_response.token)
303    }
304
305    /// Creates a lease that blocks suspension of the hardware platform.
306    ///
307    /// The hardware platform will not suspend as long as a valid
308    /// [`LeaseToken`] exists.
309    pub fn r#acquire_wake_lease(
310        &self,
311        mut name: &str,
312        ___deadline: zx::MonotonicInstant,
313    ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
314        let _response = self.client.send_query::<
315            ActivityGovernorAcquireWakeLeaseRequest,
316            fidl::encoding::FlexibleResultType<ActivityGovernorAcquireWakeLeaseResponse, AcquireWakeLeaseError>,
317        >(
318            (name,),
319            0x2de25abd8fa7c103,
320            fidl::encoding::DynamicFlags::FLEXIBLE,
321            ___deadline,
322        )?
323        .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
324        Ok(_response.map(|x| x.token))
325    }
326
327    /// Creates a lease that blocks the system from dropping below the Application
328    /// Activity 'Active' state. In particular, this blocks suspension of the
329    /// hardware platform.
330    ///
331    /// This method is _not_ safe to call during
332    /// ActivityGovernorListener.OnSuspendStarted.
333    ///
334    /// If an error occurs while creating a token for the activity lease, then the
335    /// channel to `ActivityGovernor` will be closed by the server and no
336    /// response will be returned.
337    pub fn r#take_application_activity_lease(
338        &self,
339        mut name: &str,
340        ___deadline: zx::MonotonicInstant,
341    ) -> Result<fidl::EventPair, fidl::Error> {
342        let _response = self.client.send_query::<
343            ActivityGovernorTakeApplicationActivityLeaseRequest,
344            fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
345        >(
346            (name,),
347            0x37cd5364de7ada14,
348            fidl::encoding::DynamicFlags::FLEXIBLE,
349            ___deadline,
350        )?
351        .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
352        Ok(_response.token)
353    }
354
355    /// Registers a listener for activity governor events.
356    ///
357    /// If there is an error in registering the listener, then the given
358    /// `ActivityGovernorListener` channel will be closed before the response
359    /// is sent.
360    ///
361    /// To unregister, close the `ActivityGovernorListener` channel.
362    pub fn r#register_listener(
363        &self,
364        mut payload: ActivityGovernorRegisterListenerRequest,
365        ___deadline: zx::MonotonicInstant,
366    ) -> Result<(), fidl::Error> {
367        let _response = self.client.send_query::<
368            ActivityGovernorRegisterListenerRequest,
369            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
370        >(
371            &mut payload,
372            0x836144d0722e5c1,
373            fidl::encoding::DynamicFlags::FLEXIBLE,
374            ___deadline,
375        )?
376        .into_result::<ActivityGovernorMarker>("register_listener")?;
377        Ok(_response)
378    }
379
380    /// Registers a suspend blocker.
381    ///
382    /// On successful registration, a wake lease token is returned. This token
383    /// prevents hardware platform suspension while it exists. Clients are
384    /// expected to perform any initialization of the given `suspend_blocker`
385    /// server while holding this token. Additionally, this means the first call
386    /// `suspend_blocker` will get is `BeforeSuspend`.
387    ///
388    /// To unregister, close the `SuspendBlocker` channel.
389    ///
390    /// If any required field of the table is missing, the error
391    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
392    ///
393    /// If an error occurs while registering `suspend_blocker`, it will be
394    /// dropped, closing the channel.
395    pub fn r#register_suspend_blocker(
396        &self,
397        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
398        ___deadline: zx::MonotonicInstant,
399    ) -> Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error> {
400        let _response = self.client.send_query::<
401            ActivityGovernorRegisterSuspendBlockerRequest,
402            fidl::encoding::FlexibleResultType<ActivityGovernorRegisterSuspendBlockerResponse, RegisterSuspendBlockerError>,
403        >(
404            &mut payload,
405            0x34ef55b180feef01,
406            fidl::encoding::DynamicFlags::FLEXIBLE,
407            ___deadline,
408        )?
409        .into_result::<ActivityGovernorMarker>("register_suspend_blocker")?;
410        Ok(_response.map(|x| x.token))
411    }
412}
413
414#[cfg(target_os = "fuchsia")]
415impl From<ActivityGovernorSynchronousProxy> for zx::Handle {
416    fn from(value: ActivityGovernorSynchronousProxy) -> Self {
417        value.into_channel().into()
418    }
419}
420
421#[cfg(target_os = "fuchsia")]
422impl From<fidl::Channel> for ActivityGovernorSynchronousProxy {
423    fn from(value: fidl::Channel) -> Self {
424        Self::new(value)
425    }
426}
427
428#[cfg(target_os = "fuchsia")]
429impl fidl::endpoints::FromClient for ActivityGovernorSynchronousProxy {
430    type Protocol = ActivityGovernorMarker;
431
432    fn from_client(value: fidl::endpoints::ClientEnd<ActivityGovernorMarker>) -> Self {
433        Self::new(value.into_channel())
434    }
435}
436
437#[derive(Debug, Clone)]
438pub struct ActivityGovernorProxy {
439    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
440}
441
442impl fidl::endpoints::Proxy for ActivityGovernorProxy {
443    type Protocol = ActivityGovernorMarker;
444
445    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
446        Self::new(inner)
447    }
448
449    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
450        self.client.into_channel().map_err(|client| Self { client })
451    }
452
453    fn as_channel(&self) -> &::fidl::AsyncChannel {
454        self.client.as_channel()
455    }
456}
457
458impl ActivityGovernorProxy {
459    /// Create a new Proxy for fuchsia.power.system/ActivityGovernor.
460    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
461        let protocol_name = <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
462        Self { client: fidl::client::Client::new(channel, protocol_name) }
463    }
464
465    /// Get a Stream of events from the remote end of the protocol.
466    ///
467    /// # Panics
468    ///
469    /// Panics if the event stream was already taken.
470    pub fn take_event_stream(&self) -> ActivityGovernorEventStream {
471        ActivityGovernorEventStream { event_receiver: self.client.take_event_receiver() }
472    }
473
474    /// Gets the power elements owned by the activity governor.
475    ///
476    /// If an error occurs while the server is registering a power element with
477    /// the power broker or an error occurs while creating a token for a power
478    /// element, then the channel to `ActivityGovernor` will be closed by the
479    /// server and no response will be returned.
480    pub fn r#get_power_elements(
481        &self,
482    ) -> fidl::client::QueryResponseFut<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
483    {
484        ActivityGovernorProxyInterface::r#get_power_elements(self)
485    }
486
487    /// Creates a lease that blocks suspension of the hardware platform.
488    ///
489    /// The hardware platform will not suspend as long as a valid
490    /// [`LeaseToken`] exists.
491    ///
492    /// If an error occurs while creating a token for the wake lease, then the
493    /// channel to `ActivityGovernor` will be closed by the server and no
494    /// response will be returned.
495    pub fn r#take_wake_lease(
496        &self,
497        mut name: &str,
498    ) -> fidl::client::QueryResponseFut<
499        fidl::EventPair,
500        fidl::encoding::DefaultFuchsiaResourceDialect,
501    > {
502        ActivityGovernorProxyInterface::r#take_wake_lease(self, name)
503    }
504
505    /// Creates a lease that blocks suspension of the hardware platform.
506    ///
507    /// The hardware platform will not suspend as long as a valid
508    /// [`LeaseToken`] exists.
509    pub fn r#acquire_wake_lease(
510        &self,
511        mut name: &str,
512    ) -> fidl::client::QueryResponseFut<
513        ActivityGovernorAcquireWakeLeaseResult,
514        fidl::encoding::DefaultFuchsiaResourceDialect,
515    > {
516        ActivityGovernorProxyInterface::r#acquire_wake_lease(self, name)
517    }
518
519    /// Creates a lease that blocks the system from dropping below the Application
520    /// Activity 'Active' state. In particular, this blocks suspension of the
521    /// hardware platform.
522    ///
523    /// This method is _not_ safe to call during
524    /// ActivityGovernorListener.OnSuspendStarted.
525    ///
526    /// If an error occurs while creating a token for the activity lease, then the
527    /// channel to `ActivityGovernor` will be closed by the server and no
528    /// response will be returned.
529    pub fn r#take_application_activity_lease(
530        &self,
531        mut name: &str,
532    ) -> fidl::client::QueryResponseFut<
533        fidl::EventPair,
534        fidl::encoding::DefaultFuchsiaResourceDialect,
535    > {
536        ActivityGovernorProxyInterface::r#take_application_activity_lease(self, name)
537    }
538
539    /// Registers a listener for activity governor events.
540    ///
541    /// If there is an error in registering the listener, then the given
542    /// `ActivityGovernorListener` channel will be closed before the response
543    /// is sent.
544    ///
545    /// To unregister, close the `ActivityGovernorListener` channel.
546    pub fn r#register_listener(
547        &self,
548        mut payload: ActivityGovernorRegisterListenerRequest,
549    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
550        ActivityGovernorProxyInterface::r#register_listener(self, payload)
551    }
552
553    /// Registers a suspend blocker.
554    ///
555    /// On successful registration, a wake lease token is returned. This token
556    /// prevents hardware platform suspension while it exists. Clients are
557    /// expected to perform any initialization of the given `suspend_blocker`
558    /// server while holding this token. Additionally, this means the first call
559    /// `suspend_blocker` will get is `BeforeSuspend`.
560    ///
561    /// To unregister, close the `SuspendBlocker` channel.
562    ///
563    /// If any required field of the table is missing, the error
564    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
565    ///
566    /// If an error occurs while registering `suspend_blocker`, it will be
567    /// dropped, closing the channel.
568    pub fn r#register_suspend_blocker(
569        &self,
570        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
571    ) -> fidl::client::QueryResponseFut<
572        ActivityGovernorRegisterSuspendBlockerResult,
573        fidl::encoding::DefaultFuchsiaResourceDialect,
574    > {
575        ActivityGovernorProxyInterface::r#register_suspend_blocker(self, payload)
576    }
577}
578
579impl ActivityGovernorProxyInterface for ActivityGovernorProxy {
580    type GetPowerElementsResponseFut = fidl::client::QueryResponseFut<
581        PowerElements,
582        fidl::encoding::DefaultFuchsiaResourceDialect,
583    >;
584    fn r#get_power_elements(&self) -> Self::GetPowerElementsResponseFut {
585        fn _decode(
586            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
587        ) -> Result<PowerElements, fidl::Error> {
588            let _response = fidl::client::decode_transaction_body::<
589                fidl::encoding::FlexibleType<PowerElements>,
590                fidl::encoding::DefaultFuchsiaResourceDialect,
591                0x798003259dfb5672,
592            >(_buf?)?
593            .into_result::<ActivityGovernorMarker>("get_power_elements")?;
594            Ok(_response)
595        }
596        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, PowerElements>(
597            (),
598            0x798003259dfb5672,
599            fidl::encoding::DynamicFlags::FLEXIBLE,
600            _decode,
601        )
602    }
603
604    type TakeWakeLeaseResponseFut = fidl::client::QueryResponseFut<
605        fidl::EventPair,
606        fidl::encoding::DefaultFuchsiaResourceDialect,
607    >;
608    fn r#take_wake_lease(&self, mut name: &str) -> Self::TakeWakeLeaseResponseFut {
609        fn _decode(
610            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
611        ) -> Result<fidl::EventPair, fidl::Error> {
612            let _response = fidl::client::decode_transaction_body::<
613                fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>,
614                fidl::encoding::DefaultFuchsiaResourceDialect,
615                0x291cfb42b2d3bf69,
616            >(_buf?)?
617            .into_result::<ActivityGovernorMarker>("take_wake_lease")?;
618            Ok(_response.token)
619        }
620        self.client.send_query_and_decode::<ActivityGovernorTakeWakeLeaseRequest, fidl::EventPair>(
621            (name,),
622            0x291cfb42b2d3bf69,
623            fidl::encoding::DynamicFlags::FLEXIBLE,
624            _decode,
625        )
626    }
627
628    type AcquireWakeLeaseResponseFut = fidl::client::QueryResponseFut<
629        ActivityGovernorAcquireWakeLeaseResult,
630        fidl::encoding::DefaultFuchsiaResourceDialect,
631    >;
632    fn r#acquire_wake_lease(&self, mut name: &str) -> Self::AcquireWakeLeaseResponseFut {
633        fn _decode(
634            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
635        ) -> Result<ActivityGovernorAcquireWakeLeaseResult, fidl::Error> {
636            let _response = fidl::client::decode_transaction_body::<
637                fidl::encoding::FlexibleResultType<
638                    ActivityGovernorAcquireWakeLeaseResponse,
639                    AcquireWakeLeaseError,
640                >,
641                fidl::encoding::DefaultFuchsiaResourceDialect,
642                0x2de25abd8fa7c103,
643            >(_buf?)?
644            .into_result::<ActivityGovernorMarker>("acquire_wake_lease")?;
645            Ok(_response.map(|x| x.token))
646        }
647        self.client.send_query_and_decode::<
648            ActivityGovernorAcquireWakeLeaseRequest,
649            ActivityGovernorAcquireWakeLeaseResult,
650        >(
651            (name,),
652            0x2de25abd8fa7c103,
653            fidl::encoding::DynamicFlags::FLEXIBLE,
654            _decode,
655        )
656    }
657
658    type TakeApplicationActivityLeaseResponseFut = fidl::client::QueryResponseFut<
659        fidl::EventPair,
660        fidl::encoding::DefaultFuchsiaResourceDialect,
661    >;
662    fn r#take_application_activity_lease(
663        &self,
664        mut name: &str,
665    ) -> Self::TakeApplicationActivityLeaseResponseFut {
666        fn _decode(
667            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
668        ) -> Result<fidl::EventPair, fidl::Error> {
669            let _response = fidl::client::decode_transaction_body::<
670                fidl::encoding::FlexibleType<ActivityGovernorTakeApplicationActivityLeaseResponse>,
671                fidl::encoding::DefaultFuchsiaResourceDialect,
672                0x37cd5364de7ada14,
673            >(_buf?)?
674            .into_result::<ActivityGovernorMarker>("take_application_activity_lease")?;
675            Ok(_response.token)
676        }
677        self.client.send_query_and_decode::<
678            ActivityGovernorTakeApplicationActivityLeaseRequest,
679            fidl::EventPair,
680        >(
681            (name,),
682            0x37cd5364de7ada14,
683            fidl::encoding::DynamicFlags::FLEXIBLE,
684            _decode,
685        )
686    }
687
688    type RegisterListenerResponseFut =
689        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
690    fn r#register_listener(
691        &self,
692        mut payload: ActivityGovernorRegisterListenerRequest,
693    ) -> Self::RegisterListenerResponseFut {
694        fn _decode(
695            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
696        ) -> Result<(), fidl::Error> {
697            let _response = fidl::client::decode_transaction_body::<
698                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
699                fidl::encoding::DefaultFuchsiaResourceDialect,
700                0x836144d0722e5c1,
701            >(_buf?)?
702            .into_result::<ActivityGovernorMarker>("register_listener")?;
703            Ok(_response)
704        }
705        self.client.send_query_and_decode::<ActivityGovernorRegisterListenerRequest, ()>(
706            &mut payload,
707            0x836144d0722e5c1,
708            fidl::encoding::DynamicFlags::FLEXIBLE,
709            _decode,
710        )
711    }
712
713    type RegisterSuspendBlockerResponseFut = fidl::client::QueryResponseFut<
714        ActivityGovernorRegisterSuspendBlockerResult,
715        fidl::encoding::DefaultFuchsiaResourceDialect,
716    >;
717    fn r#register_suspend_blocker(
718        &self,
719        mut payload: ActivityGovernorRegisterSuspendBlockerRequest,
720    ) -> Self::RegisterSuspendBlockerResponseFut {
721        fn _decode(
722            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
723        ) -> Result<ActivityGovernorRegisterSuspendBlockerResult, fidl::Error> {
724            let _response = fidl::client::decode_transaction_body::<
725                fidl::encoding::FlexibleResultType<
726                    ActivityGovernorRegisterSuspendBlockerResponse,
727                    RegisterSuspendBlockerError,
728                >,
729                fidl::encoding::DefaultFuchsiaResourceDialect,
730                0x34ef55b180feef01,
731            >(_buf?)?
732            .into_result::<ActivityGovernorMarker>("register_suspend_blocker")?;
733            Ok(_response.map(|x| x.token))
734        }
735        self.client.send_query_and_decode::<
736            ActivityGovernorRegisterSuspendBlockerRequest,
737            ActivityGovernorRegisterSuspendBlockerResult,
738        >(
739            &mut payload,
740            0x34ef55b180feef01,
741            fidl::encoding::DynamicFlags::FLEXIBLE,
742            _decode,
743        )
744    }
745}
746
747pub struct ActivityGovernorEventStream {
748    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
749}
750
751impl std::marker::Unpin for ActivityGovernorEventStream {}
752
753impl futures::stream::FusedStream for ActivityGovernorEventStream {
754    fn is_terminated(&self) -> bool {
755        self.event_receiver.is_terminated()
756    }
757}
758
759impl futures::Stream for ActivityGovernorEventStream {
760    type Item = Result<ActivityGovernorEvent, fidl::Error>;
761
762    fn poll_next(
763        mut self: std::pin::Pin<&mut Self>,
764        cx: &mut std::task::Context<'_>,
765    ) -> std::task::Poll<Option<Self::Item>> {
766        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
767            &mut self.event_receiver,
768            cx
769        )?) {
770            Some(buf) => std::task::Poll::Ready(Some(ActivityGovernorEvent::decode(buf))),
771            None => std::task::Poll::Ready(None),
772        }
773    }
774}
775
776#[derive(Debug)]
777pub enum ActivityGovernorEvent {
778    #[non_exhaustive]
779    _UnknownEvent {
780        /// Ordinal of the event that was sent.
781        ordinal: u64,
782    },
783}
784
785impl ActivityGovernorEvent {
786    /// Decodes a message buffer as a [`ActivityGovernorEvent`].
787    fn decode(
788        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
789    ) -> Result<ActivityGovernorEvent, fidl::Error> {
790        let (bytes, _handles) = buf.split_mut();
791        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
792        debug_assert_eq!(tx_header.tx_id, 0);
793        match tx_header.ordinal {
794            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
795                Ok(ActivityGovernorEvent::_UnknownEvent { ordinal: tx_header.ordinal })
796            }
797            _ => Err(fidl::Error::UnknownOrdinal {
798                ordinal: tx_header.ordinal,
799                protocol_name:
800                    <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
801            }),
802        }
803    }
804}
805
806/// A Stream of incoming requests for fuchsia.power.system/ActivityGovernor.
807pub struct ActivityGovernorRequestStream {
808    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
809    is_terminated: bool,
810}
811
812impl std::marker::Unpin for ActivityGovernorRequestStream {}
813
814impl futures::stream::FusedStream for ActivityGovernorRequestStream {
815    fn is_terminated(&self) -> bool {
816        self.is_terminated
817    }
818}
819
820impl fidl::endpoints::RequestStream for ActivityGovernorRequestStream {
821    type Protocol = ActivityGovernorMarker;
822    type ControlHandle = ActivityGovernorControlHandle;
823
824    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
825        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
826    }
827
828    fn control_handle(&self) -> Self::ControlHandle {
829        ActivityGovernorControlHandle { inner: self.inner.clone() }
830    }
831
832    fn into_inner(
833        self,
834    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
835    {
836        (self.inner, self.is_terminated)
837    }
838
839    fn from_inner(
840        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
841        is_terminated: bool,
842    ) -> Self {
843        Self { inner, is_terminated }
844    }
845}
846
847impl futures::Stream for ActivityGovernorRequestStream {
848    type Item = Result<ActivityGovernorRequest, fidl::Error>;
849
850    fn poll_next(
851        mut self: std::pin::Pin<&mut Self>,
852        cx: &mut std::task::Context<'_>,
853    ) -> std::task::Poll<Option<Self::Item>> {
854        let this = &mut *self;
855        if this.inner.check_shutdown(cx) {
856            this.is_terminated = true;
857            return std::task::Poll::Ready(None);
858        }
859        if this.is_terminated {
860            panic!("polled ActivityGovernorRequestStream after completion");
861        }
862        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
863            |bytes, handles| {
864                match this.inner.channel().read_etc(cx, bytes, handles) {
865                    std::task::Poll::Ready(Ok(())) => {}
866                    std::task::Poll::Pending => return std::task::Poll::Pending,
867                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
868                        this.is_terminated = true;
869                        return std::task::Poll::Ready(None);
870                    }
871                    std::task::Poll::Ready(Err(e)) => {
872                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
873                            e.into(),
874                        ))))
875                    }
876                }
877
878                // A message has been received from the channel
879                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
880
881                std::task::Poll::Ready(Some(match header.ordinal {
882                    0x798003259dfb5672 => {
883                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
884                        let mut req = fidl::new_empty!(
885                            fidl::encoding::EmptyPayload,
886                            fidl::encoding::DefaultFuchsiaResourceDialect
887                        );
888                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
889                        let control_handle =
890                            ActivityGovernorControlHandle { inner: this.inner.clone() };
891                        Ok(ActivityGovernorRequest::GetPowerElements {
892                            responder: ActivityGovernorGetPowerElementsResponder {
893                                control_handle: std::mem::ManuallyDrop::new(control_handle),
894                                tx_id: header.tx_id,
895                            },
896                        })
897                    }
898                    0x291cfb42b2d3bf69 => {
899                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
900                        let mut req = fidl::new_empty!(
901                            ActivityGovernorTakeWakeLeaseRequest,
902                            fidl::encoding::DefaultFuchsiaResourceDialect
903                        );
904                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorTakeWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
905                        let control_handle =
906                            ActivityGovernorControlHandle { inner: this.inner.clone() };
907                        Ok(ActivityGovernorRequest::TakeWakeLease {
908                            name: req.name,
909
910                            responder: ActivityGovernorTakeWakeLeaseResponder {
911                                control_handle: std::mem::ManuallyDrop::new(control_handle),
912                                tx_id: header.tx_id,
913                            },
914                        })
915                    }
916                    0x2de25abd8fa7c103 => {
917                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
918                        let mut req = fidl::new_empty!(
919                            ActivityGovernorAcquireWakeLeaseRequest,
920                            fidl::encoding::DefaultFuchsiaResourceDialect
921                        );
922                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorAcquireWakeLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
923                        let control_handle =
924                            ActivityGovernorControlHandle { inner: this.inner.clone() };
925                        Ok(ActivityGovernorRequest::AcquireWakeLease {
926                            name: req.name,
927
928                            responder: ActivityGovernorAcquireWakeLeaseResponder {
929                                control_handle: std::mem::ManuallyDrop::new(control_handle),
930                                tx_id: header.tx_id,
931                            },
932                        })
933                    }
934                    0x37cd5364de7ada14 => {
935                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
936                        let mut req = fidl::new_empty!(
937                            ActivityGovernorTakeApplicationActivityLeaseRequest,
938                            fidl::encoding::DefaultFuchsiaResourceDialect
939                        );
940                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorTakeApplicationActivityLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
941                        let control_handle =
942                            ActivityGovernorControlHandle { inner: this.inner.clone() };
943                        Ok(ActivityGovernorRequest::TakeApplicationActivityLease {
944                            name: req.name,
945
946                            responder: ActivityGovernorTakeApplicationActivityLeaseResponder {
947                                control_handle: std::mem::ManuallyDrop::new(control_handle),
948                                tx_id: header.tx_id,
949                            },
950                        })
951                    }
952                    0x836144d0722e5c1 => {
953                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
954                        let mut req = fidl::new_empty!(
955                            ActivityGovernorRegisterListenerRequest,
956                            fidl::encoding::DefaultFuchsiaResourceDialect
957                        );
958                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorRegisterListenerRequest>(&header, _body_bytes, handles, &mut req)?;
959                        let control_handle =
960                            ActivityGovernorControlHandle { inner: this.inner.clone() };
961                        Ok(ActivityGovernorRequest::RegisterListener {
962                            payload: req,
963                            responder: ActivityGovernorRegisterListenerResponder {
964                                control_handle: std::mem::ManuallyDrop::new(control_handle),
965                                tx_id: header.tx_id,
966                            },
967                        })
968                    }
969                    0x34ef55b180feef01 => {
970                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
971                        let mut req = fidl::new_empty!(
972                            ActivityGovernorRegisterSuspendBlockerRequest,
973                            fidl::encoding::DefaultFuchsiaResourceDialect
974                        );
975                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ActivityGovernorRegisterSuspendBlockerRequest>(&header, _body_bytes, handles, &mut req)?;
976                        let control_handle =
977                            ActivityGovernorControlHandle { inner: this.inner.clone() };
978                        Ok(ActivityGovernorRequest::RegisterSuspendBlocker {
979                            payload: req,
980                            responder: ActivityGovernorRegisterSuspendBlockerResponder {
981                                control_handle: std::mem::ManuallyDrop::new(control_handle),
982                                tx_id: header.tx_id,
983                            },
984                        })
985                    }
986                    _ if header.tx_id == 0
987                        && header
988                            .dynamic_flags()
989                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
990                    {
991                        Ok(ActivityGovernorRequest::_UnknownMethod {
992                            ordinal: header.ordinal,
993                            control_handle: ActivityGovernorControlHandle {
994                                inner: this.inner.clone(),
995                            },
996                            method_type: fidl::MethodType::OneWay,
997                        })
998                    }
999                    _ if header
1000                        .dynamic_flags()
1001                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1002                    {
1003                        this.inner.send_framework_err(
1004                            fidl::encoding::FrameworkErr::UnknownMethod,
1005                            header.tx_id,
1006                            header.ordinal,
1007                            header.dynamic_flags(),
1008                            (bytes, handles),
1009                        )?;
1010                        Ok(ActivityGovernorRequest::_UnknownMethod {
1011                            ordinal: header.ordinal,
1012                            control_handle: ActivityGovernorControlHandle {
1013                                inner: this.inner.clone(),
1014                            },
1015                            method_type: fidl::MethodType::TwoWay,
1016                        })
1017                    }
1018                    _ => Err(fidl::Error::UnknownOrdinal {
1019                        ordinal: header.ordinal,
1020                        protocol_name:
1021                            <ActivityGovernorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1022                    }),
1023                }))
1024            },
1025        )
1026    }
1027}
1028
1029/// A service for exposing events and power elements managed by the system
1030/// activity governor (SAG).
1031///
1032/// SAG is responsible for managing the execution state of the hardware
1033/// platform. The hardware platform consists of the components required to
1034/// execute code on the device. This typically includes the CPU, memory,
1035/// operating system, and other components required for these components to
1036/// function (clock trees, power domains, etc.).
1037#[derive(Debug)]
1038pub enum ActivityGovernorRequest {
1039    /// Gets the power elements owned by the activity governor.
1040    ///
1041    /// If an error occurs while the server is registering a power element with
1042    /// the power broker or an error occurs while creating a token for a power
1043    /// element, then the channel to `ActivityGovernor` will be closed by the
1044    /// server and no response will be returned.
1045    GetPowerElements { responder: ActivityGovernorGetPowerElementsResponder },
1046    /// Creates a lease that blocks suspension of the hardware platform.
1047    ///
1048    /// The hardware platform will not suspend as long as a valid
1049    /// [`LeaseToken`] exists.
1050    ///
1051    /// If an error occurs while creating a token for the wake lease, then the
1052    /// channel to `ActivityGovernor` will be closed by the server and no
1053    /// response will be returned.
1054    TakeWakeLease { name: String, responder: ActivityGovernorTakeWakeLeaseResponder },
1055    /// Creates a lease that blocks suspension of the hardware platform.
1056    ///
1057    /// The hardware platform will not suspend as long as a valid
1058    /// [`LeaseToken`] exists.
1059    AcquireWakeLease { name: String, responder: ActivityGovernorAcquireWakeLeaseResponder },
1060    /// Creates a lease that blocks the system from dropping below the Application
1061    /// Activity 'Active' state. In particular, this blocks suspension of the
1062    /// hardware platform.
1063    ///
1064    /// This method is _not_ safe to call during
1065    /// ActivityGovernorListener.OnSuspendStarted.
1066    ///
1067    /// If an error occurs while creating a token for the activity lease, then the
1068    /// channel to `ActivityGovernor` will be closed by the server and no
1069    /// response will be returned.
1070    TakeApplicationActivityLease {
1071        name: String,
1072        responder: ActivityGovernorTakeApplicationActivityLeaseResponder,
1073    },
1074    /// Registers a listener for activity governor events.
1075    ///
1076    /// If there is an error in registering the listener, then the given
1077    /// `ActivityGovernorListener` channel will be closed before the response
1078    /// is sent.
1079    ///
1080    /// To unregister, close the `ActivityGovernorListener` channel.
1081    RegisterListener {
1082        payload: ActivityGovernorRegisterListenerRequest,
1083        responder: ActivityGovernorRegisterListenerResponder,
1084    },
1085    /// Registers a suspend blocker.
1086    ///
1087    /// On successful registration, a wake lease token is returned. This token
1088    /// prevents hardware platform suspension while it exists. Clients are
1089    /// expected to perform any initialization of the given `suspend_blocker`
1090    /// server while holding this token. Additionally, this means the first call
1091    /// `suspend_blocker` will get is `BeforeSuspend`.
1092    ///
1093    /// To unregister, close the `SuspendBlocker` channel.
1094    ///
1095    /// If any required field of the table is missing, the error
1096    /// [`RegisterSuspendBlockerError.INVALID_ARGS`] is returned.
1097    ///
1098    /// If an error occurs while registering `suspend_blocker`, it will be
1099    /// dropped, closing the channel.
1100    RegisterSuspendBlocker {
1101        payload: ActivityGovernorRegisterSuspendBlockerRequest,
1102        responder: ActivityGovernorRegisterSuspendBlockerResponder,
1103    },
1104    /// An interaction was received which does not match any known method.
1105    #[non_exhaustive]
1106    _UnknownMethod {
1107        /// Ordinal of the method that was called.
1108        ordinal: u64,
1109        control_handle: ActivityGovernorControlHandle,
1110        method_type: fidl::MethodType,
1111    },
1112}
1113
1114impl ActivityGovernorRequest {
1115    #[allow(irrefutable_let_patterns)]
1116    pub fn into_get_power_elements(self) -> Option<(ActivityGovernorGetPowerElementsResponder)> {
1117        if let ActivityGovernorRequest::GetPowerElements { responder } = self {
1118            Some((responder))
1119        } else {
1120            None
1121        }
1122    }
1123
1124    #[allow(irrefutable_let_patterns)]
1125    pub fn into_take_wake_lease(self) -> Option<(String, ActivityGovernorTakeWakeLeaseResponder)> {
1126        if let ActivityGovernorRequest::TakeWakeLease { name, responder } = self {
1127            Some((name, responder))
1128        } else {
1129            None
1130        }
1131    }
1132
1133    #[allow(irrefutable_let_patterns)]
1134    pub fn into_acquire_wake_lease(
1135        self,
1136    ) -> Option<(String, ActivityGovernorAcquireWakeLeaseResponder)> {
1137        if let ActivityGovernorRequest::AcquireWakeLease { name, responder } = self {
1138            Some((name, responder))
1139        } else {
1140            None
1141        }
1142    }
1143
1144    #[allow(irrefutable_let_patterns)]
1145    pub fn into_take_application_activity_lease(
1146        self,
1147    ) -> Option<(String, ActivityGovernorTakeApplicationActivityLeaseResponder)> {
1148        if let ActivityGovernorRequest::TakeApplicationActivityLease { name, responder } = self {
1149            Some((name, responder))
1150        } else {
1151            None
1152        }
1153    }
1154
1155    #[allow(irrefutable_let_patterns)]
1156    pub fn into_register_listener(
1157        self,
1158    ) -> Option<(ActivityGovernorRegisterListenerRequest, ActivityGovernorRegisterListenerResponder)>
1159    {
1160        if let ActivityGovernorRequest::RegisterListener { payload, responder } = self {
1161            Some((payload, responder))
1162        } else {
1163            None
1164        }
1165    }
1166
1167    #[allow(irrefutable_let_patterns)]
1168    pub fn into_register_suspend_blocker(
1169        self,
1170    ) -> Option<(
1171        ActivityGovernorRegisterSuspendBlockerRequest,
1172        ActivityGovernorRegisterSuspendBlockerResponder,
1173    )> {
1174        if let ActivityGovernorRequest::RegisterSuspendBlocker { payload, responder } = self {
1175            Some((payload, responder))
1176        } else {
1177            None
1178        }
1179    }
1180
1181    /// Name of the method defined in FIDL
1182    pub fn method_name(&self) -> &'static str {
1183        match *self {
1184            ActivityGovernorRequest::GetPowerElements { .. } => "get_power_elements",
1185            ActivityGovernorRequest::TakeWakeLease { .. } => "take_wake_lease",
1186            ActivityGovernorRequest::AcquireWakeLease { .. } => "acquire_wake_lease",
1187            ActivityGovernorRequest::TakeApplicationActivityLease { .. } => {
1188                "take_application_activity_lease"
1189            }
1190            ActivityGovernorRequest::RegisterListener { .. } => "register_listener",
1191            ActivityGovernorRequest::RegisterSuspendBlocker { .. } => "register_suspend_blocker",
1192            ActivityGovernorRequest::_UnknownMethod {
1193                method_type: fidl::MethodType::OneWay,
1194                ..
1195            } => "unknown one-way method",
1196            ActivityGovernorRequest::_UnknownMethod {
1197                method_type: fidl::MethodType::TwoWay,
1198                ..
1199            } => "unknown two-way method",
1200        }
1201    }
1202}
1203
1204#[derive(Debug, Clone)]
1205pub struct ActivityGovernorControlHandle {
1206    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1207}
1208
1209impl fidl::endpoints::ControlHandle for ActivityGovernorControlHandle {
1210    fn shutdown(&self) {
1211        self.inner.shutdown()
1212    }
1213    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1214        self.inner.shutdown_with_epitaph(status)
1215    }
1216
1217    fn is_closed(&self) -> bool {
1218        self.inner.channel().is_closed()
1219    }
1220    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1221        self.inner.channel().on_closed()
1222    }
1223
1224    #[cfg(target_os = "fuchsia")]
1225    fn signal_peer(
1226        &self,
1227        clear_mask: zx::Signals,
1228        set_mask: zx::Signals,
1229    ) -> Result<(), zx_status::Status> {
1230        use fidl::Peered;
1231        self.inner.channel().signal_peer(clear_mask, set_mask)
1232    }
1233}
1234
1235impl ActivityGovernorControlHandle {}
1236
1237#[must_use = "FIDL methods require a response to be sent"]
1238#[derive(Debug)]
1239pub struct ActivityGovernorGetPowerElementsResponder {
1240    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1241    tx_id: u32,
1242}
1243
1244/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1245/// if the responder is dropped without sending a response, so that the client
1246/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1247impl std::ops::Drop for ActivityGovernorGetPowerElementsResponder {
1248    fn drop(&mut self) {
1249        self.control_handle.shutdown();
1250        // Safety: drops once, never accessed again
1251        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1252    }
1253}
1254
1255impl fidl::endpoints::Responder for ActivityGovernorGetPowerElementsResponder {
1256    type ControlHandle = ActivityGovernorControlHandle;
1257
1258    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1259        &self.control_handle
1260    }
1261
1262    fn drop_without_shutdown(mut self) {
1263        // Safety: drops once, never accessed again due to mem::forget
1264        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1265        // Prevent Drop from running (which would shut down the channel)
1266        std::mem::forget(self);
1267    }
1268}
1269
1270impl ActivityGovernorGetPowerElementsResponder {
1271    /// Sends a response to the FIDL transaction.
1272    ///
1273    /// Sets the channel to shutdown if an error occurs.
1274    pub fn send(self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1275        let _result = self.send_raw(payload);
1276        if _result.is_err() {
1277            self.control_handle.shutdown();
1278        }
1279        self.drop_without_shutdown();
1280        _result
1281    }
1282
1283    /// Similar to "send" but does not shutdown the channel if an error occurs.
1284    pub fn send_no_shutdown_on_err(self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1285        let _result = self.send_raw(payload);
1286        self.drop_without_shutdown();
1287        _result
1288    }
1289
1290    fn send_raw(&self, mut payload: PowerElements) -> Result<(), fidl::Error> {
1291        self.control_handle.inner.send::<fidl::encoding::FlexibleType<PowerElements>>(
1292            fidl::encoding::Flexible::new(&mut payload),
1293            self.tx_id,
1294            0x798003259dfb5672,
1295            fidl::encoding::DynamicFlags::FLEXIBLE,
1296        )
1297    }
1298}
1299
1300#[must_use = "FIDL methods require a response to be sent"]
1301#[derive(Debug)]
1302pub struct ActivityGovernorTakeWakeLeaseResponder {
1303    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1304    tx_id: u32,
1305}
1306
1307/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1308/// if the responder is dropped without sending a response, so that the client
1309/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1310impl std::ops::Drop for ActivityGovernorTakeWakeLeaseResponder {
1311    fn drop(&mut self) {
1312        self.control_handle.shutdown();
1313        // Safety: drops once, never accessed again
1314        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1315    }
1316}
1317
1318impl fidl::endpoints::Responder for ActivityGovernorTakeWakeLeaseResponder {
1319    type ControlHandle = ActivityGovernorControlHandle;
1320
1321    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1322        &self.control_handle
1323    }
1324
1325    fn drop_without_shutdown(mut self) {
1326        // Safety: drops once, never accessed again due to mem::forget
1327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1328        // Prevent Drop from running (which would shut down the channel)
1329        std::mem::forget(self);
1330    }
1331}
1332
1333impl ActivityGovernorTakeWakeLeaseResponder {
1334    /// Sends a response to the FIDL transaction.
1335    ///
1336    /// Sets the channel to shutdown if an error occurs.
1337    pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1338        let _result = self.send_raw(token);
1339        if _result.is_err() {
1340            self.control_handle.shutdown();
1341        }
1342        self.drop_without_shutdown();
1343        _result
1344    }
1345
1346    /// Similar to "send" but does not shutdown the channel if an error occurs.
1347    pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1348        let _result = self.send_raw(token);
1349        self.drop_without_shutdown();
1350        _result
1351    }
1352
1353    fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1354        self.control_handle
1355            .inner
1356            .send::<fidl::encoding::FlexibleType<ActivityGovernorTakeWakeLeaseResponse>>(
1357                fidl::encoding::Flexible::new((token,)),
1358                self.tx_id,
1359                0x291cfb42b2d3bf69,
1360                fidl::encoding::DynamicFlags::FLEXIBLE,
1361            )
1362    }
1363}
1364
1365#[must_use = "FIDL methods require a response to be sent"]
1366#[derive(Debug)]
1367pub struct ActivityGovernorAcquireWakeLeaseResponder {
1368    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1369    tx_id: u32,
1370}
1371
1372/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1373/// if the responder is dropped without sending a response, so that the client
1374/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1375impl std::ops::Drop for ActivityGovernorAcquireWakeLeaseResponder {
1376    fn drop(&mut self) {
1377        self.control_handle.shutdown();
1378        // Safety: drops once, never accessed again
1379        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1380    }
1381}
1382
1383impl fidl::endpoints::Responder for ActivityGovernorAcquireWakeLeaseResponder {
1384    type ControlHandle = ActivityGovernorControlHandle;
1385
1386    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1387        &self.control_handle
1388    }
1389
1390    fn drop_without_shutdown(mut self) {
1391        // Safety: drops once, never accessed again due to mem::forget
1392        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1393        // Prevent Drop from running (which would shut down the channel)
1394        std::mem::forget(self);
1395    }
1396}
1397
1398impl ActivityGovernorAcquireWakeLeaseResponder {
1399    /// Sends a response to the FIDL transaction.
1400    ///
1401    /// Sets the channel to shutdown if an error occurs.
1402    pub fn send(
1403        self,
1404        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1405    ) -> Result<(), fidl::Error> {
1406        let _result = self.send_raw(result);
1407        if _result.is_err() {
1408            self.control_handle.shutdown();
1409        }
1410        self.drop_without_shutdown();
1411        _result
1412    }
1413
1414    /// Similar to "send" but does not shutdown the channel if an error occurs.
1415    pub fn send_no_shutdown_on_err(
1416        self,
1417        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1418    ) -> Result<(), fidl::Error> {
1419        let _result = self.send_raw(result);
1420        self.drop_without_shutdown();
1421        _result
1422    }
1423
1424    fn send_raw(
1425        &self,
1426        mut result: Result<fidl::EventPair, AcquireWakeLeaseError>,
1427    ) -> Result<(), fidl::Error> {
1428        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1429            ActivityGovernorAcquireWakeLeaseResponse,
1430            AcquireWakeLeaseError,
1431        >>(
1432            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1433            self.tx_id,
1434            0x2de25abd8fa7c103,
1435            fidl::encoding::DynamicFlags::FLEXIBLE,
1436        )
1437    }
1438}
1439
1440#[must_use = "FIDL methods require a response to be sent"]
1441#[derive(Debug)]
1442pub struct ActivityGovernorTakeApplicationActivityLeaseResponder {
1443    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1444    tx_id: u32,
1445}
1446
1447/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1448/// if the responder is dropped without sending a response, so that the client
1449/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1450impl std::ops::Drop for ActivityGovernorTakeApplicationActivityLeaseResponder {
1451    fn drop(&mut self) {
1452        self.control_handle.shutdown();
1453        // Safety: drops once, never accessed again
1454        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1455    }
1456}
1457
1458impl fidl::endpoints::Responder for ActivityGovernorTakeApplicationActivityLeaseResponder {
1459    type ControlHandle = ActivityGovernorControlHandle;
1460
1461    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1462        &self.control_handle
1463    }
1464
1465    fn drop_without_shutdown(mut self) {
1466        // Safety: drops once, never accessed again due to mem::forget
1467        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1468        // Prevent Drop from running (which would shut down the channel)
1469        std::mem::forget(self);
1470    }
1471}
1472
1473impl ActivityGovernorTakeApplicationActivityLeaseResponder {
1474    /// Sends a response to the FIDL transaction.
1475    ///
1476    /// Sets the channel to shutdown if an error occurs.
1477    pub fn send(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1478        let _result = self.send_raw(token);
1479        if _result.is_err() {
1480            self.control_handle.shutdown();
1481        }
1482        self.drop_without_shutdown();
1483        _result
1484    }
1485
1486    /// Similar to "send" but does not shutdown the channel if an error occurs.
1487    pub fn send_no_shutdown_on_err(self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1488        let _result = self.send_raw(token);
1489        self.drop_without_shutdown();
1490        _result
1491    }
1492
1493    fn send_raw(&self, mut token: fidl::EventPair) -> Result<(), fidl::Error> {
1494        self.control_handle.inner.send::<fidl::encoding::FlexibleType<
1495            ActivityGovernorTakeApplicationActivityLeaseResponse,
1496        >>(
1497            fidl::encoding::Flexible::new((token,)),
1498            self.tx_id,
1499            0x37cd5364de7ada14,
1500            fidl::encoding::DynamicFlags::FLEXIBLE,
1501        )
1502    }
1503}
1504
1505#[must_use = "FIDL methods require a response to be sent"]
1506#[derive(Debug)]
1507pub struct ActivityGovernorRegisterListenerResponder {
1508    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1509    tx_id: u32,
1510}
1511
1512/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1513/// if the responder is dropped without sending a response, so that the client
1514/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1515impl std::ops::Drop for ActivityGovernorRegisterListenerResponder {
1516    fn drop(&mut self) {
1517        self.control_handle.shutdown();
1518        // Safety: drops once, never accessed again
1519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1520    }
1521}
1522
1523impl fidl::endpoints::Responder for ActivityGovernorRegisterListenerResponder {
1524    type ControlHandle = ActivityGovernorControlHandle;
1525
1526    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1527        &self.control_handle
1528    }
1529
1530    fn drop_without_shutdown(mut self) {
1531        // Safety: drops once, never accessed again due to mem::forget
1532        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1533        // Prevent Drop from running (which would shut down the channel)
1534        std::mem::forget(self);
1535    }
1536}
1537
1538impl ActivityGovernorRegisterListenerResponder {
1539    /// Sends a response to the FIDL transaction.
1540    ///
1541    /// Sets the channel to shutdown if an error occurs.
1542    pub fn send(self) -> Result<(), fidl::Error> {
1543        let _result = self.send_raw();
1544        if _result.is_err() {
1545            self.control_handle.shutdown();
1546        }
1547        self.drop_without_shutdown();
1548        _result
1549    }
1550
1551    /// Similar to "send" but does not shutdown the channel if an error occurs.
1552    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1553        let _result = self.send_raw();
1554        self.drop_without_shutdown();
1555        _result
1556    }
1557
1558    fn send_raw(&self) -> Result<(), fidl::Error> {
1559        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
1560            fidl::encoding::Flexible::new(()),
1561            self.tx_id,
1562            0x836144d0722e5c1,
1563            fidl::encoding::DynamicFlags::FLEXIBLE,
1564        )
1565    }
1566}
1567
1568#[must_use = "FIDL methods require a response to be sent"]
1569#[derive(Debug)]
1570pub struct ActivityGovernorRegisterSuspendBlockerResponder {
1571    control_handle: std::mem::ManuallyDrop<ActivityGovernorControlHandle>,
1572    tx_id: u32,
1573}
1574
1575/// Set the the channel to be shutdown (see [`ActivityGovernorControlHandle::shutdown`])
1576/// if the responder is dropped without sending a response, so that the client
1577/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1578impl std::ops::Drop for ActivityGovernorRegisterSuspendBlockerResponder {
1579    fn drop(&mut self) {
1580        self.control_handle.shutdown();
1581        // Safety: drops once, never accessed again
1582        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1583    }
1584}
1585
1586impl fidl::endpoints::Responder for ActivityGovernorRegisterSuspendBlockerResponder {
1587    type ControlHandle = ActivityGovernorControlHandle;
1588
1589    fn control_handle(&self) -> &ActivityGovernorControlHandle {
1590        &self.control_handle
1591    }
1592
1593    fn drop_without_shutdown(mut self) {
1594        // Safety: drops once, never accessed again due to mem::forget
1595        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1596        // Prevent Drop from running (which would shut down the channel)
1597        std::mem::forget(self);
1598    }
1599}
1600
1601impl ActivityGovernorRegisterSuspendBlockerResponder {
1602    /// Sends a response to the FIDL transaction.
1603    ///
1604    /// Sets the channel to shutdown if an error occurs.
1605    pub fn send(
1606        self,
1607        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1608    ) -> Result<(), fidl::Error> {
1609        let _result = self.send_raw(result);
1610        if _result.is_err() {
1611            self.control_handle.shutdown();
1612        }
1613        self.drop_without_shutdown();
1614        _result
1615    }
1616
1617    /// Similar to "send" but does not shutdown the channel if an error occurs.
1618    pub fn send_no_shutdown_on_err(
1619        self,
1620        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1621    ) -> Result<(), fidl::Error> {
1622        let _result = self.send_raw(result);
1623        self.drop_without_shutdown();
1624        _result
1625    }
1626
1627    fn send_raw(
1628        &self,
1629        mut result: Result<fidl::EventPair, RegisterSuspendBlockerError>,
1630    ) -> Result<(), fidl::Error> {
1631        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1632            ActivityGovernorRegisterSuspendBlockerResponse,
1633            RegisterSuspendBlockerError,
1634        >>(
1635            fidl::encoding::FlexibleResult::new(result.map(|token| (token,))),
1636            self.tx_id,
1637            0x34ef55b180feef01,
1638            fidl::encoding::DynamicFlags::FLEXIBLE,
1639        )
1640    }
1641}
1642
1643#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1644pub struct ActivityGovernorListenerMarker;
1645
1646impl fidl::endpoints::ProtocolMarker for ActivityGovernorListenerMarker {
1647    type Proxy = ActivityGovernorListenerProxy;
1648    type RequestStream = ActivityGovernorListenerRequestStream;
1649    #[cfg(target_os = "fuchsia")]
1650    type SynchronousProxy = ActivityGovernorListenerSynchronousProxy;
1651
1652    const DEBUG_NAME: &'static str = "(anonymous) ActivityGovernorListener";
1653}
1654
1655pub trait ActivityGovernorListenerProxyInterface: Send + Sync {
1656    type OnResumeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1657    fn r#on_resume(&self) -> Self::OnResumeResponseFut;
1658    type OnSuspendStartedResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
1659    fn r#on_suspend_started(&self) -> Self::OnSuspendStartedResponseFut;
1660}
1661#[derive(Debug)]
1662#[cfg(target_os = "fuchsia")]
1663pub struct ActivityGovernorListenerSynchronousProxy {
1664    client: fidl::client::sync::Client,
1665}
1666
1667#[cfg(target_os = "fuchsia")]
1668impl fidl::endpoints::SynchronousProxy for ActivityGovernorListenerSynchronousProxy {
1669    type Proxy = ActivityGovernorListenerProxy;
1670    type Protocol = ActivityGovernorListenerMarker;
1671
1672    fn from_channel(inner: fidl::Channel) -> Self {
1673        Self::new(inner)
1674    }
1675
1676    fn into_channel(self) -> fidl::Channel {
1677        self.client.into_channel()
1678    }
1679
1680    fn as_channel(&self) -> &fidl::Channel {
1681        self.client.as_channel()
1682    }
1683}
1684
1685#[cfg(target_os = "fuchsia")]
1686impl ActivityGovernorListenerSynchronousProxy {
1687    pub fn new(channel: fidl::Channel) -> Self {
1688        let protocol_name =
1689            <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1690        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1691    }
1692
1693    pub fn into_channel(self) -> fidl::Channel {
1694        self.client.into_channel()
1695    }
1696
1697    /// Waits until an event arrives and returns it. It is safe for other
1698    /// threads to make concurrent requests while waiting for an event.
1699    pub fn wait_for_event(
1700        &self,
1701        deadline: zx::MonotonicInstant,
1702    ) -> Result<ActivityGovernorListenerEvent, fidl::Error> {
1703        ActivityGovernorListenerEvent::decode(self.client.wait_for_event(deadline)?)
1704    }
1705
1706    /// Called when the activity governor detects a system resume.
1707    ///
1708    /// This is only called when the wakeup reason returned by the platform
1709    /// requires a full system resume. All dependencies of
1710    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
1711    /// this call is issued, and the listener's OnSuspendStarted method will be
1712    /// invoked before that guarantee is removed.
1713    ///
1714    /// SAG does not block on the response to this method, so the listener may
1715    /// safely take actions that block on raising Execution State's power level.
1716    /// In particular, it is not affected by https://fxbug.dev/391429689.
1717    pub fn r#on_resume(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
1718        let _response =
1719            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
1720                (),
1721                0x5b48f847154cfd48,
1722                fidl::encoding::DynamicFlags::empty(),
1723                ___deadline,
1724            )?;
1725        Ok(_response)
1726    }
1727
1728    /// Called before the activity governor initiates a system suspension.
1729    ///
1730    /// The server is expected to respond once it has performed the operations
1731    /// it needs to prepare itself for suspend, if any. All dependencies of
1732    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
1733    /// duration of this call.
1734    ///
1735    /// It is not safe for this method to call
1736    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
1737    /// other action that blocks on raising Execution State above its Inactive
1738    /// level. (However, AcquireWakeLease does _not_ block in this way and is
1739    /// safe to call.) Doing so will currently result in a deadlock. This
1740    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
1741    pub fn r#on_suspend_started(
1742        &self,
1743        ___deadline: zx::MonotonicInstant,
1744    ) -> Result<(), fidl::Error> {
1745        let _response = self.client.send_query::<
1746            fidl::encoding::EmptyPayload,
1747            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1748        >(
1749            (),
1750            0x5858cc3412a8eabf,
1751            fidl::encoding::DynamicFlags::FLEXIBLE,
1752            ___deadline,
1753        )?
1754        .into_result::<ActivityGovernorListenerMarker>("on_suspend_started")?;
1755        Ok(_response)
1756    }
1757}
1758
1759#[cfg(target_os = "fuchsia")]
1760impl From<ActivityGovernorListenerSynchronousProxy> for zx::Handle {
1761    fn from(value: ActivityGovernorListenerSynchronousProxy) -> Self {
1762        value.into_channel().into()
1763    }
1764}
1765
1766#[cfg(target_os = "fuchsia")]
1767impl From<fidl::Channel> for ActivityGovernorListenerSynchronousProxy {
1768    fn from(value: fidl::Channel) -> Self {
1769        Self::new(value)
1770    }
1771}
1772
1773#[cfg(target_os = "fuchsia")]
1774impl fidl::endpoints::FromClient for ActivityGovernorListenerSynchronousProxy {
1775    type Protocol = ActivityGovernorListenerMarker;
1776
1777    fn from_client(value: fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>) -> Self {
1778        Self::new(value.into_channel())
1779    }
1780}
1781
1782#[derive(Debug, Clone)]
1783pub struct ActivityGovernorListenerProxy {
1784    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1785}
1786
1787impl fidl::endpoints::Proxy for ActivityGovernorListenerProxy {
1788    type Protocol = ActivityGovernorListenerMarker;
1789
1790    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1791        Self::new(inner)
1792    }
1793
1794    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1795        self.client.into_channel().map_err(|client| Self { client })
1796    }
1797
1798    fn as_channel(&self) -> &::fidl::AsyncChannel {
1799        self.client.as_channel()
1800    }
1801}
1802
1803impl ActivityGovernorListenerProxy {
1804    /// Create a new Proxy for fuchsia.power.system/ActivityGovernorListener.
1805    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1806        let protocol_name =
1807            <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1808        Self { client: fidl::client::Client::new(channel, protocol_name) }
1809    }
1810
1811    /// Get a Stream of events from the remote end of the protocol.
1812    ///
1813    /// # Panics
1814    ///
1815    /// Panics if the event stream was already taken.
1816    pub fn take_event_stream(&self) -> ActivityGovernorListenerEventStream {
1817        ActivityGovernorListenerEventStream { event_receiver: self.client.take_event_receiver() }
1818    }
1819
1820    /// Called when the activity governor detects a system resume.
1821    ///
1822    /// This is only called when the wakeup reason returned by the platform
1823    /// requires a full system resume. All dependencies of
1824    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
1825    /// this call is issued, and the listener's OnSuspendStarted method will be
1826    /// invoked before that guarantee is removed.
1827    ///
1828    /// SAG does not block on the response to this method, so the listener may
1829    /// safely take actions that block on raising Execution State's power level.
1830    /// In particular, it is not affected by https://fxbug.dev/391429689.
1831    pub fn r#on_resume(
1832        &self,
1833    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1834        ActivityGovernorListenerProxyInterface::r#on_resume(self)
1835    }
1836
1837    /// Called before the activity governor initiates a system suspension.
1838    ///
1839    /// The server is expected to respond once it has performed the operations
1840    /// it needs to prepare itself for suspend, if any. All dependencies of
1841    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
1842    /// duration of this call.
1843    ///
1844    /// It is not safe for this method to call
1845    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
1846    /// other action that blocks on raising Execution State above its Inactive
1847    /// level. (However, AcquireWakeLease does _not_ block in this way and is
1848    /// safe to call.) Doing so will currently result in a deadlock. This
1849    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
1850    pub fn r#on_suspend_started(
1851        &self,
1852    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
1853        ActivityGovernorListenerProxyInterface::r#on_suspend_started(self)
1854    }
1855}
1856
1857impl ActivityGovernorListenerProxyInterface for ActivityGovernorListenerProxy {
1858    type OnResumeResponseFut =
1859        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1860    fn r#on_resume(&self) -> Self::OnResumeResponseFut {
1861        fn _decode(
1862            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1863        ) -> Result<(), fidl::Error> {
1864            let _response = fidl::client::decode_transaction_body::<
1865                fidl::encoding::EmptyPayload,
1866                fidl::encoding::DefaultFuchsiaResourceDialect,
1867                0x5b48f847154cfd48,
1868            >(_buf?)?;
1869            Ok(_response)
1870        }
1871        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1872            (),
1873            0x5b48f847154cfd48,
1874            fidl::encoding::DynamicFlags::empty(),
1875            _decode,
1876        )
1877    }
1878
1879    type OnSuspendStartedResponseFut =
1880        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
1881    fn r#on_suspend_started(&self) -> Self::OnSuspendStartedResponseFut {
1882        fn _decode(
1883            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1884        ) -> Result<(), fidl::Error> {
1885            let _response = fidl::client::decode_transaction_body::<
1886                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
1887                fidl::encoding::DefaultFuchsiaResourceDialect,
1888                0x5858cc3412a8eabf,
1889            >(_buf?)?
1890            .into_result::<ActivityGovernorListenerMarker>("on_suspend_started")?;
1891            Ok(_response)
1892        }
1893        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
1894            (),
1895            0x5858cc3412a8eabf,
1896            fidl::encoding::DynamicFlags::FLEXIBLE,
1897            _decode,
1898        )
1899    }
1900}
1901
1902pub struct ActivityGovernorListenerEventStream {
1903    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1904}
1905
1906impl std::marker::Unpin for ActivityGovernorListenerEventStream {}
1907
1908impl futures::stream::FusedStream for ActivityGovernorListenerEventStream {
1909    fn is_terminated(&self) -> bool {
1910        self.event_receiver.is_terminated()
1911    }
1912}
1913
1914impl futures::Stream for ActivityGovernorListenerEventStream {
1915    type Item = Result<ActivityGovernorListenerEvent, fidl::Error>;
1916
1917    fn poll_next(
1918        mut self: std::pin::Pin<&mut Self>,
1919        cx: &mut std::task::Context<'_>,
1920    ) -> std::task::Poll<Option<Self::Item>> {
1921        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1922            &mut self.event_receiver,
1923            cx
1924        )?) {
1925            Some(buf) => std::task::Poll::Ready(Some(ActivityGovernorListenerEvent::decode(buf))),
1926            None => std::task::Poll::Ready(None),
1927        }
1928    }
1929}
1930
1931#[derive(Debug)]
1932pub enum ActivityGovernorListenerEvent {
1933    #[non_exhaustive]
1934    _UnknownEvent {
1935        /// Ordinal of the event that was sent.
1936        ordinal: u64,
1937    },
1938}
1939
1940impl ActivityGovernorListenerEvent {
1941    /// Decodes a message buffer as a [`ActivityGovernorListenerEvent`].
1942    fn decode(
1943        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1944    ) -> Result<ActivityGovernorListenerEvent, fidl::Error> {
1945        let (bytes, _handles) = buf.split_mut();
1946        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1947        debug_assert_eq!(tx_header.tx_id, 0);
1948        match tx_header.ordinal {
1949            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1950                Ok(ActivityGovernorListenerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1951            }
1952            _ => Err(fidl::Error::UnknownOrdinal {
1953                ordinal: tx_header.ordinal,
1954                protocol_name:
1955                    <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1956            }),
1957        }
1958    }
1959}
1960
1961/// A Stream of incoming requests for fuchsia.power.system/ActivityGovernorListener.
1962pub struct ActivityGovernorListenerRequestStream {
1963    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1964    is_terminated: bool,
1965}
1966
1967impl std::marker::Unpin for ActivityGovernorListenerRequestStream {}
1968
1969impl futures::stream::FusedStream for ActivityGovernorListenerRequestStream {
1970    fn is_terminated(&self) -> bool {
1971        self.is_terminated
1972    }
1973}
1974
1975impl fidl::endpoints::RequestStream for ActivityGovernorListenerRequestStream {
1976    type Protocol = ActivityGovernorListenerMarker;
1977    type ControlHandle = ActivityGovernorListenerControlHandle;
1978
1979    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1980        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1981    }
1982
1983    fn control_handle(&self) -> Self::ControlHandle {
1984        ActivityGovernorListenerControlHandle { inner: self.inner.clone() }
1985    }
1986
1987    fn into_inner(
1988        self,
1989    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1990    {
1991        (self.inner, self.is_terminated)
1992    }
1993
1994    fn from_inner(
1995        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1996        is_terminated: bool,
1997    ) -> Self {
1998        Self { inner, is_terminated }
1999    }
2000}
2001
2002impl futures::Stream for ActivityGovernorListenerRequestStream {
2003    type Item = Result<ActivityGovernorListenerRequest, fidl::Error>;
2004
2005    fn poll_next(
2006        mut self: std::pin::Pin<&mut Self>,
2007        cx: &mut std::task::Context<'_>,
2008    ) -> std::task::Poll<Option<Self::Item>> {
2009        let this = &mut *self;
2010        if this.inner.check_shutdown(cx) {
2011            this.is_terminated = true;
2012            return std::task::Poll::Ready(None);
2013        }
2014        if this.is_terminated {
2015            panic!("polled ActivityGovernorListenerRequestStream after completion");
2016        }
2017        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2018            |bytes, handles| {
2019                match this.inner.channel().read_etc(cx, bytes, handles) {
2020                    std::task::Poll::Ready(Ok(())) => {}
2021                    std::task::Poll::Pending => return std::task::Poll::Pending,
2022                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2023                        this.is_terminated = true;
2024                        return std::task::Poll::Ready(None);
2025                    }
2026                    std::task::Poll::Ready(Err(e)) => {
2027                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2028                            e.into(),
2029                        ))))
2030                    }
2031                }
2032
2033                // A message has been received from the channel
2034                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2035
2036                std::task::Poll::Ready(Some(match header.ordinal {
2037                0x5b48f847154cfd48 => {
2038                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2039                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2040                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2041                    let control_handle = ActivityGovernorListenerControlHandle {
2042                        inner: this.inner.clone(),
2043                    };
2044                    Ok(ActivityGovernorListenerRequest::OnResume {
2045                        responder: ActivityGovernorListenerOnResumeResponder {
2046                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2047                            tx_id: header.tx_id,
2048                        },
2049                    })
2050                }
2051                0x5858cc3412a8eabf => {
2052                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2053                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
2054                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2055                    let control_handle = ActivityGovernorListenerControlHandle {
2056                        inner: this.inner.clone(),
2057                    };
2058                    Ok(ActivityGovernorListenerRequest::OnSuspendStarted {
2059                        responder: ActivityGovernorListenerOnSuspendStartedResponder {
2060                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2061                            tx_id: header.tx_id,
2062                        },
2063                    })
2064                }
2065                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2066                    Ok(ActivityGovernorListenerRequest::_UnknownMethod {
2067                        ordinal: header.ordinal,
2068                        control_handle: ActivityGovernorListenerControlHandle { inner: this.inner.clone() },
2069                        method_type: fidl::MethodType::OneWay,
2070                    })
2071                }
2072                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2073                    this.inner.send_framework_err(
2074                        fidl::encoding::FrameworkErr::UnknownMethod,
2075                        header.tx_id,
2076                        header.ordinal,
2077                        header.dynamic_flags(),
2078                        (bytes, handles),
2079                    )?;
2080                    Ok(ActivityGovernorListenerRequest::_UnknownMethod {
2081                        ordinal: header.ordinal,
2082                        control_handle: ActivityGovernorListenerControlHandle { inner: this.inner.clone() },
2083                        method_type: fidl::MethodType::TwoWay,
2084                    })
2085                }
2086                _ => Err(fidl::Error::UnknownOrdinal {
2087                    ordinal: header.ordinal,
2088                    protocol_name: <ActivityGovernorListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2089                }),
2090            }))
2091            },
2092        )
2093    }
2094}
2095
2096/// A listener for activity governor events.
2097#[derive(Debug)]
2098pub enum ActivityGovernorListenerRequest {
2099    /// Called when the activity governor detects a system resume.
2100    ///
2101    /// This is only called when the wakeup reason returned by the platform
2102    /// requires a full system resume. All dependencies of
2103    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified when
2104    /// this call is issued, and the listener's OnSuspendStarted method will be
2105    /// invoked before that guarantee is removed.
2106    ///
2107    /// SAG does not block on the response to this method, so the listener may
2108    /// safely take actions that block on raising Execution State's power level.
2109    /// In particular, it is not affected by https://fxbug.dev/391429689.
2110    OnResume { responder: ActivityGovernorListenerOnResumeResponder },
2111    /// Called before the activity governor initiates a system suspension.
2112    ///
2113    /// The server is expected to respond once it has performed the operations
2114    /// it needs to prepare itself for suspend, if any. All dependencies of
2115    /// ExecutionStateLevel::SUSPENDING are guaranteed to be satisified for the
2116    /// duration of this call.
2117    ///
2118    /// It is not safe for this method to call
2119    /// ActivityGovernor.TakeApplicationActivityLease or to perform any
2120    /// other action that blocks on raising Execution State above its Inactive
2121    /// level. (However, AcquireWakeLease does _not_ block in this way and is
2122    /// safe to call.) Doing so will currently result in a deadlock. This
2123    /// constraint will eventually be removed; see https://fxbug.dev/391429689.
2124    OnSuspendStarted { responder: ActivityGovernorListenerOnSuspendStartedResponder },
2125    /// An interaction was received which does not match any known method.
2126    #[non_exhaustive]
2127    _UnknownMethod {
2128        /// Ordinal of the method that was called.
2129        ordinal: u64,
2130        control_handle: ActivityGovernorListenerControlHandle,
2131        method_type: fidl::MethodType,
2132    },
2133}
2134
2135impl ActivityGovernorListenerRequest {
2136    #[allow(irrefutable_let_patterns)]
2137    pub fn into_on_resume(self) -> Option<(ActivityGovernorListenerOnResumeResponder)> {
2138        if let ActivityGovernorListenerRequest::OnResume { responder } = self {
2139            Some((responder))
2140        } else {
2141            None
2142        }
2143    }
2144
2145    #[allow(irrefutable_let_patterns)]
2146    pub fn into_on_suspend_started(
2147        self,
2148    ) -> Option<(ActivityGovernorListenerOnSuspendStartedResponder)> {
2149        if let ActivityGovernorListenerRequest::OnSuspendStarted { responder } = self {
2150            Some((responder))
2151        } else {
2152            None
2153        }
2154    }
2155
2156    /// Name of the method defined in FIDL
2157    pub fn method_name(&self) -> &'static str {
2158        match *self {
2159            ActivityGovernorListenerRequest::OnResume { .. } => "on_resume",
2160            ActivityGovernorListenerRequest::OnSuspendStarted { .. } => "on_suspend_started",
2161            ActivityGovernorListenerRequest::_UnknownMethod {
2162                method_type: fidl::MethodType::OneWay,
2163                ..
2164            } => "unknown one-way method",
2165            ActivityGovernorListenerRequest::_UnknownMethod {
2166                method_type: fidl::MethodType::TwoWay,
2167                ..
2168            } => "unknown two-way method",
2169        }
2170    }
2171}
2172
2173#[derive(Debug, Clone)]
2174pub struct ActivityGovernorListenerControlHandle {
2175    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2176}
2177
2178impl fidl::endpoints::ControlHandle for ActivityGovernorListenerControlHandle {
2179    fn shutdown(&self) {
2180        self.inner.shutdown()
2181    }
2182    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2183        self.inner.shutdown_with_epitaph(status)
2184    }
2185
2186    fn is_closed(&self) -> bool {
2187        self.inner.channel().is_closed()
2188    }
2189    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2190        self.inner.channel().on_closed()
2191    }
2192
2193    #[cfg(target_os = "fuchsia")]
2194    fn signal_peer(
2195        &self,
2196        clear_mask: zx::Signals,
2197        set_mask: zx::Signals,
2198    ) -> Result<(), zx_status::Status> {
2199        use fidl::Peered;
2200        self.inner.channel().signal_peer(clear_mask, set_mask)
2201    }
2202}
2203
2204impl ActivityGovernorListenerControlHandle {}
2205
2206#[must_use = "FIDL methods require a response to be sent"]
2207#[derive(Debug)]
2208pub struct ActivityGovernorListenerOnResumeResponder {
2209    control_handle: std::mem::ManuallyDrop<ActivityGovernorListenerControlHandle>,
2210    tx_id: u32,
2211}
2212
2213/// Set the the channel to be shutdown (see [`ActivityGovernorListenerControlHandle::shutdown`])
2214/// if the responder is dropped without sending a response, so that the client
2215/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2216impl std::ops::Drop for ActivityGovernorListenerOnResumeResponder {
2217    fn drop(&mut self) {
2218        self.control_handle.shutdown();
2219        // Safety: drops once, never accessed again
2220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2221    }
2222}
2223
2224impl fidl::endpoints::Responder for ActivityGovernorListenerOnResumeResponder {
2225    type ControlHandle = ActivityGovernorListenerControlHandle;
2226
2227    fn control_handle(&self) -> &ActivityGovernorListenerControlHandle {
2228        &self.control_handle
2229    }
2230
2231    fn drop_without_shutdown(mut self) {
2232        // Safety: drops once, never accessed again due to mem::forget
2233        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2234        // Prevent Drop from running (which would shut down the channel)
2235        std::mem::forget(self);
2236    }
2237}
2238
2239impl ActivityGovernorListenerOnResumeResponder {
2240    /// Sends a response to the FIDL transaction.
2241    ///
2242    /// Sets the channel to shutdown if an error occurs.
2243    pub fn send(self) -> Result<(), fidl::Error> {
2244        let _result = self.send_raw();
2245        if _result.is_err() {
2246            self.control_handle.shutdown();
2247        }
2248        self.drop_without_shutdown();
2249        _result
2250    }
2251
2252    /// Similar to "send" but does not shutdown the channel if an error occurs.
2253    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2254        let _result = self.send_raw();
2255        self.drop_without_shutdown();
2256        _result
2257    }
2258
2259    fn send_raw(&self) -> Result<(), fidl::Error> {
2260        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
2261            (),
2262            self.tx_id,
2263            0x5b48f847154cfd48,
2264            fidl::encoding::DynamicFlags::empty(),
2265        )
2266    }
2267}
2268
2269#[must_use = "FIDL methods require a response to be sent"]
2270#[derive(Debug)]
2271pub struct ActivityGovernorListenerOnSuspendStartedResponder {
2272    control_handle: std::mem::ManuallyDrop<ActivityGovernorListenerControlHandle>,
2273    tx_id: u32,
2274}
2275
2276/// Set the the channel to be shutdown (see [`ActivityGovernorListenerControlHandle::shutdown`])
2277/// if the responder is dropped without sending a response, so that the client
2278/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2279impl std::ops::Drop for ActivityGovernorListenerOnSuspendStartedResponder {
2280    fn drop(&mut self) {
2281        self.control_handle.shutdown();
2282        // Safety: drops once, never accessed again
2283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2284    }
2285}
2286
2287impl fidl::endpoints::Responder for ActivityGovernorListenerOnSuspendStartedResponder {
2288    type ControlHandle = ActivityGovernorListenerControlHandle;
2289
2290    fn control_handle(&self) -> &ActivityGovernorListenerControlHandle {
2291        &self.control_handle
2292    }
2293
2294    fn drop_without_shutdown(mut self) {
2295        // Safety: drops once, never accessed again due to mem::forget
2296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2297        // Prevent Drop from running (which would shut down the channel)
2298        std::mem::forget(self);
2299    }
2300}
2301
2302impl ActivityGovernorListenerOnSuspendStartedResponder {
2303    /// Sends a response to the FIDL transaction.
2304    ///
2305    /// Sets the channel to shutdown if an error occurs.
2306    pub fn send(self) -> Result<(), fidl::Error> {
2307        let _result = self.send_raw();
2308        if _result.is_err() {
2309            self.control_handle.shutdown();
2310        }
2311        self.drop_without_shutdown();
2312        _result
2313    }
2314
2315    /// Similar to "send" but does not shutdown the channel if an error occurs.
2316    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2317        let _result = self.send_raw();
2318        self.drop_without_shutdown();
2319        _result
2320    }
2321
2322    fn send_raw(&self) -> Result<(), fidl::Error> {
2323        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2324            fidl::encoding::Flexible::new(()),
2325            self.tx_id,
2326            0x5858cc3412a8eabf,
2327            fidl::encoding::DynamicFlags::FLEXIBLE,
2328        )
2329    }
2330}
2331
2332#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2333pub struct BootControlMarker;
2334
2335impl fidl::endpoints::ProtocolMarker for BootControlMarker {
2336    type Proxy = BootControlProxy;
2337    type RequestStream = BootControlRequestStream;
2338    #[cfg(target_os = "fuchsia")]
2339    type SynchronousProxy = BootControlSynchronousProxy;
2340
2341    const DEBUG_NAME: &'static str = "fuchsia.power.system.BootControl";
2342}
2343impl fidl::endpoints::DiscoverableProtocolMarker for BootControlMarker {}
2344
2345pub trait BootControlProxyInterface: Send + Sync {
2346    type SetBootCompleteResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
2347    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut;
2348}
2349#[derive(Debug)]
2350#[cfg(target_os = "fuchsia")]
2351pub struct BootControlSynchronousProxy {
2352    client: fidl::client::sync::Client,
2353}
2354
2355#[cfg(target_os = "fuchsia")]
2356impl fidl::endpoints::SynchronousProxy for BootControlSynchronousProxy {
2357    type Proxy = BootControlProxy;
2358    type Protocol = BootControlMarker;
2359
2360    fn from_channel(inner: fidl::Channel) -> Self {
2361        Self::new(inner)
2362    }
2363
2364    fn into_channel(self) -> fidl::Channel {
2365        self.client.into_channel()
2366    }
2367
2368    fn as_channel(&self) -> &fidl::Channel {
2369        self.client.as_channel()
2370    }
2371}
2372
2373#[cfg(target_os = "fuchsia")]
2374impl BootControlSynchronousProxy {
2375    pub fn new(channel: fidl::Channel) -> Self {
2376        let protocol_name = <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2377        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2378    }
2379
2380    pub fn into_channel(self) -> fidl::Channel {
2381        self.client.into_channel()
2382    }
2383
2384    /// Waits until an event arrives and returns it. It is safe for other
2385    /// threads to make concurrent requests while waiting for an event.
2386    pub fn wait_for_event(
2387        &self,
2388        deadline: zx::MonotonicInstant,
2389    ) -> Result<BootControlEvent, fidl::Error> {
2390        BootControlEvent::decode(self.client.wait_for_event(deadline)?)
2391    }
2392
2393    /// Notify the SAG that the system has booted. SAG will not suspend the
2394    /// hardware platform until this method is called at least once per boot.
2395    pub fn r#set_boot_complete(
2396        &self,
2397        ___deadline: zx::MonotonicInstant,
2398    ) -> Result<(), fidl::Error> {
2399        let _response = self.client.send_query::<
2400            fidl::encoding::EmptyPayload,
2401            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2402        >(
2403            (),
2404            0x3c9b9f24ad3ca2b5,
2405            fidl::encoding::DynamicFlags::FLEXIBLE,
2406            ___deadline,
2407        )?
2408        .into_result::<BootControlMarker>("set_boot_complete")?;
2409        Ok(_response)
2410    }
2411}
2412
2413#[cfg(target_os = "fuchsia")]
2414impl From<BootControlSynchronousProxy> for zx::Handle {
2415    fn from(value: BootControlSynchronousProxy) -> Self {
2416        value.into_channel().into()
2417    }
2418}
2419
2420#[cfg(target_os = "fuchsia")]
2421impl From<fidl::Channel> for BootControlSynchronousProxy {
2422    fn from(value: fidl::Channel) -> Self {
2423        Self::new(value)
2424    }
2425}
2426
2427#[cfg(target_os = "fuchsia")]
2428impl fidl::endpoints::FromClient for BootControlSynchronousProxy {
2429    type Protocol = BootControlMarker;
2430
2431    fn from_client(value: fidl::endpoints::ClientEnd<BootControlMarker>) -> Self {
2432        Self::new(value.into_channel())
2433    }
2434}
2435
2436#[derive(Debug, Clone)]
2437pub struct BootControlProxy {
2438    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2439}
2440
2441impl fidl::endpoints::Proxy for BootControlProxy {
2442    type Protocol = BootControlMarker;
2443
2444    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2445        Self::new(inner)
2446    }
2447
2448    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2449        self.client.into_channel().map_err(|client| Self { client })
2450    }
2451
2452    fn as_channel(&self) -> &::fidl::AsyncChannel {
2453        self.client.as_channel()
2454    }
2455}
2456
2457impl BootControlProxy {
2458    /// Create a new Proxy for fuchsia.power.system/BootControl.
2459    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2460        let protocol_name = <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2461        Self { client: fidl::client::Client::new(channel, protocol_name) }
2462    }
2463
2464    /// Get a Stream of events from the remote end of the protocol.
2465    ///
2466    /// # Panics
2467    ///
2468    /// Panics if the event stream was already taken.
2469    pub fn take_event_stream(&self) -> BootControlEventStream {
2470        BootControlEventStream { event_receiver: self.client.take_event_receiver() }
2471    }
2472
2473    /// Notify the SAG that the system has booted. SAG will not suspend the
2474    /// hardware platform until this method is called at least once per boot.
2475    pub fn r#set_boot_complete(
2476        &self,
2477    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
2478        BootControlProxyInterface::r#set_boot_complete(self)
2479    }
2480}
2481
2482impl BootControlProxyInterface for BootControlProxy {
2483    type SetBootCompleteResponseFut =
2484        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
2485    fn r#set_boot_complete(&self) -> Self::SetBootCompleteResponseFut {
2486        fn _decode(
2487            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2488        ) -> Result<(), fidl::Error> {
2489            let _response = fidl::client::decode_transaction_body::<
2490                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2491                fidl::encoding::DefaultFuchsiaResourceDialect,
2492                0x3c9b9f24ad3ca2b5,
2493            >(_buf?)?
2494            .into_result::<BootControlMarker>("set_boot_complete")?;
2495            Ok(_response)
2496        }
2497        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
2498            (),
2499            0x3c9b9f24ad3ca2b5,
2500            fidl::encoding::DynamicFlags::FLEXIBLE,
2501            _decode,
2502        )
2503    }
2504}
2505
2506pub struct BootControlEventStream {
2507    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2508}
2509
2510impl std::marker::Unpin for BootControlEventStream {}
2511
2512impl futures::stream::FusedStream for BootControlEventStream {
2513    fn is_terminated(&self) -> bool {
2514        self.event_receiver.is_terminated()
2515    }
2516}
2517
2518impl futures::Stream for BootControlEventStream {
2519    type Item = Result<BootControlEvent, fidl::Error>;
2520
2521    fn poll_next(
2522        mut self: std::pin::Pin<&mut Self>,
2523        cx: &mut std::task::Context<'_>,
2524    ) -> std::task::Poll<Option<Self::Item>> {
2525        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2526            &mut self.event_receiver,
2527            cx
2528        )?) {
2529            Some(buf) => std::task::Poll::Ready(Some(BootControlEvent::decode(buf))),
2530            None => std::task::Poll::Ready(None),
2531        }
2532    }
2533}
2534
2535#[derive(Debug)]
2536pub enum BootControlEvent {
2537    #[non_exhaustive]
2538    _UnknownEvent {
2539        /// Ordinal of the event that was sent.
2540        ordinal: u64,
2541    },
2542}
2543
2544impl BootControlEvent {
2545    /// Decodes a message buffer as a [`BootControlEvent`].
2546    fn decode(
2547        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2548    ) -> Result<BootControlEvent, fidl::Error> {
2549        let (bytes, _handles) = buf.split_mut();
2550        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2551        debug_assert_eq!(tx_header.tx_id, 0);
2552        match tx_header.ordinal {
2553            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2554                Ok(BootControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2555            }
2556            _ => Err(fidl::Error::UnknownOrdinal {
2557                ordinal: tx_header.ordinal,
2558                protocol_name: <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2559            }),
2560        }
2561    }
2562}
2563
2564/// A Stream of incoming requests for fuchsia.power.system/BootControl.
2565pub struct BootControlRequestStream {
2566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2567    is_terminated: bool,
2568}
2569
2570impl std::marker::Unpin for BootControlRequestStream {}
2571
2572impl futures::stream::FusedStream for BootControlRequestStream {
2573    fn is_terminated(&self) -> bool {
2574        self.is_terminated
2575    }
2576}
2577
2578impl fidl::endpoints::RequestStream for BootControlRequestStream {
2579    type Protocol = BootControlMarker;
2580    type ControlHandle = BootControlControlHandle;
2581
2582    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2583        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2584    }
2585
2586    fn control_handle(&self) -> Self::ControlHandle {
2587        BootControlControlHandle { inner: self.inner.clone() }
2588    }
2589
2590    fn into_inner(
2591        self,
2592    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2593    {
2594        (self.inner, self.is_terminated)
2595    }
2596
2597    fn from_inner(
2598        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2599        is_terminated: bool,
2600    ) -> Self {
2601        Self { inner, is_terminated }
2602    }
2603}
2604
2605impl futures::Stream for BootControlRequestStream {
2606    type Item = Result<BootControlRequest, fidl::Error>;
2607
2608    fn poll_next(
2609        mut self: std::pin::Pin<&mut Self>,
2610        cx: &mut std::task::Context<'_>,
2611    ) -> std::task::Poll<Option<Self::Item>> {
2612        let this = &mut *self;
2613        if this.inner.check_shutdown(cx) {
2614            this.is_terminated = true;
2615            return std::task::Poll::Ready(None);
2616        }
2617        if this.is_terminated {
2618            panic!("polled BootControlRequestStream after completion");
2619        }
2620        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2621            |bytes, handles| {
2622                match this.inner.channel().read_etc(cx, bytes, handles) {
2623                    std::task::Poll::Ready(Ok(())) => {}
2624                    std::task::Poll::Pending => return std::task::Poll::Pending,
2625                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2626                        this.is_terminated = true;
2627                        return std::task::Poll::Ready(None);
2628                    }
2629                    std::task::Poll::Ready(Err(e)) => {
2630                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2631                            e.into(),
2632                        ))))
2633                    }
2634                }
2635
2636                // A message has been received from the channel
2637                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2638
2639                std::task::Poll::Ready(Some(match header.ordinal {
2640                    0x3c9b9f24ad3ca2b5 => {
2641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2642                        let mut req = fidl::new_empty!(
2643                            fidl::encoding::EmptyPayload,
2644                            fidl::encoding::DefaultFuchsiaResourceDialect
2645                        );
2646                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
2647                        let control_handle = BootControlControlHandle { inner: this.inner.clone() };
2648                        Ok(BootControlRequest::SetBootComplete {
2649                            responder: BootControlSetBootCompleteResponder {
2650                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2651                                tx_id: header.tx_id,
2652                            },
2653                        })
2654                    }
2655                    _ if header.tx_id == 0
2656                        && header
2657                            .dynamic_flags()
2658                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2659                    {
2660                        Ok(BootControlRequest::_UnknownMethod {
2661                            ordinal: header.ordinal,
2662                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2663                            method_type: fidl::MethodType::OneWay,
2664                        })
2665                    }
2666                    _ if header
2667                        .dynamic_flags()
2668                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
2669                    {
2670                        this.inner.send_framework_err(
2671                            fidl::encoding::FrameworkErr::UnknownMethod,
2672                            header.tx_id,
2673                            header.ordinal,
2674                            header.dynamic_flags(),
2675                            (bytes, handles),
2676                        )?;
2677                        Ok(BootControlRequest::_UnknownMethod {
2678                            ordinal: header.ordinal,
2679                            control_handle: BootControlControlHandle { inner: this.inner.clone() },
2680                            method_type: fidl::MethodType::TwoWay,
2681                        })
2682                    }
2683                    _ => Err(fidl::Error::UnknownOrdinal {
2684                        ordinal: header.ordinal,
2685                        protocol_name:
2686                            <BootControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2687                    }),
2688                }))
2689            },
2690        )
2691    }
2692}
2693
2694/// A service that processes notification about the system boot state.
2695#[derive(Debug)]
2696pub enum BootControlRequest {
2697    /// Notify the SAG that the system has booted. SAG will not suspend the
2698    /// hardware platform until this method is called at least once per boot.
2699    SetBootComplete { responder: BootControlSetBootCompleteResponder },
2700    /// An interaction was received which does not match any known method.
2701    #[non_exhaustive]
2702    _UnknownMethod {
2703        /// Ordinal of the method that was called.
2704        ordinal: u64,
2705        control_handle: BootControlControlHandle,
2706        method_type: fidl::MethodType,
2707    },
2708}
2709
2710impl BootControlRequest {
2711    #[allow(irrefutable_let_patterns)]
2712    pub fn into_set_boot_complete(self) -> Option<(BootControlSetBootCompleteResponder)> {
2713        if let BootControlRequest::SetBootComplete { responder } = self {
2714            Some((responder))
2715        } else {
2716            None
2717        }
2718    }
2719
2720    /// Name of the method defined in FIDL
2721    pub fn method_name(&self) -> &'static str {
2722        match *self {
2723            BootControlRequest::SetBootComplete { .. } => "set_boot_complete",
2724            BootControlRequest::_UnknownMethod {
2725                method_type: fidl::MethodType::OneWay, ..
2726            } => "unknown one-way method",
2727            BootControlRequest::_UnknownMethod {
2728                method_type: fidl::MethodType::TwoWay, ..
2729            } => "unknown two-way method",
2730        }
2731    }
2732}
2733
2734#[derive(Debug, Clone)]
2735pub struct BootControlControlHandle {
2736    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2737}
2738
2739impl fidl::endpoints::ControlHandle for BootControlControlHandle {
2740    fn shutdown(&self) {
2741        self.inner.shutdown()
2742    }
2743    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2744        self.inner.shutdown_with_epitaph(status)
2745    }
2746
2747    fn is_closed(&self) -> bool {
2748        self.inner.channel().is_closed()
2749    }
2750    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2751        self.inner.channel().on_closed()
2752    }
2753
2754    #[cfg(target_os = "fuchsia")]
2755    fn signal_peer(
2756        &self,
2757        clear_mask: zx::Signals,
2758        set_mask: zx::Signals,
2759    ) -> Result<(), zx_status::Status> {
2760        use fidl::Peered;
2761        self.inner.channel().signal_peer(clear_mask, set_mask)
2762    }
2763}
2764
2765impl BootControlControlHandle {}
2766
2767#[must_use = "FIDL methods require a response to be sent"]
2768#[derive(Debug)]
2769pub struct BootControlSetBootCompleteResponder {
2770    control_handle: std::mem::ManuallyDrop<BootControlControlHandle>,
2771    tx_id: u32,
2772}
2773
2774/// Set the the channel to be shutdown (see [`BootControlControlHandle::shutdown`])
2775/// if the responder is dropped without sending a response, so that the client
2776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2777impl std::ops::Drop for BootControlSetBootCompleteResponder {
2778    fn drop(&mut self) {
2779        self.control_handle.shutdown();
2780        // Safety: drops once, never accessed again
2781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2782    }
2783}
2784
2785impl fidl::endpoints::Responder for BootControlSetBootCompleteResponder {
2786    type ControlHandle = BootControlControlHandle;
2787
2788    fn control_handle(&self) -> &BootControlControlHandle {
2789        &self.control_handle
2790    }
2791
2792    fn drop_without_shutdown(mut self) {
2793        // Safety: drops once, never accessed again due to mem::forget
2794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2795        // Prevent Drop from running (which would shut down the channel)
2796        std::mem::forget(self);
2797    }
2798}
2799
2800impl BootControlSetBootCompleteResponder {
2801    /// Sends a response to the FIDL transaction.
2802    ///
2803    /// Sets the channel to shutdown if an error occurs.
2804    pub fn send(self) -> Result<(), fidl::Error> {
2805        let _result = self.send_raw();
2806        if _result.is_err() {
2807            self.control_handle.shutdown();
2808        }
2809        self.drop_without_shutdown();
2810        _result
2811    }
2812
2813    /// Similar to "send" but does not shutdown the channel if an error occurs.
2814    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
2815        let _result = self.send_raw();
2816        self.drop_without_shutdown();
2817        _result
2818    }
2819
2820    fn send_raw(&self) -> Result<(), fidl::Error> {
2821        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
2822            fidl::encoding::Flexible::new(()),
2823            self.tx_id,
2824            0x3c9b9f24ad3ca2b5,
2825            fidl::encoding::DynamicFlags::FLEXIBLE,
2826        )
2827    }
2828}
2829
2830#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2831pub struct CpuElementManagerMarker;
2832
2833impl fidl::endpoints::ProtocolMarker for CpuElementManagerMarker {
2834    type Proxy = CpuElementManagerProxy;
2835    type RequestStream = CpuElementManagerRequestStream;
2836    #[cfg(target_os = "fuchsia")]
2837    type SynchronousProxy = CpuElementManagerSynchronousProxy;
2838
2839    const DEBUG_NAME: &'static str = "fuchsia.power.system.CpuElementManager";
2840}
2841impl fidl::endpoints::DiscoverableProtocolMarker for CpuElementManagerMarker {}
2842pub type CpuElementManagerAddExecutionStateDependencyResult =
2843    Result<(), AddExecutionStateDependencyError>;
2844
2845pub trait CpuElementManagerProxyInterface: Send + Sync {
2846    type GetCpuDependencyTokenResponseFut: std::future::Future<Output = Result<Cpu, fidl::Error>>
2847        + Send;
2848    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut;
2849    type AddExecutionStateDependencyResponseFut: std::future::Future<
2850            Output = Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error>,
2851        > + Send;
2852    fn r#add_execution_state_dependency(
2853        &self,
2854        payload: CpuElementManagerAddExecutionStateDependencyRequest,
2855    ) -> Self::AddExecutionStateDependencyResponseFut;
2856}
2857#[derive(Debug)]
2858#[cfg(target_os = "fuchsia")]
2859pub struct CpuElementManagerSynchronousProxy {
2860    client: fidl::client::sync::Client,
2861}
2862
2863#[cfg(target_os = "fuchsia")]
2864impl fidl::endpoints::SynchronousProxy for CpuElementManagerSynchronousProxy {
2865    type Proxy = CpuElementManagerProxy;
2866    type Protocol = CpuElementManagerMarker;
2867
2868    fn from_channel(inner: fidl::Channel) -> Self {
2869        Self::new(inner)
2870    }
2871
2872    fn into_channel(self) -> fidl::Channel {
2873        self.client.into_channel()
2874    }
2875
2876    fn as_channel(&self) -> &fidl::Channel {
2877        self.client.as_channel()
2878    }
2879}
2880
2881#[cfg(target_os = "fuchsia")]
2882impl CpuElementManagerSynchronousProxy {
2883    pub fn new(channel: fidl::Channel) -> Self {
2884        let protocol_name =
2885            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2886        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2887    }
2888
2889    pub fn into_channel(self) -> fidl::Channel {
2890        self.client.into_channel()
2891    }
2892
2893    /// Waits until an event arrives and returns it. It is safe for other
2894    /// threads to make concurrent requests while waiting for an event.
2895    pub fn wait_for_event(
2896        &self,
2897        deadline: zx::MonotonicInstant,
2898    ) -> Result<CpuElementManagerEvent, fidl::Error> {
2899        CpuElementManagerEvent::decode(self.client.wait_for_event(deadline)?)
2900    }
2901
2902    /// Gets the assertive dependency token for the CPU power element.
2903    pub fn r#get_cpu_dependency_token(
2904        &self,
2905        ___deadline: zx::MonotonicInstant,
2906    ) -> Result<Cpu, fidl::Error> {
2907        let _response = self
2908            .client
2909            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleType<Cpu>>(
2910                (),
2911                0x2c43645ed70344ba,
2912                fidl::encoding::DynamicFlags::FLEXIBLE,
2913                ___deadline,
2914            )?
2915            .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
2916        Ok(_response)
2917    }
2918
2919    /// Adds a dependency from the Execution State power element to the target
2920    /// power element identified by [`dependency_token`] at [`power_level`].
2921    ///
2922    /// Once the Execution State power element is created, future calls will
2923    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
2924    /// and no changes to Execution State dependencies will be made.
2925    ///
2926    /// If any required entries in the request are missing, the server will
2927    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
2928    pub fn r#add_execution_state_dependency(
2929        &self,
2930        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
2931        ___deadline: zx::MonotonicInstant,
2932    ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
2933        let _response = self.client.send_query::<
2934            CpuElementManagerAddExecutionStateDependencyRequest,
2935            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, AddExecutionStateDependencyError>,
2936        >(
2937            &mut payload,
2938            0xdf2f5ea2af76234,
2939            fidl::encoding::DynamicFlags::FLEXIBLE,
2940            ___deadline,
2941        )?
2942        .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
2943        Ok(_response.map(|x| x))
2944    }
2945}
2946
2947#[cfg(target_os = "fuchsia")]
2948impl From<CpuElementManagerSynchronousProxy> for zx::Handle {
2949    fn from(value: CpuElementManagerSynchronousProxy) -> Self {
2950        value.into_channel().into()
2951    }
2952}
2953
2954#[cfg(target_os = "fuchsia")]
2955impl From<fidl::Channel> for CpuElementManagerSynchronousProxy {
2956    fn from(value: fidl::Channel) -> Self {
2957        Self::new(value)
2958    }
2959}
2960
2961#[cfg(target_os = "fuchsia")]
2962impl fidl::endpoints::FromClient for CpuElementManagerSynchronousProxy {
2963    type Protocol = CpuElementManagerMarker;
2964
2965    fn from_client(value: fidl::endpoints::ClientEnd<CpuElementManagerMarker>) -> Self {
2966        Self::new(value.into_channel())
2967    }
2968}
2969
2970#[derive(Debug, Clone)]
2971pub struct CpuElementManagerProxy {
2972    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2973}
2974
2975impl fidl::endpoints::Proxy for CpuElementManagerProxy {
2976    type Protocol = CpuElementManagerMarker;
2977
2978    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2979        Self::new(inner)
2980    }
2981
2982    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2983        self.client.into_channel().map_err(|client| Self { client })
2984    }
2985
2986    fn as_channel(&self) -> &::fidl::AsyncChannel {
2987        self.client.as_channel()
2988    }
2989}
2990
2991impl CpuElementManagerProxy {
2992    /// Create a new Proxy for fuchsia.power.system/CpuElementManager.
2993    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2994        let protocol_name =
2995            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2996        Self { client: fidl::client::Client::new(channel, protocol_name) }
2997    }
2998
2999    /// Get a Stream of events from the remote end of the protocol.
3000    ///
3001    /// # Panics
3002    ///
3003    /// Panics if the event stream was already taken.
3004    pub fn take_event_stream(&self) -> CpuElementManagerEventStream {
3005        CpuElementManagerEventStream { event_receiver: self.client.take_event_receiver() }
3006    }
3007
3008    /// Gets the assertive dependency token for the CPU power element.
3009    pub fn r#get_cpu_dependency_token(
3010        &self,
3011    ) -> fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect> {
3012        CpuElementManagerProxyInterface::r#get_cpu_dependency_token(self)
3013    }
3014
3015    /// Adds a dependency from the Execution State power element to the target
3016    /// power element identified by [`dependency_token`] at [`power_level`].
3017    ///
3018    /// Once the Execution State power element is created, future calls will
3019    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
3020    /// and no changes to Execution State dependencies will be made.
3021    ///
3022    /// If any required entries in the request are missing, the server will
3023    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
3024    pub fn r#add_execution_state_dependency(
3025        &self,
3026        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
3027    ) -> fidl::client::QueryResponseFut<
3028        CpuElementManagerAddExecutionStateDependencyResult,
3029        fidl::encoding::DefaultFuchsiaResourceDialect,
3030    > {
3031        CpuElementManagerProxyInterface::r#add_execution_state_dependency(self, payload)
3032    }
3033}
3034
3035impl CpuElementManagerProxyInterface for CpuElementManagerProxy {
3036    type GetCpuDependencyTokenResponseFut =
3037        fidl::client::QueryResponseFut<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>;
3038    fn r#get_cpu_dependency_token(&self) -> Self::GetCpuDependencyTokenResponseFut {
3039        fn _decode(
3040            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3041        ) -> Result<Cpu, fidl::Error> {
3042            let _response = fidl::client::decode_transaction_body::<
3043                fidl::encoding::FlexibleType<Cpu>,
3044                fidl::encoding::DefaultFuchsiaResourceDialect,
3045                0x2c43645ed70344ba,
3046            >(_buf?)?
3047            .into_result::<CpuElementManagerMarker>("get_cpu_dependency_token")?;
3048            Ok(_response)
3049        }
3050        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Cpu>(
3051            (),
3052            0x2c43645ed70344ba,
3053            fidl::encoding::DynamicFlags::FLEXIBLE,
3054            _decode,
3055        )
3056    }
3057
3058    type AddExecutionStateDependencyResponseFut = fidl::client::QueryResponseFut<
3059        CpuElementManagerAddExecutionStateDependencyResult,
3060        fidl::encoding::DefaultFuchsiaResourceDialect,
3061    >;
3062    fn r#add_execution_state_dependency(
3063        &self,
3064        mut payload: CpuElementManagerAddExecutionStateDependencyRequest,
3065    ) -> Self::AddExecutionStateDependencyResponseFut {
3066        fn _decode(
3067            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3068        ) -> Result<CpuElementManagerAddExecutionStateDependencyResult, fidl::Error> {
3069            let _response = fidl::client::decode_transaction_body::<
3070                fidl::encoding::FlexibleResultType<
3071                    fidl::encoding::EmptyStruct,
3072                    AddExecutionStateDependencyError,
3073                >,
3074                fidl::encoding::DefaultFuchsiaResourceDialect,
3075                0xdf2f5ea2af76234,
3076            >(_buf?)?
3077            .into_result::<CpuElementManagerMarker>("add_execution_state_dependency")?;
3078            Ok(_response.map(|x| x))
3079        }
3080        self.client.send_query_and_decode::<
3081            CpuElementManagerAddExecutionStateDependencyRequest,
3082            CpuElementManagerAddExecutionStateDependencyResult,
3083        >(
3084            &mut payload,
3085            0xdf2f5ea2af76234,
3086            fidl::encoding::DynamicFlags::FLEXIBLE,
3087            _decode,
3088        )
3089    }
3090}
3091
3092pub struct CpuElementManagerEventStream {
3093    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3094}
3095
3096impl std::marker::Unpin for CpuElementManagerEventStream {}
3097
3098impl futures::stream::FusedStream for CpuElementManagerEventStream {
3099    fn is_terminated(&self) -> bool {
3100        self.event_receiver.is_terminated()
3101    }
3102}
3103
3104impl futures::Stream for CpuElementManagerEventStream {
3105    type Item = Result<CpuElementManagerEvent, fidl::Error>;
3106
3107    fn poll_next(
3108        mut self: std::pin::Pin<&mut Self>,
3109        cx: &mut std::task::Context<'_>,
3110    ) -> std::task::Poll<Option<Self::Item>> {
3111        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3112            &mut self.event_receiver,
3113            cx
3114        )?) {
3115            Some(buf) => std::task::Poll::Ready(Some(CpuElementManagerEvent::decode(buf))),
3116            None => std::task::Poll::Ready(None),
3117        }
3118    }
3119}
3120
3121#[derive(Debug)]
3122pub enum CpuElementManagerEvent {
3123    #[non_exhaustive]
3124    _UnknownEvent {
3125        /// Ordinal of the event that was sent.
3126        ordinal: u64,
3127    },
3128}
3129
3130impl CpuElementManagerEvent {
3131    /// Decodes a message buffer as a [`CpuElementManagerEvent`].
3132    fn decode(
3133        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3134    ) -> Result<CpuElementManagerEvent, fidl::Error> {
3135        let (bytes, _handles) = buf.split_mut();
3136        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3137        debug_assert_eq!(tx_header.tx_id, 0);
3138        match tx_header.ordinal {
3139            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3140                Ok(CpuElementManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3141            }
3142            _ => Err(fidl::Error::UnknownOrdinal {
3143                ordinal: tx_header.ordinal,
3144                protocol_name:
3145                    <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3146            }),
3147        }
3148    }
3149}
3150
3151/// A Stream of incoming requests for fuchsia.power.system/CpuElementManager.
3152pub struct CpuElementManagerRequestStream {
3153    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3154    is_terminated: bool,
3155}
3156
3157impl std::marker::Unpin for CpuElementManagerRequestStream {}
3158
3159impl futures::stream::FusedStream for CpuElementManagerRequestStream {
3160    fn is_terminated(&self) -> bool {
3161        self.is_terminated
3162    }
3163}
3164
3165impl fidl::endpoints::RequestStream for CpuElementManagerRequestStream {
3166    type Protocol = CpuElementManagerMarker;
3167    type ControlHandle = CpuElementManagerControlHandle;
3168
3169    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3170        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3171    }
3172
3173    fn control_handle(&self) -> Self::ControlHandle {
3174        CpuElementManagerControlHandle { inner: self.inner.clone() }
3175    }
3176
3177    fn into_inner(
3178        self,
3179    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3180    {
3181        (self.inner, self.is_terminated)
3182    }
3183
3184    fn from_inner(
3185        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3186        is_terminated: bool,
3187    ) -> Self {
3188        Self { inner, is_terminated }
3189    }
3190}
3191
3192impl futures::Stream for CpuElementManagerRequestStream {
3193    type Item = Result<CpuElementManagerRequest, fidl::Error>;
3194
3195    fn poll_next(
3196        mut self: std::pin::Pin<&mut Self>,
3197        cx: &mut std::task::Context<'_>,
3198    ) -> std::task::Poll<Option<Self::Item>> {
3199        let this = &mut *self;
3200        if this.inner.check_shutdown(cx) {
3201            this.is_terminated = true;
3202            return std::task::Poll::Ready(None);
3203        }
3204        if this.is_terminated {
3205            panic!("polled CpuElementManagerRequestStream after completion");
3206        }
3207        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3208            |bytes, handles| {
3209                match this.inner.channel().read_etc(cx, bytes, handles) {
3210                    std::task::Poll::Ready(Ok(())) => {}
3211                    std::task::Poll::Pending => return std::task::Poll::Pending,
3212                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3213                        this.is_terminated = true;
3214                        return std::task::Poll::Ready(None);
3215                    }
3216                    std::task::Poll::Ready(Err(e)) => {
3217                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3218                            e.into(),
3219                        ))))
3220                    }
3221                }
3222
3223                // A message has been received from the channel
3224                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3225
3226                std::task::Poll::Ready(Some(match header.ordinal {
3227                    0x2c43645ed70344ba => {
3228                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3229                        let mut req = fidl::new_empty!(
3230                            fidl::encoding::EmptyPayload,
3231                            fidl::encoding::DefaultFuchsiaResourceDialect
3232                        );
3233                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3234                        let control_handle =
3235                            CpuElementManagerControlHandle { inner: this.inner.clone() };
3236                        Ok(CpuElementManagerRequest::GetCpuDependencyToken {
3237                            responder: CpuElementManagerGetCpuDependencyTokenResponder {
3238                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3239                                tx_id: header.tx_id,
3240                            },
3241                        })
3242                    }
3243                    0xdf2f5ea2af76234 => {
3244                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3245                        let mut req = fidl::new_empty!(
3246                            CpuElementManagerAddExecutionStateDependencyRequest,
3247                            fidl::encoding::DefaultFuchsiaResourceDialect
3248                        );
3249                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<CpuElementManagerAddExecutionStateDependencyRequest>(&header, _body_bytes, handles, &mut req)?;
3250                        let control_handle =
3251                            CpuElementManagerControlHandle { inner: this.inner.clone() };
3252                        Ok(CpuElementManagerRequest::AddExecutionStateDependency {
3253                            payload: req,
3254                            responder: CpuElementManagerAddExecutionStateDependencyResponder {
3255                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3256                                tx_id: header.tx_id,
3257                            },
3258                        })
3259                    }
3260                    _ if header.tx_id == 0
3261                        && header
3262                            .dynamic_flags()
3263                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3264                    {
3265                        Ok(CpuElementManagerRequest::_UnknownMethod {
3266                            ordinal: header.ordinal,
3267                            control_handle: CpuElementManagerControlHandle {
3268                                inner: this.inner.clone(),
3269                            },
3270                            method_type: fidl::MethodType::OneWay,
3271                        })
3272                    }
3273                    _ if header
3274                        .dynamic_flags()
3275                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3276                    {
3277                        this.inner.send_framework_err(
3278                            fidl::encoding::FrameworkErr::UnknownMethod,
3279                            header.tx_id,
3280                            header.ordinal,
3281                            header.dynamic_flags(),
3282                            (bytes, handles),
3283                        )?;
3284                        Ok(CpuElementManagerRequest::_UnknownMethod {
3285                            ordinal: header.ordinal,
3286                            control_handle: CpuElementManagerControlHandle {
3287                                inner: this.inner.clone(),
3288                            },
3289                            method_type: fidl::MethodType::TwoWay,
3290                        })
3291                    }
3292                    _ => Err(fidl::Error::UnknownOrdinal {
3293                        ordinal: header.ordinal,
3294                        protocol_name:
3295                            <CpuElementManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3296                    }),
3297                }))
3298            },
3299        )
3300    }
3301}
3302
3303/// A service that provides access to CPU-related power elements.
3304#[derive(Debug)]
3305pub enum CpuElementManagerRequest {
3306    /// Gets the assertive dependency token for the CPU power element.
3307    GetCpuDependencyToken { responder: CpuElementManagerGetCpuDependencyTokenResponder },
3308    /// Adds a dependency from the Execution State power element to the target
3309    /// power element identified by [`dependency_token`] at [`power_level`].
3310    ///
3311    /// Once the Execution State power element is created, future calls will
3312    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.BAD_STATE`]
3313    /// and no changes to Execution State dependencies will be made.
3314    ///
3315    /// If any required entries in the request are missing, the server will
3316    /// return [`fuchsia.power.system/AddExecutionStateDependencyError.INVALID_ARGS`].
3317    AddExecutionStateDependency {
3318        payload: CpuElementManagerAddExecutionStateDependencyRequest,
3319        responder: CpuElementManagerAddExecutionStateDependencyResponder,
3320    },
3321    /// An interaction was received which does not match any known method.
3322    #[non_exhaustive]
3323    _UnknownMethod {
3324        /// Ordinal of the method that was called.
3325        ordinal: u64,
3326        control_handle: CpuElementManagerControlHandle,
3327        method_type: fidl::MethodType,
3328    },
3329}
3330
3331impl CpuElementManagerRequest {
3332    #[allow(irrefutable_let_patterns)]
3333    pub fn into_get_cpu_dependency_token(
3334        self,
3335    ) -> Option<(CpuElementManagerGetCpuDependencyTokenResponder)> {
3336        if let CpuElementManagerRequest::GetCpuDependencyToken { responder } = self {
3337            Some((responder))
3338        } else {
3339            None
3340        }
3341    }
3342
3343    #[allow(irrefutable_let_patterns)]
3344    pub fn into_add_execution_state_dependency(
3345        self,
3346    ) -> Option<(
3347        CpuElementManagerAddExecutionStateDependencyRequest,
3348        CpuElementManagerAddExecutionStateDependencyResponder,
3349    )> {
3350        if let CpuElementManagerRequest::AddExecutionStateDependency { payload, responder } = self {
3351            Some((payload, responder))
3352        } else {
3353            None
3354        }
3355    }
3356
3357    /// Name of the method defined in FIDL
3358    pub fn method_name(&self) -> &'static str {
3359        match *self {
3360            CpuElementManagerRequest::GetCpuDependencyToken { .. } => "get_cpu_dependency_token",
3361            CpuElementManagerRequest::AddExecutionStateDependency { .. } => {
3362                "add_execution_state_dependency"
3363            }
3364            CpuElementManagerRequest::_UnknownMethod {
3365                method_type: fidl::MethodType::OneWay,
3366                ..
3367            } => "unknown one-way method",
3368            CpuElementManagerRequest::_UnknownMethod {
3369                method_type: fidl::MethodType::TwoWay,
3370                ..
3371            } => "unknown two-way method",
3372        }
3373    }
3374}
3375
3376#[derive(Debug, Clone)]
3377pub struct CpuElementManagerControlHandle {
3378    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3379}
3380
3381impl fidl::endpoints::ControlHandle for CpuElementManagerControlHandle {
3382    fn shutdown(&self) {
3383        self.inner.shutdown()
3384    }
3385    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3386        self.inner.shutdown_with_epitaph(status)
3387    }
3388
3389    fn is_closed(&self) -> bool {
3390        self.inner.channel().is_closed()
3391    }
3392    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3393        self.inner.channel().on_closed()
3394    }
3395
3396    #[cfg(target_os = "fuchsia")]
3397    fn signal_peer(
3398        &self,
3399        clear_mask: zx::Signals,
3400        set_mask: zx::Signals,
3401    ) -> Result<(), zx_status::Status> {
3402        use fidl::Peered;
3403        self.inner.channel().signal_peer(clear_mask, set_mask)
3404    }
3405}
3406
3407impl CpuElementManagerControlHandle {}
3408
3409#[must_use = "FIDL methods require a response to be sent"]
3410#[derive(Debug)]
3411pub struct CpuElementManagerGetCpuDependencyTokenResponder {
3412    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
3413    tx_id: u32,
3414}
3415
3416/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
3417/// if the responder is dropped without sending a response, so that the client
3418/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3419impl std::ops::Drop for CpuElementManagerGetCpuDependencyTokenResponder {
3420    fn drop(&mut self) {
3421        self.control_handle.shutdown();
3422        // Safety: drops once, never accessed again
3423        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3424    }
3425}
3426
3427impl fidl::endpoints::Responder for CpuElementManagerGetCpuDependencyTokenResponder {
3428    type ControlHandle = CpuElementManagerControlHandle;
3429
3430    fn control_handle(&self) -> &CpuElementManagerControlHandle {
3431        &self.control_handle
3432    }
3433
3434    fn drop_without_shutdown(mut self) {
3435        // Safety: drops once, never accessed again due to mem::forget
3436        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3437        // Prevent Drop from running (which would shut down the channel)
3438        std::mem::forget(self);
3439    }
3440}
3441
3442impl CpuElementManagerGetCpuDependencyTokenResponder {
3443    /// Sends a response to the FIDL transaction.
3444    ///
3445    /// Sets the channel to shutdown if an error occurs.
3446    pub fn send(self, mut payload: Cpu) -> Result<(), fidl::Error> {
3447        let _result = self.send_raw(payload);
3448        if _result.is_err() {
3449            self.control_handle.shutdown();
3450        }
3451        self.drop_without_shutdown();
3452        _result
3453    }
3454
3455    /// Similar to "send" but does not shutdown the channel if an error occurs.
3456    pub fn send_no_shutdown_on_err(self, mut payload: Cpu) -> Result<(), fidl::Error> {
3457        let _result = self.send_raw(payload);
3458        self.drop_without_shutdown();
3459        _result
3460    }
3461
3462    fn send_raw(&self, mut payload: Cpu) -> Result<(), fidl::Error> {
3463        self.control_handle.inner.send::<fidl::encoding::FlexibleType<Cpu>>(
3464            fidl::encoding::Flexible::new(&mut payload),
3465            self.tx_id,
3466            0x2c43645ed70344ba,
3467            fidl::encoding::DynamicFlags::FLEXIBLE,
3468        )
3469    }
3470}
3471
3472#[must_use = "FIDL methods require a response to be sent"]
3473#[derive(Debug)]
3474pub struct CpuElementManagerAddExecutionStateDependencyResponder {
3475    control_handle: std::mem::ManuallyDrop<CpuElementManagerControlHandle>,
3476    tx_id: u32,
3477}
3478
3479/// Set the the channel to be shutdown (see [`CpuElementManagerControlHandle::shutdown`])
3480/// if the responder is dropped without sending a response, so that the client
3481/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3482impl std::ops::Drop for CpuElementManagerAddExecutionStateDependencyResponder {
3483    fn drop(&mut self) {
3484        self.control_handle.shutdown();
3485        // Safety: drops once, never accessed again
3486        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3487    }
3488}
3489
3490impl fidl::endpoints::Responder for CpuElementManagerAddExecutionStateDependencyResponder {
3491    type ControlHandle = CpuElementManagerControlHandle;
3492
3493    fn control_handle(&self) -> &CpuElementManagerControlHandle {
3494        &self.control_handle
3495    }
3496
3497    fn drop_without_shutdown(mut self) {
3498        // Safety: drops once, never accessed again due to mem::forget
3499        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3500        // Prevent Drop from running (which would shut down the channel)
3501        std::mem::forget(self);
3502    }
3503}
3504
3505impl CpuElementManagerAddExecutionStateDependencyResponder {
3506    /// Sends a response to the FIDL transaction.
3507    ///
3508    /// Sets the channel to shutdown if an error occurs.
3509    pub fn send(
3510        self,
3511        mut result: Result<(), AddExecutionStateDependencyError>,
3512    ) -> Result<(), fidl::Error> {
3513        let _result = self.send_raw(result);
3514        if _result.is_err() {
3515            self.control_handle.shutdown();
3516        }
3517        self.drop_without_shutdown();
3518        _result
3519    }
3520
3521    /// Similar to "send" but does not shutdown the channel if an error occurs.
3522    pub fn send_no_shutdown_on_err(
3523        self,
3524        mut result: Result<(), AddExecutionStateDependencyError>,
3525    ) -> Result<(), fidl::Error> {
3526        let _result = self.send_raw(result);
3527        self.drop_without_shutdown();
3528        _result
3529    }
3530
3531    fn send_raw(
3532        &self,
3533        mut result: Result<(), AddExecutionStateDependencyError>,
3534    ) -> Result<(), fidl::Error> {
3535        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
3536            fidl::encoding::EmptyStruct,
3537            AddExecutionStateDependencyError,
3538        >>(
3539            fidl::encoding::FlexibleResult::new(result),
3540            self.tx_id,
3541            0xdf2f5ea2af76234,
3542            fidl::encoding::DynamicFlags::FLEXIBLE,
3543        )
3544    }
3545}
3546
3547#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
3548pub struct SuspendBlockerMarker;
3549
3550impl fidl::endpoints::ProtocolMarker for SuspendBlockerMarker {
3551    type Proxy = SuspendBlockerProxy;
3552    type RequestStream = SuspendBlockerRequestStream;
3553    #[cfg(target_os = "fuchsia")]
3554    type SynchronousProxy = SuspendBlockerSynchronousProxy;
3555
3556    const DEBUG_NAME: &'static str = "(anonymous) SuspendBlocker";
3557}
3558
3559pub trait SuspendBlockerProxyInterface: Send + Sync {
3560    type BeforeSuspendResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3561    fn r#before_suspend(&self) -> Self::BeforeSuspendResponseFut;
3562    type AfterResumeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
3563    fn r#after_resume(&self) -> Self::AfterResumeResponseFut;
3564}
3565#[derive(Debug)]
3566#[cfg(target_os = "fuchsia")]
3567pub struct SuspendBlockerSynchronousProxy {
3568    client: fidl::client::sync::Client,
3569}
3570
3571#[cfg(target_os = "fuchsia")]
3572impl fidl::endpoints::SynchronousProxy for SuspendBlockerSynchronousProxy {
3573    type Proxy = SuspendBlockerProxy;
3574    type Protocol = SuspendBlockerMarker;
3575
3576    fn from_channel(inner: fidl::Channel) -> Self {
3577        Self::new(inner)
3578    }
3579
3580    fn into_channel(self) -> fidl::Channel {
3581        self.client.into_channel()
3582    }
3583
3584    fn as_channel(&self) -> &fidl::Channel {
3585        self.client.as_channel()
3586    }
3587}
3588
3589#[cfg(target_os = "fuchsia")]
3590impl SuspendBlockerSynchronousProxy {
3591    pub fn new(channel: fidl::Channel) -> Self {
3592        let protocol_name = <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3593        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
3594    }
3595
3596    pub fn into_channel(self) -> fidl::Channel {
3597        self.client.into_channel()
3598    }
3599
3600    /// Waits until an event arrives and returns it. It is safe for other
3601    /// threads to make concurrent requests while waiting for an event.
3602    pub fn wait_for_event(
3603        &self,
3604        deadline: zx::MonotonicInstant,
3605    ) -> Result<SuspendBlockerEvent, fidl::Error> {
3606        SuspendBlockerEvent::decode(self.client.wait_for_event(deadline)?)
3607    }
3608
3609    /// Called after system activity governor begins operations to suspend the
3610    /// hardware platform.
3611    ///
3612    /// The server is expected to respond once it has performed the operations
3613    /// it needs to prepare itself for suspend, if any. All dependencies of
3614    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3615    /// the duration of this call and may be revoked once the server replies.
3616    ///
3617    /// Operations to suspend the hardware platform may vary between different
3618    /// hardware platforms and product configurations. At a minimum, the client
3619    /// and server MUST assume that general code execution continues
3620    /// until a reply to this call is received by the client. If the
3621    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3622    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3623    ///
3624    /// SuspendBlocker MUST NOT call
3625    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
3626    /// that blocks on raising Execution State above its Inactive level.
3627    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
3628    /// call.) Doing so will currently result in a deadlock. This constraint
3629    /// will eventually be removed; see https://fxbug.dev/391429689.
3630    pub fn r#before_suspend(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3631        let _response = self.client.send_query::<
3632            fidl::encoding::EmptyPayload,
3633            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3634        >(
3635            (),
3636            0x6b569393a01a6d80,
3637            fidl::encoding::DynamicFlags::FLEXIBLE,
3638            ___deadline,
3639        )?
3640        .into_result::<SuspendBlockerMarker>("before_suspend")?;
3641        Ok(_response)
3642    }
3643
3644    /// Called after system activity governor is aware that the hardware
3645    /// platform has resumed.
3646    ///
3647    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
3648    /// be satisified when this call is issued, and the `BeforeSuspend` method
3649    /// will be invoked before that guarantee is removed.
3650    ///
3651    /// SAG does not block on the response to this method, so the SuspendBlocker
3652    /// may safely take actions that block on raising Execution State's power
3653    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
3654    pub fn r#after_resume(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
3655        let _response = self.client.send_query::<
3656            fidl::encoding::EmptyPayload,
3657            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3658        >(
3659            (),
3660            0x6a329cfcc73f2dea,
3661            fidl::encoding::DynamicFlags::FLEXIBLE,
3662            ___deadline,
3663        )?
3664        .into_result::<SuspendBlockerMarker>("after_resume")?;
3665        Ok(_response)
3666    }
3667}
3668
3669#[cfg(target_os = "fuchsia")]
3670impl From<SuspendBlockerSynchronousProxy> for zx::Handle {
3671    fn from(value: SuspendBlockerSynchronousProxy) -> Self {
3672        value.into_channel().into()
3673    }
3674}
3675
3676#[cfg(target_os = "fuchsia")]
3677impl From<fidl::Channel> for SuspendBlockerSynchronousProxy {
3678    fn from(value: fidl::Channel) -> Self {
3679        Self::new(value)
3680    }
3681}
3682
3683#[cfg(target_os = "fuchsia")]
3684impl fidl::endpoints::FromClient for SuspendBlockerSynchronousProxy {
3685    type Protocol = SuspendBlockerMarker;
3686
3687    fn from_client(value: fidl::endpoints::ClientEnd<SuspendBlockerMarker>) -> Self {
3688        Self::new(value.into_channel())
3689    }
3690}
3691
3692#[derive(Debug, Clone)]
3693pub struct SuspendBlockerProxy {
3694    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3695}
3696
3697impl fidl::endpoints::Proxy for SuspendBlockerProxy {
3698    type Protocol = SuspendBlockerMarker;
3699
3700    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3701        Self::new(inner)
3702    }
3703
3704    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3705        self.client.into_channel().map_err(|client| Self { client })
3706    }
3707
3708    fn as_channel(&self) -> &::fidl::AsyncChannel {
3709        self.client.as_channel()
3710    }
3711}
3712
3713impl SuspendBlockerProxy {
3714    /// Create a new Proxy for fuchsia.power.system/SuspendBlocker.
3715    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3716        let protocol_name = <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3717        Self { client: fidl::client::Client::new(channel, protocol_name) }
3718    }
3719
3720    /// Get a Stream of events from the remote end of the protocol.
3721    ///
3722    /// # Panics
3723    ///
3724    /// Panics if the event stream was already taken.
3725    pub fn take_event_stream(&self) -> SuspendBlockerEventStream {
3726        SuspendBlockerEventStream { event_receiver: self.client.take_event_receiver() }
3727    }
3728
3729    /// Called after system activity governor begins operations to suspend the
3730    /// hardware platform.
3731    ///
3732    /// The server is expected to respond once it has performed the operations
3733    /// it needs to prepare itself for suspend, if any. All dependencies of
3734    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3735    /// the duration of this call and may be revoked once the server replies.
3736    ///
3737    /// Operations to suspend the hardware platform may vary between different
3738    /// hardware platforms and product configurations. At a minimum, the client
3739    /// and server MUST assume that general code execution continues
3740    /// until a reply to this call is received by the client. If the
3741    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3742    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3743    ///
3744    /// SuspendBlocker MUST NOT call
3745    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
3746    /// that blocks on raising Execution State above its Inactive level.
3747    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
3748    /// call.) Doing so will currently result in a deadlock. This constraint
3749    /// will eventually be removed; see https://fxbug.dev/391429689.
3750    pub fn r#before_suspend(
3751        &self,
3752    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3753        SuspendBlockerProxyInterface::r#before_suspend(self)
3754    }
3755
3756    /// Called after system activity governor is aware that the hardware
3757    /// platform has resumed.
3758    ///
3759    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
3760    /// be satisified when this call is issued, and the `BeforeSuspend` method
3761    /// will be invoked before that guarantee is removed.
3762    ///
3763    /// SAG does not block on the response to this method, so the SuspendBlocker
3764    /// may safely take actions that block on raising Execution State's power
3765    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
3766    pub fn r#after_resume(
3767        &self,
3768    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3769        SuspendBlockerProxyInterface::r#after_resume(self)
3770    }
3771}
3772
3773impl SuspendBlockerProxyInterface for SuspendBlockerProxy {
3774    type BeforeSuspendResponseFut =
3775        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3776    fn r#before_suspend(&self) -> Self::BeforeSuspendResponseFut {
3777        fn _decode(
3778            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3779        ) -> Result<(), fidl::Error> {
3780            let _response = fidl::client::decode_transaction_body::<
3781                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3782                fidl::encoding::DefaultFuchsiaResourceDialect,
3783                0x6b569393a01a6d80,
3784            >(_buf?)?
3785            .into_result::<SuspendBlockerMarker>("before_suspend")?;
3786            Ok(_response)
3787        }
3788        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3789            (),
3790            0x6b569393a01a6d80,
3791            fidl::encoding::DynamicFlags::FLEXIBLE,
3792            _decode,
3793        )
3794    }
3795
3796    type AfterResumeResponseFut =
3797        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3798    fn r#after_resume(&self) -> Self::AfterResumeResponseFut {
3799        fn _decode(
3800            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3801        ) -> Result<(), fidl::Error> {
3802            let _response = fidl::client::decode_transaction_body::<
3803                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3804                fidl::encoding::DefaultFuchsiaResourceDialect,
3805                0x6a329cfcc73f2dea,
3806            >(_buf?)?
3807            .into_result::<SuspendBlockerMarker>("after_resume")?;
3808            Ok(_response)
3809        }
3810        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3811            (),
3812            0x6a329cfcc73f2dea,
3813            fidl::encoding::DynamicFlags::FLEXIBLE,
3814            _decode,
3815        )
3816    }
3817}
3818
3819pub struct SuspendBlockerEventStream {
3820    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3821}
3822
3823impl std::marker::Unpin for SuspendBlockerEventStream {}
3824
3825impl futures::stream::FusedStream for SuspendBlockerEventStream {
3826    fn is_terminated(&self) -> bool {
3827        self.event_receiver.is_terminated()
3828    }
3829}
3830
3831impl futures::Stream for SuspendBlockerEventStream {
3832    type Item = Result<SuspendBlockerEvent, fidl::Error>;
3833
3834    fn poll_next(
3835        mut self: std::pin::Pin<&mut Self>,
3836        cx: &mut std::task::Context<'_>,
3837    ) -> std::task::Poll<Option<Self::Item>> {
3838        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3839            &mut self.event_receiver,
3840            cx
3841        )?) {
3842            Some(buf) => std::task::Poll::Ready(Some(SuspendBlockerEvent::decode(buf))),
3843            None => std::task::Poll::Ready(None),
3844        }
3845    }
3846}
3847
3848#[derive(Debug)]
3849pub enum SuspendBlockerEvent {
3850    #[non_exhaustive]
3851    _UnknownEvent {
3852        /// Ordinal of the event that was sent.
3853        ordinal: u64,
3854    },
3855}
3856
3857impl SuspendBlockerEvent {
3858    /// Decodes a message buffer as a [`SuspendBlockerEvent`].
3859    fn decode(
3860        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3861    ) -> Result<SuspendBlockerEvent, fidl::Error> {
3862        let (bytes, _handles) = buf.split_mut();
3863        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3864        debug_assert_eq!(tx_header.tx_id, 0);
3865        match tx_header.ordinal {
3866            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3867                Ok(SuspendBlockerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3868            }
3869            _ => Err(fidl::Error::UnknownOrdinal {
3870                ordinal: tx_header.ordinal,
3871                protocol_name:
3872                    <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3873            }),
3874        }
3875    }
3876}
3877
3878/// A Stream of incoming requests for fuchsia.power.system/SuspendBlocker.
3879pub struct SuspendBlockerRequestStream {
3880    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3881    is_terminated: bool,
3882}
3883
3884impl std::marker::Unpin for SuspendBlockerRequestStream {}
3885
3886impl futures::stream::FusedStream for SuspendBlockerRequestStream {
3887    fn is_terminated(&self) -> bool {
3888        self.is_terminated
3889    }
3890}
3891
3892impl fidl::endpoints::RequestStream for SuspendBlockerRequestStream {
3893    type Protocol = SuspendBlockerMarker;
3894    type ControlHandle = SuspendBlockerControlHandle;
3895
3896    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3897        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3898    }
3899
3900    fn control_handle(&self) -> Self::ControlHandle {
3901        SuspendBlockerControlHandle { inner: self.inner.clone() }
3902    }
3903
3904    fn into_inner(
3905        self,
3906    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3907    {
3908        (self.inner, self.is_terminated)
3909    }
3910
3911    fn from_inner(
3912        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3913        is_terminated: bool,
3914    ) -> Self {
3915        Self { inner, is_terminated }
3916    }
3917}
3918
3919impl futures::Stream for SuspendBlockerRequestStream {
3920    type Item = Result<SuspendBlockerRequest, fidl::Error>;
3921
3922    fn poll_next(
3923        mut self: std::pin::Pin<&mut Self>,
3924        cx: &mut std::task::Context<'_>,
3925    ) -> std::task::Poll<Option<Self::Item>> {
3926        let this = &mut *self;
3927        if this.inner.check_shutdown(cx) {
3928            this.is_terminated = true;
3929            return std::task::Poll::Ready(None);
3930        }
3931        if this.is_terminated {
3932            panic!("polled SuspendBlockerRequestStream after completion");
3933        }
3934        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3935            |bytes, handles| {
3936                match this.inner.channel().read_etc(cx, bytes, handles) {
3937                    std::task::Poll::Ready(Ok(())) => {}
3938                    std::task::Poll::Pending => return std::task::Poll::Pending,
3939                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3940                        this.is_terminated = true;
3941                        return std::task::Poll::Ready(None);
3942                    }
3943                    std::task::Poll::Ready(Err(e)) => {
3944                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3945                            e.into(),
3946                        ))))
3947                    }
3948                }
3949
3950                // A message has been received from the channel
3951                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3952
3953                std::task::Poll::Ready(Some(match header.ordinal {
3954                    0x6b569393a01a6d80 => {
3955                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3956                        let mut req = fidl::new_empty!(
3957                            fidl::encoding::EmptyPayload,
3958                            fidl::encoding::DefaultFuchsiaResourceDialect
3959                        );
3960                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3961                        let control_handle =
3962                            SuspendBlockerControlHandle { inner: this.inner.clone() };
3963                        Ok(SuspendBlockerRequest::BeforeSuspend {
3964                            responder: SuspendBlockerBeforeSuspendResponder {
3965                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3966                                tx_id: header.tx_id,
3967                            },
3968                        })
3969                    }
3970                    0x6a329cfcc73f2dea => {
3971                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3972                        let mut req = fidl::new_empty!(
3973                            fidl::encoding::EmptyPayload,
3974                            fidl::encoding::DefaultFuchsiaResourceDialect
3975                        );
3976                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3977                        let control_handle =
3978                            SuspendBlockerControlHandle { inner: this.inner.clone() };
3979                        Ok(SuspendBlockerRequest::AfterResume {
3980                            responder: SuspendBlockerAfterResumeResponder {
3981                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3982                                tx_id: header.tx_id,
3983                            },
3984                        })
3985                    }
3986                    _ if header.tx_id == 0
3987                        && header
3988                            .dynamic_flags()
3989                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3990                    {
3991                        Ok(SuspendBlockerRequest::_UnknownMethod {
3992                            ordinal: header.ordinal,
3993                            control_handle: SuspendBlockerControlHandle {
3994                                inner: this.inner.clone(),
3995                            },
3996                            method_type: fidl::MethodType::OneWay,
3997                        })
3998                    }
3999                    _ if header
4000                        .dynamic_flags()
4001                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
4002                    {
4003                        this.inner.send_framework_err(
4004                            fidl::encoding::FrameworkErr::UnknownMethod,
4005                            header.tx_id,
4006                            header.ordinal,
4007                            header.dynamic_flags(),
4008                            (bytes, handles),
4009                        )?;
4010                        Ok(SuspendBlockerRequest::_UnknownMethod {
4011                            ordinal: header.ordinal,
4012                            control_handle: SuspendBlockerControlHandle {
4013                                inner: this.inner.clone(),
4014                            },
4015                            method_type: fidl::MethodType::TwoWay,
4016                        })
4017                    }
4018                    _ => Err(fidl::Error::UnknownOrdinal {
4019                        ordinal: header.ordinal,
4020                        protocol_name:
4021                            <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4022                    }),
4023                }))
4024            },
4025        )
4026    }
4027}
4028
4029/// An entity that blocks suspend until it handles transitions across hardware
4030/// platform suspend and resume.
4031#[derive(Debug)]
4032pub enum SuspendBlockerRequest {
4033    /// Called after system activity governor begins operations to suspend the
4034    /// hardware platform.
4035    ///
4036    /// The server is expected to respond once it has performed the operations
4037    /// it needs to prepare itself for suspend, if any. All dependencies of
4038    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
4039    /// the duration of this call and may be revoked once the server replies.
4040    ///
4041    /// Operations to suspend the hardware platform may vary between different
4042    /// hardware platforms and product configurations. At a minimum, the client
4043    /// and server MUST assume that general code execution continues
4044    /// until a reply to this call is received by the client. If the
4045    /// SuspendBlocker wants to preempt suspend operations, it MUST call
4046    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
4047    ///
4048    /// SuspendBlocker MUST NOT call
4049    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
4050    /// that blocks on raising Execution State above its Inactive level.
4051    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
4052    /// call.) Doing so will currently result in a deadlock. This constraint
4053    /// will eventually be removed; see https://fxbug.dev/391429689.
4054    BeforeSuspend { responder: SuspendBlockerBeforeSuspendResponder },
4055    /// Called after system activity governor is aware that the hardware
4056    /// platform has resumed.
4057    ///
4058    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
4059    /// be satisified when this call is issued, and the `BeforeSuspend` method
4060    /// will be invoked before that guarantee is removed.
4061    ///
4062    /// SAG does not block on the response to this method, so the SuspendBlocker
4063    /// may safely take actions that block on raising Execution State's power
4064    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
4065    AfterResume { responder: SuspendBlockerAfterResumeResponder },
4066    /// An interaction was received which does not match any known method.
4067    #[non_exhaustive]
4068    _UnknownMethod {
4069        /// Ordinal of the method that was called.
4070        ordinal: u64,
4071        control_handle: SuspendBlockerControlHandle,
4072        method_type: fidl::MethodType,
4073    },
4074}
4075
4076impl SuspendBlockerRequest {
4077    #[allow(irrefutable_let_patterns)]
4078    pub fn into_before_suspend(self) -> Option<(SuspendBlockerBeforeSuspendResponder)> {
4079        if let SuspendBlockerRequest::BeforeSuspend { responder } = self {
4080            Some((responder))
4081        } else {
4082            None
4083        }
4084    }
4085
4086    #[allow(irrefutable_let_patterns)]
4087    pub fn into_after_resume(self) -> Option<(SuspendBlockerAfterResumeResponder)> {
4088        if let SuspendBlockerRequest::AfterResume { responder } = self {
4089            Some((responder))
4090        } else {
4091            None
4092        }
4093    }
4094
4095    /// Name of the method defined in FIDL
4096    pub fn method_name(&self) -> &'static str {
4097        match *self {
4098            SuspendBlockerRequest::BeforeSuspend { .. } => "before_suspend",
4099            SuspendBlockerRequest::AfterResume { .. } => "after_resume",
4100            SuspendBlockerRequest::_UnknownMethod {
4101                method_type: fidl::MethodType::OneWay, ..
4102            } => "unknown one-way method",
4103            SuspendBlockerRequest::_UnknownMethod {
4104                method_type: fidl::MethodType::TwoWay, ..
4105            } => "unknown two-way method",
4106        }
4107    }
4108}
4109
4110#[derive(Debug, Clone)]
4111pub struct SuspendBlockerControlHandle {
4112    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
4113}
4114
4115impl fidl::endpoints::ControlHandle for SuspendBlockerControlHandle {
4116    fn shutdown(&self) {
4117        self.inner.shutdown()
4118    }
4119    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
4120        self.inner.shutdown_with_epitaph(status)
4121    }
4122
4123    fn is_closed(&self) -> bool {
4124        self.inner.channel().is_closed()
4125    }
4126    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
4127        self.inner.channel().on_closed()
4128    }
4129
4130    #[cfg(target_os = "fuchsia")]
4131    fn signal_peer(
4132        &self,
4133        clear_mask: zx::Signals,
4134        set_mask: zx::Signals,
4135    ) -> Result<(), zx_status::Status> {
4136        use fidl::Peered;
4137        self.inner.channel().signal_peer(clear_mask, set_mask)
4138    }
4139}
4140
4141impl SuspendBlockerControlHandle {}
4142
4143#[must_use = "FIDL methods require a response to be sent"]
4144#[derive(Debug)]
4145pub struct SuspendBlockerBeforeSuspendResponder {
4146    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
4147    tx_id: u32,
4148}
4149
4150/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
4151/// if the responder is dropped without sending a response, so that the client
4152/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4153impl std::ops::Drop for SuspendBlockerBeforeSuspendResponder {
4154    fn drop(&mut self) {
4155        self.control_handle.shutdown();
4156        // Safety: drops once, never accessed again
4157        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4158    }
4159}
4160
4161impl fidl::endpoints::Responder for SuspendBlockerBeforeSuspendResponder {
4162    type ControlHandle = SuspendBlockerControlHandle;
4163
4164    fn control_handle(&self) -> &SuspendBlockerControlHandle {
4165        &self.control_handle
4166    }
4167
4168    fn drop_without_shutdown(mut self) {
4169        // Safety: drops once, never accessed again due to mem::forget
4170        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4171        // Prevent Drop from running (which would shut down the channel)
4172        std::mem::forget(self);
4173    }
4174}
4175
4176impl SuspendBlockerBeforeSuspendResponder {
4177    /// Sends a response to the FIDL transaction.
4178    ///
4179    /// Sets the channel to shutdown if an error occurs.
4180    pub fn send(self) -> Result<(), fidl::Error> {
4181        let _result = self.send_raw();
4182        if _result.is_err() {
4183            self.control_handle.shutdown();
4184        }
4185        self.drop_without_shutdown();
4186        _result
4187    }
4188
4189    /// Similar to "send" but does not shutdown the channel if an error occurs.
4190    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4191        let _result = self.send_raw();
4192        self.drop_without_shutdown();
4193        _result
4194    }
4195
4196    fn send_raw(&self) -> Result<(), fidl::Error> {
4197        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4198            fidl::encoding::Flexible::new(()),
4199            self.tx_id,
4200            0x6b569393a01a6d80,
4201            fidl::encoding::DynamicFlags::FLEXIBLE,
4202        )
4203    }
4204}
4205
4206#[must_use = "FIDL methods require a response to be sent"]
4207#[derive(Debug)]
4208pub struct SuspendBlockerAfterResumeResponder {
4209    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
4210    tx_id: u32,
4211}
4212
4213/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
4214/// if the responder is dropped without sending a response, so that the client
4215/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
4216impl std::ops::Drop for SuspendBlockerAfterResumeResponder {
4217    fn drop(&mut self) {
4218        self.control_handle.shutdown();
4219        // Safety: drops once, never accessed again
4220        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4221    }
4222}
4223
4224impl fidl::endpoints::Responder for SuspendBlockerAfterResumeResponder {
4225    type ControlHandle = SuspendBlockerControlHandle;
4226
4227    fn control_handle(&self) -> &SuspendBlockerControlHandle {
4228        &self.control_handle
4229    }
4230
4231    fn drop_without_shutdown(mut self) {
4232        // Safety: drops once, never accessed again due to mem::forget
4233        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
4234        // Prevent Drop from running (which would shut down the channel)
4235        std::mem::forget(self);
4236    }
4237}
4238
4239impl SuspendBlockerAfterResumeResponder {
4240    /// Sends a response to the FIDL transaction.
4241    ///
4242    /// Sets the channel to shutdown if an error occurs.
4243    pub fn send(self) -> Result<(), fidl::Error> {
4244        let _result = self.send_raw();
4245        if _result.is_err() {
4246            self.control_handle.shutdown();
4247        }
4248        self.drop_without_shutdown();
4249        _result
4250    }
4251
4252    /// Similar to "send" but does not shutdown the channel if an error occurs.
4253    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
4254        let _result = self.send_raw();
4255        self.drop_without_shutdown();
4256        _result
4257    }
4258
4259    fn send_raw(&self) -> Result<(), fidl::Error> {
4260        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
4261            fidl::encoding::Flexible::new(()),
4262            self.tx_id,
4263            0x6a329cfcc73f2dea,
4264            fidl::encoding::DynamicFlags::FLEXIBLE,
4265        )
4266    }
4267}
4268
4269mod internal {
4270    use super::*;
4271
4272    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
4273        type Borrowed<'a> = &'a mut Self;
4274        fn take_or_borrow<'a>(
4275            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4276        ) -> Self::Borrowed<'a> {
4277            value
4278        }
4279    }
4280
4281    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
4282        type Owned = Self;
4283
4284        #[inline(always)]
4285        fn inline_align(_context: fidl::encoding::Context) -> usize {
4286            4
4287        }
4288
4289        #[inline(always)]
4290        fn inline_size(_context: fidl::encoding::Context) -> usize {
4291            4
4292        }
4293    }
4294
4295    unsafe impl
4296        fidl::encoding::Encode<
4297            ActivityGovernorAcquireWakeLeaseResponse,
4298            fidl::encoding::DefaultFuchsiaResourceDialect,
4299        > for &mut ActivityGovernorAcquireWakeLeaseResponse
4300    {
4301        #[inline]
4302        unsafe fn encode(
4303            self,
4304            encoder: &mut fidl::encoding::Encoder<
4305                '_,
4306                fidl::encoding::DefaultFuchsiaResourceDialect,
4307            >,
4308            offset: usize,
4309            _depth: fidl::encoding::Depth,
4310        ) -> fidl::Result<()> {
4311            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
4312            // Delegate to tuple encoding.
4313            fidl::encoding::Encode::<
4314                ActivityGovernorAcquireWakeLeaseResponse,
4315                fidl::encoding::DefaultFuchsiaResourceDialect,
4316            >::encode(
4317                (<fidl::encoding::HandleType<
4318                    fidl::EventPair,
4319                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4320                    16387,
4321                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4322                    &mut self.token
4323                ),),
4324                encoder,
4325                offset,
4326                _depth,
4327            )
4328        }
4329    }
4330    unsafe impl<
4331            T0: fidl::encoding::Encode<
4332                fidl::encoding::HandleType<
4333                    fidl::EventPair,
4334                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4335                    16387,
4336                >,
4337                fidl::encoding::DefaultFuchsiaResourceDialect,
4338            >,
4339        >
4340        fidl::encoding::Encode<
4341            ActivityGovernorAcquireWakeLeaseResponse,
4342            fidl::encoding::DefaultFuchsiaResourceDialect,
4343        > for (T0,)
4344    {
4345        #[inline]
4346        unsafe fn encode(
4347            self,
4348            encoder: &mut fidl::encoding::Encoder<
4349                '_,
4350                fidl::encoding::DefaultFuchsiaResourceDialect,
4351            >,
4352            offset: usize,
4353            depth: fidl::encoding::Depth,
4354        ) -> fidl::Result<()> {
4355            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
4356            // Zero out padding regions. There's no need to apply masks
4357            // because the unmasked parts will be overwritten by fields.
4358            // Write the fields.
4359            self.0.encode(encoder, offset + 0, depth)?;
4360            Ok(())
4361        }
4362    }
4363
4364    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4365        for ActivityGovernorAcquireWakeLeaseResponse
4366    {
4367        #[inline(always)]
4368        fn new_empty() -> Self {
4369            Self {
4370                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4371            }
4372        }
4373
4374        #[inline]
4375        unsafe fn decode(
4376            &mut self,
4377            decoder: &mut fidl::encoding::Decoder<
4378                '_,
4379                fidl::encoding::DefaultFuchsiaResourceDialect,
4380            >,
4381            offset: usize,
4382            _depth: fidl::encoding::Depth,
4383        ) -> fidl::Result<()> {
4384            decoder.debug_check_bounds::<Self>(offset);
4385            // Verify that padding bytes are zero.
4386            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4387            Ok(())
4388        }
4389    }
4390
4391    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
4392        type Borrowed<'a> = &'a mut Self;
4393        fn take_or_borrow<'a>(
4394            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4395        ) -> Self::Borrowed<'a> {
4396            value
4397        }
4398    }
4399
4400    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
4401        type Owned = Self;
4402
4403        #[inline(always)]
4404        fn inline_align(_context: fidl::encoding::Context) -> usize {
4405            4
4406        }
4407
4408        #[inline(always)]
4409        fn inline_size(_context: fidl::encoding::Context) -> usize {
4410            4
4411        }
4412    }
4413
4414    unsafe impl
4415        fidl::encoding::Encode<
4416            ActivityGovernorRegisterSuspendBlockerResponse,
4417            fidl::encoding::DefaultFuchsiaResourceDialect,
4418        > for &mut ActivityGovernorRegisterSuspendBlockerResponse
4419    {
4420        #[inline]
4421        unsafe fn encode(
4422            self,
4423            encoder: &mut fidl::encoding::Encoder<
4424                '_,
4425                fidl::encoding::DefaultFuchsiaResourceDialect,
4426            >,
4427            offset: usize,
4428            _depth: fidl::encoding::Depth,
4429        ) -> fidl::Result<()> {
4430            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
4431            // Delegate to tuple encoding.
4432            fidl::encoding::Encode::<
4433                ActivityGovernorRegisterSuspendBlockerResponse,
4434                fidl::encoding::DefaultFuchsiaResourceDialect,
4435            >::encode(
4436                (<fidl::encoding::HandleType<
4437                    fidl::EventPair,
4438                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4439                    16387,
4440                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4441                    &mut self.token
4442                ),),
4443                encoder,
4444                offset,
4445                _depth,
4446            )
4447        }
4448    }
4449    unsafe impl<
4450            T0: fidl::encoding::Encode<
4451                fidl::encoding::HandleType<
4452                    fidl::EventPair,
4453                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4454                    16387,
4455                >,
4456                fidl::encoding::DefaultFuchsiaResourceDialect,
4457            >,
4458        >
4459        fidl::encoding::Encode<
4460            ActivityGovernorRegisterSuspendBlockerResponse,
4461            fidl::encoding::DefaultFuchsiaResourceDialect,
4462        > for (T0,)
4463    {
4464        #[inline]
4465        unsafe fn encode(
4466            self,
4467            encoder: &mut fidl::encoding::Encoder<
4468                '_,
4469                fidl::encoding::DefaultFuchsiaResourceDialect,
4470            >,
4471            offset: usize,
4472            depth: fidl::encoding::Depth,
4473        ) -> fidl::Result<()> {
4474            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
4475            // Zero out padding regions. There's no need to apply masks
4476            // because the unmasked parts will be overwritten by fields.
4477            // Write the fields.
4478            self.0.encode(encoder, offset + 0, depth)?;
4479            Ok(())
4480        }
4481    }
4482
4483    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4484        for ActivityGovernorRegisterSuspendBlockerResponse
4485    {
4486        #[inline(always)]
4487        fn new_empty() -> Self {
4488            Self {
4489                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4490            }
4491        }
4492
4493        #[inline]
4494        unsafe fn decode(
4495            &mut self,
4496            decoder: &mut fidl::encoding::Decoder<
4497                '_,
4498                fidl::encoding::DefaultFuchsiaResourceDialect,
4499            >,
4500            offset: usize,
4501            _depth: fidl::encoding::Depth,
4502        ) -> fidl::Result<()> {
4503            decoder.debug_check_bounds::<Self>(offset);
4504            // Verify that padding bytes are zero.
4505            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4506            Ok(())
4507        }
4508    }
4509
4510    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4511        type Borrowed<'a> = &'a mut Self;
4512        fn take_or_borrow<'a>(
4513            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4514        ) -> Self::Borrowed<'a> {
4515            value
4516        }
4517    }
4518
4519    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4520        type Owned = Self;
4521
4522        #[inline(always)]
4523        fn inline_align(_context: fidl::encoding::Context) -> usize {
4524            4
4525        }
4526
4527        #[inline(always)]
4528        fn inline_size(_context: fidl::encoding::Context) -> usize {
4529            4
4530        }
4531    }
4532
4533    unsafe impl
4534        fidl::encoding::Encode<
4535            ActivityGovernorTakeApplicationActivityLeaseResponse,
4536            fidl::encoding::DefaultFuchsiaResourceDialect,
4537        > for &mut ActivityGovernorTakeApplicationActivityLeaseResponse
4538    {
4539        #[inline]
4540        unsafe fn encode(
4541            self,
4542            encoder: &mut fidl::encoding::Encoder<
4543                '_,
4544                fidl::encoding::DefaultFuchsiaResourceDialect,
4545            >,
4546            offset: usize,
4547            _depth: fidl::encoding::Depth,
4548        ) -> fidl::Result<()> {
4549            encoder
4550                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
4551            // Delegate to tuple encoding.
4552            fidl::encoding::Encode::<
4553                ActivityGovernorTakeApplicationActivityLeaseResponse,
4554                fidl::encoding::DefaultFuchsiaResourceDialect,
4555            >::encode(
4556                (<fidl::encoding::HandleType<
4557                    fidl::EventPair,
4558                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4559                    16387,
4560                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4561                    &mut self.token
4562                ),),
4563                encoder,
4564                offset,
4565                _depth,
4566            )
4567        }
4568    }
4569    unsafe impl<
4570            T0: fidl::encoding::Encode<
4571                fidl::encoding::HandleType<
4572                    fidl::EventPair,
4573                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4574                    16387,
4575                >,
4576                fidl::encoding::DefaultFuchsiaResourceDialect,
4577            >,
4578        >
4579        fidl::encoding::Encode<
4580            ActivityGovernorTakeApplicationActivityLeaseResponse,
4581            fidl::encoding::DefaultFuchsiaResourceDialect,
4582        > for (T0,)
4583    {
4584        #[inline]
4585        unsafe fn encode(
4586            self,
4587            encoder: &mut fidl::encoding::Encoder<
4588                '_,
4589                fidl::encoding::DefaultFuchsiaResourceDialect,
4590            >,
4591            offset: usize,
4592            depth: fidl::encoding::Depth,
4593        ) -> fidl::Result<()> {
4594            encoder
4595                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
4596            // Zero out padding regions. There's no need to apply masks
4597            // because the unmasked parts will be overwritten by fields.
4598            // Write the fields.
4599            self.0.encode(encoder, offset + 0, depth)?;
4600            Ok(())
4601        }
4602    }
4603
4604    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4605        for ActivityGovernorTakeApplicationActivityLeaseResponse
4606    {
4607        #[inline(always)]
4608        fn new_empty() -> Self {
4609            Self {
4610                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4611            }
4612        }
4613
4614        #[inline]
4615        unsafe fn decode(
4616            &mut self,
4617            decoder: &mut fidl::encoding::Decoder<
4618                '_,
4619                fidl::encoding::DefaultFuchsiaResourceDialect,
4620            >,
4621            offset: usize,
4622            _depth: fidl::encoding::Depth,
4623        ) -> fidl::Result<()> {
4624            decoder.debug_check_bounds::<Self>(offset);
4625            // Verify that padding bytes are zero.
4626            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4627            Ok(())
4628        }
4629    }
4630
4631    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeWakeLeaseResponse {
4632        type Borrowed<'a> = &'a mut Self;
4633        fn take_or_borrow<'a>(
4634            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4635        ) -> Self::Borrowed<'a> {
4636            value
4637        }
4638    }
4639
4640    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeWakeLeaseResponse {
4641        type Owned = Self;
4642
4643        #[inline(always)]
4644        fn inline_align(_context: fidl::encoding::Context) -> usize {
4645            4
4646        }
4647
4648        #[inline(always)]
4649        fn inline_size(_context: fidl::encoding::Context) -> usize {
4650            4
4651        }
4652    }
4653
4654    unsafe impl
4655        fidl::encoding::Encode<
4656            ActivityGovernorTakeWakeLeaseResponse,
4657            fidl::encoding::DefaultFuchsiaResourceDialect,
4658        > for &mut ActivityGovernorTakeWakeLeaseResponse
4659    {
4660        #[inline]
4661        unsafe fn encode(
4662            self,
4663            encoder: &mut fidl::encoding::Encoder<
4664                '_,
4665                fidl::encoding::DefaultFuchsiaResourceDialect,
4666            >,
4667            offset: usize,
4668            _depth: fidl::encoding::Depth,
4669        ) -> fidl::Result<()> {
4670            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
4671            // Delegate to tuple encoding.
4672            fidl::encoding::Encode::<
4673                ActivityGovernorTakeWakeLeaseResponse,
4674                fidl::encoding::DefaultFuchsiaResourceDialect,
4675            >::encode(
4676                (<fidl::encoding::HandleType<
4677                    fidl::EventPair,
4678                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4679                    16387,
4680                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4681                    &mut self.token
4682                ),),
4683                encoder,
4684                offset,
4685                _depth,
4686            )
4687        }
4688    }
4689    unsafe impl<
4690            T0: fidl::encoding::Encode<
4691                fidl::encoding::HandleType<
4692                    fidl::EventPair,
4693                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4694                    16387,
4695                >,
4696                fidl::encoding::DefaultFuchsiaResourceDialect,
4697            >,
4698        >
4699        fidl::encoding::Encode<
4700            ActivityGovernorTakeWakeLeaseResponse,
4701            fidl::encoding::DefaultFuchsiaResourceDialect,
4702        > for (T0,)
4703    {
4704        #[inline]
4705        unsafe fn encode(
4706            self,
4707            encoder: &mut fidl::encoding::Encoder<
4708                '_,
4709                fidl::encoding::DefaultFuchsiaResourceDialect,
4710            >,
4711            offset: usize,
4712            depth: fidl::encoding::Depth,
4713        ) -> fidl::Result<()> {
4714            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
4715            // Zero out padding regions. There's no need to apply masks
4716            // because the unmasked parts will be overwritten by fields.
4717            // Write the fields.
4718            self.0.encode(encoder, offset + 0, depth)?;
4719            Ok(())
4720        }
4721    }
4722
4723    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4724        for ActivityGovernorTakeWakeLeaseResponse
4725    {
4726        #[inline(always)]
4727        fn new_empty() -> Self {
4728            Self {
4729                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4730            }
4731        }
4732
4733        #[inline]
4734        unsafe fn decode(
4735            &mut self,
4736            decoder: &mut fidl::encoding::Decoder<
4737                '_,
4738                fidl::encoding::DefaultFuchsiaResourceDialect,
4739            >,
4740            offset: usize,
4741            _depth: fidl::encoding::Depth,
4742        ) -> fidl::Result<()> {
4743            decoder.debug_check_bounds::<Self>(offset);
4744            // Verify that padding bytes are zero.
4745            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4746            Ok(())
4747        }
4748    }
4749
4750    impl ActivityGovernorRegisterListenerRequest {
4751        #[inline(always)]
4752        fn max_ordinal_present(&self) -> u64 {
4753            if let Some(_) = self.listener {
4754                return 1;
4755            }
4756            0
4757        }
4758    }
4759
4760    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterListenerRequest {
4761        type Borrowed<'a> = &'a mut Self;
4762        fn take_or_borrow<'a>(
4763            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4764        ) -> Self::Borrowed<'a> {
4765            value
4766        }
4767    }
4768
4769    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterListenerRequest {
4770        type Owned = Self;
4771
4772        #[inline(always)]
4773        fn inline_align(_context: fidl::encoding::Context) -> usize {
4774            8
4775        }
4776
4777        #[inline(always)]
4778        fn inline_size(_context: fidl::encoding::Context) -> usize {
4779            16
4780        }
4781    }
4782
4783    unsafe impl
4784        fidl::encoding::Encode<
4785            ActivityGovernorRegisterListenerRequest,
4786            fidl::encoding::DefaultFuchsiaResourceDialect,
4787        > for &mut ActivityGovernorRegisterListenerRequest
4788    {
4789        unsafe fn encode(
4790            self,
4791            encoder: &mut fidl::encoding::Encoder<
4792                '_,
4793                fidl::encoding::DefaultFuchsiaResourceDialect,
4794            >,
4795            offset: usize,
4796            mut depth: fidl::encoding::Depth,
4797        ) -> fidl::Result<()> {
4798            encoder.debug_check_bounds::<ActivityGovernorRegisterListenerRequest>(offset);
4799            // Vector header
4800            let max_ordinal: u64 = self.max_ordinal_present();
4801            encoder.write_num(max_ordinal, offset);
4802            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4803            // Calling encoder.out_of_line_offset(0) is not allowed.
4804            if max_ordinal == 0 {
4805                return Ok(());
4806            }
4807            depth.increment()?;
4808            let envelope_size = 8;
4809            let bytes_len = max_ordinal as usize * envelope_size;
4810            #[allow(unused_variables)]
4811            let offset = encoder.out_of_line_offset(bytes_len);
4812            let mut _prev_end_offset: usize = 0;
4813            if 1 > max_ordinal {
4814                return Ok(());
4815            }
4816
4817            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4818            // are envelope_size bytes.
4819            let cur_offset: usize = (1 - 1) * envelope_size;
4820
4821            // Zero reserved fields.
4822            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4823
4824            // Safety:
4825            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4826            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4827            //   envelope_size bytes, there is always sufficient room.
4828            fidl::encoding::encode_in_envelope_optional::<
4829                fidl::encoding::Endpoint<
4830                    fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
4831                >,
4832                fidl::encoding::DefaultFuchsiaResourceDialect,
4833            >(
4834                self.listener.as_mut().map(
4835                    <fidl::encoding::Endpoint<
4836                        fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
4837                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4838                ),
4839                encoder,
4840                offset + cur_offset,
4841                depth,
4842            )?;
4843
4844            _prev_end_offset = cur_offset + envelope_size;
4845
4846            Ok(())
4847        }
4848    }
4849
4850    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4851        for ActivityGovernorRegisterListenerRequest
4852    {
4853        #[inline(always)]
4854        fn new_empty() -> Self {
4855            Self::default()
4856        }
4857
4858        unsafe fn decode(
4859            &mut self,
4860            decoder: &mut fidl::encoding::Decoder<
4861                '_,
4862                fidl::encoding::DefaultFuchsiaResourceDialect,
4863            >,
4864            offset: usize,
4865            mut depth: fidl::encoding::Depth,
4866        ) -> fidl::Result<()> {
4867            decoder.debug_check_bounds::<Self>(offset);
4868            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4869                None => return Err(fidl::Error::NotNullable),
4870                Some(len) => len,
4871            };
4872            // Calling decoder.out_of_line_offset(0) is not allowed.
4873            if len == 0 {
4874                return Ok(());
4875            };
4876            depth.increment()?;
4877            let envelope_size = 8;
4878            let bytes_len = len * envelope_size;
4879            let offset = decoder.out_of_line_offset(bytes_len)?;
4880            // Decode the envelope for each type.
4881            let mut _next_ordinal_to_read = 0;
4882            let mut next_offset = offset;
4883            let end_offset = offset + bytes_len;
4884            _next_ordinal_to_read += 1;
4885            if next_offset >= end_offset {
4886                return Ok(());
4887            }
4888
4889            // Decode unknown envelopes for gaps in ordinals.
4890            while _next_ordinal_to_read < 1 {
4891                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4892                _next_ordinal_to_read += 1;
4893                next_offset += envelope_size;
4894            }
4895
4896            let next_out_of_line = decoder.next_out_of_line();
4897            let handles_before = decoder.remaining_handles();
4898            if let Some((inlined, num_bytes, num_handles)) =
4899                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4900            {
4901                let member_inline_size = <fidl::encoding::Endpoint<
4902                    fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
4903                > as fidl::encoding::TypeMarker>::inline_size(
4904                    decoder.context
4905                );
4906                if inlined != (member_inline_size <= 4) {
4907                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4908                }
4909                let inner_offset;
4910                let mut inner_depth = depth.clone();
4911                if inlined {
4912                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4913                    inner_offset = next_offset;
4914                } else {
4915                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4916                    inner_depth.increment()?;
4917                }
4918                let val_ref = self.listener.get_or_insert_with(|| {
4919                    fidl::new_empty!(
4920                        fidl::encoding::Endpoint<
4921                            fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
4922                        >,
4923                        fidl::encoding::DefaultFuchsiaResourceDialect
4924                    )
4925                });
4926                fidl::decode!(
4927                    fidl::encoding::Endpoint<
4928                        fidl::endpoints::ClientEnd<ActivityGovernorListenerMarker>,
4929                    >,
4930                    fidl::encoding::DefaultFuchsiaResourceDialect,
4931                    val_ref,
4932                    decoder,
4933                    inner_offset,
4934                    inner_depth
4935                )?;
4936                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4937                {
4938                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4939                }
4940                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4941                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4942                }
4943            }
4944
4945            next_offset += envelope_size;
4946
4947            // Decode the remaining unknown envelopes.
4948            while next_offset < end_offset {
4949                _next_ordinal_to_read += 1;
4950                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4951                next_offset += envelope_size;
4952            }
4953
4954            Ok(())
4955        }
4956    }
4957
4958    impl ActivityGovernorRegisterSuspendBlockerRequest {
4959        #[inline(always)]
4960        fn max_ordinal_present(&self) -> u64 {
4961            if let Some(_) = self.name {
4962                return 2;
4963            }
4964            if let Some(_) = self.suspend_blocker {
4965                return 1;
4966            }
4967            0
4968        }
4969    }
4970
4971    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
4972        type Borrowed<'a> = &'a mut Self;
4973        fn take_or_borrow<'a>(
4974            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4975        ) -> Self::Borrowed<'a> {
4976            value
4977        }
4978    }
4979
4980    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
4981        type Owned = Self;
4982
4983        #[inline(always)]
4984        fn inline_align(_context: fidl::encoding::Context) -> usize {
4985            8
4986        }
4987
4988        #[inline(always)]
4989        fn inline_size(_context: fidl::encoding::Context) -> usize {
4990            16
4991        }
4992    }
4993
4994    unsafe impl
4995        fidl::encoding::Encode<
4996            ActivityGovernorRegisterSuspendBlockerRequest,
4997            fidl::encoding::DefaultFuchsiaResourceDialect,
4998        > for &mut ActivityGovernorRegisterSuspendBlockerRequest
4999    {
5000        unsafe fn encode(
5001            self,
5002            encoder: &mut fidl::encoding::Encoder<
5003                '_,
5004                fidl::encoding::DefaultFuchsiaResourceDialect,
5005            >,
5006            offset: usize,
5007            mut depth: fidl::encoding::Depth,
5008        ) -> fidl::Result<()> {
5009            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerRequest>(offset);
5010            // Vector header
5011            let max_ordinal: u64 = self.max_ordinal_present();
5012            encoder.write_num(max_ordinal, offset);
5013            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5014            // Calling encoder.out_of_line_offset(0) is not allowed.
5015            if max_ordinal == 0 {
5016                return Ok(());
5017            }
5018            depth.increment()?;
5019            let envelope_size = 8;
5020            let bytes_len = max_ordinal as usize * envelope_size;
5021            #[allow(unused_variables)]
5022            let offset = encoder.out_of_line_offset(bytes_len);
5023            let mut _prev_end_offset: usize = 0;
5024            if 1 > max_ordinal {
5025                return Ok(());
5026            }
5027
5028            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5029            // are envelope_size bytes.
5030            let cur_offset: usize = (1 - 1) * envelope_size;
5031
5032            // Zero reserved fields.
5033            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5034
5035            // Safety:
5036            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5037            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5038            //   envelope_size bytes, there is always sufficient room.
5039            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5040            self.suspend_blocker.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5041            encoder, offset + cur_offset, depth
5042        )?;
5043
5044            _prev_end_offset = cur_offset + envelope_size;
5045            if 2 > max_ordinal {
5046                return Ok(());
5047            }
5048
5049            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5050            // are envelope_size bytes.
5051            let cur_offset: usize = (2 - 1) * envelope_size;
5052
5053            // Zero reserved fields.
5054            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5055
5056            // Safety:
5057            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5058            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5059            //   envelope_size bytes, there is always sufficient room.
5060            fidl::encoding::encode_in_envelope_optional::<
5061                fidl::encoding::BoundedString<64>,
5062                fidl::encoding::DefaultFuchsiaResourceDialect,
5063            >(
5064                self.name.as_ref().map(
5065                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
5066                ),
5067                encoder,
5068                offset + cur_offset,
5069                depth,
5070            )?;
5071
5072            _prev_end_offset = cur_offset + envelope_size;
5073
5074            Ok(())
5075        }
5076    }
5077
5078    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5079        for ActivityGovernorRegisterSuspendBlockerRequest
5080    {
5081        #[inline(always)]
5082        fn new_empty() -> Self {
5083            Self::default()
5084        }
5085
5086        unsafe fn decode(
5087            &mut self,
5088            decoder: &mut fidl::encoding::Decoder<
5089                '_,
5090                fidl::encoding::DefaultFuchsiaResourceDialect,
5091            >,
5092            offset: usize,
5093            mut depth: fidl::encoding::Depth,
5094        ) -> fidl::Result<()> {
5095            decoder.debug_check_bounds::<Self>(offset);
5096            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5097                None => return Err(fidl::Error::NotNullable),
5098                Some(len) => len,
5099            };
5100            // Calling decoder.out_of_line_offset(0) is not allowed.
5101            if len == 0 {
5102                return Ok(());
5103            };
5104            depth.increment()?;
5105            let envelope_size = 8;
5106            let bytes_len = len * envelope_size;
5107            let offset = decoder.out_of_line_offset(bytes_len)?;
5108            // Decode the envelope for each type.
5109            let mut _next_ordinal_to_read = 0;
5110            let mut next_offset = offset;
5111            let end_offset = offset + bytes_len;
5112            _next_ordinal_to_read += 1;
5113            if next_offset >= end_offset {
5114                return Ok(());
5115            }
5116
5117            // Decode unknown envelopes for gaps in ordinals.
5118            while _next_ordinal_to_read < 1 {
5119                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5120                _next_ordinal_to_read += 1;
5121                next_offset += envelope_size;
5122            }
5123
5124            let next_out_of_line = decoder.next_out_of_line();
5125            let handles_before = decoder.remaining_handles();
5126            if let Some((inlined, num_bytes, num_handles)) =
5127                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5128            {
5129                let member_inline_size = <fidl::encoding::Endpoint<
5130                    fidl::endpoints::ClientEnd<SuspendBlockerMarker>,
5131                > as fidl::encoding::TypeMarker>::inline_size(
5132                    decoder.context
5133                );
5134                if inlined != (member_inline_size <= 4) {
5135                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5136                }
5137                let inner_offset;
5138                let mut inner_depth = depth.clone();
5139                if inlined {
5140                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5141                    inner_offset = next_offset;
5142                } else {
5143                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5144                    inner_depth.increment()?;
5145                }
5146                let val_ref = self.suspend_blocker.get_or_insert_with(|| {
5147                    fidl::new_empty!(
5148                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
5149                        fidl::encoding::DefaultFuchsiaResourceDialect
5150                    )
5151                });
5152                fidl::decode!(
5153                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
5154                    fidl::encoding::DefaultFuchsiaResourceDialect,
5155                    val_ref,
5156                    decoder,
5157                    inner_offset,
5158                    inner_depth
5159                )?;
5160                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5161                {
5162                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5163                }
5164                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5165                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5166                }
5167            }
5168
5169            next_offset += envelope_size;
5170            _next_ordinal_to_read += 1;
5171            if next_offset >= end_offset {
5172                return Ok(());
5173            }
5174
5175            // Decode unknown envelopes for gaps in ordinals.
5176            while _next_ordinal_to_read < 2 {
5177                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5178                _next_ordinal_to_read += 1;
5179                next_offset += envelope_size;
5180            }
5181
5182            let next_out_of_line = decoder.next_out_of_line();
5183            let handles_before = decoder.remaining_handles();
5184            if let Some((inlined, num_bytes, num_handles)) =
5185                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5186            {
5187                let member_inline_size =
5188                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
5189                        decoder.context,
5190                    );
5191                if inlined != (member_inline_size <= 4) {
5192                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5193                }
5194                let inner_offset;
5195                let mut inner_depth = depth.clone();
5196                if inlined {
5197                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5198                    inner_offset = next_offset;
5199                } else {
5200                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5201                    inner_depth.increment()?;
5202                }
5203                let val_ref = self.name.get_or_insert_with(|| {
5204                    fidl::new_empty!(
5205                        fidl::encoding::BoundedString<64>,
5206                        fidl::encoding::DefaultFuchsiaResourceDialect
5207                    )
5208                });
5209                fidl::decode!(
5210                    fidl::encoding::BoundedString<64>,
5211                    fidl::encoding::DefaultFuchsiaResourceDialect,
5212                    val_ref,
5213                    decoder,
5214                    inner_offset,
5215                    inner_depth
5216                )?;
5217                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5218                {
5219                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5220                }
5221                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5222                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5223                }
5224            }
5225
5226            next_offset += envelope_size;
5227
5228            // Decode the remaining unknown envelopes.
5229            while next_offset < end_offset {
5230                _next_ordinal_to_read += 1;
5231                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5232                next_offset += envelope_size;
5233            }
5234
5235            Ok(())
5236        }
5237    }
5238
5239    impl ApplicationActivity {
5240        #[inline(always)]
5241        fn max_ordinal_present(&self) -> u64 {
5242            if let Some(_) = self.assertive_dependency_token {
5243                return 1;
5244            }
5245            0
5246        }
5247    }
5248
5249    impl fidl::encoding::ResourceTypeMarker for ApplicationActivity {
5250        type Borrowed<'a> = &'a mut Self;
5251        fn take_or_borrow<'a>(
5252            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5253        ) -> Self::Borrowed<'a> {
5254            value
5255        }
5256    }
5257
5258    unsafe impl fidl::encoding::TypeMarker for ApplicationActivity {
5259        type Owned = Self;
5260
5261        #[inline(always)]
5262        fn inline_align(_context: fidl::encoding::Context) -> usize {
5263            8
5264        }
5265
5266        #[inline(always)]
5267        fn inline_size(_context: fidl::encoding::Context) -> usize {
5268            16
5269        }
5270    }
5271
5272    unsafe impl
5273        fidl::encoding::Encode<ApplicationActivity, fidl::encoding::DefaultFuchsiaResourceDialect>
5274        for &mut ApplicationActivity
5275    {
5276        unsafe fn encode(
5277            self,
5278            encoder: &mut fidl::encoding::Encoder<
5279                '_,
5280                fidl::encoding::DefaultFuchsiaResourceDialect,
5281            >,
5282            offset: usize,
5283            mut depth: fidl::encoding::Depth,
5284        ) -> fidl::Result<()> {
5285            encoder.debug_check_bounds::<ApplicationActivity>(offset);
5286            // Vector header
5287            let max_ordinal: u64 = self.max_ordinal_present();
5288            encoder.write_num(max_ordinal, offset);
5289            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5290            // Calling encoder.out_of_line_offset(0) is not allowed.
5291            if max_ordinal == 0 {
5292                return Ok(());
5293            }
5294            depth.increment()?;
5295            let envelope_size = 8;
5296            let bytes_len = max_ordinal as usize * envelope_size;
5297            #[allow(unused_variables)]
5298            let offset = encoder.out_of_line_offset(bytes_len);
5299            let mut _prev_end_offset: usize = 0;
5300            if 1 > max_ordinal {
5301                return Ok(());
5302            }
5303
5304            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5305            // are envelope_size bytes.
5306            let cur_offset: usize = (1 - 1) * envelope_size;
5307
5308            // Zero reserved fields.
5309            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5310
5311            // Safety:
5312            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5313            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5314            //   envelope_size bytes, there is always sufficient room.
5315            fidl::encoding::encode_in_envelope_optional::<
5316                fidl::encoding::HandleType<
5317                    fidl::Event,
5318                    { fidl::ObjectType::EVENT.into_raw() },
5319                    2147483648,
5320                >,
5321                fidl::encoding::DefaultFuchsiaResourceDialect,
5322            >(
5323                self.assertive_dependency_token.as_mut().map(
5324                    <fidl::encoding::HandleType<
5325                        fidl::Event,
5326                        { fidl::ObjectType::EVENT.into_raw() },
5327                        2147483648,
5328                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5329                ),
5330                encoder,
5331                offset + cur_offset,
5332                depth,
5333            )?;
5334
5335            _prev_end_offset = cur_offset + envelope_size;
5336
5337            Ok(())
5338        }
5339    }
5340
5341    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5342        for ApplicationActivity
5343    {
5344        #[inline(always)]
5345        fn new_empty() -> Self {
5346            Self::default()
5347        }
5348
5349        unsafe fn decode(
5350            &mut self,
5351            decoder: &mut fidl::encoding::Decoder<
5352                '_,
5353                fidl::encoding::DefaultFuchsiaResourceDialect,
5354            >,
5355            offset: usize,
5356            mut depth: fidl::encoding::Depth,
5357        ) -> fidl::Result<()> {
5358            decoder.debug_check_bounds::<Self>(offset);
5359            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5360                None => return Err(fidl::Error::NotNullable),
5361                Some(len) => len,
5362            };
5363            // Calling decoder.out_of_line_offset(0) is not allowed.
5364            if len == 0 {
5365                return Ok(());
5366            };
5367            depth.increment()?;
5368            let envelope_size = 8;
5369            let bytes_len = len * envelope_size;
5370            let offset = decoder.out_of_line_offset(bytes_len)?;
5371            // Decode the envelope for each type.
5372            let mut _next_ordinal_to_read = 0;
5373            let mut next_offset = offset;
5374            let end_offset = offset + bytes_len;
5375            _next_ordinal_to_read += 1;
5376            if next_offset >= end_offset {
5377                return Ok(());
5378            }
5379
5380            // Decode unknown envelopes for gaps in ordinals.
5381            while _next_ordinal_to_read < 1 {
5382                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5383                _next_ordinal_to_read += 1;
5384                next_offset += envelope_size;
5385            }
5386
5387            let next_out_of_line = decoder.next_out_of_line();
5388            let handles_before = decoder.remaining_handles();
5389            if let Some((inlined, num_bytes, num_handles)) =
5390                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5391            {
5392                let member_inline_size = <fidl::encoding::HandleType<
5393                    fidl::Event,
5394                    { fidl::ObjectType::EVENT.into_raw() },
5395                    2147483648,
5396                > as fidl::encoding::TypeMarker>::inline_size(
5397                    decoder.context
5398                );
5399                if inlined != (member_inline_size <= 4) {
5400                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5401                }
5402                let inner_offset;
5403                let mut inner_depth = depth.clone();
5404                if inlined {
5405                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5406                    inner_offset = next_offset;
5407                } else {
5408                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5409                    inner_depth.increment()?;
5410                }
5411                let val_ref =
5412                self.assertive_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5413                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5414                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5415                {
5416                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5417                }
5418                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5419                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5420                }
5421            }
5422
5423            next_offset += envelope_size;
5424
5425            // Decode the remaining unknown envelopes.
5426            while next_offset < end_offset {
5427                _next_ordinal_to_read += 1;
5428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5429                next_offset += envelope_size;
5430            }
5431
5432            Ok(())
5433        }
5434    }
5435
5436    impl Cpu {
5437        #[inline(always)]
5438        fn max_ordinal_present(&self) -> u64 {
5439            if let Some(_) = self.assertive_dependency_token {
5440                return 1;
5441            }
5442            0
5443        }
5444    }
5445
5446    impl fidl::encoding::ResourceTypeMarker for Cpu {
5447        type Borrowed<'a> = &'a mut Self;
5448        fn take_or_borrow<'a>(
5449            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5450        ) -> Self::Borrowed<'a> {
5451            value
5452        }
5453    }
5454
5455    unsafe impl fidl::encoding::TypeMarker for Cpu {
5456        type Owned = Self;
5457
5458        #[inline(always)]
5459        fn inline_align(_context: fidl::encoding::Context) -> usize {
5460            8
5461        }
5462
5463        #[inline(always)]
5464        fn inline_size(_context: fidl::encoding::Context) -> usize {
5465            16
5466        }
5467    }
5468
5469    unsafe impl fidl::encoding::Encode<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>
5470        for &mut Cpu
5471    {
5472        unsafe fn encode(
5473            self,
5474            encoder: &mut fidl::encoding::Encoder<
5475                '_,
5476                fidl::encoding::DefaultFuchsiaResourceDialect,
5477            >,
5478            offset: usize,
5479            mut depth: fidl::encoding::Depth,
5480        ) -> fidl::Result<()> {
5481            encoder.debug_check_bounds::<Cpu>(offset);
5482            // Vector header
5483            let max_ordinal: u64 = self.max_ordinal_present();
5484            encoder.write_num(max_ordinal, offset);
5485            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5486            // Calling encoder.out_of_line_offset(0) is not allowed.
5487            if max_ordinal == 0 {
5488                return Ok(());
5489            }
5490            depth.increment()?;
5491            let envelope_size = 8;
5492            let bytes_len = max_ordinal as usize * envelope_size;
5493            #[allow(unused_variables)]
5494            let offset = encoder.out_of_line_offset(bytes_len);
5495            let mut _prev_end_offset: usize = 0;
5496            if 1 > max_ordinal {
5497                return Ok(());
5498            }
5499
5500            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5501            // are envelope_size bytes.
5502            let cur_offset: usize = (1 - 1) * envelope_size;
5503
5504            // Zero reserved fields.
5505            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5506
5507            // Safety:
5508            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5509            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5510            //   envelope_size bytes, there is always sufficient room.
5511            fidl::encoding::encode_in_envelope_optional::<
5512                fidl::encoding::HandleType<
5513                    fidl::Event,
5514                    { fidl::ObjectType::EVENT.into_raw() },
5515                    2147483648,
5516                >,
5517                fidl::encoding::DefaultFuchsiaResourceDialect,
5518            >(
5519                self.assertive_dependency_token.as_mut().map(
5520                    <fidl::encoding::HandleType<
5521                        fidl::Event,
5522                        { fidl::ObjectType::EVENT.into_raw() },
5523                        2147483648,
5524                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5525                ),
5526                encoder,
5527                offset + cur_offset,
5528                depth,
5529            )?;
5530
5531            _prev_end_offset = cur_offset + envelope_size;
5532
5533            Ok(())
5534        }
5535    }
5536
5537    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {
5538        #[inline(always)]
5539        fn new_empty() -> Self {
5540            Self::default()
5541        }
5542
5543        unsafe fn decode(
5544            &mut self,
5545            decoder: &mut fidl::encoding::Decoder<
5546                '_,
5547                fidl::encoding::DefaultFuchsiaResourceDialect,
5548            >,
5549            offset: usize,
5550            mut depth: fidl::encoding::Depth,
5551        ) -> fidl::Result<()> {
5552            decoder.debug_check_bounds::<Self>(offset);
5553            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5554                None => return Err(fidl::Error::NotNullable),
5555                Some(len) => len,
5556            };
5557            // Calling decoder.out_of_line_offset(0) is not allowed.
5558            if len == 0 {
5559                return Ok(());
5560            };
5561            depth.increment()?;
5562            let envelope_size = 8;
5563            let bytes_len = len * envelope_size;
5564            let offset = decoder.out_of_line_offset(bytes_len)?;
5565            // Decode the envelope for each type.
5566            let mut _next_ordinal_to_read = 0;
5567            let mut next_offset = offset;
5568            let end_offset = offset + bytes_len;
5569            _next_ordinal_to_read += 1;
5570            if next_offset >= end_offset {
5571                return Ok(());
5572            }
5573
5574            // Decode unknown envelopes for gaps in ordinals.
5575            while _next_ordinal_to_read < 1 {
5576                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5577                _next_ordinal_to_read += 1;
5578                next_offset += envelope_size;
5579            }
5580
5581            let next_out_of_line = decoder.next_out_of_line();
5582            let handles_before = decoder.remaining_handles();
5583            if let Some((inlined, num_bytes, num_handles)) =
5584                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5585            {
5586                let member_inline_size = <fidl::encoding::HandleType<
5587                    fidl::Event,
5588                    { fidl::ObjectType::EVENT.into_raw() },
5589                    2147483648,
5590                > as fidl::encoding::TypeMarker>::inline_size(
5591                    decoder.context
5592                );
5593                if inlined != (member_inline_size <= 4) {
5594                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5595                }
5596                let inner_offset;
5597                let mut inner_depth = depth.clone();
5598                if inlined {
5599                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5600                    inner_offset = next_offset;
5601                } else {
5602                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5603                    inner_depth.increment()?;
5604                }
5605                let val_ref =
5606                self.assertive_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5607                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5608                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5609                {
5610                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5611                }
5612                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5613                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5614                }
5615            }
5616
5617            next_offset += envelope_size;
5618
5619            // Decode the remaining unknown envelopes.
5620            while next_offset < end_offset {
5621                _next_ordinal_to_read += 1;
5622                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5623                next_offset += envelope_size;
5624            }
5625
5626            Ok(())
5627        }
5628    }
5629
5630    impl CpuElementManagerAddExecutionStateDependencyRequest {
5631        #[inline(always)]
5632        fn max_ordinal_present(&self) -> u64 {
5633            if let Some(_) = self.power_level {
5634                return 2;
5635            }
5636            if let Some(_) = self.dependency_token {
5637                return 1;
5638            }
5639            0
5640        }
5641    }
5642
5643    impl fidl::encoding::ResourceTypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
5644        type Borrowed<'a> = &'a mut Self;
5645        fn take_or_borrow<'a>(
5646            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5647        ) -> Self::Borrowed<'a> {
5648            value
5649        }
5650    }
5651
5652    unsafe impl fidl::encoding::TypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
5653        type Owned = Self;
5654
5655        #[inline(always)]
5656        fn inline_align(_context: fidl::encoding::Context) -> usize {
5657            8
5658        }
5659
5660        #[inline(always)]
5661        fn inline_size(_context: fidl::encoding::Context) -> usize {
5662            16
5663        }
5664    }
5665
5666    unsafe impl
5667        fidl::encoding::Encode<
5668            CpuElementManagerAddExecutionStateDependencyRequest,
5669            fidl::encoding::DefaultFuchsiaResourceDialect,
5670        > for &mut CpuElementManagerAddExecutionStateDependencyRequest
5671    {
5672        unsafe fn encode(
5673            self,
5674            encoder: &mut fidl::encoding::Encoder<
5675                '_,
5676                fidl::encoding::DefaultFuchsiaResourceDialect,
5677            >,
5678            offset: usize,
5679            mut depth: fidl::encoding::Depth,
5680        ) -> fidl::Result<()> {
5681            encoder
5682                .debug_check_bounds::<CpuElementManagerAddExecutionStateDependencyRequest>(offset);
5683            // Vector header
5684            let max_ordinal: u64 = self.max_ordinal_present();
5685            encoder.write_num(max_ordinal, offset);
5686            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5687            // Calling encoder.out_of_line_offset(0) is not allowed.
5688            if max_ordinal == 0 {
5689                return Ok(());
5690            }
5691            depth.increment()?;
5692            let envelope_size = 8;
5693            let bytes_len = max_ordinal as usize * envelope_size;
5694            #[allow(unused_variables)]
5695            let offset = encoder.out_of_line_offset(bytes_len);
5696            let mut _prev_end_offset: usize = 0;
5697            if 1 > max_ordinal {
5698                return Ok(());
5699            }
5700
5701            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5702            // are envelope_size bytes.
5703            let cur_offset: usize = (1 - 1) * envelope_size;
5704
5705            // Zero reserved fields.
5706            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5707
5708            // Safety:
5709            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5710            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5711            //   envelope_size bytes, there is always sufficient room.
5712            fidl::encoding::encode_in_envelope_optional::<
5713                fidl::encoding::HandleType<
5714                    fidl::Event,
5715                    { fidl::ObjectType::EVENT.into_raw() },
5716                    2147483648,
5717                >,
5718                fidl::encoding::DefaultFuchsiaResourceDialect,
5719            >(
5720                self.dependency_token.as_mut().map(
5721                    <fidl::encoding::HandleType<
5722                        fidl::Event,
5723                        { fidl::ObjectType::EVENT.into_raw() },
5724                        2147483648,
5725                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5726                ),
5727                encoder,
5728                offset + cur_offset,
5729                depth,
5730            )?;
5731
5732            _prev_end_offset = cur_offset + envelope_size;
5733            if 2 > max_ordinal {
5734                return Ok(());
5735            }
5736
5737            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5738            // are envelope_size bytes.
5739            let cur_offset: usize = (2 - 1) * envelope_size;
5740
5741            // Zero reserved fields.
5742            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5743
5744            // Safety:
5745            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5746            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5747            //   envelope_size bytes, there is always sufficient room.
5748            fidl::encoding::encode_in_envelope_optional::<
5749                u8,
5750                fidl::encoding::DefaultFuchsiaResourceDialect,
5751            >(
5752                self.power_level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
5753                encoder,
5754                offset + cur_offset,
5755                depth,
5756            )?;
5757
5758            _prev_end_offset = cur_offset + envelope_size;
5759
5760            Ok(())
5761        }
5762    }
5763
5764    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5765        for CpuElementManagerAddExecutionStateDependencyRequest
5766    {
5767        #[inline(always)]
5768        fn new_empty() -> Self {
5769            Self::default()
5770        }
5771
5772        unsafe fn decode(
5773            &mut self,
5774            decoder: &mut fidl::encoding::Decoder<
5775                '_,
5776                fidl::encoding::DefaultFuchsiaResourceDialect,
5777            >,
5778            offset: usize,
5779            mut depth: fidl::encoding::Depth,
5780        ) -> fidl::Result<()> {
5781            decoder.debug_check_bounds::<Self>(offset);
5782            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5783                None => return Err(fidl::Error::NotNullable),
5784                Some(len) => len,
5785            };
5786            // Calling decoder.out_of_line_offset(0) is not allowed.
5787            if len == 0 {
5788                return Ok(());
5789            };
5790            depth.increment()?;
5791            let envelope_size = 8;
5792            let bytes_len = len * envelope_size;
5793            let offset = decoder.out_of_line_offset(bytes_len)?;
5794            // Decode the envelope for each type.
5795            let mut _next_ordinal_to_read = 0;
5796            let mut next_offset = offset;
5797            let end_offset = offset + bytes_len;
5798            _next_ordinal_to_read += 1;
5799            if next_offset >= end_offset {
5800                return Ok(());
5801            }
5802
5803            // Decode unknown envelopes for gaps in ordinals.
5804            while _next_ordinal_to_read < 1 {
5805                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5806                _next_ordinal_to_read += 1;
5807                next_offset += envelope_size;
5808            }
5809
5810            let next_out_of_line = decoder.next_out_of_line();
5811            let handles_before = decoder.remaining_handles();
5812            if let Some((inlined, num_bytes, num_handles)) =
5813                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5814            {
5815                let member_inline_size = <fidl::encoding::HandleType<
5816                    fidl::Event,
5817                    { fidl::ObjectType::EVENT.into_raw() },
5818                    2147483648,
5819                > as fidl::encoding::TypeMarker>::inline_size(
5820                    decoder.context
5821                );
5822                if inlined != (member_inline_size <= 4) {
5823                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5824                }
5825                let inner_offset;
5826                let mut inner_depth = depth.clone();
5827                if inlined {
5828                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5829                    inner_offset = next_offset;
5830                } else {
5831                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5832                    inner_depth.increment()?;
5833                }
5834                let val_ref =
5835                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5836                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5837                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5838                {
5839                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5840                }
5841                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5842                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5843                }
5844            }
5845
5846            next_offset += envelope_size;
5847            _next_ordinal_to_read += 1;
5848            if next_offset >= end_offset {
5849                return Ok(());
5850            }
5851
5852            // Decode unknown envelopes for gaps in ordinals.
5853            while _next_ordinal_to_read < 2 {
5854                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5855                _next_ordinal_to_read += 1;
5856                next_offset += envelope_size;
5857            }
5858
5859            let next_out_of_line = decoder.next_out_of_line();
5860            let handles_before = decoder.remaining_handles();
5861            if let Some((inlined, num_bytes, num_handles)) =
5862                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5863            {
5864                let member_inline_size =
5865                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5866                if inlined != (member_inline_size <= 4) {
5867                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5868                }
5869                let inner_offset;
5870                let mut inner_depth = depth.clone();
5871                if inlined {
5872                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5873                    inner_offset = next_offset;
5874                } else {
5875                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5876                    inner_depth.increment()?;
5877                }
5878                let val_ref = self.power_level.get_or_insert_with(|| {
5879                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
5880                });
5881                fidl::decode!(
5882                    u8,
5883                    fidl::encoding::DefaultFuchsiaResourceDialect,
5884                    val_ref,
5885                    decoder,
5886                    inner_offset,
5887                    inner_depth
5888                )?;
5889                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5890                {
5891                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5892                }
5893                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5894                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5895                }
5896            }
5897
5898            next_offset += envelope_size;
5899
5900            // Decode the remaining unknown envelopes.
5901            while next_offset < end_offset {
5902                _next_ordinal_to_read += 1;
5903                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5904                next_offset += envelope_size;
5905            }
5906
5907            Ok(())
5908        }
5909    }
5910
5911    impl ExecutionState {
5912        #[inline(always)]
5913        fn max_ordinal_present(&self) -> u64 {
5914            if let Some(_) = self.opportunistic_dependency_token {
5915                return 1;
5916            }
5917            0
5918        }
5919    }
5920
5921    impl fidl::encoding::ResourceTypeMarker for ExecutionState {
5922        type Borrowed<'a> = &'a mut Self;
5923        fn take_or_borrow<'a>(
5924            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5925        ) -> Self::Borrowed<'a> {
5926            value
5927        }
5928    }
5929
5930    unsafe impl fidl::encoding::TypeMarker for ExecutionState {
5931        type Owned = Self;
5932
5933        #[inline(always)]
5934        fn inline_align(_context: fidl::encoding::Context) -> usize {
5935            8
5936        }
5937
5938        #[inline(always)]
5939        fn inline_size(_context: fidl::encoding::Context) -> usize {
5940            16
5941        }
5942    }
5943
5944    unsafe impl
5945        fidl::encoding::Encode<ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect>
5946        for &mut ExecutionState
5947    {
5948        unsafe fn encode(
5949            self,
5950            encoder: &mut fidl::encoding::Encoder<
5951                '_,
5952                fidl::encoding::DefaultFuchsiaResourceDialect,
5953            >,
5954            offset: usize,
5955            mut depth: fidl::encoding::Depth,
5956        ) -> fidl::Result<()> {
5957            encoder.debug_check_bounds::<ExecutionState>(offset);
5958            // Vector header
5959            let max_ordinal: u64 = self.max_ordinal_present();
5960            encoder.write_num(max_ordinal, offset);
5961            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5962            // Calling encoder.out_of_line_offset(0) is not allowed.
5963            if max_ordinal == 0 {
5964                return Ok(());
5965            }
5966            depth.increment()?;
5967            let envelope_size = 8;
5968            let bytes_len = max_ordinal as usize * envelope_size;
5969            #[allow(unused_variables)]
5970            let offset = encoder.out_of_line_offset(bytes_len);
5971            let mut _prev_end_offset: usize = 0;
5972            if 1 > max_ordinal {
5973                return Ok(());
5974            }
5975
5976            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5977            // are envelope_size bytes.
5978            let cur_offset: usize = (1 - 1) * envelope_size;
5979
5980            // Zero reserved fields.
5981            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5982
5983            // Safety:
5984            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5985            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5986            //   envelope_size bytes, there is always sufficient room.
5987            fidl::encoding::encode_in_envelope_optional::<
5988                fidl::encoding::HandleType<
5989                    fidl::Event,
5990                    { fidl::ObjectType::EVENT.into_raw() },
5991                    2147483648,
5992                >,
5993                fidl::encoding::DefaultFuchsiaResourceDialect,
5994            >(
5995                self.opportunistic_dependency_token.as_mut().map(
5996                    <fidl::encoding::HandleType<
5997                        fidl::Event,
5998                        { fidl::ObjectType::EVENT.into_raw() },
5999                        2147483648,
6000                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6001                ),
6002                encoder,
6003                offset + cur_offset,
6004                depth,
6005            )?;
6006
6007            _prev_end_offset = cur_offset + envelope_size;
6008
6009            Ok(())
6010        }
6011    }
6012
6013    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
6014        for ExecutionState
6015    {
6016        #[inline(always)]
6017        fn new_empty() -> Self {
6018            Self::default()
6019        }
6020
6021        unsafe fn decode(
6022            &mut self,
6023            decoder: &mut fidl::encoding::Decoder<
6024                '_,
6025                fidl::encoding::DefaultFuchsiaResourceDialect,
6026            >,
6027            offset: usize,
6028            mut depth: fidl::encoding::Depth,
6029        ) -> fidl::Result<()> {
6030            decoder.debug_check_bounds::<Self>(offset);
6031            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6032                None => return Err(fidl::Error::NotNullable),
6033                Some(len) => len,
6034            };
6035            // Calling decoder.out_of_line_offset(0) is not allowed.
6036            if len == 0 {
6037                return Ok(());
6038            };
6039            depth.increment()?;
6040            let envelope_size = 8;
6041            let bytes_len = len * envelope_size;
6042            let offset = decoder.out_of_line_offset(bytes_len)?;
6043            // Decode the envelope for each type.
6044            let mut _next_ordinal_to_read = 0;
6045            let mut next_offset = offset;
6046            let end_offset = offset + bytes_len;
6047            _next_ordinal_to_read += 1;
6048            if next_offset >= end_offset {
6049                return Ok(());
6050            }
6051
6052            // Decode unknown envelopes for gaps in ordinals.
6053            while _next_ordinal_to_read < 1 {
6054                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6055                _next_ordinal_to_read += 1;
6056                next_offset += envelope_size;
6057            }
6058
6059            let next_out_of_line = decoder.next_out_of_line();
6060            let handles_before = decoder.remaining_handles();
6061            if let Some((inlined, num_bytes, num_handles)) =
6062                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6063            {
6064                let member_inline_size = <fidl::encoding::HandleType<
6065                    fidl::Event,
6066                    { fidl::ObjectType::EVENT.into_raw() },
6067                    2147483648,
6068                > as fidl::encoding::TypeMarker>::inline_size(
6069                    decoder.context
6070                );
6071                if inlined != (member_inline_size <= 4) {
6072                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6073                }
6074                let inner_offset;
6075                let mut inner_depth = depth.clone();
6076                if inlined {
6077                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6078                    inner_offset = next_offset;
6079                } else {
6080                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6081                    inner_depth.increment()?;
6082                }
6083                let val_ref =
6084                self.opportunistic_dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
6085                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
6086                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6087                {
6088                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6089                }
6090                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6091                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6092                }
6093            }
6094
6095            next_offset += envelope_size;
6096
6097            // Decode the remaining unknown envelopes.
6098            while next_offset < end_offset {
6099                _next_ordinal_to_read += 1;
6100                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6101                next_offset += envelope_size;
6102            }
6103
6104            Ok(())
6105        }
6106    }
6107
6108    impl PowerElements {
6109        #[inline(always)]
6110        fn max_ordinal_present(&self) -> u64 {
6111            if let Some(_) = self.application_activity {
6112                return 3;
6113            }
6114            if let Some(_) = self.execution_state {
6115                return 1;
6116            }
6117            0
6118        }
6119    }
6120
6121    impl fidl::encoding::ResourceTypeMarker for PowerElements {
6122        type Borrowed<'a> = &'a mut Self;
6123        fn take_or_borrow<'a>(
6124            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6125        ) -> Self::Borrowed<'a> {
6126            value
6127        }
6128    }
6129
6130    unsafe impl fidl::encoding::TypeMarker for PowerElements {
6131        type Owned = Self;
6132
6133        #[inline(always)]
6134        fn inline_align(_context: fidl::encoding::Context) -> usize {
6135            8
6136        }
6137
6138        #[inline(always)]
6139        fn inline_size(_context: fidl::encoding::Context) -> usize {
6140            16
6141        }
6142    }
6143
6144    unsafe impl fidl::encoding::Encode<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
6145        for &mut PowerElements
6146    {
6147        unsafe fn encode(
6148            self,
6149            encoder: &mut fidl::encoding::Encoder<
6150                '_,
6151                fidl::encoding::DefaultFuchsiaResourceDialect,
6152            >,
6153            offset: usize,
6154            mut depth: fidl::encoding::Depth,
6155        ) -> fidl::Result<()> {
6156            encoder.debug_check_bounds::<PowerElements>(offset);
6157            // Vector header
6158            let max_ordinal: u64 = self.max_ordinal_present();
6159            encoder.write_num(max_ordinal, offset);
6160            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
6161            // Calling encoder.out_of_line_offset(0) is not allowed.
6162            if max_ordinal == 0 {
6163                return Ok(());
6164            }
6165            depth.increment()?;
6166            let envelope_size = 8;
6167            let bytes_len = max_ordinal as usize * envelope_size;
6168            #[allow(unused_variables)]
6169            let offset = encoder.out_of_line_offset(bytes_len);
6170            let mut _prev_end_offset: usize = 0;
6171            if 1 > max_ordinal {
6172                return Ok(());
6173            }
6174
6175            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6176            // are envelope_size bytes.
6177            let cur_offset: usize = (1 - 1) * envelope_size;
6178
6179            // Zero reserved fields.
6180            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6181
6182            // Safety:
6183            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6184            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6185            //   envelope_size bytes, there is always sufficient room.
6186            fidl::encoding::encode_in_envelope_optional::<
6187                ExecutionState,
6188                fidl::encoding::DefaultFuchsiaResourceDialect,
6189            >(
6190                self.execution_state
6191                    .as_mut()
6192                    .map(<ExecutionState as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
6193                encoder,
6194                offset + cur_offset,
6195                depth,
6196            )?;
6197
6198            _prev_end_offset = cur_offset + envelope_size;
6199            if 3 > max_ordinal {
6200                return Ok(());
6201            }
6202
6203            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
6204            // are envelope_size bytes.
6205            let cur_offset: usize = (3 - 1) * envelope_size;
6206
6207            // Zero reserved fields.
6208            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
6209
6210            // Safety:
6211            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
6212            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
6213            //   envelope_size bytes, there is always sufficient room.
6214            fidl::encoding::encode_in_envelope_optional::<
6215                ApplicationActivity,
6216                fidl::encoding::DefaultFuchsiaResourceDialect,
6217            >(
6218                self.application_activity.as_mut().map(
6219                    <ApplicationActivity as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
6220                ),
6221                encoder,
6222                offset + cur_offset,
6223                depth,
6224            )?;
6225
6226            _prev_end_offset = cur_offset + envelope_size;
6227
6228            Ok(())
6229        }
6230    }
6231
6232    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {
6233        #[inline(always)]
6234        fn new_empty() -> Self {
6235            Self::default()
6236        }
6237
6238        unsafe fn decode(
6239            &mut self,
6240            decoder: &mut fidl::encoding::Decoder<
6241                '_,
6242                fidl::encoding::DefaultFuchsiaResourceDialect,
6243            >,
6244            offset: usize,
6245            mut depth: fidl::encoding::Depth,
6246        ) -> fidl::Result<()> {
6247            decoder.debug_check_bounds::<Self>(offset);
6248            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
6249                None => return Err(fidl::Error::NotNullable),
6250                Some(len) => len,
6251            };
6252            // Calling decoder.out_of_line_offset(0) is not allowed.
6253            if len == 0 {
6254                return Ok(());
6255            };
6256            depth.increment()?;
6257            let envelope_size = 8;
6258            let bytes_len = len * envelope_size;
6259            let offset = decoder.out_of_line_offset(bytes_len)?;
6260            // Decode the envelope for each type.
6261            let mut _next_ordinal_to_read = 0;
6262            let mut next_offset = offset;
6263            let end_offset = offset + bytes_len;
6264            _next_ordinal_to_read += 1;
6265            if next_offset >= end_offset {
6266                return Ok(());
6267            }
6268
6269            // Decode unknown envelopes for gaps in ordinals.
6270            while _next_ordinal_to_read < 1 {
6271                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6272                _next_ordinal_to_read += 1;
6273                next_offset += envelope_size;
6274            }
6275
6276            let next_out_of_line = decoder.next_out_of_line();
6277            let handles_before = decoder.remaining_handles();
6278            if let Some((inlined, num_bytes, num_handles)) =
6279                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6280            {
6281                let member_inline_size =
6282                    <ExecutionState as fidl::encoding::TypeMarker>::inline_size(decoder.context);
6283                if inlined != (member_inline_size <= 4) {
6284                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6285                }
6286                let inner_offset;
6287                let mut inner_depth = depth.clone();
6288                if inlined {
6289                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6290                    inner_offset = next_offset;
6291                } else {
6292                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6293                    inner_depth.increment()?;
6294                }
6295                let val_ref = self.execution_state.get_or_insert_with(|| {
6296                    fidl::new_empty!(ExecutionState, fidl::encoding::DefaultFuchsiaResourceDialect)
6297                });
6298                fidl::decode!(
6299                    ExecutionState,
6300                    fidl::encoding::DefaultFuchsiaResourceDialect,
6301                    val_ref,
6302                    decoder,
6303                    inner_offset,
6304                    inner_depth
6305                )?;
6306                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6307                {
6308                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6309                }
6310                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6311                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6312                }
6313            }
6314
6315            next_offset += envelope_size;
6316            _next_ordinal_to_read += 1;
6317            if next_offset >= end_offset {
6318                return Ok(());
6319            }
6320
6321            // Decode unknown envelopes for gaps in ordinals.
6322            while _next_ordinal_to_read < 3 {
6323                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6324                _next_ordinal_to_read += 1;
6325                next_offset += envelope_size;
6326            }
6327
6328            let next_out_of_line = decoder.next_out_of_line();
6329            let handles_before = decoder.remaining_handles();
6330            if let Some((inlined, num_bytes, num_handles)) =
6331                fidl::encoding::decode_envelope_header(decoder, next_offset)?
6332            {
6333                let member_inline_size =
6334                    <ApplicationActivity as fidl::encoding::TypeMarker>::inline_size(
6335                        decoder.context,
6336                    );
6337                if inlined != (member_inline_size <= 4) {
6338                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
6339                }
6340                let inner_offset;
6341                let mut inner_depth = depth.clone();
6342                if inlined {
6343                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
6344                    inner_offset = next_offset;
6345                } else {
6346                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6347                    inner_depth.increment()?;
6348                }
6349                let val_ref = self.application_activity.get_or_insert_with(|| {
6350                    fidl::new_empty!(
6351                        ApplicationActivity,
6352                        fidl::encoding::DefaultFuchsiaResourceDialect
6353                    )
6354                });
6355                fidl::decode!(
6356                    ApplicationActivity,
6357                    fidl::encoding::DefaultFuchsiaResourceDialect,
6358                    val_ref,
6359                    decoder,
6360                    inner_offset,
6361                    inner_depth
6362                )?;
6363                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
6364                {
6365                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
6366                }
6367                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6368                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6369                }
6370            }
6371
6372            next_offset += envelope_size;
6373
6374            // Decode the remaining unknown envelopes.
6375            while next_offset < end_offset {
6376                _next_ordinal_to_read += 1;
6377                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6378                next_offset += envelope_size;
6379            }
6380
6381            Ok(())
6382        }
6383    }
6384}