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_systemmode_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ClientConfiguratorMarker;
16
17impl fidl::endpoints::ProtocolMarker for ClientConfiguratorMarker {
18 type Proxy = ClientConfiguratorProxy;
19 type RequestStream = ClientConfiguratorRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = ClientConfiguratorSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.ClientConfigurator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ClientConfiguratorMarker {}
26
27pub trait ClientConfiguratorProxyInterface: Send + Sync {
28 type GetResponseFut: std::future::Future<Output = Result<Option<Box<ClientConfig>>, fidl::Error>>
29 + Send;
30 fn r#get(
31 &self,
32 client_type: fidl_fuchsia_power_clientlevel::ClientType,
33 ) -> Self::GetResponseFut;
34 type SetResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
35 fn r#set(
36 &self,
37 client_type: fidl_fuchsia_power_clientlevel::ClientType,
38 config: &ClientConfig,
39 ) -> Self::SetResponseFut;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct ClientConfiguratorSynchronousProxy {
44 client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for ClientConfiguratorSynchronousProxy {
49 type Proxy = ClientConfiguratorProxy;
50 type Protocol = ClientConfiguratorMarker;
51
52 fn from_channel(inner: fidl::Channel) -> Self {
53 Self::new(inner)
54 }
55
56 fn into_channel(self) -> fidl::Channel {
57 self.client.into_channel()
58 }
59
60 fn as_channel(&self) -> &fidl::Channel {
61 self.client.as_channel()
62 }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl ClientConfiguratorSynchronousProxy {
67 pub fn new(channel: fidl::Channel) -> Self {
68 Self { client: fidl::client::sync::Client::new(channel) }
69 }
70
71 pub fn into_channel(self) -> fidl::Channel {
72 self.client.into_channel()
73 }
74
75 pub fn wait_for_event(
78 &self,
79 deadline: zx::MonotonicInstant,
80 ) -> Result<ClientConfiguratorEvent, fidl::Error> {
81 ClientConfiguratorEvent::decode(
82 self.client.wait_for_event::<ClientConfiguratorMarker>(deadline)?,
83 )
84 }
85
86 pub fn r#get(
95 &self,
96 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
97 ___deadline: zx::MonotonicInstant,
98 ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
99 let _response = self.client.send_query::<
100 ClientConfiguratorGetRequest,
101 ClientConfiguratorGetResponse,
102 ClientConfiguratorMarker,
103 >(
104 (client_type,),
105 0x1e37597b4d247d7b,
106 fidl::encoding::DynamicFlags::empty(),
107 ___deadline,
108 )?;
109 Ok(_response.config)
110 }
111
112 pub fn r#set(
138 &self,
139 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
140 mut config: &ClientConfig,
141 ___deadline: zx::MonotonicInstant,
142 ) -> Result<(), fidl::Error> {
143 let _response = self.client.send_query::<
144 ClientConfiguratorSetRequest,
145 fidl::encoding::EmptyPayload,
146 ClientConfiguratorMarker,
147 >(
148 (client_type, config,),
149 0x2204fb91b32f6435,
150 fidl::encoding::DynamicFlags::empty(),
151 ___deadline,
152 )?;
153 Ok(_response)
154 }
155}
156
157#[cfg(target_os = "fuchsia")]
158impl From<ClientConfiguratorSynchronousProxy> for zx::NullableHandle {
159 fn from(value: ClientConfiguratorSynchronousProxy) -> Self {
160 value.into_channel().into()
161 }
162}
163
164#[cfg(target_os = "fuchsia")]
165impl From<fidl::Channel> for ClientConfiguratorSynchronousProxy {
166 fn from(value: fidl::Channel) -> Self {
167 Self::new(value)
168 }
169}
170
171#[cfg(target_os = "fuchsia")]
172impl fidl::endpoints::FromClient for ClientConfiguratorSynchronousProxy {
173 type Protocol = ClientConfiguratorMarker;
174
175 fn from_client(value: fidl::endpoints::ClientEnd<ClientConfiguratorMarker>) -> Self {
176 Self::new(value.into_channel())
177 }
178}
179
180#[derive(Debug, Clone)]
181pub struct ClientConfiguratorProxy {
182 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
183}
184
185impl fidl::endpoints::Proxy for ClientConfiguratorProxy {
186 type Protocol = ClientConfiguratorMarker;
187
188 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
189 Self::new(inner)
190 }
191
192 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
193 self.client.into_channel().map_err(|client| Self { client })
194 }
195
196 fn as_channel(&self) -> &::fidl::AsyncChannel {
197 self.client.as_channel()
198 }
199}
200
201impl ClientConfiguratorProxy {
202 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
204 let protocol_name =
205 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
206 Self { client: fidl::client::Client::new(channel, protocol_name) }
207 }
208
209 pub fn take_event_stream(&self) -> ClientConfiguratorEventStream {
215 ClientConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
216 }
217
218 pub fn r#get(
227 &self,
228 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
229 ) -> fidl::client::QueryResponseFut<
230 Option<Box<ClientConfig>>,
231 fidl::encoding::DefaultFuchsiaResourceDialect,
232 > {
233 ClientConfiguratorProxyInterface::r#get(self, client_type)
234 }
235
236 pub fn r#set(
262 &self,
263 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
264 mut config: &ClientConfig,
265 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
266 ClientConfiguratorProxyInterface::r#set(self, client_type, config)
267 }
268}
269
270impl ClientConfiguratorProxyInterface for ClientConfiguratorProxy {
271 type GetResponseFut = fidl::client::QueryResponseFut<
272 Option<Box<ClientConfig>>,
273 fidl::encoding::DefaultFuchsiaResourceDialect,
274 >;
275 fn r#get(
276 &self,
277 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
278 ) -> Self::GetResponseFut {
279 fn _decode(
280 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
281 ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
282 let _response = fidl::client::decode_transaction_body::<
283 ClientConfiguratorGetResponse,
284 fidl::encoding::DefaultFuchsiaResourceDialect,
285 0x1e37597b4d247d7b,
286 >(_buf?)?;
287 Ok(_response.config)
288 }
289 self.client
290 .send_query_and_decode::<ClientConfiguratorGetRequest, Option<Box<ClientConfig>>>(
291 (client_type,),
292 0x1e37597b4d247d7b,
293 fidl::encoding::DynamicFlags::empty(),
294 _decode,
295 )
296 }
297
298 type SetResponseFut =
299 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
300 fn r#set(
301 &self,
302 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
303 mut config: &ClientConfig,
304 ) -> Self::SetResponseFut {
305 fn _decode(
306 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
307 ) -> Result<(), fidl::Error> {
308 let _response = fidl::client::decode_transaction_body::<
309 fidl::encoding::EmptyPayload,
310 fidl::encoding::DefaultFuchsiaResourceDialect,
311 0x2204fb91b32f6435,
312 >(_buf?)?;
313 Ok(_response)
314 }
315 self.client.send_query_and_decode::<ClientConfiguratorSetRequest, ()>(
316 (client_type, config),
317 0x2204fb91b32f6435,
318 fidl::encoding::DynamicFlags::empty(),
319 _decode,
320 )
321 }
322}
323
324pub struct ClientConfiguratorEventStream {
325 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
326}
327
328impl std::marker::Unpin for ClientConfiguratorEventStream {}
329
330impl futures::stream::FusedStream for ClientConfiguratorEventStream {
331 fn is_terminated(&self) -> bool {
332 self.event_receiver.is_terminated()
333 }
334}
335
336impl futures::Stream for ClientConfiguratorEventStream {
337 type Item = Result<ClientConfiguratorEvent, fidl::Error>;
338
339 fn poll_next(
340 mut self: std::pin::Pin<&mut Self>,
341 cx: &mut std::task::Context<'_>,
342 ) -> std::task::Poll<Option<Self::Item>> {
343 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
344 &mut self.event_receiver,
345 cx
346 )?) {
347 Some(buf) => std::task::Poll::Ready(Some(ClientConfiguratorEvent::decode(buf))),
348 None => std::task::Poll::Ready(None),
349 }
350 }
351}
352
353#[derive(Debug)]
354pub enum ClientConfiguratorEvent {}
355
356impl ClientConfiguratorEvent {
357 fn decode(
359 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
360 ) -> Result<ClientConfiguratorEvent, fidl::Error> {
361 let (bytes, _handles) = buf.split_mut();
362 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
363 debug_assert_eq!(tx_header.tx_id, 0);
364 match tx_header.ordinal {
365 _ => Err(fidl::Error::UnknownOrdinal {
366 ordinal: tx_header.ordinal,
367 protocol_name:
368 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
369 }),
370 }
371 }
372}
373
374pub struct ClientConfiguratorRequestStream {
376 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377 is_terminated: bool,
378}
379
380impl std::marker::Unpin for ClientConfiguratorRequestStream {}
381
382impl futures::stream::FusedStream for ClientConfiguratorRequestStream {
383 fn is_terminated(&self) -> bool {
384 self.is_terminated
385 }
386}
387
388impl fidl::endpoints::RequestStream for ClientConfiguratorRequestStream {
389 type Protocol = ClientConfiguratorMarker;
390 type ControlHandle = ClientConfiguratorControlHandle;
391
392 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
393 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
394 }
395
396 fn control_handle(&self) -> Self::ControlHandle {
397 ClientConfiguratorControlHandle { inner: self.inner.clone() }
398 }
399
400 fn into_inner(
401 self,
402 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
403 {
404 (self.inner, self.is_terminated)
405 }
406
407 fn from_inner(
408 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
409 is_terminated: bool,
410 ) -> Self {
411 Self { inner, is_terminated }
412 }
413}
414
415impl futures::Stream for ClientConfiguratorRequestStream {
416 type Item = Result<ClientConfiguratorRequest, fidl::Error>;
417
418 fn poll_next(
419 mut self: std::pin::Pin<&mut Self>,
420 cx: &mut std::task::Context<'_>,
421 ) -> std::task::Poll<Option<Self::Item>> {
422 let this = &mut *self;
423 if this.inner.check_shutdown(cx) {
424 this.is_terminated = true;
425 return std::task::Poll::Ready(None);
426 }
427 if this.is_terminated {
428 panic!("polled ClientConfiguratorRequestStream after completion");
429 }
430 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
431 |bytes, handles| {
432 match this.inner.channel().read_etc(cx, bytes, handles) {
433 std::task::Poll::Ready(Ok(())) => {}
434 std::task::Poll::Pending => return std::task::Poll::Pending,
435 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
436 this.is_terminated = true;
437 return std::task::Poll::Ready(None);
438 }
439 std::task::Poll::Ready(Err(e)) => {
440 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
441 e.into(),
442 ))));
443 }
444 }
445
446 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
448
449 std::task::Poll::Ready(Some(match header.ordinal {
450 0x1e37597b4d247d7b => {
451 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
452 let mut req = fidl::new_empty!(ClientConfiguratorGetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
453 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorGetRequest>(&header, _body_bytes, handles, &mut req)?;
454 let control_handle = ClientConfiguratorControlHandle {
455 inner: this.inner.clone(),
456 };
457 Ok(ClientConfiguratorRequest::Get {client_type: req.client_type,
458
459 responder: ClientConfiguratorGetResponder {
460 control_handle: std::mem::ManuallyDrop::new(control_handle),
461 tx_id: header.tx_id,
462 },
463 })
464 }
465 0x2204fb91b32f6435 => {
466 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
467 let mut req = fidl::new_empty!(ClientConfiguratorSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
468 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorSetRequest>(&header, _body_bytes, handles, &mut req)?;
469 let control_handle = ClientConfiguratorControlHandle {
470 inner: this.inner.clone(),
471 };
472 Ok(ClientConfiguratorRequest::Set {client_type: req.client_type,
473config: req.config,
474
475 responder: ClientConfiguratorSetResponder {
476 control_handle: std::mem::ManuallyDrop::new(control_handle),
477 tx_id: header.tx_id,
478 },
479 })
480 }
481 _ => Err(fidl::Error::UnknownOrdinal {
482 ordinal: header.ordinal,
483 protocol_name: <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
484 }),
485 }))
486 },
487 )
488 }
489}
490
491#[derive(Debug)]
494pub enum ClientConfiguratorRequest {
495 Get {
504 client_type: fidl_fuchsia_power_clientlevel::ClientType,
505 responder: ClientConfiguratorGetResponder,
506 },
507 Set {
533 client_type: fidl_fuchsia_power_clientlevel::ClientType,
534 config: ClientConfig,
535 responder: ClientConfiguratorSetResponder,
536 },
537}
538
539impl ClientConfiguratorRequest {
540 #[allow(irrefutable_let_patterns)]
541 pub fn into_get(
542 self,
543 ) -> Option<(fidl_fuchsia_power_clientlevel::ClientType, ClientConfiguratorGetResponder)> {
544 if let ClientConfiguratorRequest::Get { client_type, responder } = self {
545 Some((client_type, responder))
546 } else {
547 None
548 }
549 }
550
551 #[allow(irrefutable_let_patterns)]
552 pub fn into_set(
553 self,
554 ) -> Option<(
555 fidl_fuchsia_power_clientlevel::ClientType,
556 ClientConfig,
557 ClientConfiguratorSetResponder,
558 )> {
559 if let ClientConfiguratorRequest::Set { client_type, config, responder } = self {
560 Some((client_type, config, responder))
561 } else {
562 None
563 }
564 }
565
566 pub fn method_name(&self) -> &'static str {
568 match *self {
569 ClientConfiguratorRequest::Get { .. } => "get",
570 ClientConfiguratorRequest::Set { .. } => "set",
571 }
572 }
573}
574
575#[derive(Debug, Clone)]
576pub struct ClientConfiguratorControlHandle {
577 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
578}
579
580impl ClientConfiguratorControlHandle {
581 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
582 self.inner.shutdown_with_epitaph(status.into())
583 }
584}
585
586impl fidl::endpoints::ControlHandle for ClientConfiguratorControlHandle {
587 fn shutdown(&self) {
588 self.inner.shutdown()
589 }
590
591 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
592 self.inner.shutdown_with_epitaph(status)
593 }
594
595 fn is_closed(&self) -> bool {
596 self.inner.channel().is_closed()
597 }
598 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
599 self.inner.channel().on_closed()
600 }
601
602 #[cfg(target_os = "fuchsia")]
603 fn signal_peer(
604 &self,
605 clear_mask: zx::Signals,
606 set_mask: zx::Signals,
607 ) -> Result<(), zx_status::Status> {
608 use fidl::Peered;
609 self.inner.channel().signal_peer(clear_mask, set_mask)
610 }
611}
612
613impl ClientConfiguratorControlHandle {}
614
615#[must_use = "FIDL methods require a response to be sent"]
616#[derive(Debug)]
617pub struct ClientConfiguratorGetResponder {
618 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
619 tx_id: u32,
620}
621
622impl std::ops::Drop for ClientConfiguratorGetResponder {
626 fn drop(&mut self) {
627 self.control_handle.shutdown();
628 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
630 }
631}
632
633impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
634 type ControlHandle = ClientConfiguratorControlHandle;
635
636 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
637 &self.control_handle
638 }
639
640 fn drop_without_shutdown(mut self) {
641 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
643 std::mem::forget(self);
645 }
646}
647
648impl ClientConfiguratorGetResponder {
649 pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
653 let _result = self.send_raw(config);
654 if _result.is_err() {
655 self.control_handle.shutdown();
656 }
657 self.drop_without_shutdown();
658 _result
659 }
660
661 pub fn send_no_shutdown_on_err(
663 self,
664 mut config: Option<&ClientConfig>,
665 ) -> Result<(), fidl::Error> {
666 let _result = self.send_raw(config);
667 self.drop_without_shutdown();
668 _result
669 }
670
671 fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
672 self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
673 (config,),
674 self.tx_id,
675 0x1e37597b4d247d7b,
676 fidl::encoding::DynamicFlags::empty(),
677 )
678 }
679}
680
681#[must_use = "FIDL methods require a response to be sent"]
682#[derive(Debug)]
683pub struct ClientConfiguratorSetResponder {
684 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
685 tx_id: u32,
686}
687
688impl std::ops::Drop for ClientConfiguratorSetResponder {
692 fn drop(&mut self) {
693 self.control_handle.shutdown();
694 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
696 }
697}
698
699impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
700 type ControlHandle = ClientConfiguratorControlHandle;
701
702 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
703 &self.control_handle
704 }
705
706 fn drop_without_shutdown(mut self) {
707 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
709 std::mem::forget(self);
711 }
712}
713
714impl ClientConfiguratorSetResponder {
715 pub fn send(self) -> Result<(), fidl::Error> {
719 let _result = self.send_raw();
720 if _result.is_err() {
721 self.control_handle.shutdown();
722 }
723 self.drop_without_shutdown();
724 _result
725 }
726
727 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
729 let _result = self.send_raw();
730 self.drop_without_shutdown();
731 _result
732 }
733
734 fn send_raw(&self) -> Result<(), fidl::Error> {
735 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
736 (),
737 self.tx_id,
738 0x2204fb91b32f6435,
739 fidl::encoding::DynamicFlags::empty(),
740 )
741 }
742}
743
744#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
745pub struct RequesterMarker;
746
747impl fidl::endpoints::ProtocolMarker for RequesterMarker {
748 type Proxy = RequesterProxy;
749 type RequestStream = RequesterRequestStream;
750 #[cfg(target_os = "fuchsia")]
751 type SynchronousProxy = RequesterSynchronousProxy;
752
753 const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
754}
755impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
756pub type RequesterRequestResult = Result<(), ModeRequestError>;
757
758pub trait RequesterProxyInterface: Send + Sync {
759 type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
760 + Send;
761 fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
762}
763#[derive(Debug)]
764#[cfg(target_os = "fuchsia")]
765pub struct RequesterSynchronousProxy {
766 client: fidl::client::sync::Client,
767}
768
769#[cfg(target_os = "fuchsia")]
770impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
771 type Proxy = RequesterProxy;
772 type Protocol = RequesterMarker;
773
774 fn from_channel(inner: fidl::Channel) -> Self {
775 Self::new(inner)
776 }
777
778 fn into_channel(self) -> fidl::Channel {
779 self.client.into_channel()
780 }
781
782 fn as_channel(&self) -> &fidl::Channel {
783 self.client.as_channel()
784 }
785}
786
787#[cfg(target_os = "fuchsia")]
788impl RequesterSynchronousProxy {
789 pub fn new(channel: fidl::Channel) -> Self {
790 Self { client: fidl::client::sync::Client::new(channel) }
791 }
792
793 pub fn into_channel(self) -> fidl::Channel {
794 self.client.into_channel()
795 }
796
797 pub fn wait_for_event(
800 &self,
801 deadline: zx::MonotonicInstant,
802 ) -> Result<RequesterEvent, fidl::Error> {
803 RequesterEvent::decode(self.client.wait_for_event::<RequesterMarker>(deadline)?)
804 }
805
806 pub fn r#request(
837 &self,
838 mut mode: SystemMode,
839 mut set: bool,
840 ___deadline: zx::MonotonicInstant,
841 ) -> Result<RequesterRequestResult, fidl::Error> {
842 let _response = self.client.send_query::<
843 RequesterRequestRequest,
844 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
845 RequesterMarker,
846 >(
847 (mode, set,),
848 0x5603afcd4421f425,
849 fidl::encoding::DynamicFlags::empty(),
850 ___deadline,
851 )?;
852 Ok(_response.map(|x| x))
853 }
854}
855
856#[cfg(target_os = "fuchsia")]
857impl From<RequesterSynchronousProxy> for zx::NullableHandle {
858 fn from(value: RequesterSynchronousProxy) -> Self {
859 value.into_channel().into()
860 }
861}
862
863#[cfg(target_os = "fuchsia")]
864impl From<fidl::Channel> for RequesterSynchronousProxy {
865 fn from(value: fidl::Channel) -> Self {
866 Self::new(value)
867 }
868}
869
870#[cfg(target_os = "fuchsia")]
871impl fidl::endpoints::FromClient for RequesterSynchronousProxy {
872 type Protocol = RequesterMarker;
873
874 fn from_client(value: fidl::endpoints::ClientEnd<RequesterMarker>) -> Self {
875 Self::new(value.into_channel())
876 }
877}
878
879#[derive(Debug, Clone)]
880pub struct RequesterProxy {
881 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
882}
883
884impl fidl::endpoints::Proxy for RequesterProxy {
885 type Protocol = RequesterMarker;
886
887 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
888 Self::new(inner)
889 }
890
891 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
892 self.client.into_channel().map_err(|client| Self { client })
893 }
894
895 fn as_channel(&self) -> &::fidl::AsyncChannel {
896 self.client.as_channel()
897 }
898}
899
900impl RequesterProxy {
901 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
903 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
904 Self { client: fidl::client::Client::new(channel, protocol_name) }
905 }
906
907 pub fn take_event_stream(&self) -> RequesterEventStream {
913 RequesterEventStream { event_receiver: self.client.take_event_receiver() }
914 }
915
916 pub fn r#request(
947 &self,
948 mut mode: SystemMode,
949 mut set: bool,
950 ) -> fidl::client::QueryResponseFut<
951 RequesterRequestResult,
952 fidl::encoding::DefaultFuchsiaResourceDialect,
953 > {
954 RequesterProxyInterface::r#request(self, mode, set)
955 }
956}
957
958impl RequesterProxyInterface for RequesterProxy {
959 type RequestResponseFut = fidl::client::QueryResponseFut<
960 RequesterRequestResult,
961 fidl::encoding::DefaultFuchsiaResourceDialect,
962 >;
963 fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
964 fn _decode(
965 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
966 ) -> Result<RequesterRequestResult, fidl::Error> {
967 let _response = fidl::client::decode_transaction_body::<
968 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
969 fidl::encoding::DefaultFuchsiaResourceDialect,
970 0x5603afcd4421f425,
971 >(_buf?)?;
972 Ok(_response.map(|x| x))
973 }
974 self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
975 (mode, set),
976 0x5603afcd4421f425,
977 fidl::encoding::DynamicFlags::empty(),
978 _decode,
979 )
980 }
981}
982
983pub struct RequesterEventStream {
984 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
985}
986
987impl std::marker::Unpin for RequesterEventStream {}
988
989impl futures::stream::FusedStream for RequesterEventStream {
990 fn is_terminated(&self) -> bool {
991 self.event_receiver.is_terminated()
992 }
993}
994
995impl futures::Stream for RequesterEventStream {
996 type Item = Result<RequesterEvent, fidl::Error>;
997
998 fn poll_next(
999 mut self: std::pin::Pin<&mut Self>,
1000 cx: &mut std::task::Context<'_>,
1001 ) -> std::task::Poll<Option<Self::Item>> {
1002 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1003 &mut self.event_receiver,
1004 cx
1005 )?) {
1006 Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
1007 None => std::task::Poll::Ready(None),
1008 }
1009 }
1010}
1011
1012#[derive(Debug)]
1013pub enum RequesterEvent {}
1014
1015impl RequesterEvent {
1016 fn decode(
1018 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1019 ) -> Result<RequesterEvent, fidl::Error> {
1020 let (bytes, _handles) = buf.split_mut();
1021 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1022 debug_assert_eq!(tx_header.tx_id, 0);
1023 match tx_header.ordinal {
1024 _ => Err(fidl::Error::UnknownOrdinal {
1025 ordinal: tx_header.ordinal,
1026 protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1027 }),
1028 }
1029 }
1030}
1031
1032pub struct RequesterRequestStream {
1034 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1035 is_terminated: bool,
1036}
1037
1038impl std::marker::Unpin for RequesterRequestStream {}
1039
1040impl futures::stream::FusedStream for RequesterRequestStream {
1041 fn is_terminated(&self) -> bool {
1042 self.is_terminated
1043 }
1044}
1045
1046impl fidl::endpoints::RequestStream for RequesterRequestStream {
1047 type Protocol = RequesterMarker;
1048 type ControlHandle = RequesterControlHandle;
1049
1050 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1051 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1052 }
1053
1054 fn control_handle(&self) -> Self::ControlHandle {
1055 RequesterControlHandle { inner: self.inner.clone() }
1056 }
1057
1058 fn into_inner(
1059 self,
1060 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1061 {
1062 (self.inner, self.is_terminated)
1063 }
1064
1065 fn from_inner(
1066 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1067 is_terminated: bool,
1068 ) -> Self {
1069 Self { inner, is_terminated }
1070 }
1071}
1072
1073impl futures::Stream for RequesterRequestStream {
1074 type Item = Result<RequesterRequest, 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 let this = &mut *self;
1081 if this.inner.check_shutdown(cx) {
1082 this.is_terminated = true;
1083 return std::task::Poll::Ready(None);
1084 }
1085 if this.is_terminated {
1086 panic!("polled RequesterRequestStream after completion");
1087 }
1088 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1089 |bytes, handles| {
1090 match this.inner.channel().read_etc(cx, bytes, handles) {
1091 std::task::Poll::Ready(Ok(())) => {}
1092 std::task::Poll::Pending => return std::task::Poll::Pending,
1093 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1094 this.is_terminated = true;
1095 return std::task::Poll::Ready(None);
1096 }
1097 std::task::Poll::Ready(Err(e)) => {
1098 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1099 e.into(),
1100 ))));
1101 }
1102 }
1103
1104 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1106
1107 std::task::Poll::Ready(Some(match header.ordinal {
1108 0x5603afcd4421f425 => {
1109 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1110 let mut req = fidl::new_empty!(
1111 RequesterRequestRequest,
1112 fidl::encoding::DefaultFuchsiaResourceDialect
1113 );
1114 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1115 let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1116 Ok(RequesterRequest::Request {
1117 mode: req.mode,
1118 set: req.set,
1119
1120 responder: RequesterRequestResponder {
1121 control_handle: std::mem::ManuallyDrop::new(control_handle),
1122 tx_id: header.tx_id,
1123 },
1124 })
1125 }
1126 _ => Err(fidl::Error::UnknownOrdinal {
1127 ordinal: header.ordinal,
1128 protocol_name:
1129 <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1130 }),
1131 }))
1132 },
1133 )
1134 }
1135}
1136
1137#[derive(Debug)]
1140pub enum RequesterRequest {
1141 Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1172}
1173
1174impl RequesterRequest {
1175 #[allow(irrefutable_let_patterns)]
1176 pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1177 if let RequesterRequest::Request { mode, set, responder } = self {
1178 Some((mode, set, responder))
1179 } else {
1180 None
1181 }
1182 }
1183
1184 pub fn method_name(&self) -> &'static str {
1186 match *self {
1187 RequesterRequest::Request { .. } => "request",
1188 }
1189 }
1190}
1191
1192#[derive(Debug, Clone)]
1193pub struct RequesterControlHandle {
1194 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1195}
1196
1197impl RequesterControlHandle {
1198 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1199 self.inner.shutdown_with_epitaph(status.into())
1200 }
1201}
1202
1203impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1204 fn shutdown(&self) {
1205 self.inner.shutdown()
1206 }
1207
1208 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1209 self.inner.shutdown_with_epitaph(status)
1210 }
1211
1212 fn is_closed(&self) -> bool {
1213 self.inner.channel().is_closed()
1214 }
1215 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1216 self.inner.channel().on_closed()
1217 }
1218
1219 #[cfg(target_os = "fuchsia")]
1220 fn signal_peer(
1221 &self,
1222 clear_mask: zx::Signals,
1223 set_mask: zx::Signals,
1224 ) -> Result<(), zx_status::Status> {
1225 use fidl::Peered;
1226 self.inner.channel().signal_peer(clear_mask, set_mask)
1227 }
1228}
1229
1230impl RequesterControlHandle {}
1231
1232#[must_use = "FIDL methods require a response to be sent"]
1233#[derive(Debug)]
1234pub struct RequesterRequestResponder {
1235 control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1236 tx_id: u32,
1237}
1238
1239impl std::ops::Drop for RequesterRequestResponder {
1243 fn drop(&mut self) {
1244 self.control_handle.shutdown();
1245 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1247 }
1248}
1249
1250impl fidl::endpoints::Responder for RequesterRequestResponder {
1251 type ControlHandle = RequesterControlHandle;
1252
1253 fn control_handle(&self) -> &RequesterControlHandle {
1254 &self.control_handle
1255 }
1256
1257 fn drop_without_shutdown(mut self) {
1258 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1260 std::mem::forget(self);
1262 }
1263}
1264
1265impl RequesterRequestResponder {
1266 pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1270 let _result = self.send_raw(result);
1271 if _result.is_err() {
1272 self.control_handle.shutdown();
1273 }
1274 self.drop_without_shutdown();
1275 _result
1276 }
1277
1278 pub fn send_no_shutdown_on_err(
1280 self,
1281 mut result: Result<(), ModeRequestError>,
1282 ) -> Result<(), fidl::Error> {
1283 let _result = self.send_raw(result);
1284 self.drop_without_shutdown();
1285 _result
1286 }
1287
1288 fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1289 self.control_handle.inner.send::<fidl::encoding::ResultType<
1290 fidl::encoding::EmptyStruct,
1291 ModeRequestError,
1292 >>(
1293 result,
1294 self.tx_id,
1295 0x5603afcd4421f425,
1296 fidl::encoding::DynamicFlags::empty(),
1297 )
1298 }
1299}
1300
1301mod internal {
1302 use super::*;
1303}