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