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