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