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