fidl_fuchsia_power_topology_test/
fidl_fuchsia_power_topology_test.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_power_topology_test_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct TopologyControlOpenStatusChannelRequest {
16    pub element_name: String,
17    pub status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for TopologyControlOpenStatusChannelRequest
22{
23}
24
25#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
26pub struct SystemActivityControlMarker;
27
28impl fidl::endpoints::ProtocolMarker for SystemActivityControlMarker {
29    type Proxy = SystemActivityControlProxy;
30    type RequestStream = SystemActivityControlRequestStream;
31    #[cfg(target_os = "fuchsia")]
32    type SynchronousProxy = SystemActivityControlSynchronousProxy;
33
34    const DEBUG_NAME: &'static str = "fuchsia.power.topology.test.SystemActivityControl";
35}
36impl fidl::endpoints::DiscoverableProtocolMarker for SystemActivityControlMarker {}
37pub type SystemActivityControlStartApplicationActivityResult =
38    Result<(), SystemActivityControlError>;
39pub type SystemActivityControlStopApplicationActivityResult =
40    Result<(), SystemActivityControlError>;
41
42pub trait SystemActivityControlProxyInterface: Send + Sync {
43    type StartApplicationActivityResponseFut: std::future::Future<
44            Output = Result<SystemActivityControlStartApplicationActivityResult, fidl::Error>,
45        > + Send;
46    fn r#start_application_activity(&self) -> Self::StartApplicationActivityResponseFut;
47    type StopApplicationActivityResponseFut: std::future::Future<
48            Output = Result<SystemActivityControlStopApplicationActivityResult, fidl::Error>,
49        > + Send;
50    fn r#stop_application_activity(&self) -> Self::StopApplicationActivityResponseFut;
51}
52#[derive(Debug)]
53#[cfg(target_os = "fuchsia")]
54pub struct SystemActivityControlSynchronousProxy {
55    client: fidl::client::sync::Client,
56}
57
58#[cfg(target_os = "fuchsia")]
59impl fidl::endpoints::SynchronousProxy for SystemActivityControlSynchronousProxy {
60    type Proxy = SystemActivityControlProxy;
61    type Protocol = SystemActivityControlMarker;
62
63    fn from_channel(inner: fidl::Channel) -> Self {
64        Self::new(inner)
65    }
66
67    fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    fn as_channel(&self) -> &fidl::Channel {
72        self.client.as_channel()
73    }
74}
75
76#[cfg(target_os = "fuchsia")]
77impl SystemActivityControlSynchronousProxy {
78    pub fn new(channel: fidl::Channel) -> Self {
79        let protocol_name =
80            <SystemActivityControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
81        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
82    }
83
84    pub fn into_channel(self) -> fidl::Channel {
85        self.client.into_channel()
86    }
87
88    /// Waits until an event arrives and returns it. It is safe for other
89    /// threads to make concurrent requests while waiting for an event.
90    pub fn wait_for_event(
91        &self,
92        deadline: zx::MonotonicInstant,
93    ) -> Result<SystemActivityControlEvent, fidl::Error> {
94        SystemActivityControlEvent::decode(self.client.wait_for_event(deadline)?)
95    }
96
97    /// Called by a client to hold a lease to the System Activity Governor.
98    pub fn r#start_application_activity(
99        &self,
100        ___deadline: zx::MonotonicInstant,
101    ) -> Result<SystemActivityControlStartApplicationActivityResult, fidl::Error> {
102        let _response =
103            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
104                fidl::encoding::EmptyStruct,
105                SystemActivityControlError,
106            >>(
107                (),
108                0x61de6f5d5285a4e3,
109                fidl::encoding::DynamicFlags::empty(),
110                ___deadline,
111            )?;
112        Ok(_response.map(|x| x))
113    }
114
115    /// Called by a client to drop the lease to the System Activity Governor.
116    pub fn r#stop_application_activity(
117        &self,
118        ___deadline: zx::MonotonicInstant,
119    ) -> Result<SystemActivityControlStopApplicationActivityResult, fidl::Error> {
120        let _response =
121            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::ResultType<
122                fidl::encoding::EmptyStruct,
123                SystemActivityControlError,
124            >>(
125                (),
126                0x294ea5c8d0e2e0c0,
127                fidl::encoding::DynamicFlags::empty(),
128                ___deadline,
129            )?;
130        Ok(_response.map(|x| x))
131    }
132}
133
134#[derive(Debug, Clone)]
135pub struct SystemActivityControlProxy {
136    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
137}
138
139impl fidl::endpoints::Proxy for SystemActivityControlProxy {
140    type Protocol = SystemActivityControlMarker;
141
142    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
143        Self::new(inner)
144    }
145
146    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
147        self.client.into_channel().map_err(|client| Self { client })
148    }
149
150    fn as_channel(&self) -> &::fidl::AsyncChannel {
151        self.client.as_channel()
152    }
153}
154
155impl SystemActivityControlProxy {
156    /// Create a new Proxy for fuchsia.power.topology.test/SystemActivityControl.
157    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
158        let protocol_name =
159            <SystemActivityControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
160        Self { client: fidl::client::Client::new(channel, protocol_name) }
161    }
162
163    /// Get a Stream of events from the remote end of the protocol.
164    ///
165    /// # Panics
166    ///
167    /// Panics if the event stream was already taken.
168    pub fn take_event_stream(&self) -> SystemActivityControlEventStream {
169        SystemActivityControlEventStream { event_receiver: self.client.take_event_receiver() }
170    }
171
172    /// Called by a client to hold a lease to the System Activity Governor.
173    pub fn r#start_application_activity(
174        &self,
175    ) -> fidl::client::QueryResponseFut<
176        SystemActivityControlStartApplicationActivityResult,
177        fidl::encoding::DefaultFuchsiaResourceDialect,
178    > {
179        SystemActivityControlProxyInterface::r#start_application_activity(self)
180    }
181
182    /// Called by a client to drop the lease to the System Activity Governor.
183    pub fn r#stop_application_activity(
184        &self,
185    ) -> fidl::client::QueryResponseFut<
186        SystemActivityControlStopApplicationActivityResult,
187        fidl::encoding::DefaultFuchsiaResourceDialect,
188    > {
189        SystemActivityControlProxyInterface::r#stop_application_activity(self)
190    }
191}
192
193impl SystemActivityControlProxyInterface for SystemActivityControlProxy {
194    type StartApplicationActivityResponseFut = fidl::client::QueryResponseFut<
195        SystemActivityControlStartApplicationActivityResult,
196        fidl::encoding::DefaultFuchsiaResourceDialect,
197    >;
198    fn r#start_application_activity(&self) -> Self::StartApplicationActivityResponseFut {
199        fn _decode(
200            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
201        ) -> Result<SystemActivityControlStartApplicationActivityResult, fidl::Error> {
202            let _response = fidl::client::decode_transaction_body::<
203                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SystemActivityControlError>,
204                fidl::encoding::DefaultFuchsiaResourceDialect,
205                0x61de6f5d5285a4e3,
206            >(_buf?)?;
207            Ok(_response.map(|x| x))
208        }
209        self.client.send_query_and_decode::<
210            fidl::encoding::EmptyPayload,
211            SystemActivityControlStartApplicationActivityResult,
212        >(
213            (),
214            0x61de6f5d5285a4e3,
215            fidl::encoding::DynamicFlags::empty(),
216            _decode,
217        )
218    }
219
220    type StopApplicationActivityResponseFut = fidl::client::QueryResponseFut<
221        SystemActivityControlStopApplicationActivityResult,
222        fidl::encoding::DefaultFuchsiaResourceDialect,
223    >;
224    fn r#stop_application_activity(&self) -> Self::StopApplicationActivityResponseFut {
225        fn _decode(
226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
227        ) -> Result<SystemActivityControlStopApplicationActivityResult, fidl::Error> {
228            let _response = fidl::client::decode_transaction_body::<
229                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, SystemActivityControlError>,
230                fidl::encoding::DefaultFuchsiaResourceDialect,
231                0x294ea5c8d0e2e0c0,
232            >(_buf?)?;
233            Ok(_response.map(|x| x))
234        }
235        self.client.send_query_and_decode::<
236            fidl::encoding::EmptyPayload,
237            SystemActivityControlStopApplicationActivityResult,
238        >(
239            (),
240            0x294ea5c8d0e2e0c0,
241            fidl::encoding::DynamicFlags::empty(),
242            _decode,
243        )
244    }
245}
246
247pub struct SystemActivityControlEventStream {
248    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
249}
250
251impl std::marker::Unpin for SystemActivityControlEventStream {}
252
253impl futures::stream::FusedStream for SystemActivityControlEventStream {
254    fn is_terminated(&self) -> bool {
255        self.event_receiver.is_terminated()
256    }
257}
258
259impl futures::Stream for SystemActivityControlEventStream {
260    type Item = Result<SystemActivityControlEvent, fidl::Error>;
261
262    fn poll_next(
263        mut self: std::pin::Pin<&mut Self>,
264        cx: &mut std::task::Context<'_>,
265    ) -> std::task::Poll<Option<Self::Item>> {
266        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
267            &mut self.event_receiver,
268            cx
269        )?) {
270            Some(buf) => std::task::Poll::Ready(Some(SystemActivityControlEvent::decode(buf))),
271            None => std::task::Poll::Ready(None),
272        }
273    }
274}
275
276#[derive(Debug)]
277pub enum SystemActivityControlEvent {
278    #[non_exhaustive]
279    _UnknownEvent {
280        /// Ordinal of the event that was sent.
281        ordinal: u64,
282    },
283}
284
285impl SystemActivityControlEvent {
286    /// Decodes a message buffer as a [`SystemActivityControlEvent`].
287    fn decode(
288        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
289    ) -> Result<SystemActivityControlEvent, fidl::Error> {
290        let (bytes, _handles) = buf.split_mut();
291        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
292        debug_assert_eq!(tx_header.tx_id, 0);
293        match tx_header.ordinal {
294            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
295                Ok(SystemActivityControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
296            }
297            _ => Err(fidl::Error::UnknownOrdinal {
298                ordinal: tx_header.ordinal,
299                protocol_name:
300                    <SystemActivityControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
301            }),
302        }
303    }
304}
305
306/// A Stream of incoming requests for fuchsia.power.topology.test/SystemActivityControl.
307pub struct SystemActivityControlRequestStream {
308    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
309    is_terminated: bool,
310}
311
312impl std::marker::Unpin for SystemActivityControlRequestStream {}
313
314impl futures::stream::FusedStream for SystemActivityControlRequestStream {
315    fn is_terminated(&self) -> bool {
316        self.is_terminated
317    }
318}
319
320impl fidl::endpoints::RequestStream for SystemActivityControlRequestStream {
321    type Protocol = SystemActivityControlMarker;
322    type ControlHandle = SystemActivityControlControlHandle;
323
324    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
325        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
326    }
327
328    fn control_handle(&self) -> Self::ControlHandle {
329        SystemActivityControlControlHandle { inner: self.inner.clone() }
330    }
331
332    fn into_inner(
333        self,
334    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
335    {
336        (self.inner, self.is_terminated)
337    }
338
339    fn from_inner(
340        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
341        is_terminated: bool,
342    ) -> Self {
343        Self { inner, is_terminated }
344    }
345}
346
347impl futures::Stream for SystemActivityControlRequestStream {
348    type Item = Result<SystemActivityControlRequest, fidl::Error>;
349
350    fn poll_next(
351        mut self: std::pin::Pin<&mut Self>,
352        cx: &mut std::task::Context<'_>,
353    ) -> std::task::Poll<Option<Self::Item>> {
354        let this = &mut *self;
355        if this.inner.check_shutdown(cx) {
356            this.is_terminated = true;
357            return std::task::Poll::Ready(None);
358        }
359        if this.is_terminated {
360            panic!("polled SystemActivityControlRequestStream after completion");
361        }
362        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
363            |bytes, handles| {
364                match this.inner.channel().read_etc(cx, bytes, handles) {
365                    std::task::Poll::Ready(Ok(())) => {}
366                    std::task::Poll::Pending => return std::task::Poll::Pending,
367                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
368                        this.is_terminated = true;
369                        return std::task::Poll::Ready(None);
370                    }
371                    std::task::Poll::Ready(Err(e)) => {
372                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
373                            e.into(),
374                        ))))
375                    }
376                }
377
378                // A message has been received from the channel
379                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
380
381                std::task::Poll::Ready(Some(match header.ordinal {
382                0x61de6f5d5285a4e3 => {
383                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
384                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
385                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
386                    let control_handle = SystemActivityControlControlHandle {
387                        inner: this.inner.clone(),
388                    };
389                    Ok(SystemActivityControlRequest::StartApplicationActivity {
390                        responder: SystemActivityControlStartApplicationActivityResponder {
391                            control_handle: std::mem::ManuallyDrop::new(control_handle),
392                            tx_id: header.tx_id,
393                        },
394                    })
395                }
396                0x294ea5c8d0e2e0c0 => {
397                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
398                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
399                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
400                    let control_handle = SystemActivityControlControlHandle {
401                        inner: this.inner.clone(),
402                    };
403                    Ok(SystemActivityControlRequest::StopApplicationActivity {
404                        responder: SystemActivityControlStopApplicationActivityResponder {
405                            control_handle: std::mem::ManuallyDrop::new(control_handle),
406                            tx_id: header.tx_id,
407                        },
408                    })
409                }
410                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
411                    Ok(SystemActivityControlRequest::_UnknownMethod {
412                        ordinal: header.ordinal,
413                        control_handle: SystemActivityControlControlHandle { inner: this.inner.clone() },
414                        method_type: fidl::MethodType::OneWay,
415                    })
416                }
417                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
418                    this.inner.send_framework_err(
419                        fidl::encoding::FrameworkErr::UnknownMethod,
420                        header.tx_id,
421                        header.ordinal,
422                        header.dynamic_flags(),
423                        (bytes, handles),
424                    )?;
425                    Ok(SystemActivityControlRequest::_UnknownMethod {
426                        ordinal: header.ordinal,
427                        control_handle: SystemActivityControlControlHandle { inner: this.inner.clone() },
428                        method_type: fidl::MethodType::TwoWay,
429                    })
430                }
431                _ => Err(fidl::Error::UnknownOrdinal {
432                    ordinal: header.ordinal,
433                    protocol_name: <SystemActivityControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
434                }),
435            }))
436            },
437        )
438    }
439}
440
441/// The protocol used by a client to hold or drop the lease to the System Activity Governor.
442#[derive(Debug)]
443pub enum SystemActivityControlRequest {
444    /// Called by a client to hold a lease to the System Activity Governor.
445    StartApplicationActivity { responder: SystemActivityControlStartApplicationActivityResponder },
446    /// Called by a client to drop the lease to the System Activity Governor.
447    StopApplicationActivity { responder: SystemActivityControlStopApplicationActivityResponder },
448    /// An interaction was received which does not match any known method.
449    #[non_exhaustive]
450    _UnknownMethod {
451        /// Ordinal of the method that was called.
452        ordinal: u64,
453        control_handle: SystemActivityControlControlHandle,
454        method_type: fidl::MethodType,
455    },
456}
457
458impl SystemActivityControlRequest {
459    #[allow(irrefutable_let_patterns)]
460    pub fn into_start_application_activity(
461        self,
462    ) -> Option<(SystemActivityControlStartApplicationActivityResponder)> {
463        if let SystemActivityControlRequest::StartApplicationActivity { responder } = self {
464            Some((responder))
465        } else {
466            None
467        }
468    }
469
470    #[allow(irrefutable_let_patterns)]
471    pub fn into_stop_application_activity(
472        self,
473    ) -> Option<(SystemActivityControlStopApplicationActivityResponder)> {
474        if let SystemActivityControlRequest::StopApplicationActivity { responder } = self {
475            Some((responder))
476        } else {
477            None
478        }
479    }
480
481    /// Name of the method defined in FIDL
482    pub fn method_name(&self) -> &'static str {
483        match *self {
484            SystemActivityControlRequest::StartApplicationActivity { .. } => {
485                "start_application_activity"
486            }
487            SystemActivityControlRequest::StopApplicationActivity { .. } => {
488                "stop_application_activity"
489            }
490            SystemActivityControlRequest::_UnknownMethod {
491                method_type: fidl::MethodType::OneWay,
492                ..
493            } => "unknown one-way method",
494            SystemActivityControlRequest::_UnknownMethod {
495                method_type: fidl::MethodType::TwoWay,
496                ..
497            } => "unknown two-way method",
498        }
499    }
500}
501
502#[derive(Debug, Clone)]
503pub struct SystemActivityControlControlHandle {
504    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
505}
506
507impl fidl::endpoints::ControlHandle for SystemActivityControlControlHandle {
508    fn shutdown(&self) {
509        self.inner.shutdown()
510    }
511    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
512        self.inner.shutdown_with_epitaph(status)
513    }
514
515    fn is_closed(&self) -> bool {
516        self.inner.channel().is_closed()
517    }
518    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
519        self.inner.channel().on_closed()
520    }
521
522    #[cfg(target_os = "fuchsia")]
523    fn signal_peer(
524        &self,
525        clear_mask: zx::Signals,
526        set_mask: zx::Signals,
527    ) -> Result<(), zx_status::Status> {
528        use fidl::Peered;
529        self.inner.channel().signal_peer(clear_mask, set_mask)
530    }
531}
532
533impl SystemActivityControlControlHandle {}
534
535#[must_use = "FIDL methods require a response to be sent"]
536#[derive(Debug)]
537pub struct SystemActivityControlStartApplicationActivityResponder {
538    control_handle: std::mem::ManuallyDrop<SystemActivityControlControlHandle>,
539    tx_id: u32,
540}
541
542/// Set the the channel to be shutdown (see [`SystemActivityControlControlHandle::shutdown`])
543/// if the responder is dropped without sending a response, so that the client
544/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
545impl std::ops::Drop for SystemActivityControlStartApplicationActivityResponder {
546    fn drop(&mut self) {
547        self.control_handle.shutdown();
548        // Safety: drops once, never accessed again
549        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
550    }
551}
552
553impl fidl::endpoints::Responder for SystemActivityControlStartApplicationActivityResponder {
554    type ControlHandle = SystemActivityControlControlHandle;
555
556    fn control_handle(&self) -> &SystemActivityControlControlHandle {
557        &self.control_handle
558    }
559
560    fn drop_without_shutdown(mut self) {
561        // Safety: drops once, never accessed again due to mem::forget
562        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
563        // Prevent Drop from running (which would shut down the channel)
564        std::mem::forget(self);
565    }
566}
567
568impl SystemActivityControlStartApplicationActivityResponder {
569    /// Sends a response to the FIDL transaction.
570    ///
571    /// Sets the channel to shutdown if an error occurs.
572    pub fn send(
573        self,
574        mut result: Result<(), SystemActivityControlError>,
575    ) -> Result<(), fidl::Error> {
576        let _result = self.send_raw(result);
577        if _result.is_err() {
578            self.control_handle.shutdown();
579        }
580        self.drop_without_shutdown();
581        _result
582    }
583
584    /// Similar to "send" but does not shutdown the channel if an error occurs.
585    pub fn send_no_shutdown_on_err(
586        self,
587        mut result: Result<(), SystemActivityControlError>,
588    ) -> Result<(), fidl::Error> {
589        let _result = self.send_raw(result);
590        self.drop_without_shutdown();
591        _result
592    }
593
594    fn send_raw(
595        &self,
596        mut result: Result<(), SystemActivityControlError>,
597    ) -> Result<(), fidl::Error> {
598        self.control_handle.inner.send::<fidl::encoding::ResultType<
599            fidl::encoding::EmptyStruct,
600            SystemActivityControlError,
601        >>(
602            result,
603            self.tx_id,
604            0x61de6f5d5285a4e3,
605            fidl::encoding::DynamicFlags::empty(),
606        )
607    }
608}
609
610#[must_use = "FIDL methods require a response to be sent"]
611#[derive(Debug)]
612pub struct SystemActivityControlStopApplicationActivityResponder {
613    control_handle: std::mem::ManuallyDrop<SystemActivityControlControlHandle>,
614    tx_id: u32,
615}
616
617/// Set the the channel to be shutdown (see [`SystemActivityControlControlHandle::shutdown`])
618/// if the responder is dropped without sending a response, so that the client
619/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
620impl std::ops::Drop for SystemActivityControlStopApplicationActivityResponder {
621    fn drop(&mut self) {
622        self.control_handle.shutdown();
623        // Safety: drops once, never accessed again
624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
625    }
626}
627
628impl fidl::endpoints::Responder for SystemActivityControlStopApplicationActivityResponder {
629    type ControlHandle = SystemActivityControlControlHandle;
630
631    fn control_handle(&self) -> &SystemActivityControlControlHandle {
632        &self.control_handle
633    }
634
635    fn drop_without_shutdown(mut self) {
636        // Safety: drops once, never accessed again due to mem::forget
637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
638        // Prevent Drop from running (which would shut down the channel)
639        std::mem::forget(self);
640    }
641}
642
643impl SystemActivityControlStopApplicationActivityResponder {
644    /// Sends a response to the FIDL transaction.
645    ///
646    /// Sets the channel to shutdown if an error occurs.
647    pub fn send(
648        self,
649        mut result: Result<(), SystemActivityControlError>,
650    ) -> Result<(), fidl::Error> {
651        let _result = self.send_raw(result);
652        if _result.is_err() {
653            self.control_handle.shutdown();
654        }
655        self.drop_without_shutdown();
656        _result
657    }
658
659    /// Similar to "send" but does not shutdown the channel if an error occurs.
660    pub fn send_no_shutdown_on_err(
661        self,
662        mut result: Result<(), SystemActivityControlError>,
663    ) -> Result<(), fidl::Error> {
664        let _result = self.send_raw(result);
665        self.drop_without_shutdown();
666        _result
667    }
668
669    fn send_raw(
670        &self,
671        mut result: Result<(), SystemActivityControlError>,
672    ) -> Result<(), fidl::Error> {
673        self.control_handle.inner.send::<fidl::encoding::ResultType<
674            fidl::encoding::EmptyStruct,
675            SystemActivityControlError,
676        >>(
677            result,
678            self.tx_id,
679            0x294ea5c8d0e2e0c0,
680            fidl::encoding::DynamicFlags::empty(),
681        )
682    }
683}
684
685#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
686pub struct TopologyControlMarker;
687
688impl fidl::endpoints::ProtocolMarker for TopologyControlMarker {
689    type Proxy = TopologyControlProxy;
690    type RequestStream = TopologyControlRequestStream;
691    #[cfg(target_os = "fuchsia")]
692    type SynchronousProxy = TopologyControlSynchronousProxy;
693
694    const DEBUG_NAME: &'static str = "fuchsia.power.topology.test.TopologyControl";
695}
696impl fidl::endpoints::DiscoverableProtocolMarker for TopologyControlMarker {}
697pub type TopologyControlCreateResult = Result<(), CreateTopologyGraphError>;
698pub type TopologyControlAcquireLeaseResult = Result<(), LeaseControlError>;
699pub type TopologyControlDropLeaseResult = Result<(), LeaseControlError>;
700pub type TopologyControlOpenStatusChannelResult = Result<(), OpenStatusChannelError>;
701
702pub trait TopologyControlProxyInterface: Send + Sync {
703    type CreateResponseFut: std::future::Future<Output = Result<TopologyControlCreateResult, fidl::Error>>
704        + Send;
705    fn r#create(&self, elements: &[Element]) -> Self::CreateResponseFut;
706    type AcquireLeaseResponseFut: std::future::Future<Output = Result<TopologyControlAcquireLeaseResult, fidl::Error>>
707        + Send;
708    fn r#acquire_lease(&self, element_name: &str, level: u8) -> Self::AcquireLeaseResponseFut;
709    type DropLeaseResponseFut: std::future::Future<Output = Result<TopologyControlDropLeaseResult, fidl::Error>>
710        + Send;
711    fn r#drop_lease(&self, element_name: &str) -> Self::DropLeaseResponseFut;
712    type OpenStatusChannelResponseFut: std::future::Future<Output = Result<TopologyControlOpenStatusChannelResult, fidl::Error>>
713        + Send;
714    fn r#open_status_channel(
715        &self,
716        element_name: &str,
717        status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
718    ) -> Self::OpenStatusChannelResponseFut;
719}
720#[derive(Debug)]
721#[cfg(target_os = "fuchsia")]
722pub struct TopologyControlSynchronousProxy {
723    client: fidl::client::sync::Client,
724}
725
726#[cfg(target_os = "fuchsia")]
727impl fidl::endpoints::SynchronousProxy for TopologyControlSynchronousProxy {
728    type Proxy = TopologyControlProxy;
729    type Protocol = TopologyControlMarker;
730
731    fn from_channel(inner: fidl::Channel) -> Self {
732        Self::new(inner)
733    }
734
735    fn into_channel(self) -> fidl::Channel {
736        self.client.into_channel()
737    }
738
739    fn as_channel(&self) -> &fidl::Channel {
740        self.client.as_channel()
741    }
742}
743
744#[cfg(target_os = "fuchsia")]
745impl TopologyControlSynchronousProxy {
746    pub fn new(channel: fidl::Channel) -> Self {
747        let protocol_name = <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
748        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
749    }
750
751    pub fn into_channel(self) -> fidl::Channel {
752        self.client.into_channel()
753    }
754
755    /// Waits until an event arrives and returns it. It is safe for other
756    /// threads to make concurrent requests while waiting for an event.
757    pub fn wait_for_event(
758        &self,
759        deadline: zx::MonotonicInstant,
760    ) -> Result<TopologyControlEvent, fidl::Error> {
761        TopologyControlEvent::decode(self.client.wait_for_event(deadline)?)
762    }
763
764    pub fn r#create(
765        &self,
766        mut elements: &[Element],
767        ___deadline: zx::MonotonicInstant,
768    ) -> Result<TopologyControlCreateResult, fidl::Error> {
769        let _response =
770            self.client.send_query::<TopologyControlCreateRequest, fidl::encoding::ResultType<
771                fidl::encoding::EmptyStruct,
772                CreateTopologyGraphError,
773            >>(
774                (elements,),
775                0x12033976b88716fa,
776                fidl::encoding::DynamicFlags::empty(),
777                ___deadline,
778            )?;
779        Ok(_response.map(|x| x))
780    }
781
782    pub fn r#acquire_lease(
783        &self,
784        mut element_name: &str,
785        mut level: u8,
786        ___deadline: zx::MonotonicInstant,
787    ) -> Result<TopologyControlAcquireLeaseResult, fidl::Error> {
788        let _response = self.client.send_query::<
789            TopologyControlAcquireLeaseRequest,
790            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
791        >(
792            (element_name, level,),
793            0x1bedc35d9b68bac8,
794            fidl::encoding::DynamicFlags::empty(),
795            ___deadline,
796        )?;
797        Ok(_response.map(|x| x))
798    }
799
800    pub fn r#drop_lease(
801        &self,
802        mut element_name: &str,
803        ___deadline: zx::MonotonicInstant,
804    ) -> Result<TopologyControlDropLeaseResult, fidl::Error> {
805        let _response =
806            self.client.send_query::<TopologyControlDropLeaseRequest, fidl::encoding::ResultType<
807                fidl::encoding::EmptyStruct,
808                LeaseControlError,
809            >>(
810                (element_name,),
811                0x7107f8f1080faddc,
812                fidl::encoding::DynamicFlags::empty(),
813                ___deadline,
814            )?;
815        Ok(_response.map(|x| x))
816    }
817
818    /// Register a new Status channel on which Power Broker will send
819    /// read-only updates of the element's current power level.
820    pub fn r#open_status_channel(
821        &self,
822        mut element_name: &str,
823        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
824        ___deadline: zx::MonotonicInstant,
825    ) -> Result<TopologyControlOpenStatusChannelResult, fidl::Error> {
826        let _response = self.client.send_query::<
827            TopologyControlOpenStatusChannelRequest,
828            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OpenStatusChannelError>,
829        >(
830            (element_name, status_channel,),
831            0x69fba616c3ee2e90,
832            fidl::encoding::DynamicFlags::empty(),
833            ___deadline,
834        )?;
835        Ok(_response.map(|x| x))
836    }
837}
838
839#[derive(Debug, Clone)]
840pub struct TopologyControlProxy {
841    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
842}
843
844impl fidl::endpoints::Proxy for TopologyControlProxy {
845    type Protocol = TopologyControlMarker;
846
847    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
848        Self::new(inner)
849    }
850
851    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
852        self.client.into_channel().map_err(|client| Self { client })
853    }
854
855    fn as_channel(&self) -> &::fidl::AsyncChannel {
856        self.client.as_channel()
857    }
858}
859
860impl TopologyControlProxy {
861    /// Create a new Proxy for fuchsia.power.topology.test/TopologyControl.
862    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
863        let protocol_name = <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
864        Self { client: fidl::client::Client::new(channel, protocol_name) }
865    }
866
867    /// Get a Stream of events from the remote end of the protocol.
868    ///
869    /// # Panics
870    ///
871    /// Panics if the event stream was already taken.
872    pub fn take_event_stream(&self) -> TopologyControlEventStream {
873        TopologyControlEventStream { event_receiver: self.client.take_event_receiver() }
874    }
875
876    pub fn r#create(
877        &self,
878        mut elements: &[Element],
879    ) -> fidl::client::QueryResponseFut<
880        TopologyControlCreateResult,
881        fidl::encoding::DefaultFuchsiaResourceDialect,
882    > {
883        TopologyControlProxyInterface::r#create(self, elements)
884    }
885
886    pub fn r#acquire_lease(
887        &self,
888        mut element_name: &str,
889        mut level: u8,
890    ) -> fidl::client::QueryResponseFut<
891        TopologyControlAcquireLeaseResult,
892        fidl::encoding::DefaultFuchsiaResourceDialect,
893    > {
894        TopologyControlProxyInterface::r#acquire_lease(self, element_name, level)
895    }
896
897    pub fn r#drop_lease(
898        &self,
899        mut element_name: &str,
900    ) -> fidl::client::QueryResponseFut<
901        TopologyControlDropLeaseResult,
902        fidl::encoding::DefaultFuchsiaResourceDialect,
903    > {
904        TopologyControlProxyInterface::r#drop_lease(self, element_name)
905    }
906
907    /// Register a new Status channel on which Power Broker will send
908    /// read-only updates of the element's current power level.
909    pub fn r#open_status_channel(
910        &self,
911        mut element_name: &str,
912        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
913    ) -> fidl::client::QueryResponseFut<
914        TopologyControlOpenStatusChannelResult,
915        fidl::encoding::DefaultFuchsiaResourceDialect,
916    > {
917        TopologyControlProxyInterface::r#open_status_channel(self, element_name, status_channel)
918    }
919}
920
921impl TopologyControlProxyInterface for TopologyControlProxy {
922    type CreateResponseFut = fidl::client::QueryResponseFut<
923        TopologyControlCreateResult,
924        fidl::encoding::DefaultFuchsiaResourceDialect,
925    >;
926    fn r#create(&self, mut elements: &[Element]) -> Self::CreateResponseFut {
927        fn _decode(
928            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
929        ) -> Result<TopologyControlCreateResult, fidl::Error> {
930            let _response = fidl::client::decode_transaction_body::<
931                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CreateTopologyGraphError>,
932                fidl::encoding::DefaultFuchsiaResourceDialect,
933                0x12033976b88716fa,
934            >(_buf?)?;
935            Ok(_response.map(|x| x))
936        }
937        self.client
938            .send_query_and_decode::<TopologyControlCreateRequest, TopologyControlCreateResult>(
939                (elements,),
940                0x12033976b88716fa,
941                fidl::encoding::DynamicFlags::empty(),
942                _decode,
943            )
944    }
945
946    type AcquireLeaseResponseFut = fidl::client::QueryResponseFut<
947        TopologyControlAcquireLeaseResult,
948        fidl::encoding::DefaultFuchsiaResourceDialect,
949    >;
950    fn r#acquire_lease(
951        &self,
952        mut element_name: &str,
953        mut level: u8,
954    ) -> Self::AcquireLeaseResponseFut {
955        fn _decode(
956            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
957        ) -> Result<TopologyControlAcquireLeaseResult, fidl::Error> {
958            let _response = fidl::client::decode_transaction_body::<
959                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
960                fidl::encoding::DefaultFuchsiaResourceDialect,
961                0x1bedc35d9b68bac8,
962            >(_buf?)?;
963            Ok(_response.map(|x| x))
964        }
965        self.client.send_query_and_decode::<
966            TopologyControlAcquireLeaseRequest,
967            TopologyControlAcquireLeaseResult,
968        >(
969            (element_name, level,),
970            0x1bedc35d9b68bac8,
971            fidl::encoding::DynamicFlags::empty(),
972            _decode,
973        )
974    }
975
976    type DropLeaseResponseFut = fidl::client::QueryResponseFut<
977        TopologyControlDropLeaseResult,
978        fidl::encoding::DefaultFuchsiaResourceDialect,
979    >;
980    fn r#drop_lease(&self, mut element_name: &str) -> Self::DropLeaseResponseFut {
981        fn _decode(
982            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
983        ) -> Result<TopologyControlDropLeaseResult, fidl::Error> {
984            let _response = fidl::client::decode_transaction_body::<
985                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
986                fidl::encoding::DefaultFuchsiaResourceDialect,
987                0x7107f8f1080faddc,
988            >(_buf?)?;
989            Ok(_response.map(|x| x))
990        }
991        self.client.send_query_and_decode::<
992            TopologyControlDropLeaseRequest,
993            TopologyControlDropLeaseResult,
994        >(
995            (element_name,),
996            0x7107f8f1080faddc,
997            fidl::encoding::DynamicFlags::empty(),
998            _decode,
999        )
1000    }
1001
1002    type OpenStatusChannelResponseFut = fidl::client::QueryResponseFut<
1003        TopologyControlOpenStatusChannelResult,
1004        fidl::encoding::DefaultFuchsiaResourceDialect,
1005    >;
1006    fn r#open_status_channel(
1007        &self,
1008        mut element_name: &str,
1009        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1010    ) -> Self::OpenStatusChannelResponseFut {
1011        fn _decode(
1012            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1013        ) -> Result<TopologyControlOpenStatusChannelResult, fidl::Error> {
1014            let _response = fidl::client::decode_transaction_body::<
1015                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OpenStatusChannelError>,
1016                fidl::encoding::DefaultFuchsiaResourceDialect,
1017                0x69fba616c3ee2e90,
1018            >(_buf?)?;
1019            Ok(_response.map(|x| x))
1020        }
1021        self.client.send_query_and_decode::<
1022            TopologyControlOpenStatusChannelRequest,
1023            TopologyControlOpenStatusChannelResult,
1024        >(
1025            (element_name, status_channel,),
1026            0x69fba616c3ee2e90,
1027            fidl::encoding::DynamicFlags::empty(),
1028            _decode,
1029        )
1030    }
1031}
1032
1033pub struct TopologyControlEventStream {
1034    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1035}
1036
1037impl std::marker::Unpin for TopologyControlEventStream {}
1038
1039impl futures::stream::FusedStream for TopologyControlEventStream {
1040    fn is_terminated(&self) -> bool {
1041        self.event_receiver.is_terminated()
1042    }
1043}
1044
1045impl futures::Stream for TopologyControlEventStream {
1046    type Item = Result<TopologyControlEvent, fidl::Error>;
1047
1048    fn poll_next(
1049        mut self: std::pin::Pin<&mut Self>,
1050        cx: &mut std::task::Context<'_>,
1051    ) -> std::task::Poll<Option<Self::Item>> {
1052        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1053            &mut self.event_receiver,
1054            cx
1055        )?) {
1056            Some(buf) => std::task::Poll::Ready(Some(TopologyControlEvent::decode(buf))),
1057            None => std::task::Poll::Ready(None),
1058        }
1059    }
1060}
1061
1062#[derive(Debug)]
1063pub enum TopologyControlEvent {
1064    #[non_exhaustive]
1065    _UnknownEvent {
1066        /// Ordinal of the event that was sent.
1067        ordinal: u64,
1068    },
1069}
1070
1071impl TopologyControlEvent {
1072    /// Decodes a message buffer as a [`TopologyControlEvent`].
1073    fn decode(
1074        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1075    ) -> Result<TopologyControlEvent, fidl::Error> {
1076        let (bytes, _handles) = buf.split_mut();
1077        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1078        debug_assert_eq!(tx_header.tx_id, 0);
1079        match tx_header.ordinal {
1080            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1081                Ok(TopologyControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1082            }
1083            _ => Err(fidl::Error::UnknownOrdinal {
1084                ordinal: tx_header.ordinal,
1085                protocol_name:
1086                    <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1087            }),
1088        }
1089    }
1090}
1091
1092/// A Stream of incoming requests for fuchsia.power.topology.test/TopologyControl.
1093pub struct TopologyControlRequestStream {
1094    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1095    is_terminated: bool,
1096}
1097
1098impl std::marker::Unpin for TopologyControlRequestStream {}
1099
1100impl futures::stream::FusedStream for TopologyControlRequestStream {
1101    fn is_terminated(&self) -> bool {
1102        self.is_terminated
1103    }
1104}
1105
1106impl fidl::endpoints::RequestStream for TopologyControlRequestStream {
1107    type Protocol = TopologyControlMarker;
1108    type ControlHandle = TopologyControlControlHandle;
1109
1110    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1111        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1112    }
1113
1114    fn control_handle(&self) -> Self::ControlHandle {
1115        TopologyControlControlHandle { inner: self.inner.clone() }
1116    }
1117
1118    fn into_inner(
1119        self,
1120    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1121    {
1122        (self.inner, self.is_terminated)
1123    }
1124
1125    fn from_inner(
1126        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1127        is_terminated: bool,
1128    ) -> Self {
1129        Self { inner, is_terminated }
1130    }
1131}
1132
1133impl futures::Stream for TopologyControlRequestStream {
1134    type Item = Result<TopologyControlRequest, fidl::Error>;
1135
1136    fn poll_next(
1137        mut self: std::pin::Pin<&mut Self>,
1138        cx: &mut std::task::Context<'_>,
1139    ) -> std::task::Poll<Option<Self::Item>> {
1140        let this = &mut *self;
1141        if this.inner.check_shutdown(cx) {
1142            this.is_terminated = true;
1143            return std::task::Poll::Ready(None);
1144        }
1145        if this.is_terminated {
1146            panic!("polled TopologyControlRequestStream after completion");
1147        }
1148        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1149            |bytes, handles| {
1150                match this.inner.channel().read_etc(cx, bytes, handles) {
1151                    std::task::Poll::Ready(Ok(())) => {}
1152                    std::task::Poll::Pending => return std::task::Poll::Pending,
1153                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1154                        this.is_terminated = true;
1155                        return std::task::Poll::Ready(None);
1156                    }
1157                    std::task::Poll::Ready(Err(e)) => {
1158                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1159                            e.into(),
1160                        ))))
1161                    }
1162                }
1163
1164                // A message has been received from the channel
1165                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1166
1167                std::task::Poll::Ready(Some(match header.ordinal {
1168                    0x12033976b88716fa => {
1169                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1170                        let mut req = fidl::new_empty!(
1171                            TopologyControlCreateRequest,
1172                            fidl::encoding::DefaultFuchsiaResourceDialect
1173                        );
1174                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlCreateRequest>(&header, _body_bytes, handles, &mut req)?;
1175                        let control_handle =
1176                            TopologyControlControlHandle { inner: this.inner.clone() };
1177                        Ok(TopologyControlRequest::Create {
1178                            elements: req.elements,
1179
1180                            responder: TopologyControlCreateResponder {
1181                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1182                                tx_id: header.tx_id,
1183                            },
1184                        })
1185                    }
1186                    0x1bedc35d9b68bac8 => {
1187                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1188                        let mut req = fidl::new_empty!(
1189                            TopologyControlAcquireLeaseRequest,
1190                            fidl::encoding::DefaultFuchsiaResourceDialect
1191                        );
1192                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlAcquireLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1193                        let control_handle =
1194                            TopologyControlControlHandle { inner: this.inner.clone() };
1195                        Ok(TopologyControlRequest::AcquireLease {
1196                            element_name: req.element_name,
1197                            level: req.level,
1198
1199                            responder: TopologyControlAcquireLeaseResponder {
1200                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1201                                tx_id: header.tx_id,
1202                            },
1203                        })
1204                    }
1205                    0x7107f8f1080faddc => {
1206                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1207                        let mut req = fidl::new_empty!(
1208                            TopologyControlDropLeaseRequest,
1209                            fidl::encoding::DefaultFuchsiaResourceDialect
1210                        );
1211                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlDropLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1212                        let control_handle =
1213                            TopologyControlControlHandle { inner: this.inner.clone() };
1214                        Ok(TopologyControlRequest::DropLease {
1215                            element_name: req.element_name,
1216
1217                            responder: TopologyControlDropLeaseResponder {
1218                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1219                                tx_id: header.tx_id,
1220                            },
1221                        })
1222                    }
1223                    0x69fba616c3ee2e90 => {
1224                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1225                        let mut req = fidl::new_empty!(
1226                            TopologyControlOpenStatusChannelRequest,
1227                            fidl::encoding::DefaultFuchsiaResourceDialect
1228                        );
1229                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlOpenStatusChannelRequest>(&header, _body_bytes, handles, &mut req)?;
1230                        let control_handle =
1231                            TopologyControlControlHandle { inner: this.inner.clone() };
1232                        Ok(TopologyControlRequest::OpenStatusChannel {
1233                            element_name: req.element_name,
1234                            status_channel: req.status_channel,
1235
1236                            responder: TopologyControlOpenStatusChannelResponder {
1237                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1238                                tx_id: header.tx_id,
1239                            },
1240                        })
1241                    }
1242                    _ if header.tx_id == 0
1243                        && header
1244                            .dynamic_flags()
1245                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1246                    {
1247                        Ok(TopologyControlRequest::_UnknownMethod {
1248                            ordinal: header.ordinal,
1249                            control_handle: TopologyControlControlHandle {
1250                                inner: this.inner.clone(),
1251                            },
1252                            method_type: fidl::MethodType::OneWay,
1253                        })
1254                    }
1255                    _ if header
1256                        .dynamic_flags()
1257                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1258                    {
1259                        this.inner.send_framework_err(
1260                            fidl::encoding::FrameworkErr::UnknownMethod,
1261                            header.tx_id,
1262                            header.ordinal,
1263                            header.dynamic_flags(),
1264                            (bytes, handles),
1265                        )?;
1266                        Ok(TopologyControlRequest::_UnknownMethod {
1267                            ordinal: header.ordinal,
1268                            control_handle: TopologyControlControlHandle {
1269                                inner: this.inner.clone(),
1270                            },
1271                            method_type: fidl::MethodType::TwoWay,
1272                        })
1273                    }
1274                    _ => Err(fidl::Error::UnknownOrdinal {
1275                        ordinal: header.ordinal,
1276                        protocol_name:
1277                            <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1278                    }),
1279                }))
1280            },
1281        )
1282    }
1283}
1284
1285/// The primary initial protocol used by a client tool to communiate with the topology-test-daemon.
1286/// The client can create the whole topology, and then acquire or drop lease according to element
1287/// names.
1288#[derive(Debug)]
1289pub enum TopologyControlRequest {
1290    Create {
1291        elements: Vec<Element>,
1292        responder: TopologyControlCreateResponder,
1293    },
1294    AcquireLease {
1295        element_name: String,
1296        level: u8,
1297        responder: TopologyControlAcquireLeaseResponder,
1298    },
1299    DropLease {
1300        element_name: String,
1301        responder: TopologyControlDropLeaseResponder,
1302    },
1303    /// Register a new Status channel on which Power Broker will send
1304    /// read-only updates of the element's current power level.
1305    OpenStatusChannel {
1306        element_name: String,
1307        status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1308        responder: TopologyControlOpenStatusChannelResponder,
1309    },
1310    /// An interaction was received which does not match any known method.
1311    #[non_exhaustive]
1312    _UnknownMethod {
1313        /// Ordinal of the method that was called.
1314        ordinal: u64,
1315        control_handle: TopologyControlControlHandle,
1316        method_type: fidl::MethodType,
1317    },
1318}
1319
1320impl TopologyControlRequest {
1321    #[allow(irrefutable_let_patterns)]
1322    pub fn into_create(self) -> Option<(Vec<Element>, TopologyControlCreateResponder)> {
1323        if let TopologyControlRequest::Create { elements, responder } = self {
1324            Some((elements, responder))
1325        } else {
1326            None
1327        }
1328    }
1329
1330    #[allow(irrefutable_let_patterns)]
1331    pub fn into_acquire_lease(self) -> Option<(String, u8, TopologyControlAcquireLeaseResponder)> {
1332        if let TopologyControlRequest::AcquireLease { element_name, level, responder } = self {
1333            Some((element_name, level, responder))
1334        } else {
1335            None
1336        }
1337    }
1338
1339    #[allow(irrefutable_let_patterns)]
1340    pub fn into_drop_lease(self) -> Option<(String, TopologyControlDropLeaseResponder)> {
1341        if let TopologyControlRequest::DropLease { element_name, responder } = self {
1342            Some((element_name, responder))
1343        } else {
1344            None
1345        }
1346    }
1347
1348    #[allow(irrefutable_let_patterns)]
1349    pub fn into_open_status_channel(
1350        self,
1351    ) -> Option<(
1352        String,
1353        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1354        TopologyControlOpenStatusChannelResponder,
1355    )> {
1356        if let TopologyControlRequest::OpenStatusChannel {
1357            element_name,
1358            status_channel,
1359            responder,
1360        } = self
1361        {
1362            Some((element_name, status_channel, responder))
1363        } else {
1364            None
1365        }
1366    }
1367
1368    /// Name of the method defined in FIDL
1369    pub fn method_name(&self) -> &'static str {
1370        match *self {
1371            TopologyControlRequest::Create { .. } => "create",
1372            TopologyControlRequest::AcquireLease { .. } => "acquire_lease",
1373            TopologyControlRequest::DropLease { .. } => "drop_lease",
1374            TopologyControlRequest::OpenStatusChannel { .. } => "open_status_channel",
1375            TopologyControlRequest::_UnknownMethod {
1376                method_type: fidl::MethodType::OneWay,
1377                ..
1378            } => "unknown one-way method",
1379            TopologyControlRequest::_UnknownMethod {
1380                method_type: fidl::MethodType::TwoWay,
1381                ..
1382            } => "unknown two-way method",
1383        }
1384    }
1385}
1386
1387#[derive(Debug, Clone)]
1388pub struct TopologyControlControlHandle {
1389    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1390}
1391
1392impl fidl::endpoints::ControlHandle for TopologyControlControlHandle {
1393    fn shutdown(&self) {
1394        self.inner.shutdown()
1395    }
1396    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1397        self.inner.shutdown_with_epitaph(status)
1398    }
1399
1400    fn is_closed(&self) -> bool {
1401        self.inner.channel().is_closed()
1402    }
1403    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1404        self.inner.channel().on_closed()
1405    }
1406
1407    #[cfg(target_os = "fuchsia")]
1408    fn signal_peer(
1409        &self,
1410        clear_mask: zx::Signals,
1411        set_mask: zx::Signals,
1412    ) -> Result<(), zx_status::Status> {
1413        use fidl::Peered;
1414        self.inner.channel().signal_peer(clear_mask, set_mask)
1415    }
1416}
1417
1418impl TopologyControlControlHandle {}
1419
1420#[must_use = "FIDL methods require a response to be sent"]
1421#[derive(Debug)]
1422pub struct TopologyControlCreateResponder {
1423    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1424    tx_id: u32,
1425}
1426
1427/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1428/// if the responder is dropped without sending a response, so that the client
1429/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1430impl std::ops::Drop for TopologyControlCreateResponder {
1431    fn drop(&mut self) {
1432        self.control_handle.shutdown();
1433        // Safety: drops once, never accessed again
1434        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1435    }
1436}
1437
1438impl fidl::endpoints::Responder for TopologyControlCreateResponder {
1439    type ControlHandle = TopologyControlControlHandle;
1440
1441    fn control_handle(&self) -> &TopologyControlControlHandle {
1442        &self.control_handle
1443    }
1444
1445    fn drop_without_shutdown(mut self) {
1446        // Safety: drops once, never accessed again due to mem::forget
1447        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1448        // Prevent Drop from running (which would shut down the channel)
1449        std::mem::forget(self);
1450    }
1451}
1452
1453impl TopologyControlCreateResponder {
1454    /// Sends a response to the FIDL transaction.
1455    ///
1456    /// Sets the channel to shutdown if an error occurs.
1457    pub fn send(self, mut result: Result<(), CreateTopologyGraphError>) -> Result<(), fidl::Error> {
1458        let _result = self.send_raw(result);
1459        if _result.is_err() {
1460            self.control_handle.shutdown();
1461        }
1462        self.drop_without_shutdown();
1463        _result
1464    }
1465
1466    /// Similar to "send" but does not shutdown the channel if an error occurs.
1467    pub fn send_no_shutdown_on_err(
1468        self,
1469        mut result: Result<(), CreateTopologyGraphError>,
1470    ) -> Result<(), fidl::Error> {
1471        let _result = self.send_raw(result);
1472        self.drop_without_shutdown();
1473        _result
1474    }
1475
1476    fn send_raw(
1477        &self,
1478        mut result: Result<(), CreateTopologyGraphError>,
1479    ) -> Result<(), fidl::Error> {
1480        self.control_handle.inner.send::<fidl::encoding::ResultType<
1481            fidl::encoding::EmptyStruct,
1482            CreateTopologyGraphError,
1483        >>(
1484            result,
1485            self.tx_id,
1486            0x12033976b88716fa,
1487            fidl::encoding::DynamicFlags::empty(),
1488        )
1489    }
1490}
1491
1492#[must_use = "FIDL methods require a response to be sent"]
1493#[derive(Debug)]
1494pub struct TopologyControlAcquireLeaseResponder {
1495    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1496    tx_id: u32,
1497}
1498
1499/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1500/// if the responder is dropped without sending a response, so that the client
1501/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1502impl std::ops::Drop for TopologyControlAcquireLeaseResponder {
1503    fn drop(&mut self) {
1504        self.control_handle.shutdown();
1505        // Safety: drops once, never accessed again
1506        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1507    }
1508}
1509
1510impl fidl::endpoints::Responder for TopologyControlAcquireLeaseResponder {
1511    type ControlHandle = TopologyControlControlHandle;
1512
1513    fn control_handle(&self) -> &TopologyControlControlHandle {
1514        &self.control_handle
1515    }
1516
1517    fn drop_without_shutdown(mut self) {
1518        // Safety: drops once, never accessed again due to mem::forget
1519        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1520        // Prevent Drop from running (which would shut down the channel)
1521        std::mem::forget(self);
1522    }
1523}
1524
1525impl TopologyControlAcquireLeaseResponder {
1526    /// Sends a response to the FIDL transaction.
1527    ///
1528    /// Sets the channel to shutdown if an error occurs.
1529    pub fn send(self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1530        let _result = self.send_raw(result);
1531        if _result.is_err() {
1532            self.control_handle.shutdown();
1533        }
1534        self.drop_without_shutdown();
1535        _result
1536    }
1537
1538    /// Similar to "send" but does not shutdown the channel if an error occurs.
1539    pub fn send_no_shutdown_on_err(
1540        self,
1541        mut result: Result<(), LeaseControlError>,
1542    ) -> Result<(), fidl::Error> {
1543        let _result = self.send_raw(result);
1544        self.drop_without_shutdown();
1545        _result
1546    }
1547
1548    fn send_raw(&self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1549        self.control_handle.inner.send::<fidl::encoding::ResultType<
1550            fidl::encoding::EmptyStruct,
1551            LeaseControlError,
1552        >>(
1553            result,
1554            self.tx_id,
1555            0x1bedc35d9b68bac8,
1556            fidl::encoding::DynamicFlags::empty(),
1557        )
1558    }
1559}
1560
1561#[must_use = "FIDL methods require a response to be sent"]
1562#[derive(Debug)]
1563pub struct TopologyControlDropLeaseResponder {
1564    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1565    tx_id: u32,
1566}
1567
1568/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1569/// if the responder is dropped without sending a response, so that the client
1570/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1571impl std::ops::Drop for TopologyControlDropLeaseResponder {
1572    fn drop(&mut self) {
1573        self.control_handle.shutdown();
1574        // Safety: drops once, never accessed again
1575        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1576    }
1577}
1578
1579impl fidl::endpoints::Responder for TopologyControlDropLeaseResponder {
1580    type ControlHandle = TopologyControlControlHandle;
1581
1582    fn control_handle(&self) -> &TopologyControlControlHandle {
1583        &self.control_handle
1584    }
1585
1586    fn drop_without_shutdown(mut self) {
1587        // Safety: drops once, never accessed again due to mem::forget
1588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1589        // Prevent Drop from running (which would shut down the channel)
1590        std::mem::forget(self);
1591    }
1592}
1593
1594impl TopologyControlDropLeaseResponder {
1595    /// Sends a response to the FIDL transaction.
1596    ///
1597    /// Sets the channel to shutdown if an error occurs.
1598    pub fn send(self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1599        let _result = self.send_raw(result);
1600        if _result.is_err() {
1601            self.control_handle.shutdown();
1602        }
1603        self.drop_without_shutdown();
1604        _result
1605    }
1606
1607    /// Similar to "send" but does not shutdown the channel if an error occurs.
1608    pub fn send_no_shutdown_on_err(
1609        self,
1610        mut result: Result<(), LeaseControlError>,
1611    ) -> Result<(), fidl::Error> {
1612        let _result = self.send_raw(result);
1613        self.drop_without_shutdown();
1614        _result
1615    }
1616
1617    fn send_raw(&self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1618        self.control_handle.inner.send::<fidl::encoding::ResultType<
1619            fidl::encoding::EmptyStruct,
1620            LeaseControlError,
1621        >>(
1622            result,
1623            self.tx_id,
1624            0x7107f8f1080faddc,
1625            fidl::encoding::DynamicFlags::empty(),
1626        )
1627    }
1628}
1629
1630#[must_use = "FIDL methods require a response to be sent"]
1631#[derive(Debug)]
1632pub struct TopologyControlOpenStatusChannelResponder {
1633    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1634    tx_id: u32,
1635}
1636
1637/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1638/// if the responder is dropped without sending a response, so that the client
1639/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1640impl std::ops::Drop for TopologyControlOpenStatusChannelResponder {
1641    fn drop(&mut self) {
1642        self.control_handle.shutdown();
1643        // Safety: drops once, never accessed again
1644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1645    }
1646}
1647
1648impl fidl::endpoints::Responder for TopologyControlOpenStatusChannelResponder {
1649    type ControlHandle = TopologyControlControlHandle;
1650
1651    fn control_handle(&self) -> &TopologyControlControlHandle {
1652        &self.control_handle
1653    }
1654
1655    fn drop_without_shutdown(mut self) {
1656        // Safety: drops once, never accessed again due to mem::forget
1657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1658        // Prevent Drop from running (which would shut down the channel)
1659        std::mem::forget(self);
1660    }
1661}
1662
1663impl TopologyControlOpenStatusChannelResponder {
1664    /// Sends a response to the FIDL transaction.
1665    ///
1666    /// Sets the channel to shutdown if an error occurs.
1667    pub fn send(self, mut result: Result<(), OpenStatusChannelError>) -> Result<(), fidl::Error> {
1668        let _result = self.send_raw(result);
1669        if _result.is_err() {
1670            self.control_handle.shutdown();
1671        }
1672        self.drop_without_shutdown();
1673        _result
1674    }
1675
1676    /// Similar to "send" but does not shutdown the channel if an error occurs.
1677    pub fn send_no_shutdown_on_err(
1678        self,
1679        mut result: Result<(), OpenStatusChannelError>,
1680    ) -> Result<(), fidl::Error> {
1681        let _result = self.send_raw(result);
1682        self.drop_without_shutdown();
1683        _result
1684    }
1685
1686    fn send_raw(&self, mut result: Result<(), OpenStatusChannelError>) -> Result<(), fidl::Error> {
1687        self.control_handle.inner.send::<fidl::encoding::ResultType<
1688            fidl::encoding::EmptyStruct,
1689            OpenStatusChannelError,
1690        >>(
1691            result,
1692            self.tx_id,
1693            0x69fba616c3ee2e90,
1694            fidl::encoding::DynamicFlags::empty(),
1695        )
1696    }
1697}
1698
1699mod internal {
1700    use super::*;
1701
1702    impl fidl::encoding::ResourceTypeMarker for TopologyControlOpenStatusChannelRequest {
1703        type Borrowed<'a> = &'a mut Self;
1704        fn take_or_borrow<'a>(
1705            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1706        ) -> Self::Borrowed<'a> {
1707            value
1708        }
1709    }
1710
1711    unsafe impl fidl::encoding::TypeMarker for TopologyControlOpenStatusChannelRequest {
1712        type Owned = Self;
1713
1714        #[inline(always)]
1715        fn inline_align(_context: fidl::encoding::Context) -> usize {
1716            8
1717        }
1718
1719        #[inline(always)]
1720        fn inline_size(_context: fidl::encoding::Context) -> usize {
1721            24
1722        }
1723    }
1724
1725    unsafe impl
1726        fidl::encoding::Encode<
1727            TopologyControlOpenStatusChannelRequest,
1728            fidl::encoding::DefaultFuchsiaResourceDialect,
1729        > for &mut TopologyControlOpenStatusChannelRequest
1730    {
1731        #[inline]
1732        unsafe fn encode(
1733            self,
1734            encoder: &mut fidl::encoding::Encoder<
1735                '_,
1736                fidl::encoding::DefaultFuchsiaResourceDialect,
1737            >,
1738            offset: usize,
1739            _depth: fidl::encoding::Depth,
1740        ) -> fidl::Result<()> {
1741            encoder.debug_check_bounds::<TopologyControlOpenStatusChannelRequest>(offset);
1742            // Delegate to tuple encoding.
1743            fidl::encoding::Encode::<
1744                TopologyControlOpenStatusChannelRequest,
1745                fidl::encoding::DefaultFuchsiaResourceDialect,
1746            >::encode(
1747                (
1748                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
1749                        &self.element_name,
1750                    ),
1751                    <fidl::encoding::Endpoint<
1752                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1753                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1754                        &mut self.status_channel,
1755                    ),
1756                ),
1757                encoder,
1758                offset,
1759                _depth,
1760            )
1761        }
1762    }
1763    unsafe impl<
1764            T0: fidl::encoding::Encode<
1765                fidl::encoding::BoundedString<64>,
1766                fidl::encoding::DefaultFuchsiaResourceDialect,
1767            >,
1768            T1: fidl::encoding::Encode<
1769                fidl::encoding::Endpoint<
1770                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1771                >,
1772                fidl::encoding::DefaultFuchsiaResourceDialect,
1773            >,
1774        >
1775        fidl::encoding::Encode<
1776            TopologyControlOpenStatusChannelRequest,
1777            fidl::encoding::DefaultFuchsiaResourceDialect,
1778        > for (T0, T1)
1779    {
1780        #[inline]
1781        unsafe fn encode(
1782            self,
1783            encoder: &mut fidl::encoding::Encoder<
1784                '_,
1785                fidl::encoding::DefaultFuchsiaResourceDialect,
1786            >,
1787            offset: usize,
1788            depth: fidl::encoding::Depth,
1789        ) -> fidl::Result<()> {
1790            encoder.debug_check_bounds::<TopologyControlOpenStatusChannelRequest>(offset);
1791            // Zero out padding regions. There's no need to apply masks
1792            // because the unmasked parts will be overwritten by fields.
1793            unsafe {
1794                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1795                (ptr as *mut u64).write_unaligned(0);
1796            }
1797            // Write the fields.
1798            self.0.encode(encoder, offset + 0, depth)?;
1799            self.1.encode(encoder, offset + 16, depth)?;
1800            Ok(())
1801        }
1802    }
1803
1804    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1805        for TopologyControlOpenStatusChannelRequest
1806    {
1807        #[inline(always)]
1808        fn new_empty() -> Self {
1809            Self {
1810                element_name: fidl::new_empty!(
1811                    fidl::encoding::BoundedString<64>,
1812                    fidl::encoding::DefaultFuchsiaResourceDialect
1813                ),
1814                status_channel: fidl::new_empty!(
1815                    fidl::encoding::Endpoint<
1816                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1817                    >,
1818                    fidl::encoding::DefaultFuchsiaResourceDialect
1819                ),
1820            }
1821        }
1822
1823        #[inline]
1824        unsafe fn decode(
1825            &mut self,
1826            decoder: &mut fidl::encoding::Decoder<
1827                '_,
1828                fidl::encoding::DefaultFuchsiaResourceDialect,
1829            >,
1830            offset: usize,
1831            _depth: fidl::encoding::Depth,
1832        ) -> fidl::Result<()> {
1833            decoder.debug_check_bounds::<Self>(offset);
1834            // Verify that padding bytes are zero.
1835            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1836            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1837            let mask = 0xffffffff00000000u64;
1838            let maskedval = padval & mask;
1839            if maskedval != 0 {
1840                return Err(fidl::Error::NonZeroPadding {
1841                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1842                });
1843            }
1844            fidl::decode!(
1845                fidl::encoding::BoundedString<64>,
1846                fidl::encoding::DefaultFuchsiaResourceDialect,
1847                &mut self.element_name,
1848                decoder,
1849                offset + 0,
1850                _depth
1851            )?;
1852            fidl::decode!(
1853                fidl::encoding::Endpoint<
1854                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1855                >,
1856                fidl::encoding::DefaultFuchsiaResourceDialect,
1857                &mut self.status_channel,
1858                decoder,
1859                offset + 16,
1860                _depth
1861            )?;
1862            Ok(())
1863        }
1864    }
1865}