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