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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
579 self.inner.shutdown_with_epitaph(status)
580 }
581
582 fn is_closed(&self) -> bool {
583 self.inner.channel().is_closed()
584 }
585 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
586 self.inner.channel().on_closed()
587 }
588
589 #[cfg(target_os = "fuchsia")]
590 fn signal_peer(
591 &self,
592 clear_mask: zx::Signals,
593 set_mask: zx::Signals,
594 ) -> Result<(), zx_status::Status> {
595 use fidl::Peered;
596 self.inner.channel().signal_peer(clear_mask, set_mask)
597 }
598}
599
600impl ClientConfiguratorControlHandle {}
601
602#[must_use = "FIDL methods require a response to be sent"]
603#[derive(Debug)]
604pub struct ClientConfiguratorGetResponder {
605 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
606 tx_id: u32,
607}
608
609impl std::ops::Drop for ClientConfiguratorGetResponder {
613 fn drop(&mut self) {
614 self.control_handle.shutdown();
615 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
617 }
618}
619
620impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
621 type ControlHandle = ClientConfiguratorControlHandle;
622
623 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
624 &self.control_handle
625 }
626
627 fn drop_without_shutdown(mut self) {
628 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
630 std::mem::forget(self);
632 }
633}
634
635impl ClientConfiguratorGetResponder {
636 pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
640 let _result = self.send_raw(config);
641 if _result.is_err() {
642 self.control_handle.shutdown();
643 }
644 self.drop_without_shutdown();
645 _result
646 }
647
648 pub fn send_no_shutdown_on_err(
650 self,
651 mut config: Option<&ClientConfig>,
652 ) -> Result<(), fidl::Error> {
653 let _result = self.send_raw(config);
654 self.drop_without_shutdown();
655 _result
656 }
657
658 fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
659 self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
660 (config,),
661 self.tx_id,
662 0x1e37597b4d247d7b,
663 fidl::encoding::DynamicFlags::empty(),
664 )
665 }
666}
667
668#[must_use = "FIDL methods require a response to be sent"]
669#[derive(Debug)]
670pub struct ClientConfiguratorSetResponder {
671 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
672 tx_id: u32,
673}
674
675impl std::ops::Drop for ClientConfiguratorSetResponder {
679 fn drop(&mut self) {
680 self.control_handle.shutdown();
681 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
683 }
684}
685
686impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
687 type ControlHandle = ClientConfiguratorControlHandle;
688
689 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
690 &self.control_handle
691 }
692
693 fn drop_without_shutdown(mut self) {
694 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
696 std::mem::forget(self);
698 }
699}
700
701impl ClientConfiguratorSetResponder {
702 pub fn send(self) -> Result<(), fidl::Error> {
706 let _result = self.send_raw();
707 if _result.is_err() {
708 self.control_handle.shutdown();
709 }
710 self.drop_without_shutdown();
711 _result
712 }
713
714 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
716 let _result = self.send_raw();
717 self.drop_without_shutdown();
718 _result
719 }
720
721 fn send_raw(&self) -> Result<(), fidl::Error> {
722 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
723 (),
724 self.tx_id,
725 0x2204fb91b32f6435,
726 fidl::encoding::DynamicFlags::empty(),
727 )
728 }
729}
730
731#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
732pub struct RequesterMarker;
733
734impl fidl::endpoints::ProtocolMarker for RequesterMarker {
735 type Proxy = RequesterProxy;
736 type RequestStream = RequesterRequestStream;
737 #[cfg(target_os = "fuchsia")]
738 type SynchronousProxy = RequesterSynchronousProxy;
739
740 const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
741}
742impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
743pub type RequesterRequestResult = Result<(), ModeRequestError>;
744
745pub trait RequesterProxyInterface: Send + Sync {
746 type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
747 + Send;
748 fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
749}
750#[derive(Debug)]
751#[cfg(target_os = "fuchsia")]
752pub struct RequesterSynchronousProxy {
753 client: fidl::client::sync::Client,
754}
755
756#[cfg(target_os = "fuchsia")]
757impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
758 type Proxy = RequesterProxy;
759 type Protocol = RequesterMarker;
760
761 fn from_channel(inner: fidl::Channel) -> Self {
762 Self::new(inner)
763 }
764
765 fn into_channel(self) -> fidl::Channel {
766 self.client.into_channel()
767 }
768
769 fn as_channel(&self) -> &fidl::Channel {
770 self.client.as_channel()
771 }
772}
773
774#[cfg(target_os = "fuchsia")]
775impl RequesterSynchronousProxy {
776 pub fn new(channel: fidl::Channel) -> Self {
777 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
778 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
779 }
780
781 pub fn into_channel(self) -> fidl::Channel {
782 self.client.into_channel()
783 }
784
785 pub fn wait_for_event(
788 &self,
789 deadline: zx::MonotonicInstant,
790 ) -> Result<RequesterEvent, fidl::Error> {
791 RequesterEvent::decode(self.client.wait_for_event(deadline)?)
792 }
793
794 pub fn r#request(
825 &self,
826 mut mode: SystemMode,
827 mut set: bool,
828 ___deadline: zx::MonotonicInstant,
829 ) -> Result<RequesterRequestResult, fidl::Error> {
830 let _response = self.client.send_query::<
831 RequesterRequestRequest,
832 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
833 >(
834 (mode, set,),
835 0x5603afcd4421f425,
836 fidl::encoding::DynamicFlags::empty(),
837 ___deadline,
838 )?;
839 Ok(_response.map(|x| x))
840 }
841}
842
843#[cfg(target_os = "fuchsia")]
844impl From<RequesterSynchronousProxy> for zx::Handle {
845 fn from(value: RequesterSynchronousProxy) -> Self {
846 value.into_channel().into()
847 }
848}
849
850#[cfg(target_os = "fuchsia")]
851impl From<fidl::Channel> for RequesterSynchronousProxy {
852 fn from(value: fidl::Channel) -> Self {
853 Self::new(value)
854 }
855}
856
857#[cfg(target_os = "fuchsia")]
858impl fidl::endpoints::FromClient for RequesterSynchronousProxy {
859 type Protocol = RequesterMarker;
860
861 fn from_client(value: fidl::endpoints::ClientEnd<RequesterMarker>) -> Self {
862 Self::new(value.into_channel())
863 }
864}
865
866#[derive(Debug, Clone)]
867pub struct RequesterProxy {
868 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
869}
870
871impl fidl::endpoints::Proxy for RequesterProxy {
872 type Protocol = RequesterMarker;
873
874 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
875 Self::new(inner)
876 }
877
878 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
879 self.client.into_channel().map_err(|client| Self { client })
880 }
881
882 fn as_channel(&self) -> &::fidl::AsyncChannel {
883 self.client.as_channel()
884 }
885}
886
887impl RequesterProxy {
888 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
890 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
891 Self { client: fidl::client::Client::new(channel, protocol_name) }
892 }
893
894 pub fn take_event_stream(&self) -> RequesterEventStream {
900 RequesterEventStream { event_receiver: self.client.take_event_receiver() }
901 }
902
903 pub fn r#request(
934 &self,
935 mut mode: SystemMode,
936 mut set: bool,
937 ) -> fidl::client::QueryResponseFut<
938 RequesterRequestResult,
939 fidl::encoding::DefaultFuchsiaResourceDialect,
940 > {
941 RequesterProxyInterface::r#request(self, mode, set)
942 }
943}
944
945impl RequesterProxyInterface for RequesterProxy {
946 type RequestResponseFut = fidl::client::QueryResponseFut<
947 RequesterRequestResult,
948 fidl::encoding::DefaultFuchsiaResourceDialect,
949 >;
950 fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
951 fn _decode(
952 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
953 ) -> Result<RequesterRequestResult, fidl::Error> {
954 let _response = fidl::client::decode_transaction_body::<
955 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
956 fidl::encoding::DefaultFuchsiaResourceDialect,
957 0x5603afcd4421f425,
958 >(_buf?)?;
959 Ok(_response.map(|x| x))
960 }
961 self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
962 (mode, set),
963 0x5603afcd4421f425,
964 fidl::encoding::DynamicFlags::empty(),
965 _decode,
966 )
967 }
968}
969
970pub struct RequesterEventStream {
971 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
972}
973
974impl std::marker::Unpin for RequesterEventStream {}
975
976impl futures::stream::FusedStream for RequesterEventStream {
977 fn is_terminated(&self) -> bool {
978 self.event_receiver.is_terminated()
979 }
980}
981
982impl futures::Stream for RequesterEventStream {
983 type Item = Result<RequesterEvent, fidl::Error>;
984
985 fn poll_next(
986 mut self: std::pin::Pin<&mut Self>,
987 cx: &mut std::task::Context<'_>,
988 ) -> std::task::Poll<Option<Self::Item>> {
989 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
990 &mut self.event_receiver,
991 cx
992 )?) {
993 Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
994 None => std::task::Poll::Ready(None),
995 }
996 }
997}
998
999#[derive(Debug)]
1000pub enum RequesterEvent {}
1001
1002impl RequesterEvent {
1003 fn decode(
1005 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1006 ) -> Result<RequesterEvent, fidl::Error> {
1007 let (bytes, _handles) = buf.split_mut();
1008 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1009 debug_assert_eq!(tx_header.tx_id, 0);
1010 match tx_header.ordinal {
1011 _ => Err(fidl::Error::UnknownOrdinal {
1012 ordinal: tx_header.ordinal,
1013 protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1014 }),
1015 }
1016 }
1017}
1018
1019pub struct RequesterRequestStream {
1021 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1022 is_terminated: bool,
1023}
1024
1025impl std::marker::Unpin for RequesterRequestStream {}
1026
1027impl futures::stream::FusedStream for RequesterRequestStream {
1028 fn is_terminated(&self) -> bool {
1029 self.is_terminated
1030 }
1031}
1032
1033impl fidl::endpoints::RequestStream for RequesterRequestStream {
1034 type Protocol = RequesterMarker;
1035 type ControlHandle = RequesterControlHandle;
1036
1037 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1038 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1039 }
1040
1041 fn control_handle(&self) -> Self::ControlHandle {
1042 RequesterControlHandle { inner: self.inner.clone() }
1043 }
1044
1045 fn into_inner(
1046 self,
1047 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1048 {
1049 (self.inner, self.is_terminated)
1050 }
1051
1052 fn from_inner(
1053 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1054 is_terminated: bool,
1055 ) -> Self {
1056 Self { inner, is_terminated }
1057 }
1058}
1059
1060impl futures::Stream for RequesterRequestStream {
1061 type Item = Result<RequesterRequest, fidl::Error>;
1062
1063 fn poll_next(
1064 mut self: std::pin::Pin<&mut Self>,
1065 cx: &mut std::task::Context<'_>,
1066 ) -> std::task::Poll<Option<Self::Item>> {
1067 let this = &mut *self;
1068 if this.inner.check_shutdown(cx) {
1069 this.is_terminated = true;
1070 return std::task::Poll::Ready(None);
1071 }
1072 if this.is_terminated {
1073 panic!("polled RequesterRequestStream after completion");
1074 }
1075 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1076 |bytes, handles| {
1077 match this.inner.channel().read_etc(cx, bytes, handles) {
1078 std::task::Poll::Ready(Ok(())) => {}
1079 std::task::Poll::Pending => return std::task::Poll::Pending,
1080 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1081 this.is_terminated = true;
1082 return std::task::Poll::Ready(None);
1083 }
1084 std::task::Poll::Ready(Err(e)) => {
1085 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1086 e.into(),
1087 ))))
1088 }
1089 }
1090
1091 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1093
1094 std::task::Poll::Ready(Some(match header.ordinal {
1095 0x5603afcd4421f425 => {
1096 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1097 let mut req = fidl::new_empty!(
1098 RequesterRequestRequest,
1099 fidl::encoding::DefaultFuchsiaResourceDialect
1100 );
1101 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1102 let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1103 Ok(RequesterRequest::Request {
1104 mode: req.mode,
1105 set: req.set,
1106
1107 responder: RequesterRequestResponder {
1108 control_handle: std::mem::ManuallyDrop::new(control_handle),
1109 tx_id: header.tx_id,
1110 },
1111 })
1112 }
1113 _ => Err(fidl::Error::UnknownOrdinal {
1114 ordinal: header.ordinal,
1115 protocol_name:
1116 <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1117 }),
1118 }))
1119 },
1120 )
1121 }
1122}
1123
1124#[derive(Debug)]
1127pub enum RequesterRequest {
1128 Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1159}
1160
1161impl RequesterRequest {
1162 #[allow(irrefutable_let_patterns)]
1163 pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1164 if let RequesterRequest::Request { mode, set, responder } = self {
1165 Some((mode, set, responder))
1166 } else {
1167 None
1168 }
1169 }
1170
1171 pub fn method_name(&self) -> &'static str {
1173 match *self {
1174 RequesterRequest::Request { .. } => "request",
1175 }
1176 }
1177}
1178
1179#[derive(Debug, Clone)]
1180pub struct RequesterControlHandle {
1181 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1182}
1183
1184impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1185 fn shutdown(&self) {
1186 self.inner.shutdown()
1187 }
1188 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1189 self.inner.shutdown_with_epitaph(status)
1190 }
1191
1192 fn is_closed(&self) -> bool {
1193 self.inner.channel().is_closed()
1194 }
1195 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1196 self.inner.channel().on_closed()
1197 }
1198
1199 #[cfg(target_os = "fuchsia")]
1200 fn signal_peer(
1201 &self,
1202 clear_mask: zx::Signals,
1203 set_mask: zx::Signals,
1204 ) -> Result<(), zx_status::Status> {
1205 use fidl::Peered;
1206 self.inner.channel().signal_peer(clear_mask, set_mask)
1207 }
1208}
1209
1210impl RequesterControlHandle {}
1211
1212#[must_use = "FIDL methods require a response to be sent"]
1213#[derive(Debug)]
1214pub struct RequesterRequestResponder {
1215 control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1216 tx_id: u32,
1217}
1218
1219impl std::ops::Drop for RequesterRequestResponder {
1223 fn drop(&mut self) {
1224 self.control_handle.shutdown();
1225 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1227 }
1228}
1229
1230impl fidl::endpoints::Responder for RequesterRequestResponder {
1231 type ControlHandle = RequesterControlHandle;
1232
1233 fn control_handle(&self) -> &RequesterControlHandle {
1234 &self.control_handle
1235 }
1236
1237 fn drop_without_shutdown(mut self) {
1238 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1240 std::mem::forget(self);
1242 }
1243}
1244
1245impl RequesterRequestResponder {
1246 pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1250 let _result = self.send_raw(result);
1251 if _result.is_err() {
1252 self.control_handle.shutdown();
1253 }
1254 self.drop_without_shutdown();
1255 _result
1256 }
1257
1258 pub fn send_no_shutdown_on_err(
1260 self,
1261 mut result: Result<(), ModeRequestError>,
1262 ) -> Result<(), fidl::Error> {
1263 let _result = self.send_raw(result);
1264 self.drop_without_shutdown();
1265 _result
1266 }
1267
1268 fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1269 self.control_handle.inner.send::<fidl::encoding::ResultType<
1270 fidl::encoding::EmptyStruct,
1271 ModeRequestError,
1272 >>(
1273 result,
1274 self.tx_id,
1275 0x5603afcd4421f425,
1276 fidl::encoding::DynamicFlags::empty(),
1277 )
1278 }
1279}
1280
1281mod internal {
1282 use super::*;
1283}