Skip to main content

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