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