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