Skip to main content

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