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 SystemActivityControlControlHandle {
637    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
638        self.inner.shutdown_with_epitaph(status.into())
639    }
640}
641
642impl fidl::endpoints::ControlHandle for SystemActivityControlControlHandle {
643    fn shutdown(&self) {
644        self.inner.shutdown()
645    }
646
647    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
648        self.inner.shutdown_with_epitaph(status)
649    }
650
651    fn is_closed(&self) -> bool {
652        self.inner.channel().is_closed()
653    }
654    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
655        self.inner.channel().on_closed()
656    }
657
658    #[cfg(target_os = "fuchsia")]
659    fn signal_peer(
660        &self,
661        clear_mask: zx::Signals,
662        set_mask: zx::Signals,
663    ) -> Result<(), zx_status::Status> {
664        use fidl::Peered;
665        self.inner.channel().signal_peer(clear_mask, set_mask)
666    }
667}
668
669impl SystemActivityControlControlHandle {}
670
671#[must_use = "FIDL methods require a response to be sent"]
672#[derive(Debug)]
673pub struct SystemActivityControlStartApplicationActivityResponder {
674    control_handle: std::mem::ManuallyDrop<SystemActivityControlControlHandle>,
675    tx_id: u32,
676}
677
678/// Set the the channel to be shutdown (see [`SystemActivityControlControlHandle::shutdown`])
679/// if the responder is dropped without sending a response, so that the client
680/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
681impl std::ops::Drop for SystemActivityControlStartApplicationActivityResponder {
682    fn drop(&mut self) {
683        self.control_handle.shutdown();
684        // Safety: drops once, never accessed again
685        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
686    }
687}
688
689impl fidl::endpoints::Responder for SystemActivityControlStartApplicationActivityResponder {
690    type ControlHandle = SystemActivityControlControlHandle;
691
692    fn control_handle(&self) -> &SystemActivityControlControlHandle {
693        &self.control_handle
694    }
695
696    fn drop_without_shutdown(mut self) {
697        // Safety: drops once, never accessed again due to mem::forget
698        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
699        // Prevent Drop from running (which would shut down the channel)
700        std::mem::forget(self);
701    }
702}
703
704impl SystemActivityControlStartApplicationActivityResponder {
705    /// Sends a response to the FIDL transaction.
706    ///
707    /// Sets the channel to shutdown if an error occurs.
708    pub fn send(
709        self,
710        mut result: Result<(), SystemActivityControlError>,
711    ) -> Result<(), fidl::Error> {
712        let _result = self.send_raw(result);
713        if _result.is_err() {
714            self.control_handle.shutdown();
715        }
716        self.drop_without_shutdown();
717        _result
718    }
719
720    /// Similar to "send" but does not shutdown the channel if an error occurs.
721    pub fn send_no_shutdown_on_err(
722        self,
723        mut result: Result<(), SystemActivityControlError>,
724    ) -> Result<(), fidl::Error> {
725        let _result = self.send_raw(result);
726        self.drop_without_shutdown();
727        _result
728    }
729
730    fn send_raw(
731        &self,
732        mut result: Result<(), SystemActivityControlError>,
733    ) -> Result<(), fidl::Error> {
734        self.control_handle.inner.send::<fidl::encoding::ResultType<
735            fidl::encoding::EmptyStruct,
736            SystemActivityControlError,
737        >>(
738            result,
739            self.tx_id,
740            0x61de6f5d5285a4e3,
741            fidl::encoding::DynamicFlags::empty(),
742        )
743    }
744}
745
746#[must_use = "FIDL methods require a response to be sent"]
747#[derive(Debug)]
748pub struct SystemActivityControlStopApplicationActivityResponder {
749    control_handle: std::mem::ManuallyDrop<SystemActivityControlControlHandle>,
750    tx_id: u32,
751}
752
753/// Set the the channel to be shutdown (see [`SystemActivityControlControlHandle::shutdown`])
754/// if the responder is dropped without sending a response, so that the client
755/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
756impl std::ops::Drop for SystemActivityControlStopApplicationActivityResponder {
757    fn drop(&mut self) {
758        self.control_handle.shutdown();
759        // Safety: drops once, never accessed again
760        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
761    }
762}
763
764impl fidl::endpoints::Responder for SystemActivityControlStopApplicationActivityResponder {
765    type ControlHandle = SystemActivityControlControlHandle;
766
767    fn control_handle(&self) -> &SystemActivityControlControlHandle {
768        &self.control_handle
769    }
770
771    fn drop_without_shutdown(mut self) {
772        // Safety: drops once, never accessed again due to mem::forget
773        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
774        // Prevent Drop from running (which would shut down the channel)
775        std::mem::forget(self);
776    }
777}
778
779impl SystemActivityControlStopApplicationActivityResponder {
780    /// Sends a response to the FIDL transaction.
781    ///
782    /// Sets the channel to shutdown if an error occurs.
783    pub fn send(
784        self,
785        mut result: Result<(), SystemActivityControlError>,
786    ) -> Result<(), fidl::Error> {
787        let _result = self.send_raw(result);
788        if _result.is_err() {
789            self.control_handle.shutdown();
790        }
791        self.drop_without_shutdown();
792        _result
793    }
794
795    /// Similar to "send" but does not shutdown the channel if an error occurs.
796    pub fn send_no_shutdown_on_err(
797        self,
798        mut result: Result<(), SystemActivityControlError>,
799    ) -> Result<(), fidl::Error> {
800        let _result = self.send_raw(result);
801        self.drop_without_shutdown();
802        _result
803    }
804
805    fn send_raw(
806        &self,
807        mut result: Result<(), SystemActivityControlError>,
808    ) -> Result<(), fidl::Error> {
809        self.control_handle.inner.send::<fidl::encoding::ResultType<
810            fidl::encoding::EmptyStruct,
811            SystemActivityControlError,
812        >>(
813            result,
814            self.tx_id,
815            0x294ea5c8d0e2e0c0,
816            fidl::encoding::DynamicFlags::empty(),
817        )
818    }
819}
820
821#[must_use = "FIDL methods require a response to be sent"]
822#[derive(Debug)]
823pub struct SystemActivityControlRestartApplicationActivityResponder {
824    control_handle: std::mem::ManuallyDrop<SystemActivityControlControlHandle>,
825    tx_id: u32,
826}
827
828/// Set the the channel to be shutdown (see [`SystemActivityControlControlHandle::shutdown`])
829/// if the responder is dropped without sending a response, so that the client
830/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
831impl std::ops::Drop for SystemActivityControlRestartApplicationActivityResponder {
832    fn drop(&mut self) {
833        self.control_handle.shutdown();
834        // Safety: drops once, never accessed again
835        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
836    }
837}
838
839impl fidl::endpoints::Responder for SystemActivityControlRestartApplicationActivityResponder {
840    type ControlHandle = SystemActivityControlControlHandle;
841
842    fn control_handle(&self) -> &SystemActivityControlControlHandle {
843        &self.control_handle
844    }
845
846    fn drop_without_shutdown(mut self) {
847        // Safety: drops once, never accessed again due to mem::forget
848        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
849        // Prevent Drop from running (which would shut down the channel)
850        std::mem::forget(self);
851    }
852}
853
854impl SystemActivityControlRestartApplicationActivityResponder {
855    /// Sends a response to the FIDL transaction.
856    ///
857    /// Sets the channel to shutdown if an error occurs.
858    pub fn send(
859        self,
860        mut result: Result<(), SystemActivityControlError>,
861    ) -> Result<(), fidl::Error> {
862        let _result = self.send_raw(result);
863        if _result.is_err() {
864            self.control_handle.shutdown();
865        }
866        self.drop_without_shutdown();
867        _result
868    }
869
870    /// Similar to "send" but does not shutdown the channel if an error occurs.
871    pub fn send_no_shutdown_on_err(
872        self,
873        mut result: Result<(), SystemActivityControlError>,
874    ) -> Result<(), fidl::Error> {
875        let _result = self.send_raw(result);
876        self.drop_without_shutdown();
877        _result
878    }
879
880    fn send_raw(
881        &self,
882        mut result: Result<(), SystemActivityControlError>,
883    ) -> Result<(), fidl::Error> {
884        self.control_handle.inner.send::<fidl::encoding::ResultType<
885            fidl::encoding::EmptyStruct,
886            SystemActivityControlError,
887        >>(
888            result,
889            self.tx_id,
890            0x2881d47bba86f3d4,
891            fidl::encoding::DynamicFlags::empty(),
892        )
893    }
894}
895
896#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
897pub struct TopologyControlMarker;
898
899impl fidl::endpoints::ProtocolMarker for TopologyControlMarker {
900    type Proxy = TopologyControlProxy;
901    type RequestStream = TopologyControlRequestStream;
902    #[cfg(target_os = "fuchsia")]
903    type SynchronousProxy = TopologyControlSynchronousProxy;
904
905    const DEBUG_NAME: &'static str = "fuchsia.power.topology.test.TopologyControl";
906}
907impl fidl::endpoints::DiscoverableProtocolMarker for TopologyControlMarker {}
908pub type TopologyControlCreateResult = Result<(), CreateTopologyGraphError>;
909pub type TopologyControlAcquireLeaseResult = Result<(), LeaseControlError>;
910pub type TopologyControlDropLeaseResult = Result<(), LeaseControlError>;
911pub type TopologyControlOpenStatusChannelResult = Result<(), OpenStatusChannelError>;
912
913pub trait TopologyControlProxyInterface: Send + Sync {
914    type CreateResponseFut: std::future::Future<Output = Result<TopologyControlCreateResult, fidl::Error>>
915        + Send;
916    fn r#create(&self, elements: &[Element]) -> Self::CreateResponseFut;
917    type AcquireLeaseResponseFut: std::future::Future<Output = Result<TopologyControlAcquireLeaseResult, fidl::Error>>
918        + Send;
919    fn r#acquire_lease(
920        &self,
921        element_name: &str,
922        level: u8,
923        wait_for_status: fidl_fuchsia_power_broker::LeaseStatus,
924    ) -> Self::AcquireLeaseResponseFut;
925    type DropLeaseResponseFut: std::future::Future<Output = Result<TopologyControlDropLeaseResult, fidl::Error>>
926        + Send;
927    fn r#drop_lease(&self, element_name: &str) -> Self::DropLeaseResponseFut;
928    type OpenStatusChannelResponseFut: std::future::Future<Output = Result<TopologyControlOpenStatusChannelResult, fidl::Error>>
929        + Send;
930    fn r#open_status_channel(
931        &self,
932        element_name: &str,
933        status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
934    ) -> Self::OpenStatusChannelResponseFut;
935}
936#[derive(Debug)]
937#[cfg(target_os = "fuchsia")]
938pub struct TopologyControlSynchronousProxy {
939    client: fidl::client::sync::Client,
940}
941
942#[cfg(target_os = "fuchsia")]
943impl fidl::endpoints::SynchronousProxy for TopologyControlSynchronousProxy {
944    type Proxy = TopologyControlProxy;
945    type Protocol = TopologyControlMarker;
946
947    fn from_channel(inner: fidl::Channel) -> Self {
948        Self::new(inner)
949    }
950
951    fn into_channel(self) -> fidl::Channel {
952        self.client.into_channel()
953    }
954
955    fn as_channel(&self) -> &fidl::Channel {
956        self.client.as_channel()
957    }
958}
959
960#[cfg(target_os = "fuchsia")]
961impl TopologyControlSynchronousProxy {
962    pub fn new(channel: fidl::Channel) -> Self {
963        Self { client: fidl::client::sync::Client::new(channel) }
964    }
965
966    pub fn into_channel(self) -> fidl::Channel {
967        self.client.into_channel()
968    }
969
970    /// Waits until an event arrives and returns it. It is safe for other
971    /// threads to make concurrent requests while waiting for an event.
972    pub fn wait_for_event(
973        &self,
974        deadline: zx::MonotonicInstant,
975    ) -> Result<TopologyControlEvent, fidl::Error> {
976        TopologyControlEvent::decode(self.client.wait_for_event::<TopologyControlMarker>(deadline)?)
977    }
978
979    pub fn r#create(
980        &self,
981        mut elements: &[Element],
982        ___deadline: zx::MonotonicInstant,
983    ) -> Result<TopologyControlCreateResult, fidl::Error> {
984        let _response =
985            self.client.send_query::<TopologyControlCreateRequest, fidl::encoding::ResultType<
986                fidl::encoding::EmptyStruct,
987                CreateTopologyGraphError,
988            >, TopologyControlMarker>(
989                (elements,),
990                0x12033976b88716fa,
991                fidl::encoding::DynamicFlags::empty(),
992                ___deadline,
993            )?;
994        Ok(_response.map(|x| x))
995    }
996
997    pub fn r#acquire_lease(
998        &self,
999        mut element_name: &str,
1000        mut level: u8,
1001        mut wait_for_status: fidl_fuchsia_power_broker::LeaseStatus,
1002        ___deadline: zx::MonotonicInstant,
1003    ) -> Result<TopologyControlAcquireLeaseResult, fidl::Error> {
1004        let _response = self.client.send_query::<
1005            TopologyControlAcquireLeaseRequest,
1006            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
1007            TopologyControlMarker,
1008        >(
1009            (element_name, level, wait_for_status,),
1010            0x1bedc35d9b68bac8,
1011            fidl::encoding::DynamicFlags::empty(),
1012            ___deadline,
1013        )?;
1014        Ok(_response.map(|x| x))
1015    }
1016
1017    pub fn r#drop_lease(
1018        &self,
1019        mut element_name: &str,
1020        ___deadline: zx::MonotonicInstant,
1021    ) -> Result<TopologyControlDropLeaseResult, fidl::Error> {
1022        let _response =
1023            self.client.send_query::<TopologyControlDropLeaseRequest, fidl::encoding::ResultType<
1024                fidl::encoding::EmptyStruct,
1025                LeaseControlError,
1026            >, TopologyControlMarker>(
1027                (element_name,),
1028                0x7107f8f1080faddc,
1029                fidl::encoding::DynamicFlags::empty(),
1030                ___deadline,
1031            )?;
1032        Ok(_response.map(|x| x))
1033    }
1034
1035    /// Register a new Status channel on which Power Broker will send
1036    /// read-only updates of the element's current power level.
1037    pub fn r#open_status_channel(
1038        &self,
1039        mut element_name: &str,
1040        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1041        ___deadline: zx::MonotonicInstant,
1042    ) -> Result<TopologyControlOpenStatusChannelResult, fidl::Error> {
1043        let _response = self.client.send_query::<
1044            TopologyControlOpenStatusChannelRequest,
1045            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OpenStatusChannelError>,
1046            TopologyControlMarker,
1047        >(
1048            (element_name, status_channel,),
1049            0x69fba616c3ee2e90,
1050            fidl::encoding::DynamicFlags::empty(),
1051            ___deadline,
1052        )?;
1053        Ok(_response.map(|x| x))
1054    }
1055}
1056
1057#[cfg(target_os = "fuchsia")]
1058impl From<TopologyControlSynchronousProxy> for zx::NullableHandle {
1059    fn from(value: TopologyControlSynchronousProxy) -> Self {
1060        value.into_channel().into()
1061    }
1062}
1063
1064#[cfg(target_os = "fuchsia")]
1065impl From<fidl::Channel> for TopologyControlSynchronousProxy {
1066    fn from(value: fidl::Channel) -> Self {
1067        Self::new(value)
1068    }
1069}
1070
1071#[cfg(target_os = "fuchsia")]
1072impl fidl::endpoints::FromClient for TopologyControlSynchronousProxy {
1073    type Protocol = TopologyControlMarker;
1074
1075    fn from_client(value: fidl::endpoints::ClientEnd<TopologyControlMarker>) -> Self {
1076        Self::new(value.into_channel())
1077    }
1078}
1079
1080#[derive(Debug, Clone)]
1081pub struct TopologyControlProxy {
1082    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1083}
1084
1085impl fidl::endpoints::Proxy for TopologyControlProxy {
1086    type Protocol = TopologyControlMarker;
1087
1088    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1089        Self::new(inner)
1090    }
1091
1092    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1093        self.client.into_channel().map_err(|client| Self { client })
1094    }
1095
1096    fn as_channel(&self) -> &::fidl::AsyncChannel {
1097        self.client.as_channel()
1098    }
1099}
1100
1101impl TopologyControlProxy {
1102    /// Create a new Proxy for fuchsia.power.topology.test/TopologyControl.
1103    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1104        let protocol_name = <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1105        Self { client: fidl::client::Client::new(channel, protocol_name) }
1106    }
1107
1108    /// Get a Stream of events from the remote end of the protocol.
1109    ///
1110    /// # Panics
1111    ///
1112    /// Panics if the event stream was already taken.
1113    pub fn take_event_stream(&self) -> TopologyControlEventStream {
1114        TopologyControlEventStream { event_receiver: self.client.take_event_receiver() }
1115    }
1116
1117    pub fn r#create(
1118        &self,
1119        mut elements: &[Element],
1120    ) -> fidl::client::QueryResponseFut<
1121        TopologyControlCreateResult,
1122        fidl::encoding::DefaultFuchsiaResourceDialect,
1123    > {
1124        TopologyControlProxyInterface::r#create(self, elements)
1125    }
1126
1127    pub fn r#acquire_lease(
1128        &self,
1129        mut element_name: &str,
1130        mut level: u8,
1131        mut wait_for_status: fidl_fuchsia_power_broker::LeaseStatus,
1132    ) -> fidl::client::QueryResponseFut<
1133        TopologyControlAcquireLeaseResult,
1134        fidl::encoding::DefaultFuchsiaResourceDialect,
1135    > {
1136        TopologyControlProxyInterface::r#acquire_lease(self, element_name, level, wait_for_status)
1137    }
1138
1139    pub fn r#drop_lease(
1140        &self,
1141        mut element_name: &str,
1142    ) -> fidl::client::QueryResponseFut<
1143        TopologyControlDropLeaseResult,
1144        fidl::encoding::DefaultFuchsiaResourceDialect,
1145    > {
1146        TopologyControlProxyInterface::r#drop_lease(self, element_name)
1147    }
1148
1149    /// Register a new Status channel on which Power Broker will send
1150    /// read-only updates of the element's current power level.
1151    pub fn r#open_status_channel(
1152        &self,
1153        mut element_name: &str,
1154        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1155    ) -> fidl::client::QueryResponseFut<
1156        TopologyControlOpenStatusChannelResult,
1157        fidl::encoding::DefaultFuchsiaResourceDialect,
1158    > {
1159        TopologyControlProxyInterface::r#open_status_channel(self, element_name, status_channel)
1160    }
1161}
1162
1163impl TopologyControlProxyInterface for TopologyControlProxy {
1164    type CreateResponseFut = fidl::client::QueryResponseFut<
1165        TopologyControlCreateResult,
1166        fidl::encoding::DefaultFuchsiaResourceDialect,
1167    >;
1168    fn r#create(&self, mut elements: &[Element]) -> Self::CreateResponseFut {
1169        fn _decode(
1170            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1171        ) -> Result<TopologyControlCreateResult, fidl::Error> {
1172            let _response = fidl::client::decode_transaction_body::<
1173                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, CreateTopologyGraphError>,
1174                fidl::encoding::DefaultFuchsiaResourceDialect,
1175                0x12033976b88716fa,
1176            >(_buf?)?;
1177            Ok(_response.map(|x| x))
1178        }
1179        self.client
1180            .send_query_and_decode::<TopologyControlCreateRequest, TopologyControlCreateResult>(
1181                (elements,),
1182                0x12033976b88716fa,
1183                fidl::encoding::DynamicFlags::empty(),
1184                _decode,
1185            )
1186    }
1187
1188    type AcquireLeaseResponseFut = fidl::client::QueryResponseFut<
1189        TopologyControlAcquireLeaseResult,
1190        fidl::encoding::DefaultFuchsiaResourceDialect,
1191    >;
1192    fn r#acquire_lease(
1193        &self,
1194        mut element_name: &str,
1195        mut level: u8,
1196        mut wait_for_status: fidl_fuchsia_power_broker::LeaseStatus,
1197    ) -> Self::AcquireLeaseResponseFut {
1198        fn _decode(
1199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1200        ) -> Result<TopologyControlAcquireLeaseResult, fidl::Error> {
1201            let _response = fidl::client::decode_transaction_body::<
1202                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
1203                fidl::encoding::DefaultFuchsiaResourceDialect,
1204                0x1bedc35d9b68bac8,
1205            >(_buf?)?;
1206            Ok(_response.map(|x| x))
1207        }
1208        self.client.send_query_and_decode::<
1209            TopologyControlAcquireLeaseRequest,
1210            TopologyControlAcquireLeaseResult,
1211        >(
1212            (element_name, level, wait_for_status,),
1213            0x1bedc35d9b68bac8,
1214            fidl::encoding::DynamicFlags::empty(),
1215            _decode,
1216        )
1217    }
1218
1219    type DropLeaseResponseFut = fidl::client::QueryResponseFut<
1220        TopologyControlDropLeaseResult,
1221        fidl::encoding::DefaultFuchsiaResourceDialect,
1222    >;
1223    fn r#drop_lease(&self, mut element_name: &str) -> Self::DropLeaseResponseFut {
1224        fn _decode(
1225            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1226        ) -> Result<TopologyControlDropLeaseResult, fidl::Error> {
1227            let _response = fidl::client::decode_transaction_body::<
1228                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LeaseControlError>,
1229                fidl::encoding::DefaultFuchsiaResourceDialect,
1230                0x7107f8f1080faddc,
1231            >(_buf?)?;
1232            Ok(_response.map(|x| x))
1233        }
1234        self.client.send_query_and_decode::<
1235            TopologyControlDropLeaseRequest,
1236            TopologyControlDropLeaseResult,
1237        >(
1238            (element_name,),
1239            0x7107f8f1080faddc,
1240            fidl::encoding::DynamicFlags::empty(),
1241            _decode,
1242        )
1243    }
1244
1245    type OpenStatusChannelResponseFut = fidl::client::QueryResponseFut<
1246        TopologyControlOpenStatusChannelResult,
1247        fidl::encoding::DefaultFuchsiaResourceDialect,
1248    >;
1249    fn r#open_status_channel(
1250        &self,
1251        mut element_name: &str,
1252        mut status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1253    ) -> Self::OpenStatusChannelResponseFut {
1254        fn _decode(
1255            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1256        ) -> Result<TopologyControlOpenStatusChannelResult, fidl::Error> {
1257            let _response = fidl::client::decode_transaction_body::<
1258                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, OpenStatusChannelError>,
1259                fidl::encoding::DefaultFuchsiaResourceDialect,
1260                0x69fba616c3ee2e90,
1261            >(_buf?)?;
1262            Ok(_response.map(|x| x))
1263        }
1264        self.client.send_query_and_decode::<
1265            TopologyControlOpenStatusChannelRequest,
1266            TopologyControlOpenStatusChannelResult,
1267        >(
1268            (element_name, status_channel,),
1269            0x69fba616c3ee2e90,
1270            fidl::encoding::DynamicFlags::empty(),
1271            _decode,
1272        )
1273    }
1274}
1275
1276pub struct TopologyControlEventStream {
1277    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1278}
1279
1280impl std::marker::Unpin for TopologyControlEventStream {}
1281
1282impl futures::stream::FusedStream for TopologyControlEventStream {
1283    fn is_terminated(&self) -> bool {
1284        self.event_receiver.is_terminated()
1285    }
1286}
1287
1288impl futures::Stream for TopologyControlEventStream {
1289    type Item = Result<TopologyControlEvent, fidl::Error>;
1290
1291    fn poll_next(
1292        mut self: std::pin::Pin<&mut Self>,
1293        cx: &mut std::task::Context<'_>,
1294    ) -> std::task::Poll<Option<Self::Item>> {
1295        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1296            &mut self.event_receiver,
1297            cx
1298        )?) {
1299            Some(buf) => std::task::Poll::Ready(Some(TopologyControlEvent::decode(buf))),
1300            None => std::task::Poll::Ready(None),
1301        }
1302    }
1303}
1304
1305#[derive(Debug)]
1306pub enum TopologyControlEvent {
1307    #[non_exhaustive]
1308    _UnknownEvent {
1309        /// Ordinal of the event that was sent.
1310        ordinal: u64,
1311    },
1312}
1313
1314impl TopologyControlEvent {
1315    /// Decodes a message buffer as a [`TopologyControlEvent`].
1316    fn decode(
1317        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1318    ) -> Result<TopologyControlEvent, fidl::Error> {
1319        let (bytes, _handles) = buf.split_mut();
1320        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1321        debug_assert_eq!(tx_header.tx_id, 0);
1322        match tx_header.ordinal {
1323            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
1324                Ok(TopologyControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
1325            }
1326            _ => Err(fidl::Error::UnknownOrdinal {
1327                ordinal: tx_header.ordinal,
1328                protocol_name:
1329                    <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1330            }),
1331        }
1332    }
1333}
1334
1335/// A Stream of incoming requests for fuchsia.power.topology.test/TopologyControl.
1336pub struct TopologyControlRequestStream {
1337    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1338    is_terminated: bool,
1339}
1340
1341impl std::marker::Unpin for TopologyControlRequestStream {}
1342
1343impl futures::stream::FusedStream for TopologyControlRequestStream {
1344    fn is_terminated(&self) -> bool {
1345        self.is_terminated
1346    }
1347}
1348
1349impl fidl::endpoints::RequestStream for TopologyControlRequestStream {
1350    type Protocol = TopologyControlMarker;
1351    type ControlHandle = TopologyControlControlHandle;
1352
1353    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1354        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1355    }
1356
1357    fn control_handle(&self) -> Self::ControlHandle {
1358        TopologyControlControlHandle { inner: self.inner.clone() }
1359    }
1360
1361    fn into_inner(
1362        self,
1363    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1364    {
1365        (self.inner, self.is_terminated)
1366    }
1367
1368    fn from_inner(
1369        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1370        is_terminated: bool,
1371    ) -> Self {
1372        Self { inner, is_terminated }
1373    }
1374}
1375
1376impl futures::Stream for TopologyControlRequestStream {
1377    type Item = Result<TopologyControlRequest, fidl::Error>;
1378
1379    fn poll_next(
1380        mut self: std::pin::Pin<&mut Self>,
1381        cx: &mut std::task::Context<'_>,
1382    ) -> std::task::Poll<Option<Self::Item>> {
1383        let this = &mut *self;
1384        if this.inner.check_shutdown(cx) {
1385            this.is_terminated = true;
1386            return std::task::Poll::Ready(None);
1387        }
1388        if this.is_terminated {
1389            panic!("polled TopologyControlRequestStream after completion");
1390        }
1391        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1392            |bytes, handles| {
1393                match this.inner.channel().read_etc(cx, bytes, handles) {
1394                    std::task::Poll::Ready(Ok(())) => {}
1395                    std::task::Poll::Pending => return std::task::Poll::Pending,
1396                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1397                        this.is_terminated = true;
1398                        return std::task::Poll::Ready(None);
1399                    }
1400                    std::task::Poll::Ready(Err(e)) => {
1401                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1402                            e.into(),
1403                        ))));
1404                    }
1405                }
1406
1407                // A message has been received from the channel
1408                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1409
1410                std::task::Poll::Ready(Some(match header.ordinal {
1411                    0x12033976b88716fa => {
1412                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1413                        let mut req = fidl::new_empty!(
1414                            TopologyControlCreateRequest,
1415                            fidl::encoding::DefaultFuchsiaResourceDialect
1416                        );
1417                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlCreateRequest>(&header, _body_bytes, handles, &mut req)?;
1418                        let control_handle =
1419                            TopologyControlControlHandle { inner: this.inner.clone() };
1420                        Ok(TopologyControlRequest::Create {
1421                            elements: req.elements,
1422
1423                            responder: TopologyControlCreateResponder {
1424                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1425                                tx_id: header.tx_id,
1426                            },
1427                        })
1428                    }
1429                    0x1bedc35d9b68bac8 => {
1430                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1431                        let mut req = fidl::new_empty!(
1432                            TopologyControlAcquireLeaseRequest,
1433                            fidl::encoding::DefaultFuchsiaResourceDialect
1434                        );
1435                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlAcquireLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1436                        let control_handle =
1437                            TopologyControlControlHandle { inner: this.inner.clone() };
1438                        Ok(TopologyControlRequest::AcquireLease {
1439                            element_name: req.element_name,
1440                            level: req.level,
1441                            wait_for_status: req.wait_for_status,
1442
1443                            responder: TopologyControlAcquireLeaseResponder {
1444                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1445                                tx_id: header.tx_id,
1446                            },
1447                        })
1448                    }
1449                    0x7107f8f1080faddc => {
1450                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1451                        let mut req = fidl::new_empty!(
1452                            TopologyControlDropLeaseRequest,
1453                            fidl::encoding::DefaultFuchsiaResourceDialect
1454                        );
1455                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlDropLeaseRequest>(&header, _body_bytes, handles, &mut req)?;
1456                        let control_handle =
1457                            TopologyControlControlHandle { inner: this.inner.clone() };
1458                        Ok(TopologyControlRequest::DropLease {
1459                            element_name: req.element_name,
1460
1461                            responder: TopologyControlDropLeaseResponder {
1462                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1463                                tx_id: header.tx_id,
1464                            },
1465                        })
1466                    }
1467                    0x69fba616c3ee2e90 => {
1468                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1469                        let mut req = fidl::new_empty!(
1470                            TopologyControlOpenStatusChannelRequest,
1471                            fidl::encoding::DefaultFuchsiaResourceDialect
1472                        );
1473                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<TopologyControlOpenStatusChannelRequest>(&header, _body_bytes, handles, &mut req)?;
1474                        let control_handle =
1475                            TopologyControlControlHandle { inner: this.inner.clone() };
1476                        Ok(TopologyControlRequest::OpenStatusChannel {
1477                            element_name: req.element_name,
1478                            status_channel: req.status_channel,
1479
1480                            responder: TopologyControlOpenStatusChannelResponder {
1481                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1482                                tx_id: header.tx_id,
1483                            },
1484                        })
1485                    }
1486                    _ if header.tx_id == 0
1487                        && header
1488                            .dynamic_flags()
1489                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1490                    {
1491                        Ok(TopologyControlRequest::_UnknownMethod {
1492                            ordinal: header.ordinal,
1493                            control_handle: TopologyControlControlHandle {
1494                                inner: this.inner.clone(),
1495                            },
1496                            method_type: fidl::MethodType::OneWay,
1497                        })
1498                    }
1499                    _ if header
1500                        .dynamic_flags()
1501                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1502                    {
1503                        this.inner.send_framework_err(
1504                            fidl::encoding::FrameworkErr::UnknownMethod,
1505                            header.tx_id,
1506                            header.ordinal,
1507                            header.dynamic_flags(),
1508                            (bytes, handles),
1509                        )?;
1510                        Ok(TopologyControlRequest::_UnknownMethod {
1511                            ordinal: header.ordinal,
1512                            control_handle: TopologyControlControlHandle {
1513                                inner: this.inner.clone(),
1514                            },
1515                            method_type: fidl::MethodType::TwoWay,
1516                        })
1517                    }
1518                    _ => Err(fidl::Error::UnknownOrdinal {
1519                        ordinal: header.ordinal,
1520                        protocol_name:
1521                            <TopologyControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1522                    }),
1523                }))
1524            },
1525        )
1526    }
1527}
1528
1529/// The primary initial protocol used by a client tool to communiate with the topology-test-daemon.
1530/// The client can create the whole topology, and then acquire or drop lease according to element
1531/// names.
1532#[derive(Debug)]
1533pub enum TopologyControlRequest {
1534    Create {
1535        elements: Vec<Element>,
1536        responder: TopologyControlCreateResponder,
1537    },
1538    AcquireLease {
1539        element_name: String,
1540        level: u8,
1541        wait_for_status: fidl_fuchsia_power_broker::LeaseStatus,
1542        responder: TopologyControlAcquireLeaseResponder,
1543    },
1544    DropLease {
1545        element_name: String,
1546        responder: TopologyControlDropLeaseResponder,
1547    },
1548    /// Register a new Status channel on which Power Broker will send
1549    /// read-only updates of the element's current power level.
1550    OpenStatusChannel {
1551        element_name: String,
1552        status_channel: fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1553        responder: TopologyControlOpenStatusChannelResponder,
1554    },
1555    /// An interaction was received which does not match any known method.
1556    #[non_exhaustive]
1557    _UnknownMethod {
1558        /// Ordinal of the method that was called.
1559        ordinal: u64,
1560        control_handle: TopologyControlControlHandle,
1561        method_type: fidl::MethodType,
1562    },
1563}
1564
1565impl TopologyControlRequest {
1566    #[allow(irrefutable_let_patterns)]
1567    pub fn into_create(self) -> Option<(Vec<Element>, TopologyControlCreateResponder)> {
1568        if let TopologyControlRequest::Create { elements, responder } = self {
1569            Some((elements, responder))
1570        } else {
1571            None
1572        }
1573    }
1574
1575    #[allow(irrefutable_let_patterns)]
1576    pub fn into_acquire_lease(
1577        self,
1578    ) -> Option<(
1579        String,
1580        u8,
1581        fidl_fuchsia_power_broker::LeaseStatus,
1582        TopologyControlAcquireLeaseResponder,
1583    )> {
1584        if let TopologyControlRequest::AcquireLease {
1585            element_name,
1586            level,
1587            wait_for_status,
1588            responder,
1589        } = self
1590        {
1591            Some((element_name, level, wait_for_status, responder))
1592        } else {
1593            None
1594        }
1595    }
1596
1597    #[allow(irrefutable_let_patterns)]
1598    pub fn into_drop_lease(self) -> Option<(String, TopologyControlDropLeaseResponder)> {
1599        if let TopologyControlRequest::DropLease { element_name, responder } = self {
1600            Some((element_name, responder))
1601        } else {
1602            None
1603        }
1604    }
1605
1606    #[allow(irrefutable_let_patterns)]
1607    pub fn into_open_status_channel(
1608        self,
1609    ) -> Option<(
1610        String,
1611        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
1612        TopologyControlOpenStatusChannelResponder,
1613    )> {
1614        if let TopologyControlRequest::OpenStatusChannel {
1615            element_name,
1616            status_channel,
1617            responder,
1618        } = self
1619        {
1620            Some((element_name, status_channel, responder))
1621        } else {
1622            None
1623        }
1624    }
1625
1626    /// Name of the method defined in FIDL
1627    pub fn method_name(&self) -> &'static str {
1628        match *self {
1629            TopologyControlRequest::Create { .. } => "create",
1630            TopologyControlRequest::AcquireLease { .. } => "acquire_lease",
1631            TopologyControlRequest::DropLease { .. } => "drop_lease",
1632            TopologyControlRequest::OpenStatusChannel { .. } => "open_status_channel",
1633            TopologyControlRequest::_UnknownMethod {
1634                method_type: fidl::MethodType::OneWay,
1635                ..
1636            } => "unknown one-way method",
1637            TopologyControlRequest::_UnknownMethod {
1638                method_type: fidl::MethodType::TwoWay,
1639                ..
1640            } => "unknown two-way method",
1641        }
1642    }
1643}
1644
1645#[derive(Debug, Clone)]
1646pub struct TopologyControlControlHandle {
1647    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1648}
1649
1650impl TopologyControlControlHandle {
1651    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1652        self.inner.shutdown_with_epitaph(status.into())
1653    }
1654}
1655
1656impl fidl::endpoints::ControlHandle for TopologyControlControlHandle {
1657    fn shutdown(&self) {
1658        self.inner.shutdown()
1659    }
1660
1661    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1662        self.inner.shutdown_with_epitaph(status)
1663    }
1664
1665    fn is_closed(&self) -> bool {
1666        self.inner.channel().is_closed()
1667    }
1668    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1669        self.inner.channel().on_closed()
1670    }
1671
1672    #[cfg(target_os = "fuchsia")]
1673    fn signal_peer(
1674        &self,
1675        clear_mask: zx::Signals,
1676        set_mask: zx::Signals,
1677    ) -> Result<(), zx_status::Status> {
1678        use fidl::Peered;
1679        self.inner.channel().signal_peer(clear_mask, set_mask)
1680    }
1681}
1682
1683impl TopologyControlControlHandle {}
1684
1685#[must_use = "FIDL methods require a response to be sent"]
1686#[derive(Debug)]
1687pub struct TopologyControlCreateResponder {
1688    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1689    tx_id: u32,
1690}
1691
1692/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1693/// if the responder is dropped without sending a response, so that the client
1694/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1695impl std::ops::Drop for TopologyControlCreateResponder {
1696    fn drop(&mut self) {
1697        self.control_handle.shutdown();
1698        // Safety: drops once, never accessed again
1699        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1700    }
1701}
1702
1703impl fidl::endpoints::Responder for TopologyControlCreateResponder {
1704    type ControlHandle = TopologyControlControlHandle;
1705
1706    fn control_handle(&self) -> &TopologyControlControlHandle {
1707        &self.control_handle
1708    }
1709
1710    fn drop_without_shutdown(mut self) {
1711        // Safety: drops once, never accessed again due to mem::forget
1712        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1713        // Prevent Drop from running (which would shut down the channel)
1714        std::mem::forget(self);
1715    }
1716}
1717
1718impl TopologyControlCreateResponder {
1719    /// Sends a response to the FIDL transaction.
1720    ///
1721    /// Sets the channel to shutdown if an error occurs.
1722    pub fn send(self, mut result: Result<(), CreateTopologyGraphError>) -> Result<(), fidl::Error> {
1723        let _result = self.send_raw(result);
1724        if _result.is_err() {
1725            self.control_handle.shutdown();
1726        }
1727        self.drop_without_shutdown();
1728        _result
1729    }
1730
1731    /// Similar to "send" but does not shutdown the channel if an error occurs.
1732    pub fn send_no_shutdown_on_err(
1733        self,
1734        mut result: Result<(), CreateTopologyGraphError>,
1735    ) -> Result<(), fidl::Error> {
1736        let _result = self.send_raw(result);
1737        self.drop_without_shutdown();
1738        _result
1739    }
1740
1741    fn send_raw(
1742        &self,
1743        mut result: Result<(), CreateTopologyGraphError>,
1744    ) -> Result<(), fidl::Error> {
1745        self.control_handle.inner.send::<fidl::encoding::ResultType<
1746            fidl::encoding::EmptyStruct,
1747            CreateTopologyGraphError,
1748        >>(
1749            result,
1750            self.tx_id,
1751            0x12033976b88716fa,
1752            fidl::encoding::DynamicFlags::empty(),
1753        )
1754    }
1755}
1756
1757#[must_use = "FIDL methods require a response to be sent"]
1758#[derive(Debug)]
1759pub struct TopologyControlAcquireLeaseResponder {
1760    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1761    tx_id: u32,
1762}
1763
1764/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1765/// if the responder is dropped without sending a response, so that the client
1766/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1767impl std::ops::Drop for TopologyControlAcquireLeaseResponder {
1768    fn drop(&mut self) {
1769        self.control_handle.shutdown();
1770        // Safety: drops once, never accessed again
1771        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1772    }
1773}
1774
1775impl fidl::endpoints::Responder for TopologyControlAcquireLeaseResponder {
1776    type ControlHandle = TopologyControlControlHandle;
1777
1778    fn control_handle(&self) -> &TopologyControlControlHandle {
1779        &self.control_handle
1780    }
1781
1782    fn drop_without_shutdown(mut self) {
1783        // Safety: drops once, never accessed again due to mem::forget
1784        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1785        // Prevent Drop from running (which would shut down the channel)
1786        std::mem::forget(self);
1787    }
1788}
1789
1790impl TopologyControlAcquireLeaseResponder {
1791    /// Sends a response to the FIDL transaction.
1792    ///
1793    /// Sets the channel to shutdown if an error occurs.
1794    pub fn send(self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1795        let _result = self.send_raw(result);
1796        if _result.is_err() {
1797            self.control_handle.shutdown();
1798        }
1799        self.drop_without_shutdown();
1800        _result
1801    }
1802
1803    /// Similar to "send" but does not shutdown the channel if an error occurs.
1804    pub fn send_no_shutdown_on_err(
1805        self,
1806        mut result: Result<(), LeaseControlError>,
1807    ) -> Result<(), fidl::Error> {
1808        let _result = self.send_raw(result);
1809        self.drop_without_shutdown();
1810        _result
1811    }
1812
1813    fn send_raw(&self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1814        self.control_handle.inner.send::<fidl::encoding::ResultType<
1815            fidl::encoding::EmptyStruct,
1816            LeaseControlError,
1817        >>(
1818            result,
1819            self.tx_id,
1820            0x1bedc35d9b68bac8,
1821            fidl::encoding::DynamicFlags::empty(),
1822        )
1823    }
1824}
1825
1826#[must_use = "FIDL methods require a response to be sent"]
1827#[derive(Debug)]
1828pub struct TopologyControlDropLeaseResponder {
1829    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1830    tx_id: u32,
1831}
1832
1833/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1834/// if the responder is dropped without sending a response, so that the client
1835/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1836impl std::ops::Drop for TopologyControlDropLeaseResponder {
1837    fn drop(&mut self) {
1838        self.control_handle.shutdown();
1839        // Safety: drops once, never accessed again
1840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1841    }
1842}
1843
1844impl fidl::endpoints::Responder for TopologyControlDropLeaseResponder {
1845    type ControlHandle = TopologyControlControlHandle;
1846
1847    fn control_handle(&self) -> &TopologyControlControlHandle {
1848        &self.control_handle
1849    }
1850
1851    fn drop_without_shutdown(mut self) {
1852        // Safety: drops once, never accessed again due to mem::forget
1853        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1854        // Prevent Drop from running (which would shut down the channel)
1855        std::mem::forget(self);
1856    }
1857}
1858
1859impl TopologyControlDropLeaseResponder {
1860    /// Sends a response to the FIDL transaction.
1861    ///
1862    /// Sets the channel to shutdown if an error occurs.
1863    pub fn send(self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1864        let _result = self.send_raw(result);
1865        if _result.is_err() {
1866            self.control_handle.shutdown();
1867        }
1868        self.drop_without_shutdown();
1869        _result
1870    }
1871
1872    /// Similar to "send" but does not shutdown the channel if an error occurs.
1873    pub fn send_no_shutdown_on_err(
1874        self,
1875        mut result: Result<(), LeaseControlError>,
1876    ) -> Result<(), fidl::Error> {
1877        let _result = self.send_raw(result);
1878        self.drop_without_shutdown();
1879        _result
1880    }
1881
1882    fn send_raw(&self, mut result: Result<(), LeaseControlError>) -> Result<(), fidl::Error> {
1883        self.control_handle.inner.send::<fidl::encoding::ResultType<
1884            fidl::encoding::EmptyStruct,
1885            LeaseControlError,
1886        >>(
1887            result,
1888            self.tx_id,
1889            0x7107f8f1080faddc,
1890            fidl::encoding::DynamicFlags::empty(),
1891        )
1892    }
1893}
1894
1895#[must_use = "FIDL methods require a response to be sent"]
1896#[derive(Debug)]
1897pub struct TopologyControlOpenStatusChannelResponder {
1898    control_handle: std::mem::ManuallyDrop<TopologyControlControlHandle>,
1899    tx_id: u32,
1900}
1901
1902/// Set the the channel to be shutdown (see [`TopologyControlControlHandle::shutdown`])
1903/// if the responder is dropped without sending a response, so that the client
1904/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1905impl std::ops::Drop for TopologyControlOpenStatusChannelResponder {
1906    fn drop(&mut self) {
1907        self.control_handle.shutdown();
1908        // Safety: drops once, never accessed again
1909        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1910    }
1911}
1912
1913impl fidl::endpoints::Responder for TopologyControlOpenStatusChannelResponder {
1914    type ControlHandle = TopologyControlControlHandle;
1915
1916    fn control_handle(&self) -> &TopologyControlControlHandle {
1917        &self.control_handle
1918    }
1919
1920    fn drop_without_shutdown(mut self) {
1921        // Safety: drops once, never accessed again due to mem::forget
1922        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1923        // Prevent Drop from running (which would shut down the channel)
1924        std::mem::forget(self);
1925    }
1926}
1927
1928impl TopologyControlOpenStatusChannelResponder {
1929    /// Sends a response to the FIDL transaction.
1930    ///
1931    /// Sets the channel to shutdown if an error occurs.
1932    pub fn send(self, mut result: Result<(), OpenStatusChannelError>) -> Result<(), fidl::Error> {
1933        let _result = self.send_raw(result);
1934        if _result.is_err() {
1935            self.control_handle.shutdown();
1936        }
1937        self.drop_without_shutdown();
1938        _result
1939    }
1940
1941    /// Similar to "send" but does not shutdown the channel if an error occurs.
1942    pub fn send_no_shutdown_on_err(
1943        self,
1944        mut result: Result<(), OpenStatusChannelError>,
1945    ) -> Result<(), fidl::Error> {
1946        let _result = self.send_raw(result);
1947        self.drop_without_shutdown();
1948        _result
1949    }
1950
1951    fn send_raw(&self, mut result: Result<(), OpenStatusChannelError>) -> Result<(), fidl::Error> {
1952        self.control_handle.inner.send::<fidl::encoding::ResultType<
1953            fidl::encoding::EmptyStruct,
1954            OpenStatusChannelError,
1955        >>(
1956            result,
1957            self.tx_id,
1958            0x69fba616c3ee2e90,
1959            fidl::encoding::DynamicFlags::empty(),
1960        )
1961    }
1962}
1963
1964mod internal {
1965    use super::*;
1966
1967    impl fidl::encoding::ResourceTypeMarker for TopologyControlOpenStatusChannelRequest {
1968        type Borrowed<'a> = &'a mut Self;
1969        fn take_or_borrow<'a>(
1970            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1971        ) -> Self::Borrowed<'a> {
1972            value
1973        }
1974    }
1975
1976    unsafe impl fidl::encoding::TypeMarker for TopologyControlOpenStatusChannelRequest {
1977        type Owned = Self;
1978
1979        #[inline(always)]
1980        fn inline_align(_context: fidl::encoding::Context) -> usize {
1981            8
1982        }
1983
1984        #[inline(always)]
1985        fn inline_size(_context: fidl::encoding::Context) -> usize {
1986            24
1987        }
1988    }
1989
1990    unsafe impl
1991        fidl::encoding::Encode<
1992            TopologyControlOpenStatusChannelRequest,
1993            fidl::encoding::DefaultFuchsiaResourceDialect,
1994        > for &mut TopologyControlOpenStatusChannelRequest
1995    {
1996        #[inline]
1997        unsafe fn encode(
1998            self,
1999            encoder: &mut fidl::encoding::Encoder<
2000                '_,
2001                fidl::encoding::DefaultFuchsiaResourceDialect,
2002            >,
2003            offset: usize,
2004            _depth: fidl::encoding::Depth,
2005        ) -> fidl::Result<()> {
2006            encoder.debug_check_bounds::<TopologyControlOpenStatusChannelRequest>(offset);
2007            // Delegate to tuple encoding.
2008            fidl::encoding::Encode::<
2009                TopologyControlOpenStatusChannelRequest,
2010                fidl::encoding::DefaultFuchsiaResourceDialect,
2011            >::encode(
2012                (
2013                    <fidl::encoding::BoundedString<64> as fidl::encoding::ValueTypeMarker>::borrow(
2014                        &self.element_name,
2015                    ),
2016                    <fidl::encoding::Endpoint<
2017                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
2018                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2019                        &mut self.status_channel,
2020                    ),
2021                ),
2022                encoder,
2023                offset,
2024                _depth,
2025            )
2026        }
2027    }
2028    unsafe impl<
2029        T0: fidl::encoding::Encode<
2030                fidl::encoding::BoundedString<64>,
2031                fidl::encoding::DefaultFuchsiaResourceDialect,
2032            >,
2033        T1: fidl::encoding::Encode<
2034                fidl::encoding::Endpoint<
2035                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
2036                >,
2037                fidl::encoding::DefaultFuchsiaResourceDialect,
2038            >,
2039    >
2040        fidl::encoding::Encode<
2041            TopologyControlOpenStatusChannelRequest,
2042            fidl::encoding::DefaultFuchsiaResourceDialect,
2043        > for (T0, T1)
2044    {
2045        #[inline]
2046        unsafe fn encode(
2047            self,
2048            encoder: &mut fidl::encoding::Encoder<
2049                '_,
2050                fidl::encoding::DefaultFuchsiaResourceDialect,
2051            >,
2052            offset: usize,
2053            depth: fidl::encoding::Depth,
2054        ) -> fidl::Result<()> {
2055            encoder.debug_check_bounds::<TopologyControlOpenStatusChannelRequest>(offset);
2056            // Zero out padding regions. There's no need to apply masks
2057            // because the unmasked parts will be overwritten by fields.
2058            unsafe {
2059                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2060                (ptr as *mut u64).write_unaligned(0);
2061            }
2062            // Write the fields.
2063            self.0.encode(encoder, offset + 0, depth)?;
2064            self.1.encode(encoder, offset + 16, depth)?;
2065            Ok(())
2066        }
2067    }
2068
2069    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2070        for TopologyControlOpenStatusChannelRequest
2071    {
2072        #[inline(always)]
2073        fn new_empty() -> Self {
2074            Self {
2075                element_name: fidl::new_empty!(
2076                    fidl::encoding::BoundedString<64>,
2077                    fidl::encoding::DefaultFuchsiaResourceDialect
2078                ),
2079                status_channel: fidl::new_empty!(
2080                    fidl::encoding::Endpoint<
2081                        fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
2082                    >,
2083                    fidl::encoding::DefaultFuchsiaResourceDialect
2084                ),
2085            }
2086        }
2087
2088        #[inline]
2089        unsafe fn decode(
2090            &mut self,
2091            decoder: &mut fidl::encoding::Decoder<
2092                '_,
2093                fidl::encoding::DefaultFuchsiaResourceDialect,
2094            >,
2095            offset: usize,
2096            _depth: fidl::encoding::Depth,
2097        ) -> fidl::Result<()> {
2098            decoder.debug_check_bounds::<Self>(offset);
2099            // Verify that padding bytes are zero.
2100            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2101            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2102            let mask = 0xffffffff00000000u64;
2103            let maskedval = padval & mask;
2104            if maskedval != 0 {
2105                return Err(fidl::Error::NonZeroPadding {
2106                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2107                });
2108            }
2109            fidl::decode!(
2110                fidl::encoding::BoundedString<64>,
2111                fidl::encoding::DefaultFuchsiaResourceDialect,
2112                &mut self.element_name,
2113                decoder,
2114                offset + 0,
2115                _depth
2116            )?;
2117            fidl::decode!(
2118                fidl::encoding::Endpoint<
2119                    fidl::endpoints::ServerEnd<fidl_fuchsia_power_broker::StatusMarker>,
2120                >,
2121                fidl::encoding::DefaultFuchsiaResourceDialect,
2122                &mut self.status_channel,
2123                decoder,
2124                offset + 16,
2125                _depth
2126            )?;
2127            Ok(())
2128        }
2129    }
2130}