Skip to main content

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