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