Skip to main content

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