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