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    /// SuspendBlocker MUST NOT call
2959    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
2960    /// that blocks on raising Execution State above its Inactive level.
2961    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
2962    /// call.) Doing so will currently result in a deadlock. This constraint
2963    /// will eventually be removed; see https://fxbug.dev/391429689.
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    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
2982    /// be satisified when this call is issued, and the `BeforeSuspend` method
2983    /// will be invoked before that guarantee is removed.
2984    ///
2985    /// SAG does not block on the response to this method, so the SuspendBlocker
2986    /// may safely take actions that block on raising Execution State's power
2987    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
2988    pub fn r#after_resume(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
2989        let _response = self.client.send_query::<
2990            fidl::encoding::EmptyPayload,
2991            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
2992        >(
2993            (),
2994            0x6a329cfcc73f2dea,
2995            fidl::encoding::DynamicFlags::FLEXIBLE,
2996            ___deadline,
2997        )?
2998        .into_result::<SuspendBlockerMarker>("after_resume")?;
2999        Ok(_response)
3000    }
3001}
3002
3003#[cfg(target_os = "fuchsia")]
3004impl From<SuspendBlockerSynchronousProxy> for zx::NullableHandle {
3005    fn from(value: SuspendBlockerSynchronousProxy) -> Self {
3006        value.into_channel().into()
3007    }
3008}
3009
3010#[cfg(target_os = "fuchsia")]
3011impl From<fidl::Channel> for SuspendBlockerSynchronousProxy {
3012    fn from(value: fidl::Channel) -> Self {
3013        Self::new(value)
3014    }
3015}
3016
3017#[cfg(target_os = "fuchsia")]
3018impl fidl::endpoints::FromClient for SuspendBlockerSynchronousProxy {
3019    type Protocol = SuspendBlockerMarker;
3020
3021    fn from_client(value: fidl::endpoints::ClientEnd<SuspendBlockerMarker>) -> Self {
3022        Self::new(value.into_channel())
3023    }
3024}
3025
3026#[derive(Debug, Clone)]
3027pub struct SuspendBlockerProxy {
3028    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3029}
3030
3031impl fidl::endpoints::Proxy for SuspendBlockerProxy {
3032    type Protocol = SuspendBlockerMarker;
3033
3034    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3035        Self::new(inner)
3036    }
3037
3038    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3039        self.client.into_channel().map_err(|client| Self { client })
3040    }
3041
3042    fn as_channel(&self) -> &::fidl::AsyncChannel {
3043        self.client.as_channel()
3044    }
3045}
3046
3047impl SuspendBlockerProxy {
3048    /// Create a new Proxy for fuchsia.power.system/SuspendBlocker.
3049    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3050        let protocol_name = <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3051        Self { client: fidl::client::Client::new(channel, protocol_name) }
3052    }
3053
3054    /// Get a Stream of events from the remote end of the protocol.
3055    ///
3056    /// # Panics
3057    ///
3058    /// Panics if the event stream was already taken.
3059    pub fn take_event_stream(&self) -> SuspendBlockerEventStream {
3060        SuspendBlockerEventStream { event_receiver: self.client.take_event_receiver() }
3061    }
3062
3063    /// Called after system activity governor begins operations to suspend the
3064    /// hardware platform.
3065    ///
3066    /// The server is expected to respond once it has performed the operations
3067    /// it needs to prepare itself for suspend, if any. All dependencies of
3068    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3069    /// the duration of this call and may be revoked once the server replies.
3070    ///
3071    /// Operations to suspend the hardware platform may vary between different
3072    /// hardware platforms and product configurations. At a minimum, the client
3073    /// and server MUST assume that general code execution continues
3074    /// until a reply to this call is received by the client. If the
3075    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3076    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3077    ///
3078    /// SuspendBlocker MUST NOT call
3079    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
3080    /// that blocks on raising Execution State above its Inactive level.
3081    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
3082    /// call.) Doing so will currently result in a deadlock. This constraint
3083    /// will eventually be removed; see https://fxbug.dev/391429689.
3084    pub fn r#before_suspend(
3085        &self,
3086    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3087        SuspendBlockerProxyInterface::r#before_suspend(self)
3088    }
3089
3090    /// Called after system activity governor is aware that the hardware
3091    /// platform has resumed.
3092    ///
3093    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
3094    /// be satisified when this call is issued, and the `BeforeSuspend` method
3095    /// will be invoked before that guarantee is removed.
3096    ///
3097    /// SAG does not block on the response to this method, so the SuspendBlocker
3098    /// may safely take actions that block on raising Execution State's power
3099    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
3100    pub fn r#after_resume(
3101        &self,
3102    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
3103        SuspendBlockerProxyInterface::r#after_resume(self)
3104    }
3105}
3106
3107impl SuspendBlockerProxyInterface for SuspendBlockerProxy {
3108    type BeforeSuspendResponseFut =
3109        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3110    fn r#before_suspend(&self) -> Self::BeforeSuspendResponseFut {
3111        fn _decode(
3112            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3113        ) -> Result<(), fidl::Error> {
3114            let _response = fidl::client::decode_transaction_body::<
3115                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3116                fidl::encoding::DefaultFuchsiaResourceDialect,
3117                0x6b569393a01a6d80,
3118            >(_buf?)?
3119            .into_result::<SuspendBlockerMarker>("before_suspend")?;
3120            Ok(_response)
3121        }
3122        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3123            (),
3124            0x6b569393a01a6d80,
3125            fidl::encoding::DynamicFlags::FLEXIBLE,
3126            _decode,
3127        )
3128    }
3129
3130    type AfterResumeResponseFut =
3131        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
3132    fn r#after_resume(&self) -> Self::AfterResumeResponseFut {
3133        fn _decode(
3134            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3135        ) -> Result<(), fidl::Error> {
3136            let _response = fidl::client::decode_transaction_body::<
3137                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
3138                fidl::encoding::DefaultFuchsiaResourceDialect,
3139                0x6a329cfcc73f2dea,
3140            >(_buf?)?
3141            .into_result::<SuspendBlockerMarker>("after_resume")?;
3142            Ok(_response)
3143        }
3144        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
3145            (),
3146            0x6a329cfcc73f2dea,
3147            fidl::encoding::DynamicFlags::FLEXIBLE,
3148            _decode,
3149        )
3150    }
3151}
3152
3153pub struct SuspendBlockerEventStream {
3154    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3155}
3156
3157impl std::marker::Unpin for SuspendBlockerEventStream {}
3158
3159impl futures::stream::FusedStream for SuspendBlockerEventStream {
3160    fn is_terminated(&self) -> bool {
3161        self.event_receiver.is_terminated()
3162    }
3163}
3164
3165impl futures::Stream for SuspendBlockerEventStream {
3166    type Item = Result<SuspendBlockerEvent, fidl::Error>;
3167
3168    fn poll_next(
3169        mut self: std::pin::Pin<&mut Self>,
3170        cx: &mut std::task::Context<'_>,
3171    ) -> std::task::Poll<Option<Self::Item>> {
3172        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3173            &mut self.event_receiver,
3174            cx
3175        )?) {
3176            Some(buf) => std::task::Poll::Ready(Some(SuspendBlockerEvent::decode(buf))),
3177            None => std::task::Poll::Ready(None),
3178        }
3179    }
3180}
3181
3182#[derive(Debug)]
3183pub enum SuspendBlockerEvent {
3184    #[non_exhaustive]
3185    _UnknownEvent {
3186        /// Ordinal of the event that was sent.
3187        ordinal: u64,
3188    },
3189}
3190
3191impl SuspendBlockerEvent {
3192    /// Decodes a message buffer as a [`SuspendBlockerEvent`].
3193    fn decode(
3194        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3195    ) -> Result<SuspendBlockerEvent, fidl::Error> {
3196        let (bytes, _handles) = buf.split_mut();
3197        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3198        debug_assert_eq!(tx_header.tx_id, 0);
3199        match tx_header.ordinal {
3200            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
3201                Ok(SuspendBlockerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
3202            }
3203            _ => Err(fidl::Error::UnknownOrdinal {
3204                ordinal: tx_header.ordinal,
3205                protocol_name:
3206                    <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3207            }),
3208        }
3209    }
3210}
3211
3212/// A Stream of incoming requests for fuchsia.power.system/SuspendBlocker.
3213pub struct SuspendBlockerRequestStream {
3214    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3215    is_terminated: bool,
3216}
3217
3218impl std::marker::Unpin for SuspendBlockerRequestStream {}
3219
3220impl futures::stream::FusedStream for SuspendBlockerRequestStream {
3221    fn is_terminated(&self) -> bool {
3222        self.is_terminated
3223    }
3224}
3225
3226impl fidl::endpoints::RequestStream for SuspendBlockerRequestStream {
3227    type Protocol = SuspendBlockerMarker;
3228    type ControlHandle = SuspendBlockerControlHandle;
3229
3230    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3231        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3232    }
3233
3234    fn control_handle(&self) -> Self::ControlHandle {
3235        SuspendBlockerControlHandle { inner: self.inner.clone() }
3236    }
3237
3238    fn into_inner(
3239        self,
3240    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3241    {
3242        (self.inner, self.is_terminated)
3243    }
3244
3245    fn from_inner(
3246        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3247        is_terminated: bool,
3248    ) -> Self {
3249        Self { inner, is_terminated }
3250    }
3251}
3252
3253impl futures::Stream for SuspendBlockerRequestStream {
3254    type Item = Result<SuspendBlockerRequest, fidl::Error>;
3255
3256    fn poll_next(
3257        mut self: std::pin::Pin<&mut Self>,
3258        cx: &mut std::task::Context<'_>,
3259    ) -> std::task::Poll<Option<Self::Item>> {
3260        let this = &mut *self;
3261        if this.inner.check_shutdown(cx) {
3262            this.is_terminated = true;
3263            return std::task::Poll::Ready(None);
3264        }
3265        if this.is_terminated {
3266            panic!("polled SuspendBlockerRequestStream after completion");
3267        }
3268        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3269            |bytes, handles| {
3270                match this.inner.channel().read_etc(cx, bytes, handles) {
3271                    std::task::Poll::Ready(Ok(())) => {}
3272                    std::task::Poll::Pending => return std::task::Poll::Pending,
3273                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3274                        this.is_terminated = true;
3275                        return std::task::Poll::Ready(None);
3276                    }
3277                    std::task::Poll::Ready(Err(e)) => {
3278                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3279                            e.into(),
3280                        ))));
3281                    }
3282                }
3283
3284                // A message has been received from the channel
3285                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3286
3287                std::task::Poll::Ready(Some(match header.ordinal {
3288                    0x6b569393a01a6d80 => {
3289                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3290                        let mut req = fidl::new_empty!(
3291                            fidl::encoding::EmptyPayload,
3292                            fidl::encoding::DefaultFuchsiaResourceDialect
3293                        );
3294                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3295                        let control_handle =
3296                            SuspendBlockerControlHandle { inner: this.inner.clone() };
3297                        Ok(SuspendBlockerRequest::BeforeSuspend {
3298                            responder: SuspendBlockerBeforeSuspendResponder {
3299                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3300                                tx_id: header.tx_id,
3301                            },
3302                        })
3303                    }
3304                    0x6a329cfcc73f2dea => {
3305                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
3306                        let mut req = fidl::new_empty!(
3307                            fidl::encoding::EmptyPayload,
3308                            fidl::encoding::DefaultFuchsiaResourceDialect
3309                        );
3310                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
3311                        let control_handle =
3312                            SuspendBlockerControlHandle { inner: this.inner.clone() };
3313                        Ok(SuspendBlockerRequest::AfterResume {
3314                            responder: SuspendBlockerAfterResumeResponder {
3315                                control_handle: std::mem::ManuallyDrop::new(control_handle),
3316                                tx_id: header.tx_id,
3317                            },
3318                        })
3319                    }
3320                    _ if header.tx_id == 0
3321                        && header
3322                            .dynamic_flags()
3323                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3324                    {
3325                        Ok(SuspendBlockerRequest::_UnknownMethod {
3326                            ordinal: header.ordinal,
3327                            control_handle: SuspendBlockerControlHandle {
3328                                inner: this.inner.clone(),
3329                            },
3330                            method_type: fidl::MethodType::OneWay,
3331                        })
3332                    }
3333                    _ if header
3334                        .dynamic_flags()
3335                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
3336                    {
3337                        this.inner.send_framework_err(
3338                            fidl::encoding::FrameworkErr::UnknownMethod,
3339                            header.tx_id,
3340                            header.ordinal,
3341                            header.dynamic_flags(),
3342                            (bytes, handles),
3343                        )?;
3344                        Ok(SuspendBlockerRequest::_UnknownMethod {
3345                            ordinal: header.ordinal,
3346                            control_handle: SuspendBlockerControlHandle {
3347                                inner: this.inner.clone(),
3348                            },
3349                            method_type: fidl::MethodType::TwoWay,
3350                        })
3351                    }
3352                    _ => Err(fidl::Error::UnknownOrdinal {
3353                        ordinal: header.ordinal,
3354                        protocol_name:
3355                            <SuspendBlockerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3356                    }),
3357                }))
3358            },
3359        )
3360    }
3361}
3362
3363/// An entity that blocks suspend until it handles transitions across hardware
3364/// platform suspend and resume.
3365#[derive(Debug)]
3366pub enum SuspendBlockerRequest {
3367    /// Called after system activity governor begins operations to suspend the
3368    /// hardware platform.
3369    ///
3370    /// The server is expected to respond once it has performed the operations
3371    /// it needs to prepare itself for suspend, if any. All dependencies of
3372    /// `ExecutionStateLevel::SUSPENDING` are guaranteed to be satisified for
3373    /// the duration of this call and may be revoked once the server replies.
3374    ///
3375    /// Operations to suspend the hardware platform may vary between different
3376    /// hardware platforms and product configurations. At a minimum, the client
3377    /// and server MUST assume that general code execution continues
3378    /// until a reply to this call is received by the client. If the
3379    /// SuspendBlocker wants to preempt suspend operations, it MUST call
3380    /// `ActivityGovernor.AcquireWakeLease` before replying to this call.
3381    ///
3382    /// SuspendBlocker MUST NOT call
3383    /// `ActivityGovernor.TakeApplicationActivityLease` nor perform any action
3384    /// that blocks on raising Execution State above its Inactive level.
3385    /// (However, AcquireWakeLease does _not_ block in this way and is safe to
3386    /// call.) Doing so will currently result in a deadlock. This constraint
3387    /// will eventually be removed; see https://fxbug.dev/391429689.
3388    BeforeSuspend { responder: SuspendBlockerBeforeSuspendResponder },
3389    /// Called after system activity governor is aware that the hardware
3390    /// platform has resumed.
3391    ///
3392    /// All dependencies of `ExecutionStateLevel::SUSPENDING` are guaranteed to
3393    /// be satisified when this call is issued, and the `BeforeSuspend` method
3394    /// will be invoked before that guarantee is removed.
3395    ///
3396    /// SAG does not block on the response to this method, so the SuspendBlocker
3397    /// may safely take actions that block on raising Execution State's power
3398    /// level. In particular, it is not affected by https://fxbug.dev/391429689.
3399    AfterResume { responder: SuspendBlockerAfterResumeResponder },
3400    /// An interaction was received which does not match any known method.
3401    #[non_exhaustive]
3402    _UnknownMethod {
3403        /// Ordinal of the method that was called.
3404        ordinal: u64,
3405        control_handle: SuspendBlockerControlHandle,
3406        method_type: fidl::MethodType,
3407    },
3408}
3409
3410impl SuspendBlockerRequest {
3411    #[allow(irrefutable_let_patterns)]
3412    pub fn into_before_suspend(self) -> Option<(SuspendBlockerBeforeSuspendResponder)> {
3413        if let SuspendBlockerRequest::BeforeSuspend { responder } = self {
3414            Some((responder))
3415        } else {
3416            None
3417        }
3418    }
3419
3420    #[allow(irrefutable_let_patterns)]
3421    pub fn into_after_resume(self) -> Option<(SuspendBlockerAfterResumeResponder)> {
3422        if let SuspendBlockerRequest::AfterResume { responder } = self {
3423            Some((responder))
3424        } else {
3425            None
3426        }
3427    }
3428
3429    /// Name of the method defined in FIDL
3430    pub fn method_name(&self) -> &'static str {
3431        match *self {
3432            SuspendBlockerRequest::BeforeSuspend { .. } => "before_suspend",
3433            SuspendBlockerRequest::AfterResume { .. } => "after_resume",
3434            SuspendBlockerRequest::_UnknownMethod {
3435                method_type: fidl::MethodType::OneWay, ..
3436            } => "unknown one-way method",
3437            SuspendBlockerRequest::_UnknownMethod {
3438                method_type: fidl::MethodType::TwoWay, ..
3439            } => "unknown two-way method",
3440        }
3441    }
3442}
3443
3444#[derive(Debug, Clone)]
3445pub struct SuspendBlockerControlHandle {
3446    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3447}
3448
3449impl fidl::endpoints::ControlHandle for SuspendBlockerControlHandle {
3450    fn shutdown(&self) {
3451        self.inner.shutdown()
3452    }
3453
3454    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3455        self.inner.shutdown_with_epitaph(status)
3456    }
3457
3458    fn is_closed(&self) -> bool {
3459        self.inner.channel().is_closed()
3460    }
3461    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3462        self.inner.channel().on_closed()
3463    }
3464
3465    #[cfg(target_os = "fuchsia")]
3466    fn signal_peer(
3467        &self,
3468        clear_mask: zx::Signals,
3469        set_mask: zx::Signals,
3470    ) -> Result<(), zx_status::Status> {
3471        use fidl::Peered;
3472        self.inner.channel().signal_peer(clear_mask, set_mask)
3473    }
3474}
3475
3476impl SuspendBlockerControlHandle {}
3477
3478#[must_use = "FIDL methods require a response to be sent"]
3479#[derive(Debug)]
3480pub struct SuspendBlockerBeforeSuspendResponder {
3481    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
3482    tx_id: u32,
3483}
3484
3485/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
3486/// if the responder is dropped without sending a response, so that the client
3487/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3488impl std::ops::Drop for SuspendBlockerBeforeSuspendResponder {
3489    fn drop(&mut self) {
3490        self.control_handle.shutdown();
3491        // Safety: drops once, never accessed again
3492        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3493    }
3494}
3495
3496impl fidl::endpoints::Responder for SuspendBlockerBeforeSuspendResponder {
3497    type ControlHandle = SuspendBlockerControlHandle;
3498
3499    fn control_handle(&self) -> &SuspendBlockerControlHandle {
3500        &self.control_handle
3501    }
3502
3503    fn drop_without_shutdown(mut self) {
3504        // Safety: drops once, never accessed again due to mem::forget
3505        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3506        // Prevent Drop from running (which would shut down the channel)
3507        std::mem::forget(self);
3508    }
3509}
3510
3511impl SuspendBlockerBeforeSuspendResponder {
3512    /// Sends a response to the FIDL transaction.
3513    ///
3514    /// Sets the channel to shutdown if an error occurs.
3515    pub fn send(self) -> Result<(), fidl::Error> {
3516        let _result = self.send_raw();
3517        if _result.is_err() {
3518            self.control_handle.shutdown();
3519        }
3520        self.drop_without_shutdown();
3521        _result
3522    }
3523
3524    /// Similar to "send" but does not shutdown the channel if an error occurs.
3525    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3526        let _result = self.send_raw();
3527        self.drop_without_shutdown();
3528        _result
3529    }
3530
3531    fn send_raw(&self) -> Result<(), fidl::Error> {
3532        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3533            fidl::encoding::Flexible::new(()),
3534            self.tx_id,
3535            0x6b569393a01a6d80,
3536            fidl::encoding::DynamicFlags::FLEXIBLE,
3537        )
3538    }
3539}
3540
3541#[must_use = "FIDL methods require a response to be sent"]
3542#[derive(Debug)]
3543pub struct SuspendBlockerAfterResumeResponder {
3544    control_handle: std::mem::ManuallyDrop<SuspendBlockerControlHandle>,
3545    tx_id: u32,
3546}
3547
3548/// Set the the channel to be shutdown (see [`SuspendBlockerControlHandle::shutdown`])
3549/// if the responder is dropped without sending a response, so that the client
3550/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
3551impl std::ops::Drop for SuspendBlockerAfterResumeResponder {
3552    fn drop(&mut self) {
3553        self.control_handle.shutdown();
3554        // Safety: drops once, never accessed again
3555        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3556    }
3557}
3558
3559impl fidl::endpoints::Responder for SuspendBlockerAfterResumeResponder {
3560    type ControlHandle = SuspendBlockerControlHandle;
3561
3562    fn control_handle(&self) -> &SuspendBlockerControlHandle {
3563        &self.control_handle
3564    }
3565
3566    fn drop_without_shutdown(mut self) {
3567        // Safety: drops once, never accessed again due to mem::forget
3568        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
3569        // Prevent Drop from running (which would shut down the channel)
3570        std::mem::forget(self);
3571    }
3572}
3573
3574impl SuspendBlockerAfterResumeResponder {
3575    /// Sends a response to the FIDL transaction.
3576    ///
3577    /// Sets the channel to shutdown if an error occurs.
3578    pub fn send(self) -> Result<(), fidl::Error> {
3579        let _result = self.send_raw();
3580        if _result.is_err() {
3581            self.control_handle.shutdown();
3582        }
3583        self.drop_without_shutdown();
3584        _result
3585    }
3586
3587    /// Similar to "send" but does not shutdown the channel if an error occurs.
3588    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
3589        let _result = self.send_raw();
3590        self.drop_without_shutdown();
3591        _result
3592    }
3593
3594    fn send_raw(&self) -> Result<(), fidl::Error> {
3595        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
3596            fidl::encoding::Flexible::new(()),
3597            self.tx_id,
3598            0x6a329cfcc73f2dea,
3599            fidl::encoding::DynamicFlags::FLEXIBLE,
3600        )
3601    }
3602}
3603
3604mod internal {
3605    use super::*;
3606
3607    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseWithTokenRequest {
3608        type Borrowed<'a> = &'a mut Self;
3609        fn take_or_borrow<'a>(
3610            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3611        ) -> Self::Borrowed<'a> {
3612            value
3613        }
3614    }
3615
3616    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseWithTokenRequest {
3617        type Owned = Self;
3618
3619        #[inline(always)]
3620        fn inline_align(_context: fidl::encoding::Context) -> usize {
3621            8
3622        }
3623
3624        #[inline(always)]
3625        fn inline_size(_context: fidl::encoding::Context) -> usize {
3626            24
3627        }
3628    }
3629
3630    unsafe impl
3631        fidl::encoding::Encode<
3632            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
3633            fidl::encoding::DefaultFuchsiaResourceDialect,
3634        > for &mut ActivityGovernorAcquireWakeLeaseWithTokenRequest
3635    {
3636        #[inline]
3637        unsafe fn encode(
3638            self,
3639            encoder: &mut fidl::encoding::Encoder<
3640                '_,
3641                fidl::encoding::DefaultFuchsiaResourceDialect,
3642            >,
3643            offset: usize,
3644            _depth: fidl::encoding::Depth,
3645        ) -> fidl::Result<()> {
3646            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseWithTokenRequest>(offset);
3647            // Delegate to tuple encoding.
3648            fidl::encoding::Encode::<
3649                ActivityGovernorAcquireWakeLeaseWithTokenRequest,
3650                fidl::encoding::DefaultFuchsiaResourceDialect,
3651            >::encode(
3652                (
3653                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
3654                        &self.name,
3655                    ),
3656                    <fidl::encoding::HandleType<
3657                        fidl::EventPair,
3658                        { fidl::ObjectType::EVENTPAIR.into_raw() },
3659                        16387,
3660                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3661                        &mut self.server_token,
3662                    ),
3663                ),
3664                encoder,
3665                offset,
3666                _depth,
3667            )
3668        }
3669    }
3670    unsafe impl<
3671        T0: fidl::encoding::Encode<
3672                fidl::encoding::BoundedString<64>,
3673                fidl::encoding::DefaultFuchsiaResourceDialect,
3674            >,
3675        T1: fidl::encoding::Encode<
3676                fidl::encoding::HandleType<
3677                    fidl::EventPair,
3678                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3679                    16387,
3680                >,
3681                fidl::encoding::DefaultFuchsiaResourceDialect,
3682            >,
3683    >
3684        fidl::encoding::Encode<
3685            ActivityGovernorAcquireWakeLeaseWithTokenRequest,
3686            fidl::encoding::DefaultFuchsiaResourceDialect,
3687        > for (T0, T1)
3688    {
3689        #[inline]
3690        unsafe fn encode(
3691            self,
3692            encoder: &mut fidl::encoding::Encoder<
3693                '_,
3694                fidl::encoding::DefaultFuchsiaResourceDialect,
3695            >,
3696            offset: usize,
3697            depth: fidl::encoding::Depth,
3698        ) -> fidl::Result<()> {
3699            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseWithTokenRequest>(offset);
3700            // Zero out padding regions. There's no need to apply masks
3701            // because the unmasked parts will be overwritten by fields.
3702            unsafe {
3703                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3704                (ptr as *mut u64).write_unaligned(0);
3705            }
3706            // Write the fields.
3707            self.0.encode(encoder, offset + 0, depth)?;
3708            self.1.encode(encoder, offset + 16, depth)?;
3709            Ok(())
3710        }
3711    }
3712
3713    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3714        for ActivityGovernorAcquireWakeLeaseWithTokenRequest
3715    {
3716        #[inline(always)]
3717        fn new_empty() -> Self {
3718            Self {
3719                name: fidl::new_empty!(
3720                    fidl::encoding::BoundedString<64>,
3721                    fidl::encoding::DefaultFuchsiaResourceDialect
3722                ),
3723                server_token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3724            }
3725        }
3726
3727        #[inline]
3728        unsafe fn decode(
3729            &mut self,
3730            decoder: &mut fidl::encoding::Decoder<
3731                '_,
3732                fidl::encoding::DefaultFuchsiaResourceDialect,
3733            >,
3734            offset: usize,
3735            _depth: fidl::encoding::Depth,
3736        ) -> fidl::Result<()> {
3737            decoder.debug_check_bounds::<Self>(offset);
3738            // Verify that padding bytes are zero.
3739            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3740            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3741            let mask = 0xffffffff00000000u64;
3742            let maskedval = padval & mask;
3743            if maskedval != 0 {
3744                return Err(fidl::Error::NonZeroPadding {
3745                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3746                });
3747            }
3748            fidl::decode!(
3749                fidl::encoding::BoundedString<64>,
3750                fidl::encoding::DefaultFuchsiaResourceDialect,
3751                &mut self.name,
3752                decoder,
3753                offset + 0,
3754                _depth
3755            )?;
3756            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_token, decoder, offset + 16, _depth)?;
3757            Ok(())
3758        }
3759    }
3760
3761    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
3762        type Borrowed<'a> = &'a mut Self;
3763        fn take_or_borrow<'a>(
3764            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3765        ) -> Self::Borrowed<'a> {
3766            value
3767        }
3768    }
3769
3770    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorAcquireWakeLeaseResponse {
3771        type Owned = Self;
3772
3773        #[inline(always)]
3774        fn inline_align(_context: fidl::encoding::Context) -> usize {
3775            4
3776        }
3777
3778        #[inline(always)]
3779        fn inline_size(_context: fidl::encoding::Context) -> usize {
3780            4
3781        }
3782    }
3783
3784    unsafe impl
3785        fidl::encoding::Encode<
3786            ActivityGovernorAcquireWakeLeaseResponse,
3787            fidl::encoding::DefaultFuchsiaResourceDialect,
3788        > for &mut ActivityGovernorAcquireWakeLeaseResponse
3789    {
3790        #[inline]
3791        unsafe fn encode(
3792            self,
3793            encoder: &mut fidl::encoding::Encoder<
3794                '_,
3795                fidl::encoding::DefaultFuchsiaResourceDialect,
3796            >,
3797            offset: usize,
3798            _depth: fidl::encoding::Depth,
3799        ) -> fidl::Result<()> {
3800            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
3801            // Delegate to tuple encoding.
3802            fidl::encoding::Encode::<
3803                ActivityGovernorAcquireWakeLeaseResponse,
3804                fidl::encoding::DefaultFuchsiaResourceDialect,
3805            >::encode(
3806                (<fidl::encoding::HandleType<
3807                    fidl::EventPair,
3808                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3809                    16387,
3810                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3811                    &mut self.token
3812                ),),
3813                encoder,
3814                offset,
3815                _depth,
3816            )
3817        }
3818    }
3819    unsafe impl<
3820        T0: fidl::encoding::Encode<
3821                fidl::encoding::HandleType<
3822                    fidl::EventPair,
3823                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3824                    16387,
3825                >,
3826                fidl::encoding::DefaultFuchsiaResourceDialect,
3827            >,
3828    >
3829        fidl::encoding::Encode<
3830            ActivityGovernorAcquireWakeLeaseResponse,
3831            fidl::encoding::DefaultFuchsiaResourceDialect,
3832        > for (T0,)
3833    {
3834        #[inline]
3835        unsafe fn encode(
3836            self,
3837            encoder: &mut fidl::encoding::Encoder<
3838                '_,
3839                fidl::encoding::DefaultFuchsiaResourceDialect,
3840            >,
3841            offset: usize,
3842            depth: fidl::encoding::Depth,
3843        ) -> fidl::Result<()> {
3844            encoder.debug_check_bounds::<ActivityGovernorAcquireWakeLeaseResponse>(offset);
3845            // Zero out padding regions. There's no need to apply masks
3846            // because the unmasked parts will be overwritten by fields.
3847            // Write the fields.
3848            self.0.encode(encoder, offset + 0, depth)?;
3849            Ok(())
3850        }
3851    }
3852
3853    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3854        for ActivityGovernorAcquireWakeLeaseResponse
3855    {
3856        #[inline(always)]
3857        fn new_empty() -> Self {
3858            Self {
3859                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3860            }
3861        }
3862
3863        #[inline]
3864        unsafe fn decode(
3865            &mut self,
3866            decoder: &mut fidl::encoding::Decoder<
3867                '_,
3868                fidl::encoding::DefaultFuchsiaResourceDialect,
3869            >,
3870            offset: usize,
3871            _depth: fidl::encoding::Depth,
3872        ) -> fidl::Result<()> {
3873            decoder.debug_check_bounds::<Self>(offset);
3874            // Verify that padding bytes are zero.
3875            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
3876            Ok(())
3877        }
3878    }
3879
3880    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
3881        type Borrowed<'a> = &'a mut Self;
3882        fn take_or_borrow<'a>(
3883            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3884        ) -> Self::Borrowed<'a> {
3885            value
3886        }
3887    }
3888
3889    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerResponse {
3890        type Owned = Self;
3891
3892        #[inline(always)]
3893        fn inline_align(_context: fidl::encoding::Context) -> usize {
3894            4
3895        }
3896
3897        #[inline(always)]
3898        fn inline_size(_context: fidl::encoding::Context) -> usize {
3899            4
3900        }
3901    }
3902
3903    unsafe impl
3904        fidl::encoding::Encode<
3905            ActivityGovernorRegisterSuspendBlockerResponse,
3906            fidl::encoding::DefaultFuchsiaResourceDialect,
3907        > for &mut ActivityGovernorRegisterSuspendBlockerResponse
3908    {
3909        #[inline]
3910        unsafe fn encode(
3911            self,
3912            encoder: &mut fidl::encoding::Encoder<
3913                '_,
3914                fidl::encoding::DefaultFuchsiaResourceDialect,
3915            >,
3916            offset: usize,
3917            _depth: fidl::encoding::Depth,
3918        ) -> fidl::Result<()> {
3919            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
3920            // Delegate to tuple encoding.
3921            fidl::encoding::Encode::<
3922                ActivityGovernorRegisterSuspendBlockerResponse,
3923                fidl::encoding::DefaultFuchsiaResourceDialect,
3924            >::encode(
3925                (<fidl::encoding::HandleType<
3926                    fidl::EventPair,
3927                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3928                    16387,
3929                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3930                    &mut self.token
3931                ),),
3932                encoder,
3933                offset,
3934                _depth,
3935            )
3936        }
3937    }
3938    unsafe impl<
3939        T0: fidl::encoding::Encode<
3940                fidl::encoding::HandleType<
3941                    fidl::EventPair,
3942                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3943                    16387,
3944                >,
3945                fidl::encoding::DefaultFuchsiaResourceDialect,
3946            >,
3947    >
3948        fidl::encoding::Encode<
3949            ActivityGovernorRegisterSuspendBlockerResponse,
3950            fidl::encoding::DefaultFuchsiaResourceDialect,
3951        > for (T0,)
3952    {
3953        #[inline]
3954        unsafe fn encode(
3955            self,
3956            encoder: &mut fidl::encoding::Encoder<
3957                '_,
3958                fidl::encoding::DefaultFuchsiaResourceDialect,
3959            >,
3960            offset: usize,
3961            depth: fidl::encoding::Depth,
3962        ) -> fidl::Result<()> {
3963            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerResponse>(offset);
3964            // Zero out padding regions. There's no need to apply masks
3965            // because the unmasked parts will be overwritten by fields.
3966            // Write the fields.
3967            self.0.encode(encoder, offset + 0, depth)?;
3968            Ok(())
3969        }
3970    }
3971
3972    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3973        for ActivityGovernorRegisterSuspendBlockerResponse
3974    {
3975        #[inline(always)]
3976        fn new_empty() -> Self {
3977            Self {
3978                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
3979            }
3980        }
3981
3982        #[inline]
3983        unsafe fn decode(
3984            &mut self,
3985            decoder: &mut fidl::encoding::Decoder<
3986                '_,
3987                fidl::encoding::DefaultFuchsiaResourceDialect,
3988            >,
3989            offset: usize,
3990            _depth: fidl::encoding::Depth,
3991        ) -> fidl::Result<()> {
3992            decoder.debug_check_bounds::<Self>(offset);
3993            // Verify that padding bytes are zero.
3994            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
3995            Ok(())
3996        }
3997    }
3998
3999    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4000        type Borrowed<'a> = &'a mut Self;
4001        fn take_or_borrow<'a>(
4002            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4003        ) -> Self::Borrowed<'a> {
4004            value
4005        }
4006    }
4007
4008    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeApplicationActivityLeaseResponse {
4009        type Owned = Self;
4010
4011        #[inline(always)]
4012        fn inline_align(_context: fidl::encoding::Context) -> usize {
4013            4
4014        }
4015
4016        #[inline(always)]
4017        fn inline_size(_context: fidl::encoding::Context) -> usize {
4018            4
4019        }
4020    }
4021
4022    unsafe impl
4023        fidl::encoding::Encode<
4024            ActivityGovernorTakeApplicationActivityLeaseResponse,
4025            fidl::encoding::DefaultFuchsiaResourceDialect,
4026        > for &mut ActivityGovernorTakeApplicationActivityLeaseResponse
4027    {
4028        #[inline]
4029        unsafe fn encode(
4030            self,
4031            encoder: &mut fidl::encoding::Encoder<
4032                '_,
4033                fidl::encoding::DefaultFuchsiaResourceDialect,
4034            >,
4035            offset: usize,
4036            _depth: fidl::encoding::Depth,
4037        ) -> fidl::Result<()> {
4038            encoder
4039                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
4040            // Delegate to tuple encoding.
4041            fidl::encoding::Encode::<
4042                ActivityGovernorTakeApplicationActivityLeaseResponse,
4043                fidl::encoding::DefaultFuchsiaResourceDialect,
4044            >::encode(
4045                (<fidl::encoding::HandleType<
4046                    fidl::EventPair,
4047                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4048                    16387,
4049                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4050                    &mut self.token
4051                ),),
4052                encoder,
4053                offset,
4054                _depth,
4055            )
4056        }
4057    }
4058    unsafe impl<
4059        T0: fidl::encoding::Encode<
4060                fidl::encoding::HandleType<
4061                    fidl::EventPair,
4062                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4063                    16387,
4064                >,
4065                fidl::encoding::DefaultFuchsiaResourceDialect,
4066            >,
4067    >
4068        fidl::encoding::Encode<
4069            ActivityGovernorTakeApplicationActivityLeaseResponse,
4070            fidl::encoding::DefaultFuchsiaResourceDialect,
4071        > for (T0,)
4072    {
4073        #[inline]
4074        unsafe fn encode(
4075            self,
4076            encoder: &mut fidl::encoding::Encoder<
4077                '_,
4078                fidl::encoding::DefaultFuchsiaResourceDialect,
4079            >,
4080            offset: usize,
4081            depth: fidl::encoding::Depth,
4082        ) -> fidl::Result<()> {
4083            encoder
4084                .debug_check_bounds::<ActivityGovernorTakeApplicationActivityLeaseResponse>(offset);
4085            // Zero out padding regions. There's no need to apply masks
4086            // because the unmasked parts will be overwritten by fields.
4087            // Write the fields.
4088            self.0.encode(encoder, offset + 0, depth)?;
4089            Ok(())
4090        }
4091    }
4092
4093    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4094        for ActivityGovernorTakeApplicationActivityLeaseResponse
4095    {
4096        #[inline(always)]
4097        fn new_empty() -> Self {
4098            Self {
4099                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4100            }
4101        }
4102
4103        #[inline]
4104        unsafe fn decode(
4105            &mut self,
4106            decoder: &mut fidl::encoding::Decoder<
4107                '_,
4108                fidl::encoding::DefaultFuchsiaResourceDialect,
4109            >,
4110            offset: usize,
4111            _depth: fidl::encoding::Depth,
4112        ) -> fidl::Result<()> {
4113            decoder.debug_check_bounds::<Self>(offset);
4114            // Verify that padding bytes are zero.
4115            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4116            Ok(())
4117        }
4118    }
4119
4120    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorTakeWakeLeaseResponse {
4121        type Borrowed<'a> = &'a mut Self;
4122        fn take_or_borrow<'a>(
4123            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4124        ) -> Self::Borrowed<'a> {
4125            value
4126        }
4127    }
4128
4129    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorTakeWakeLeaseResponse {
4130        type Owned = Self;
4131
4132        #[inline(always)]
4133        fn inline_align(_context: fidl::encoding::Context) -> usize {
4134            4
4135        }
4136
4137        #[inline(always)]
4138        fn inline_size(_context: fidl::encoding::Context) -> usize {
4139            4
4140        }
4141    }
4142
4143    unsafe impl
4144        fidl::encoding::Encode<
4145            ActivityGovernorTakeWakeLeaseResponse,
4146            fidl::encoding::DefaultFuchsiaResourceDialect,
4147        > for &mut ActivityGovernorTakeWakeLeaseResponse
4148    {
4149        #[inline]
4150        unsafe fn encode(
4151            self,
4152            encoder: &mut fidl::encoding::Encoder<
4153                '_,
4154                fidl::encoding::DefaultFuchsiaResourceDialect,
4155            >,
4156            offset: usize,
4157            _depth: fidl::encoding::Depth,
4158        ) -> fidl::Result<()> {
4159            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
4160            // Delegate to tuple encoding.
4161            fidl::encoding::Encode::<
4162                ActivityGovernorTakeWakeLeaseResponse,
4163                fidl::encoding::DefaultFuchsiaResourceDialect,
4164            >::encode(
4165                (<fidl::encoding::HandleType<
4166                    fidl::EventPair,
4167                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4168                    16387,
4169                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4170                    &mut self.token
4171                ),),
4172                encoder,
4173                offset,
4174                _depth,
4175            )
4176        }
4177    }
4178    unsafe impl<
4179        T0: fidl::encoding::Encode<
4180                fidl::encoding::HandleType<
4181                    fidl::EventPair,
4182                    { fidl::ObjectType::EVENTPAIR.into_raw() },
4183                    16387,
4184                >,
4185                fidl::encoding::DefaultFuchsiaResourceDialect,
4186            >,
4187    >
4188        fidl::encoding::Encode<
4189            ActivityGovernorTakeWakeLeaseResponse,
4190            fidl::encoding::DefaultFuchsiaResourceDialect,
4191        > for (T0,)
4192    {
4193        #[inline]
4194        unsafe fn encode(
4195            self,
4196            encoder: &mut fidl::encoding::Encoder<
4197                '_,
4198                fidl::encoding::DefaultFuchsiaResourceDialect,
4199            >,
4200            offset: usize,
4201            depth: fidl::encoding::Depth,
4202        ) -> fidl::Result<()> {
4203            encoder.debug_check_bounds::<ActivityGovernorTakeWakeLeaseResponse>(offset);
4204            // Zero out padding regions. There's no need to apply masks
4205            // because the unmasked parts will be overwritten by fields.
4206            // Write the fields.
4207            self.0.encode(encoder, offset + 0, depth)?;
4208            Ok(())
4209        }
4210    }
4211
4212    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4213        for ActivityGovernorTakeWakeLeaseResponse
4214    {
4215        #[inline(always)]
4216        fn new_empty() -> Self {
4217            Self {
4218                token: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect),
4219            }
4220        }
4221
4222        #[inline]
4223        unsafe fn decode(
4224            &mut self,
4225            decoder: &mut fidl::encoding::Decoder<
4226                '_,
4227                fidl::encoding::DefaultFuchsiaResourceDialect,
4228            >,
4229            offset: usize,
4230            _depth: fidl::encoding::Depth,
4231        ) -> fidl::Result<()> {
4232            decoder.debug_check_bounds::<Self>(offset);
4233            // Verify that padding bytes are zero.
4234            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 16387>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.token, decoder, offset + 0, _depth)?;
4235            Ok(())
4236        }
4237    }
4238
4239    impl ActivityGovernorRegisterSuspendBlockerRequest {
4240        #[inline(always)]
4241        fn max_ordinal_present(&self) -> u64 {
4242            if let Some(_) = self.name {
4243                return 2;
4244            }
4245            if let Some(_) = self.suspend_blocker {
4246                return 1;
4247            }
4248            0
4249        }
4250    }
4251
4252    impl fidl::encoding::ResourceTypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
4253        type Borrowed<'a> = &'a mut Self;
4254        fn take_or_borrow<'a>(
4255            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4256        ) -> Self::Borrowed<'a> {
4257            value
4258        }
4259    }
4260
4261    unsafe impl fidl::encoding::TypeMarker for ActivityGovernorRegisterSuspendBlockerRequest {
4262        type Owned = Self;
4263
4264        #[inline(always)]
4265        fn inline_align(_context: fidl::encoding::Context) -> usize {
4266            8
4267        }
4268
4269        #[inline(always)]
4270        fn inline_size(_context: fidl::encoding::Context) -> usize {
4271            16
4272        }
4273    }
4274
4275    unsafe impl
4276        fidl::encoding::Encode<
4277            ActivityGovernorRegisterSuspendBlockerRequest,
4278            fidl::encoding::DefaultFuchsiaResourceDialect,
4279        > for &mut ActivityGovernorRegisterSuspendBlockerRequest
4280    {
4281        unsafe fn encode(
4282            self,
4283            encoder: &mut fidl::encoding::Encoder<
4284                '_,
4285                fidl::encoding::DefaultFuchsiaResourceDialect,
4286            >,
4287            offset: usize,
4288            mut depth: fidl::encoding::Depth,
4289        ) -> fidl::Result<()> {
4290            encoder.debug_check_bounds::<ActivityGovernorRegisterSuspendBlockerRequest>(offset);
4291            // Vector header
4292            let max_ordinal: u64 = self.max_ordinal_present();
4293            encoder.write_num(max_ordinal, offset);
4294            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4295            // Calling encoder.out_of_line_offset(0) is not allowed.
4296            if max_ordinal == 0 {
4297                return Ok(());
4298            }
4299            depth.increment()?;
4300            let envelope_size = 8;
4301            let bytes_len = max_ordinal as usize * envelope_size;
4302            #[allow(unused_variables)]
4303            let offset = encoder.out_of_line_offset(bytes_len);
4304            let mut _prev_end_offset: usize = 0;
4305            if 1 > max_ordinal {
4306                return Ok(());
4307            }
4308
4309            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4310            // are envelope_size bytes.
4311            let cur_offset: usize = (1 - 1) * envelope_size;
4312
4313            // Zero reserved fields.
4314            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4315
4316            // Safety:
4317            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4318            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4319            //   envelope_size bytes, there is always sufficient room.
4320            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
4321            self.suspend_blocker.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
4322            encoder, offset + cur_offset, depth
4323        )?;
4324
4325            _prev_end_offset = cur_offset + envelope_size;
4326            if 2 > max_ordinal {
4327                return Ok(());
4328            }
4329
4330            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4331            // are envelope_size bytes.
4332            let cur_offset: usize = (2 - 1) * envelope_size;
4333
4334            // Zero reserved fields.
4335            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4336
4337            // Safety:
4338            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4339            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4340            //   envelope_size bytes, there is always sufficient room.
4341            fidl::encoding::encode_in_envelope_optional::<
4342                fidl::encoding::BoundedString<64>,
4343                fidl::encoding::DefaultFuchsiaResourceDialect,
4344            >(
4345                self.name.as_ref().map(
4346                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow,
4347                ),
4348                encoder,
4349                offset + cur_offset,
4350                depth,
4351            )?;
4352
4353            _prev_end_offset = cur_offset + envelope_size;
4354
4355            Ok(())
4356        }
4357    }
4358
4359    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4360        for ActivityGovernorRegisterSuspendBlockerRequest
4361    {
4362        #[inline(always)]
4363        fn new_empty() -> Self {
4364            Self::default()
4365        }
4366
4367        unsafe fn decode(
4368            &mut self,
4369            decoder: &mut fidl::encoding::Decoder<
4370                '_,
4371                fidl::encoding::DefaultFuchsiaResourceDialect,
4372            >,
4373            offset: usize,
4374            mut depth: fidl::encoding::Depth,
4375        ) -> fidl::Result<()> {
4376            decoder.debug_check_bounds::<Self>(offset);
4377            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4378                None => return Err(fidl::Error::NotNullable),
4379                Some(len) => len,
4380            };
4381            // Calling decoder.out_of_line_offset(0) is not allowed.
4382            if len == 0 {
4383                return Ok(());
4384            };
4385            depth.increment()?;
4386            let envelope_size = 8;
4387            let bytes_len = len * envelope_size;
4388            let offset = decoder.out_of_line_offset(bytes_len)?;
4389            // Decode the envelope for each type.
4390            let mut _next_ordinal_to_read = 0;
4391            let mut next_offset = offset;
4392            let end_offset = offset + bytes_len;
4393            _next_ordinal_to_read += 1;
4394            if next_offset >= end_offset {
4395                return Ok(());
4396            }
4397
4398            // Decode unknown envelopes for gaps in ordinals.
4399            while _next_ordinal_to_read < 1 {
4400                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4401                _next_ordinal_to_read += 1;
4402                next_offset += envelope_size;
4403            }
4404
4405            let next_out_of_line = decoder.next_out_of_line();
4406            let handles_before = decoder.remaining_handles();
4407            if let Some((inlined, num_bytes, num_handles)) =
4408                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4409            {
4410                let member_inline_size = <fidl::encoding::Endpoint<
4411                    fidl::endpoints::ClientEnd<SuspendBlockerMarker>,
4412                > as fidl::encoding::TypeMarker>::inline_size(
4413                    decoder.context
4414                );
4415                if inlined != (member_inline_size <= 4) {
4416                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4417                }
4418                let inner_offset;
4419                let mut inner_depth = depth.clone();
4420                if inlined {
4421                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4422                    inner_offset = next_offset;
4423                } else {
4424                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4425                    inner_depth.increment()?;
4426                }
4427                let val_ref = self.suspend_blocker.get_or_insert_with(|| {
4428                    fidl::new_empty!(
4429                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
4430                        fidl::encoding::DefaultFuchsiaResourceDialect
4431                    )
4432                });
4433                fidl::decode!(
4434                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SuspendBlockerMarker>>,
4435                    fidl::encoding::DefaultFuchsiaResourceDialect,
4436                    val_ref,
4437                    decoder,
4438                    inner_offset,
4439                    inner_depth
4440                )?;
4441                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4442                {
4443                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4444                }
4445                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4446                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4447                }
4448            }
4449
4450            next_offset += envelope_size;
4451            _next_ordinal_to_read += 1;
4452            if next_offset >= end_offset {
4453                return Ok(());
4454            }
4455
4456            // Decode unknown envelopes for gaps in ordinals.
4457            while _next_ordinal_to_read < 2 {
4458                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4459                _next_ordinal_to_read += 1;
4460                next_offset += envelope_size;
4461            }
4462
4463            let next_out_of_line = decoder.next_out_of_line();
4464            let handles_before = decoder.remaining_handles();
4465            if let Some((inlined, num_bytes, num_handles)) =
4466                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4467            {
4468                let member_inline_size =
4469                    <fidl::encoding::BoundedString<64> as fidl::encoding::TypeMarker>::inline_size(
4470                        decoder.context,
4471                    );
4472                if inlined != (member_inline_size <= 4) {
4473                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4474                }
4475                let inner_offset;
4476                let mut inner_depth = depth.clone();
4477                if inlined {
4478                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4479                    inner_offset = next_offset;
4480                } else {
4481                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4482                    inner_depth.increment()?;
4483                }
4484                let val_ref = self.name.get_or_insert_with(|| {
4485                    fidl::new_empty!(
4486                        fidl::encoding::BoundedString<64>,
4487                        fidl::encoding::DefaultFuchsiaResourceDialect
4488                    )
4489                });
4490                fidl::decode!(
4491                    fidl::encoding::BoundedString<64>,
4492                    fidl::encoding::DefaultFuchsiaResourceDialect,
4493                    val_ref,
4494                    decoder,
4495                    inner_offset,
4496                    inner_depth
4497                )?;
4498                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4499                {
4500                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4501                }
4502                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4503                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4504                }
4505            }
4506
4507            next_offset += envelope_size;
4508
4509            // Decode the remaining unknown envelopes.
4510            while next_offset < end_offset {
4511                _next_ordinal_to_read += 1;
4512                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4513                next_offset += envelope_size;
4514            }
4515
4516            Ok(())
4517        }
4518    }
4519
4520    impl ApplicationActivity {
4521        #[inline(always)]
4522        fn max_ordinal_present(&self) -> u64 {
4523            if let Some(_) = self.assertive_dependency_token {
4524                return 1;
4525            }
4526            0
4527        }
4528    }
4529
4530    impl fidl::encoding::ResourceTypeMarker for ApplicationActivity {
4531        type Borrowed<'a> = &'a mut Self;
4532        fn take_or_borrow<'a>(
4533            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4534        ) -> Self::Borrowed<'a> {
4535            value
4536        }
4537    }
4538
4539    unsafe impl fidl::encoding::TypeMarker for ApplicationActivity {
4540        type Owned = Self;
4541
4542        #[inline(always)]
4543        fn inline_align(_context: fidl::encoding::Context) -> usize {
4544            8
4545        }
4546
4547        #[inline(always)]
4548        fn inline_size(_context: fidl::encoding::Context) -> usize {
4549            16
4550        }
4551    }
4552
4553    unsafe impl
4554        fidl::encoding::Encode<ApplicationActivity, fidl::encoding::DefaultFuchsiaResourceDialect>
4555        for &mut ApplicationActivity
4556    {
4557        unsafe fn encode(
4558            self,
4559            encoder: &mut fidl::encoding::Encoder<
4560                '_,
4561                fidl::encoding::DefaultFuchsiaResourceDialect,
4562            >,
4563            offset: usize,
4564            mut depth: fidl::encoding::Depth,
4565        ) -> fidl::Result<()> {
4566            encoder.debug_check_bounds::<ApplicationActivity>(offset);
4567            // Vector header
4568            let max_ordinal: u64 = self.max_ordinal_present();
4569            encoder.write_num(max_ordinal, offset);
4570            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4571            // Calling encoder.out_of_line_offset(0) is not allowed.
4572            if max_ordinal == 0 {
4573                return Ok(());
4574            }
4575            depth.increment()?;
4576            let envelope_size = 8;
4577            let bytes_len = max_ordinal as usize * envelope_size;
4578            #[allow(unused_variables)]
4579            let offset = encoder.out_of_line_offset(bytes_len);
4580            let mut _prev_end_offset: usize = 0;
4581            if 1 > max_ordinal {
4582                return Ok(());
4583            }
4584
4585            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4586            // are envelope_size bytes.
4587            let cur_offset: usize = (1 - 1) * envelope_size;
4588
4589            // Zero reserved fields.
4590            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4591
4592            // Safety:
4593            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4594            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4595            //   envelope_size bytes, there is always sufficient room.
4596            fidl::encoding::encode_in_envelope_optional::<
4597                fidl::encoding::HandleType<
4598                    fidl::Event,
4599                    { fidl::ObjectType::EVENT.into_raw() },
4600                    2147483648,
4601                >,
4602                fidl::encoding::DefaultFuchsiaResourceDialect,
4603            >(
4604                self.assertive_dependency_token.as_mut().map(
4605                    <fidl::encoding::HandleType<
4606                        fidl::Event,
4607                        { fidl::ObjectType::EVENT.into_raw() },
4608                        2147483648,
4609                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4610                ),
4611                encoder,
4612                offset + cur_offset,
4613                depth,
4614            )?;
4615
4616            _prev_end_offset = cur_offset + envelope_size;
4617
4618            Ok(())
4619        }
4620    }
4621
4622    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4623        for ApplicationActivity
4624    {
4625        #[inline(always)]
4626        fn new_empty() -> Self {
4627            Self::default()
4628        }
4629
4630        unsafe fn decode(
4631            &mut self,
4632            decoder: &mut fidl::encoding::Decoder<
4633                '_,
4634                fidl::encoding::DefaultFuchsiaResourceDialect,
4635            >,
4636            offset: usize,
4637            mut depth: fidl::encoding::Depth,
4638        ) -> fidl::Result<()> {
4639            decoder.debug_check_bounds::<Self>(offset);
4640            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4641                None => return Err(fidl::Error::NotNullable),
4642                Some(len) => len,
4643            };
4644            // Calling decoder.out_of_line_offset(0) is not allowed.
4645            if len == 0 {
4646                return Ok(());
4647            };
4648            depth.increment()?;
4649            let envelope_size = 8;
4650            let bytes_len = len * envelope_size;
4651            let offset = decoder.out_of_line_offset(bytes_len)?;
4652            // Decode the envelope for each type.
4653            let mut _next_ordinal_to_read = 0;
4654            let mut next_offset = offset;
4655            let end_offset = offset + bytes_len;
4656            _next_ordinal_to_read += 1;
4657            if next_offset >= end_offset {
4658                return Ok(());
4659            }
4660
4661            // Decode unknown envelopes for gaps in ordinals.
4662            while _next_ordinal_to_read < 1 {
4663                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4664                _next_ordinal_to_read += 1;
4665                next_offset += envelope_size;
4666            }
4667
4668            let next_out_of_line = decoder.next_out_of_line();
4669            let handles_before = decoder.remaining_handles();
4670            if let Some((inlined, num_bytes, num_handles)) =
4671                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4672            {
4673                let member_inline_size = <fidl::encoding::HandleType<
4674                    fidl::Event,
4675                    { fidl::ObjectType::EVENT.into_raw() },
4676                    2147483648,
4677                > as fidl::encoding::TypeMarker>::inline_size(
4678                    decoder.context
4679                );
4680                if inlined != (member_inline_size <= 4) {
4681                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4682                }
4683                let inner_offset;
4684                let mut inner_depth = depth.clone();
4685                if inlined {
4686                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4687                    inner_offset = next_offset;
4688                } else {
4689                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4690                    inner_depth.increment()?;
4691                }
4692                let val_ref =
4693                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));
4694                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4695                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4696                {
4697                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4698                }
4699                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4700                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4701                }
4702            }
4703
4704            next_offset += envelope_size;
4705
4706            // Decode the remaining unknown envelopes.
4707            while next_offset < end_offset {
4708                _next_ordinal_to_read += 1;
4709                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4710                next_offset += envelope_size;
4711            }
4712
4713            Ok(())
4714        }
4715    }
4716
4717    impl Cpu {
4718        #[inline(always)]
4719        fn max_ordinal_present(&self) -> u64 {
4720            if let Some(_) = self.assertive_dependency_token {
4721                return 1;
4722            }
4723            0
4724        }
4725    }
4726
4727    impl fidl::encoding::ResourceTypeMarker for Cpu {
4728        type Borrowed<'a> = &'a mut Self;
4729        fn take_or_borrow<'a>(
4730            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4731        ) -> Self::Borrowed<'a> {
4732            value
4733        }
4734    }
4735
4736    unsafe impl fidl::encoding::TypeMarker for Cpu {
4737        type Owned = Self;
4738
4739        #[inline(always)]
4740        fn inline_align(_context: fidl::encoding::Context) -> usize {
4741            8
4742        }
4743
4744        #[inline(always)]
4745        fn inline_size(_context: fidl::encoding::Context) -> usize {
4746            16
4747        }
4748    }
4749
4750    unsafe impl fidl::encoding::Encode<Cpu, fidl::encoding::DefaultFuchsiaResourceDialect>
4751        for &mut Cpu
4752    {
4753        unsafe fn encode(
4754            self,
4755            encoder: &mut fidl::encoding::Encoder<
4756                '_,
4757                fidl::encoding::DefaultFuchsiaResourceDialect,
4758            >,
4759            offset: usize,
4760            mut depth: fidl::encoding::Depth,
4761        ) -> fidl::Result<()> {
4762            encoder.debug_check_bounds::<Cpu>(offset);
4763            // Vector header
4764            let max_ordinal: u64 = self.max_ordinal_present();
4765            encoder.write_num(max_ordinal, offset);
4766            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4767            // Calling encoder.out_of_line_offset(0) is not allowed.
4768            if max_ordinal == 0 {
4769                return Ok(());
4770            }
4771            depth.increment()?;
4772            let envelope_size = 8;
4773            let bytes_len = max_ordinal as usize * envelope_size;
4774            #[allow(unused_variables)]
4775            let offset = encoder.out_of_line_offset(bytes_len);
4776            let mut _prev_end_offset: usize = 0;
4777            if 1 > max_ordinal {
4778                return Ok(());
4779            }
4780
4781            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4782            // are envelope_size bytes.
4783            let cur_offset: usize = (1 - 1) * envelope_size;
4784
4785            // Zero reserved fields.
4786            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4787
4788            // Safety:
4789            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4790            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4791            //   envelope_size bytes, there is always sufficient room.
4792            fidl::encoding::encode_in_envelope_optional::<
4793                fidl::encoding::HandleType<
4794                    fidl::Event,
4795                    { fidl::ObjectType::EVENT.into_raw() },
4796                    2147483648,
4797                >,
4798                fidl::encoding::DefaultFuchsiaResourceDialect,
4799            >(
4800                self.assertive_dependency_token.as_mut().map(
4801                    <fidl::encoding::HandleType<
4802                        fidl::Event,
4803                        { fidl::ObjectType::EVENT.into_raw() },
4804                        2147483648,
4805                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4806                ),
4807                encoder,
4808                offset + cur_offset,
4809                depth,
4810            )?;
4811
4812            _prev_end_offset = cur_offset + envelope_size;
4813
4814            Ok(())
4815        }
4816    }
4817
4818    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Cpu {
4819        #[inline(always)]
4820        fn new_empty() -> Self {
4821            Self::default()
4822        }
4823
4824        unsafe fn decode(
4825            &mut self,
4826            decoder: &mut fidl::encoding::Decoder<
4827                '_,
4828                fidl::encoding::DefaultFuchsiaResourceDialect,
4829            >,
4830            offset: usize,
4831            mut depth: fidl::encoding::Depth,
4832        ) -> fidl::Result<()> {
4833            decoder.debug_check_bounds::<Self>(offset);
4834            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
4835                None => return Err(fidl::Error::NotNullable),
4836                Some(len) => len,
4837            };
4838            // Calling decoder.out_of_line_offset(0) is not allowed.
4839            if len == 0 {
4840                return Ok(());
4841            };
4842            depth.increment()?;
4843            let envelope_size = 8;
4844            let bytes_len = len * envelope_size;
4845            let offset = decoder.out_of_line_offset(bytes_len)?;
4846            // Decode the envelope for each type.
4847            let mut _next_ordinal_to_read = 0;
4848            let mut next_offset = offset;
4849            let end_offset = offset + bytes_len;
4850            _next_ordinal_to_read += 1;
4851            if next_offset >= end_offset {
4852                return Ok(());
4853            }
4854
4855            // Decode unknown envelopes for gaps in ordinals.
4856            while _next_ordinal_to_read < 1 {
4857                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4858                _next_ordinal_to_read += 1;
4859                next_offset += envelope_size;
4860            }
4861
4862            let next_out_of_line = decoder.next_out_of_line();
4863            let handles_before = decoder.remaining_handles();
4864            if let Some((inlined, num_bytes, num_handles)) =
4865                fidl::encoding::decode_envelope_header(decoder, next_offset)?
4866            {
4867                let member_inline_size = <fidl::encoding::HandleType<
4868                    fidl::Event,
4869                    { fidl::ObjectType::EVENT.into_raw() },
4870                    2147483648,
4871                > as fidl::encoding::TypeMarker>::inline_size(
4872                    decoder.context
4873                );
4874                if inlined != (member_inline_size <= 4) {
4875                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
4876                }
4877                let inner_offset;
4878                let mut inner_depth = depth.clone();
4879                if inlined {
4880                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
4881                    inner_offset = next_offset;
4882                } else {
4883                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
4884                    inner_depth.increment()?;
4885                }
4886                let val_ref =
4887                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));
4888                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
4889                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
4890                {
4891                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
4892                }
4893                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
4894                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
4895                }
4896            }
4897
4898            next_offset += envelope_size;
4899
4900            // Decode the remaining unknown envelopes.
4901            while next_offset < end_offset {
4902                _next_ordinal_to_read += 1;
4903                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
4904                next_offset += envelope_size;
4905            }
4906
4907            Ok(())
4908        }
4909    }
4910
4911    impl CpuElementManagerAddExecutionStateDependencyRequest {
4912        #[inline(always)]
4913        fn max_ordinal_present(&self) -> u64 {
4914            if let Some(_) = self.power_level {
4915                return 2;
4916            }
4917            if let Some(_) = self.dependency_token {
4918                return 1;
4919            }
4920            0
4921        }
4922    }
4923
4924    impl fidl::encoding::ResourceTypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
4925        type Borrowed<'a> = &'a mut Self;
4926        fn take_or_borrow<'a>(
4927            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4928        ) -> Self::Borrowed<'a> {
4929            value
4930        }
4931    }
4932
4933    unsafe impl fidl::encoding::TypeMarker for CpuElementManagerAddExecutionStateDependencyRequest {
4934        type Owned = Self;
4935
4936        #[inline(always)]
4937        fn inline_align(_context: fidl::encoding::Context) -> usize {
4938            8
4939        }
4940
4941        #[inline(always)]
4942        fn inline_size(_context: fidl::encoding::Context) -> usize {
4943            16
4944        }
4945    }
4946
4947    unsafe impl
4948        fidl::encoding::Encode<
4949            CpuElementManagerAddExecutionStateDependencyRequest,
4950            fidl::encoding::DefaultFuchsiaResourceDialect,
4951        > for &mut CpuElementManagerAddExecutionStateDependencyRequest
4952    {
4953        unsafe fn encode(
4954            self,
4955            encoder: &mut fidl::encoding::Encoder<
4956                '_,
4957                fidl::encoding::DefaultFuchsiaResourceDialect,
4958            >,
4959            offset: usize,
4960            mut depth: fidl::encoding::Depth,
4961        ) -> fidl::Result<()> {
4962            encoder
4963                .debug_check_bounds::<CpuElementManagerAddExecutionStateDependencyRequest>(offset);
4964            // Vector header
4965            let max_ordinal: u64 = self.max_ordinal_present();
4966            encoder.write_num(max_ordinal, offset);
4967            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4968            // Calling encoder.out_of_line_offset(0) is not allowed.
4969            if max_ordinal == 0 {
4970                return Ok(());
4971            }
4972            depth.increment()?;
4973            let envelope_size = 8;
4974            let bytes_len = max_ordinal as usize * envelope_size;
4975            #[allow(unused_variables)]
4976            let offset = encoder.out_of_line_offset(bytes_len);
4977            let mut _prev_end_offset: usize = 0;
4978            if 1 > max_ordinal {
4979                return Ok(());
4980            }
4981
4982            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4983            // are envelope_size bytes.
4984            let cur_offset: usize = (1 - 1) * envelope_size;
4985
4986            // Zero reserved fields.
4987            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4988
4989            // Safety:
4990            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4991            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4992            //   envelope_size bytes, there is always sufficient room.
4993            fidl::encoding::encode_in_envelope_optional::<
4994                fidl::encoding::HandleType<
4995                    fidl::Event,
4996                    { fidl::ObjectType::EVENT.into_raw() },
4997                    2147483648,
4998                >,
4999                fidl::encoding::DefaultFuchsiaResourceDialect,
5000            >(
5001                self.dependency_token.as_mut().map(
5002                    <fidl::encoding::HandleType<
5003                        fidl::Event,
5004                        { fidl::ObjectType::EVENT.into_raw() },
5005                        2147483648,
5006                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5007                ),
5008                encoder,
5009                offset + cur_offset,
5010                depth,
5011            )?;
5012
5013            _prev_end_offset = cur_offset + envelope_size;
5014            if 2 > max_ordinal {
5015                return Ok(());
5016            }
5017
5018            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5019            // are envelope_size bytes.
5020            let cur_offset: usize = (2 - 1) * envelope_size;
5021
5022            // Zero reserved fields.
5023            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5024
5025            // Safety:
5026            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5027            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5028            //   envelope_size bytes, there is always sufficient room.
5029            fidl::encoding::encode_in_envelope_optional::<
5030                u8,
5031                fidl::encoding::DefaultFuchsiaResourceDialect,
5032            >(
5033                self.power_level.as_ref().map(<u8 as fidl::encoding::ValueTypeMarker>::borrow),
5034                encoder,
5035                offset + cur_offset,
5036                depth,
5037            )?;
5038
5039            _prev_end_offset = cur_offset + envelope_size;
5040
5041            Ok(())
5042        }
5043    }
5044
5045    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5046        for CpuElementManagerAddExecutionStateDependencyRequest
5047    {
5048        #[inline(always)]
5049        fn new_empty() -> Self {
5050            Self::default()
5051        }
5052
5053        unsafe fn decode(
5054            &mut self,
5055            decoder: &mut fidl::encoding::Decoder<
5056                '_,
5057                fidl::encoding::DefaultFuchsiaResourceDialect,
5058            >,
5059            offset: usize,
5060            mut depth: fidl::encoding::Depth,
5061        ) -> fidl::Result<()> {
5062            decoder.debug_check_bounds::<Self>(offset);
5063            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5064                None => return Err(fidl::Error::NotNullable),
5065                Some(len) => len,
5066            };
5067            // Calling decoder.out_of_line_offset(0) is not allowed.
5068            if len == 0 {
5069                return Ok(());
5070            };
5071            depth.increment()?;
5072            let envelope_size = 8;
5073            let bytes_len = len * envelope_size;
5074            let offset = decoder.out_of_line_offset(bytes_len)?;
5075            // Decode the envelope for each type.
5076            let mut _next_ordinal_to_read = 0;
5077            let mut next_offset = offset;
5078            let end_offset = offset + bytes_len;
5079            _next_ordinal_to_read += 1;
5080            if next_offset >= end_offset {
5081                return Ok(());
5082            }
5083
5084            // Decode unknown envelopes for gaps in ordinals.
5085            while _next_ordinal_to_read < 1 {
5086                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5087                _next_ordinal_to_read += 1;
5088                next_offset += envelope_size;
5089            }
5090
5091            let next_out_of_line = decoder.next_out_of_line();
5092            let handles_before = decoder.remaining_handles();
5093            if let Some((inlined, num_bytes, num_handles)) =
5094                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5095            {
5096                let member_inline_size = <fidl::encoding::HandleType<
5097                    fidl::Event,
5098                    { fidl::ObjectType::EVENT.into_raw() },
5099                    2147483648,
5100                > as fidl::encoding::TypeMarker>::inline_size(
5101                    decoder.context
5102                );
5103                if inlined != (member_inline_size <= 4) {
5104                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5105                }
5106                let inner_offset;
5107                let mut inner_depth = depth.clone();
5108                if inlined {
5109                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5110                    inner_offset = next_offset;
5111                } else {
5112                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5113                    inner_depth.increment()?;
5114                }
5115                let val_ref =
5116                self.dependency_token.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
5117                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
5118                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5119                {
5120                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5121                }
5122                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5123                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5124                }
5125            }
5126
5127            next_offset += envelope_size;
5128            _next_ordinal_to_read += 1;
5129            if next_offset >= end_offset {
5130                return Ok(());
5131            }
5132
5133            // Decode unknown envelopes for gaps in ordinals.
5134            while _next_ordinal_to_read < 2 {
5135                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5136                _next_ordinal_to_read += 1;
5137                next_offset += envelope_size;
5138            }
5139
5140            let next_out_of_line = decoder.next_out_of_line();
5141            let handles_before = decoder.remaining_handles();
5142            if let Some((inlined, num_bytes, num_handles)) =
5143                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5144            {
5145                let member_inline_size =
5146                    <u8 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5147                if inlined != (member_inline_size <= 4) {
5148                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5149                }
5150                let inner_offset;
5151                let mut inner_depth = depth.clone();
5152                if inlined {
5153                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5154                    inner_offset = next_offset;
5155                } else {
5156                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5157                    inner_depth.increment()?;
5158                }
5159                let val_ref = self.power_level.get_or_insert_with(|| {
5160                    fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect)
5161                });
5162                fidl::decode!(
5163                    u8,
5164                    fidl::encoding::DefaultFuchsiaResourceDialect,
5165                    val_ref,
5166                    decoder,
5167                    inner_offset,
5168                    inner_depth
5169                )?;
5170                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5171                {
5172                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5173                }
5174                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5175                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5176                }
5177            }
5178
5179            next_offset += envelope_size;
5180
5181            // Decode the remaining unknown envelopes.
5182            while next_offset < end_offset {
5183                _next_ordinal_to_read += 1;
5184                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5185                next_offset += envelope_size;
5186            }
5187
5188            Ok(())
5189        }
5190    }
5191
5192    impl PowerElements {
5193        #[inline(always)]
5194        fn max_ordinal_present(&self) -> u64 {
5195            if let Some(_) = self.application_activity {
5196                return 3;
5197            }
5198            0
5199        }
5200    }
5201
5202    impl fidl::encoding::ResourceTypeMarker for PowerElements {
5203        type Borrowed<'a> = &'a mut Self;
5204        fn take_or_borrow<'a>(
5205            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5206        ) -> Self::Borrowed<'a> {
5207            value
5208        }
5209    }
5210
5211    unsafe impl fidl::encoding::TypeMarker for PowerElements {
5212        type Owned = Self;
5213
5214        #[inline(always)]
5215        fn inline_align(_context: fidl::encoding::Context) -> usize {
5216            8
5217        }
5218
5219        #[inline(always)]
5220        fn inline_size(_context: fidl::encoding::Context) -> usize {
5221            16
5222        }
5223    }
5224
5225    unsafe impl fidl::encoding::Encode<PowerElements, fidl::encoding::DefaultFuchsiaResourceDialect>
5226        for &mut PowerElements
5227    {
5228        unsafe fn encode(
5229            self,
5230            encoder: &mut fidl::encoding::Encoder<
5231                '_,
5232                fidl::encoding::DefaultFuchsiaResourceDialect,
5233            >,
5234            offset: usize,
5235            mut depth: fidl::encoding::Depth,
5236        ) -> fidl::Result<()> {
5237            encoder.debug_check_bounds::<PowerElements>(offset);
5238            // Vector header
5239            let max_ordinal: u64 = self.max_ordinal_present();
5240            encoder.write_num(max_ordinal, offset);
5241            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5242            // Calling encoder.out_of_line_offset(0) is not allowed.
5243            if max_ordinal == 0 {
5244                return Ok(());
5245            }
5246            depth.increment()?;
5247            let envelope_size = 8;
5248            let bytes_len = max_ordinal as usize * envelope_size;
5249            #[allow(unused_variables)]
5250            let offset = encoder.out_of_line_offset(bytes_len);
5251            let mut _prev_end_offset: usize = 0;
5252            if 3 > max_ordinal {
5253                return Ok(());
5254            }
5255
5256            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5257            // are envelope_size bytes.
5258            let cur_offset: usize = (3 - 1) * envelope_size;
5259
5260            // Zero reserved fields.
5261            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5262
5263            // Safety:
5264            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5265            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5266            //   envelope_size bytes, there is always sufficient room.
5267            fidl::encoding::encode_in_envelope_optional::<
5268                ApplicationActivity,
5269                fidl::encoding::DefaultFuchsiaResourceDialect,
5270            >(
5271                self.application_activity.as_mut().map(
5272                    <ApplicationActivity as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5273                ),
5274                encoder,
5275                offset + cur_offset,
5276                depth,
5277            )?;
5278
5279            _prev_end_offset = cur_offset + envelope_size;
5280
5281            Ok(())
5282        }
5283    }
5284
5285    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PowerElements {
5286        #[inline(always)]
5287        fn new_empty() -> Self {
5288            Self::default()
5289        }
5290
5291        unsafe fn decode(
5292            &mut self,
5293            decoder: &mut fidl::encoding::Decoder<
5294                '_,
5295                fidl::encoding::DefaultFuchsiaResourceDialect,
5296            >,
5297            offset: usize,
5298            mut depth: fidl::encoding::Depth,
5299        ) -> fidl::Result<()> {
5300            decoder.debug_check_bounds::<Self>(offset);
5301            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5302                None => return Err(fidl::Error::NotNullable),
5303                Some(len) => len,
5304            };
5305            // Calling decoder.out_of_line_offset(0) is not allowed.
5306            if len == 0 {
5307                return Ok(());
5308            };
5309            depth.increment()?;
5310            let envelope_size = 8;
5311            let bytes_len = len * envelope_size;
5312            let offset = decoder.out_of_line_offset(bytes_len)?;
5313            // Decode the envelope for each type.
5314            let mut _next_ordinal_to_read = 0;
5315            let mut next_offset = offset;
5316            let end_offset = offset + bytes_len;
5317            _next_ordinal_to_read += 1;
5318            if next_offset >= end_offset {
5319                return Ok(());
5320            }
5321
5322            // Decode unknown envelopes for gaps in ordinals.
5323            while _next_ordinal_to_read < 3 {
5324                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5325                _next_ordinal_to_read += 1;
5326                next_offset += envelope_size;
5327            }
5328
5329            let next_out_of_line = decoder.next_out_of_line();
5330            let handles_before = decoder.remaining_handles();
5331            if let Some((inlined, num_bytes, num_handles)) =
5332                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5333            {
5334                let member_inline_size =
5335                    <ApplicationActivity as fidl::encoding::TypeMarker>::inline_size(
5336                        decoder.context,
5337                    );
5338                if inlined != (member_inline_size <= 4) {
5339                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5340                }
5341                let inner_offset;
5342                let mut inner_depth = depth.clone();
5343                if inlined {
5344                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5345                    inner_offset = next_offset;
5346                } else {
5347                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5348                    inner_depth.increment()?;
5349                }
5350                let val_ref = self.application_activity.get_or_insert_with(|| {
5351                    fidl::new_empty!(
5352                        ApplicationActivity,
5353                        fidl::encoding::DefaultFuchsiaResourceDialect
5354                    )
5355                });
5356                fidl::decode!(
5357                    ApplicationActivity,
5358                    fidl::encoding::DefaultFuchsiaResourceDialect,
5359                    val_ref,
5360                    decoder,
5361                    inner_offset,
5362                    inner_depth
5363                )?;
5364                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5365                {
5366                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5367                }
5368                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5369                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5370                }
5371            }
5372
5373            next_offset += envelope_size;
5374
5375            // Decode the remaining unknown envelopes.
5376            while next_offset < end_offset {
5377                _next_ordinal_to_read += 1;
5378                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5379                next_offset += envelope_size;
5380            }
5381
5382            Ok(())
5383        }
5384    }
5385}