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