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 let protocol_name =
69 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
70 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
71 }
72
73 pub fn into_channel(self) -> fidl::Channel {
74 self.client.into_channel()
75 }
76
77 pub fn wait_for_event(
80 &self,
81 deadline: zx::MonotonicInstant,
82 ) -> Result<ClientConfiguratorEvent, fidl::Error> {
83 ClientConfiguratorEvent::decode(self.client.wait_for_event(deadline)?)
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 =
100 self.client.send_query::<ClientConfiguratorGetRequest, ClientConfiguratorGetResponse>(
101 (client_type,),
102 0x1e37597b4d247d7b,
103 fidl::encoding::DynamicFlags::empty(),
104 ___deadline,
105 )?;
106 Ok(_response.config)
107 }
108
109 pub fn r#set(
135 &self,
136 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
137 mut config: &ClientConfig,
138 ___deadline: zx::MonotonicInstant,
139 ) -> Result<(), fidl::Error> {
140 let _response =
141 self.client.send_query::<ClientConfiguratorSetRequest, fidl::encoding::EmptyPayload>(
142 (client_type, config),
143 0x2204fb91b32f6435,
144 fidl::encoding::DynamicFlags::empty(),
145 ___deadline,
146 )?;
147 Ok(_response)
148 }
149}
150
151#[cfg(target_os = "fuchsia")]
152impl From<ClientConfiguratorSynchronousProxy> for zx::NullableHandle {
153 fn from(value: ClientConfiguratorSynchronousProxy) -> Self {
154 value.into_channel().into()
155 }
156}
157
158#[cfg(target_os = "fuchsia")]
159impl From<fidl::Channel> for ClientConfiguratorSynchronousProxy {
160 fn from(value: fidl::Channel) -> Self {
161 Self::new(value)
162 }
163}
164
165#[cfg(target_os = "fuchsia")]
166impl fidl::endpoints::FromClient for ClientConfiguratorSynchronousProxy {
167 type Protocol = ClientConfiguratorMarker;
168
169 fn from_client(value: fidl::endpoints::ClientEnd<ClientConfiguratorMarker>) -> Self {
170 Self::new(value.into_channel())
171 }
172}
173
174#[derive(Debug, Clone)]
175pub struct ClientConfiguratorProxy {
176 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
177}
178
179impl fidl::endpoints::Proxy for ClientConfiguratorProxy {
180 type Protocol = ClientConfiguratorMarker;
181
182 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
183 Self::new(inner)
184 }
185
186 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
187 self.client.into_channel().map_err(|client| Self { client })
188 }
189
190 fn as_channel(&self) -> &::fidl::AsyncChannel {
191 self.client.as_channel()
192 }
193}
194
195impl ClientConfiguratorProxy {
196 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
198 let protocol_name =
199 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
200 Self { client: fidl::client::Client::new(channel, protocol_name) }
201 }
202
203 pub fn take_event_stream(&self) -> ClientConfiguratorEventStream {
209 ClientConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
210 }
211
212 pub fn r#get(
221 &self,
222 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
223 ) -> fidl::client::QueryResponseFut<
224 Option<Box<ClientConfig>>,
225 fidl::encoding::DefaultFuchsiaResourceDialect,
226 > {
227 ClientConfiguratorProxyInterface::r#get(self, client_type)
228 }
229
230 pub fn r#set(
256 &self,
257 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
258 mut config: &ClientConfig,
259 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
260 ClientConfiguratorProxyInterface::r#set(self, client_type, config)
261 }
262}
263
264impl ClientConfiguratorProxyInterface for ClientConfiguratorProxy {
265 type GetResponseFut = fidl::client::QueryResponseFut<
266 Option<Box<ClientConfig>>,
267 fidl::encoding::DefaultFuchsiaResourceDialect,
268 >;
269 fn r#get(
270 &self,
271 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
272 ) -> Self::GetResponseFut {
273 fn _decode(
274 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
275 ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
276 let _response = fidl::client::decode_transaction_body::<
277 ClientConfiguratorGetResponse,
278 fidl::encoding::DefaultFuchsiaResourceDialect,
279 0x1e37597b4d247d7b,
280 >(_buf?)?;
281 Ok(_response.config)
282 }
283 self.client
284 .send_query_and_decode::<ClientConfiguratorGetRequest, Option<Box<ClientConfig>>>(
285 (client_type,),
286 0x1e37597b4d247d7b,
287 fidl::encoding::DynamicFlags::empty(),
288 _decode,
289 )
290 }
291
292 type SetResponseFut =
293 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
294 fn r#set(
295 &self,
296 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
297 mut config: &ClientConfig,
298 ) -> Self::SetResponseFut {
299 fn _decode(
300 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
301 ) -> Result<(), fidl::Error> {
302 let _response = fidl::client::decode_transaction_body::<
303 fidl::encoding::EmptyPayload,
304 fidl::encoding::DefaultFuchsiaResourceDialect,
305 0x2204fb91b32f6435,
306 >(_buf?)?;
307 Ok(_response)
308 }
309 self.client.send_query_and_decode::<ClientConfiguratorSetRequest, ()>(
310 (client_type, config),
311 0x2204fb91b32f6435,
312 fidl::encoding::DynamicFlags::empty(),
313 _decode,
314 )
315 }
316}
317
318pub struct ClientConfiguratorEventStream {
319 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
320}
321
322impl std::marker::Unpin for ClientConfiguratorEventStream {}
323
324impl futures::stream::FusedStream for ClientConfiguratorEventStream {
325 fn is_terminated(&self) -> bool {
326 self.event_receiver.is_terminated()
327 }
328}
329
330impl futures::Stream for ClientConfiguratorEventStream {
331 type Item = Result<ClientConfiguratorEvent, fidl::Error>;
332
333 fn poll_next(
334 mut self: std::pin::Pin<&mut Self>,
335 cx: &mut std::task::Context<'_>,
336 ) -> std::task::Poll<Option<Self::Item>> {
337 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
338 &mut self.event_receiver,
339 cx
340 )?) {
341 Some(buf) => std::task::Poll::Ready(Some(ClientConfiguratorEvent::decode(buf))),
342 None => std::task::Poll::Ready(None),
343 }
344 }
345}
346
347#[derive(Debug)]
348pub enum ClientConfiguratorEvent {}
349
350impl ClientConfiguratorEvent {
351 fn decode(
353 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
354 ) -> Result<ClientConfiguratorEvent, fidl::Error> {
355 let (bytes, _handles) = buf.split_mut();
356 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
357 debug_assert_eq!(tx_header.tx_id, 0);
358 match tx_header.ordinal {
359 _ => Err(fidl::Error::UnknownOrdinal {
360 ordinal: tx_header.ordinal,
361 protocol_name:
362 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
363 }),
364 }
365 }
366}
367
368pub struct ClientConfiguratorRequestStream {
370 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
371 is_terminated: bool,
372}
373
374impl std::marker::Unpin for ClientConfiguratorRequestStream {}
375
376impl futures::stream::FusedStream for ClientConfiguratorRequestStream {
377 fn is_terminated(&self) -> bool {
378 self.is_terminated
379 }
380}
381
382impl fidl::endpoints::RequestStream for ClientConfiguratorRequestStream {
383 type Protocol = ClientConfiguratorMarker;
384 type ControlHandle = ClientConfiguratorControlHandle;
385
386 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
387 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
388 }
389
390 fn control_handle(&self) -> Self::ControlHandle {
391 ClientConfiguratorControlHandle { inner: self.inner.clone() }
392 }
393
394 fn into_inner(
395 self,
396 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
397 {
398 (self.inner, self.is_terminated)
399 }
400
401 fn from_inner(
402 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
403 is_terminated: bool,
404 ) -> Self {
405 Self { inner, is_terminated }
406 }
407}
408
409impl futures::Stream for ClientConfiguratorRequestStream {
410 type Item = Result<ClientConfiguratorRequest, fidl::Error>;
411
412 fn poll_next(
413 mut self: std::pin::Pin<&mut Self>,
414 cx: &mut std::task::Context<'_>,
415 ) -> std::task::Poll<Option<Self::Item>> {
416 let this = &mut *self;
417 if this.inner.check_shutdown(cx) {
418 this.is_terminated = true;
419 return std::task::Poll::Ready(None);
420 }
421 if this.is_terminated {
422 panic!("polled ClientConfiguratorRequestStream after completion");
423 }
424 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
425 |bytes, handles| {
426 match this.inner.channel().read_etc(cx, bytes, handles) {
427 std::task::Poll::Ready(Ok(())) => {}
428 std::task::Poll::Pending => return std::task::Poll::Pending,
429 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
430 this.is_terminated = true;
431 return std::task::Poll::Ready(None);
432 }
433 std::task::Poll::Ready(Err(e)) => {
434 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
435 e.into(),
436 ))));
437 }
438 }
439
440 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
442
443 std::task::Poll::Ready(Some(match header.ordinal {
444 0x1e37597b4d247d7b => {
445 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
446 let mut req = fidl::new_empty!(ClientConfiguratorGetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
447 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorGetRequest>(&header, _body_bytes, handles, &mut req)?;
448 let control_handle = ClientConfiguratorControlHandle {
449 inner: this.inner.clone(),
450 };
451 Ok(ClientConfiguratorRequest::Get {client_type: req.client_type,
452
453 responder: ClientConfiguratorGetResponder {
454 control_handle: std::mem::ManuallyDrop::new(control_handle),
455 tx_id: header.tx_id,
456 },
457 })
458 }
459 0x2204fb91b32f6435 => {
460 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
461 let mut req = fidl::new_empty!(ClientConfiguratorSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
462 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorSetRequest>(&header, _body_bytes, handles, &mut req)?;
463 let control_handle = ClientConfiguratorControlHandle {
464 inner: this.inner.clone(),
465 };
466 Ok(ClientConfiguratorRequest::Set {client_type: req.client_type,
467config: req.config,
468
469 responder: ClientConfiguratorSetResponder {
470 control_handle: std::mem::ManuallyDrop::new(control_handle),
471 tx_id: header.tx_id,
472 },
473 })
474 }
475 _ => Err(fidl::Error::UnknownOrdinal {
476 ordinal: header.ordinal,
477 protocol_name: <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
478 }),
479 }))
480 },
481 )
482 }
483}
484
485#[derive(Debug)]
488pub enum ClientConfiguratorRequest {
489 Get {
498 client_type: fidl_fuchsia_power_clientlevel::ClientType,
499 responder: ClientConfiguratorGetResponder,
500 },
501 Set {
527 client_type: fidl_fuchsia_power_clientlevel::ClientType,
528 config: ClientConfig,
529 responder: ClientConfiguratorSetResponder,
530 },
531}
532
533impl ClientConfiguratorRequest {
534 #[allow(irrefutable_let_patterns)]
535 pub fn into_get(
536 self,
537 ) -> Option<(fidl_fuchsia_power_clientlevel::ClientType, ClientConfiguratorGetResponder)> {
538 if let ClientConfiguratorRequest::Get { client_type, responder } = self {
539 Some((client_type, responder))
540 } else {
541 None
542 }
543 }
544
545 #[allow(irrefutable_let_patterns)]
546 pub fn into_set(
547 self,
548 ) -> Option<(
549 fidl_fuchsia_power_clientlevel::ClientType,
550 ClientConfig,
551 ClientConfiguratorSetResponder,
552 )> {
553 if let ClientConfiguratorRequest::Set { client_type, config, responder } = self {
554 Some((client_type, config, responder))
555 } else {
556 None
557 }
558 }
559
560 pub fn method_name(&self) -> &'static str {
562 match *self {
563 ClientConfiguratorRequest::Get { .. } => "get",
564 ClientConfiguratorRequest::Set { .. } => "set",
565 }
566 }
567}
568
569#[derive(Debug, Clone)]
570pub struct ClientConfiguratorControlHandle {
571 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
572}
573
574impl fidl::endpoints::ControlHandle for ClientConfiguratorControlHandle {
575 fn shutdown(&self) {
576 self.inner.shutdown()
577 }
578
579 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
580 self.inner.shutdown_with_epitaph(status)
581 }
582
583 fn is_closed(&self) -> bool {
584 self.inner.channel().is_closed()
585 }
586 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
587 self.inner.channel().on_closed()
588 }
589
590 #[cfg(target_os = "fuchsia")]
591 fn signal_peer(
592 &self,
593 clear_mask: zx::Signals,
594 set_mask: zx::Signals,
595 ) -> Result<(), zx_status::Status> {
596 use fidl::Peered;
597 self.inner.channel().signal_peer(clear_mask, set_mask)
598 }
599}
600
601impl ClientConfiguratorControlHandle {}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct ClientConfiguratorGetResponder {
606 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
607 tx_id: u32,
608}
609
610impl std::ops::Drop for ClientConfiguratorGetResponder {
614 fn drop(&mut self) {
615 self.control_handle.shutdown();
616 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618 }
619}
620
621impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
622 type ControlHandle = ClientConfiguratorControlHandle;
623
624 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
625 &self.control_handle
626 }
627
628 fn drop_without_shutdown(mut self) {
629 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631 std::mem::forget(self);
633 }
634}
635
636impl ClientConfiguratorGetResponder {
637 pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
641 let _result = self.send_raw(config);
642 if _result.is_err() {
643 self.control_handle.shutdown();
644 }
645 self.drop_without_shutdown();
646 _result
647 }
648
649 pub fn send_no_shutdown_on_err(
651 self,
652 mut config: Option<&ClientConfig>,
653 ) -> Result<(), fidl::Error> {
654 let _result = self.send_raw(config);
655 self.drop_without_shutdown();
656 _result
657 }
658
659 fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
660 self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
661 (config,),
662 self.tx_id,
663 0x1e37597b4d247d7b,
664 fidl::encoding::DynamicFlags::empty(),
665 )
666 }
667}
668
669#[must_use = "FIDL methods require a response to be sent"]
670#[derive(Debug)]
671pub struct ClientConfiguratorSetResponder {
672 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
673 tx_id: u32,
674}
675
676impl std::ops::Drop for ClientConfiguratorSetResponder {
680 fn drop(&mut self) {
681 self.control_handle.shutdown();
682 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
684 }
685}
686
687impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
688 type ControlHandle = ClientConfiguratorControlHandle;
689
690 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
691 &self.control_handle
692 }
693
694 fn drop_without_shutdown(mut self) {
695 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
697 std::mem::forget(self);
699 }
700}
701
702impl ClientConfiguratorSetResponder {
703 pub fn send(self) -> Result<(), fidl::Error> {
707 let _result = self.send_raw();
708 if _result.is_err() {
709 self.control_handle.shutdown();
710 }
711 self.drop_without_shutdown();
712 _result
713 }
714
715 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
717 let _result = self.send_raw();
718 self.drop_without_shutdown();
719 _result
720 }
721
722 fn send_raw(&self) -> Result<(), fidl::Error> {
723 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
724 (),
725 self.tx_id,
726 0x2204fb91b32f6435,
727 fidl::encoding::DynamicFlags::empty(),
728 )
729 }
730}
731
732#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
733pub struct RequesterMarker;
734
735impl fidl::endpoints::ProtocolMarker for RequesterMarker {
736 type Proxy = RequesterProxy;
737 type RequestStream = RequesterRequestStream;
738 #[cfg(target_os = "fuchsia")]
739 type SynchronousProxy = RequesterSynchronousProxy;
740
741 const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
742}
743impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
744pub type RequesterRequestResult = Result<(), ModeRequestError>;
745
746pub trait RequesterProxyInterface: Send + Sync {
747 type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
748 + Send;
749 fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
750}
751#[derive(Debug)]
752#[cfg(target_os = "fuchsia")]
753pub struct RequesterSynchronousProxy {
754 client: fidl::client::sync::Client,
755}
756
757#[cfg(target_os = "fuchsia")]
758impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
759 type Proxy = RequesterProxy;
760 type Protocol = RequesterMarker;
761
762 fn from_channel(inner: fidl::Channel) -> Self {
763 Self::new(inner)
764 }
765
766 fn into_channel(self) -> fidl::Channel {
767 self.client.into_channel()
768 }
769
770 fn as_channel(&self) -> &fidl::Channel {
771 self.client.as_channel()
772 }
773}
774
775#[cfg(target_os = "fuchsia")]
776impl RequesterSynchronousProxy {
777 pub fn new(channel: fidl::Channel) -> Self {
778 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
779 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
780 }
781
782 pub fn into_channel(self) -> fidl::Channel {
783 self.client.into_channel()
784 }
785
786 pub fn wait_for_event(
789 &self,
790 deadline: zx::MonotonicInstant,
791 ) -> Result<RequesterEvent, fidl::Error> {
792 RequesterEvent::decode(self.client.wait_for_event(deadline)?)
793 }
794
795 pub fn r#request(
826 &self,
827 mut mode: SystemMode,
828 mut set: bool,
829 ___deadline: zx::MonotonicInstant,
830 ) -> Result<RequesterRequestResult, fidl::Error> {
831 let _response = self.client.send_query::<
832 RequesterRequestRequest,
833 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
834 >(
835 (mode, set,),
836 0x5603afcd4421f425,
837 fidl::encoding::DynamicFlags::empty(),
838 ___deadline,
839 )?;
840 Ok(_response.map(|x| x))
841 }
842}
843
844#[cfg(target_os = "fuchsia")]
845impl From<RequesterSynchronousProxy> for zx::NullableHandle {
846 fn from(value: RequesterSynchronousProxy) -> Self {
847 value.into_channel().into()
848 }
849}
850
851#[cfg(target_os = "fuchsia")]
852impl From<fidl::Channel> for RequesterSynchronousProxy {
853 fn from(value: fidl::Channel) -> Self {
854 Self::new(value)
855 }
856}
857
858#[cfg(target_os = "fuchsia")]
859impl fidl::endpoints::FromClient for RequesterSynchronousProxy {
860 type Protocol = RequesterMarker;
861
862 fn from_client(value: fidl::endpoints::ClientEnd<RequesterMarker>) -> Self {
863 Self::new(value.into_channel())
864 }
865}
866
867#[derive(Debug, Clone)]
868pub struct RequesterProxy {
869 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
870}
871
872impl fidl::endpoints::Proxy for RequesterProxy {
873 type Protocol = RequesterMarker;
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 RequesterProxy {
889 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
891 let protocol_name = <RequesterMarker 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) -> RequesterEventStream {
901 RequesterEventStream { event_receiver: self.client.take_event_receiver() }
902 }
903
904 pub fn r#request(
935 &self,
936 mut mode: SystemMode,
937 mut set: bool,
938 ) -> fidl::client::QueryResponseFut<
939 RequesterRequestResult,
940 fidl::encoding::DefaultFuchsiaResourceDialect,
941 > {
942 RequesterProxyInterface::r#request(self, mode, set)
943 }
944}
945
946impl RequesterProxyInterface for RequesterProxy {
947 type RequestResponseFut = fidl::client::QueryResponseFut<
948 RequesterRequestResult,
949 fidl::encoding::DefaultFuchsiaResourceDialect,
950 >;
951 fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
952 fn _decode(
953 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
954 ) -> Result<RequesterRequestResult, fidl::Error> {
955 let _response = fidl::client::decode_transaction_body::<
956 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
957 fidl::encoding::DefaultFuchsiaResourceDialect,
958 0x5603afcd4421f425,
959 >(_buf?)?;
960 Ok(_response.map(|x| x))
961 }
962 self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
963 (mode, set),
964 0x5603afcd4421f425,
965 fidl::encoding::DynamicFlags::empty(),
966 _decode,
967 )
968 }
969}
970
971pub struct RequesterEventStream {
972 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
973}
974
975impl std::marker::Unpin for RequesterEventStream {}
976
977impl futures::stream::FusedStream for RequesterEventStream {
978 fn is_terminated(&self) -> bool {
979 self.event_receiver.is_terminated()
980 }
981}
982
983impl futures::Stream for RequesterEventStream {
984 type Item = Result<RequesterEvent, fidl::Error>;
985
986 fn poll_next(
987 mut self: std::pin::Pin<&mut Self>,
988 cx: &mut std::task::Context<'_>,
989 ) -> std::task::Poll<Option<Self::Item>> {
990 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
991 &mut self.event_receiver,
992 cx
993 )?) {
994 Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
995 None => std::task::Poll::Ready(None),
996 }
997 }
998}
999
1000#[derive(Debug)]
1001pub enum RequesterEvent {}
1002
1003impl RequesterEvent {
1004 fn decode(
1006 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1007 ) -> Result<RequesterEvent, fidl::Error> {
1008 let (bytes, _handles) = buf.split_mut();
1009 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1010 debug_assert_eq!(tx_header.tx_id, 0);
1011 match tx_header.ordinal {
1012 _ => Err(fidl::Error::UnknownOrdinal {
1013 ordinal: tx_header.ordinal,
1014 protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1015 }),
1016 }
1017 }
1018}
1019
1020pub struct RequesterRequestStream {
1022 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1023 is_terminated: bool,
1024}
1025
1026impl std::marker::Unpin for RequesterRequestStream {}
1027
1028impl futures::stream::FusedStream for RequesterRequestStream {
1029 fn is_terminated(&self) -> bool {
1030 self.is_terminated
1031 }
1032}
1033
1034impl fidl::endpoints::RequestStream for RequesterRequestStream {
1035 type Protocol = RequesterMarker;
1036 type ControlHandle = RequesterControlHandle;
1037
1038 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1039 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1040 }
1041
1042 fn control_handle(&self) -> Self::ControlHandle {
1043 RequesterControlHandle { inner: self.inner.clone() }
1044 }
1045
1046 fn into_inner(
1047 self,
1048 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1049 {
1050 (self.inner, self.is_terminated)
1051 }
1052
1053 fn from_inner(
1054 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1055 is_terminated: bool,
1056 ) -> Self {
1057 Self { inner, is_terminated }
1058 }
1059}
1060
1061impl futures::Stream for RequesterRequestStream {
1062 type Item = Result<RequesterRequest, fidl::Error>;
1063
1064 fn poll_next(
1065 mut self: std::pin::Pin<&mut Self>,
1066 cx: &mut std::task::Context<'_>,
1067 ) -> std::task::Poll<Option<Self::Item>> {
1068 let this = &mut *self;
1069 if this.inner.check_shutdown(cx) {
1070 this.is_terminated = true;
1071 return std::task::Poll::Ready(None);
1072 }
1073 if this.is_terminated {
1074 panic!("polled RequesterRequestStream after completion");
1075 }
1076 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1077 |bytes, handles| {
1078 match this.inner.channel().read_etc(cx, bytes, handles) {
1079 std::task::Poll::Ready(Ok(())) => {}
1080 std::task::Poll::Pending => return std::task::Poll::Pending,
1081 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1082 this.is_terminated = true;
1083 return std::task::Poll::Ready(None);
1084 }
1085 std::task::Poll::Ready(Err(e)) => {
1086 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1087 e.into(),
1088 ))));
1089 }
1090 }
1091
1092 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1094
1095 std::task::Poll::Ready(Some(match header.ordinal {
1096 0x5603afcd4421f425 => {
1097 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1098 let mut req = fidl::new_empty!(
1099 RequesterRequestRequest,
1100 fidl::encoding::DefaultFuchsiaResourceDialect
1101 );
1102 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1103 let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1104 Ok(RequesterRequest::Request {
1105 mode: req.mode,
1106 set: req.set,
1107
1108 responder: RequesterRequestResponder {
1109 control_handle: std::mem::ManuallyDrop::new(control_handle),
1110 tx_id: header.tx_id,
1111 },
1112 })
1113 }
1114 _ => Err(fidl::Error::UnknownOrdinal {
1115 ordinal: header.ordinal,
1116 protocol_name:
1117 <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1118 }),
1119 }))
1120 },
1121 )
1122 }
1123}
1124
1125#[derive(Debug)]
1128pub enum RequesterRequest {
1129 Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1160}
1161
1162impl RequesterRequest {
1163 #[allow(irrefutable_let_patterns)]
1164 pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1165 if let RequesterRequest::Request { mode, set, responder } = self {
1166 Some((mode, set, responder))
1167 } else {
1168 None
1169 }
1170 }
1171
1172 pub fn method_name(&self) -> &'static str {
1174 match *self {
1175 RequesterRequest::Request { .. } => "request",
1176 }
1177 }
1178}
1179
1180#[derive(Debug, Clone)]
1181pub struct RequesterControlHandle {
1182 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1183}
1184
1185impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1186 fn shutdown(&self) {
1187 self.inner.shutdown()
1188 }
1189
1190 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1191 self.inner.shutdown_with_epitaph(status)
1192 }
1193
1194 fn is_closed(&self) -> bool {
1195 self.inner.channel().is_closed()
1196 }
1197 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1198 self.inner.channel().on_closed()
1199 }
1200
1201 #[cfg(target_os = "fuchsia")]
1202 fn signal_peer(
1203 &self,
1204 clear_mask: zx::Signals,
1205 set_mask: zx::Signals,
1206 ) -> Result<(), zx_status::Status> {
1207 use fidl::Peered;
1208 self.inner.channel().signal_peer(clear_mask, set_mask)
1209 }
1210}
1211
1212impl RequesterControlHandle {}
1213
1214#[must_use = "FIDL methods require a response to be sent"]
1215#[derive(Debug)]
1216pub struct RequesterRequestResponder {
1217 control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1218 tx_id: u32,
1219}
1220
1221impl std::ops::Drop for RequesterRequestResponder {
1225 fn drop(&mut self) {
1226 self.control_handle.shutdown();
1227 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1229 }
1230}
1231
1232impl fidl::endpoints::Responder for RequesterRequestResponder {
1233 type ControlHandle = RequesterControlHandle;
1234
1235 fn control_handle(&self) -> &RequesterControlHandle {
1236 &self.control_handle
1237 }
1238
1239 fn drop_without_shutdown(mut self) {
1240 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1242 std::mem::forget(self);
1244 }
1245}
1246
1247impl RequesterRequestResponder {
1248 pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1252 let _result = self.send_raw(result);
1253 if _result.is_err() {
1254 self.control_handle.shutdown();
1255 }
1256 self.drop_without_shutdown();
1257 _result
1258 }
1259
1260 pub fn send_no_shutdown_on_err(
1262 self,
1263 mut result: Result<(), ModeRequestError>,
1264 ) -> Result<(), fidl::Error> {
1265 let _result = self.send_raw(result);
1266 self.drop_without_shutdown();
1267 _result
1268 }
1269
1270 fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1271 self.control_handle.inner.send::<fidl::encoding::ResultType<
1272 fidl::encoding::EmptyStruct,
1273 ModeRequestError,
1274 >>(
1275 result,
1276 self.tx_id,
1277 0x5603afcd4421f425,
1278 fidl::encoding::DynamicFlags::empty(),
1279 )
1280 }
1281}
1282
1283mod internal {
1284 use super::*;
1285}