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