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#[derive(Debug, Clone)]
152pub struct ClientConfiguratorProxy {
153 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
154}
155
156impl fidl::endpoints::Proxy for ClientConfiguratorProxy {
157 type Protocol = ClientConfiguratorMarker;
158
159 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
160 Self::new(inner)
161 }
162
163 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
164 self.client.into_channel().map_err(|client| Self { client })
165 }
166
167 fn as_channel(&self) -> &::fidl::AsyncChannel {
168 self.client.as_channel()
169 }
170}
171
172impl ClientConfiguratorProxy {
173 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
175 let protocol_name =
176 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
177 Self { client: fidl::client::Client::new(channel, protocol_name) }
178 }
179
180 pub fn take_event_stream(&self) -> ClientConfiguratorEventStream {
186 ClientConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
187 }
188
189 pub fn r#get(
198 &self,
199 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
200 ) -> fidl::client::QueryResponseFut<
201 Option<Box<ClientConfig>>,
202 fidl::encoding::DefaultFuchsiaResourceDialect,
203 > {
204 ClientConfiguratorProxyInterface::r#get(self, client_type)
205 }
206
207 pub fn r#set(
233 &self,
234 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
235 mut config: &ClientConfig,
236 ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
237 ClientConfiguratorProxyInterface::r#set(self, client_type, config)
238 }
239}
240
241impl ClientConfiguratorProxyInterface for ClientConfiguratorProxy {
242 type GetResponseFut = fidl::client::QueryResponseFut<
243 Option<Box<ClientConfig>>,
244 fidl::encoding::DefaultFuchsiaResourceDialect,
245 >;
246 fn r#get(
247 &self,
248 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
249 ) -> Self::GetResponseFut {
250 fn _decode(
251 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
252 ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
253 let _response = fidl::client::decode_transaction_body::<
254 ClientConfiguratorGetResponse,
255 fidl::encoding::DefaultFuchsiaResourceDialect,
256 0x1e37597b4d247d7b,
257 >(_buf?)?;
258 Ok(_response.config)
259 }
260 self.client
261 .send_query_and_decode::<ClientConfiguratorGetRequest, Option<Box<ClientConfig>>>(
262 (client_type,),
263 0x1e37597b4d247d7b,
264 fidl::encoding::DynamicFlags::empty(),
265 _decode,
266 )
267 }
268
269 type SetResponseFut =
270 fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
271 fn r#set(
272 &self,
273 mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
274 mut config: &ClientConfig,
275 ) -> Self::SetResponseFut {
276 fn _decode(
277 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
278 ) -> Result<(), fidl::Error> {
279 let _response = fidl::client::decode_transaction_body::<
280 fidl::encoding::EmptyPayload,
281 fidl::encoding::DefaultFuchsiaResourceDialect,
282 0x2204fb91b32f6435,
283 >(_buf?)?;
284 Ok(_response)
285 }
286 self.client.send_query_and_decode::<ClientConfiguratorSetRequest, ()>(
287 (client_type, config),
288 0x2204fb91b32f6435,
289 fidl::encoding::DynamicFlags::empty(),
290 _decode,
291 )
292 }
293}
294
295pub struct ClientConfiguratorEventStream {
296 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
297}
298
299impl std::marker::Unpin for ClientConfiguratorEventStream {}
300
301impl futures::stream::FusedStream for ClientConfiguratorEventStream {
302 fn is_terminated(&self) -> bool {
303 self.event_receiver.is_terminated()
304 }
305}
306
307impl futures::Stream for ClientConfiguratorEventStream {
308 type Item = Result<ClientConfiguratorEvent, fidl::Error>;
309
310 fn poll_next(
311 mut self: std::pin::Pin<&mut Self>,
312 cx: &mut std::task::Context<'_>,
313 ) -> std::task::Poll<Option<Self::Item>> {
314 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
315 &mut self.event_receiver,
316 cx
317 )?) {
318 Some(buf) => std::task::Poll::Ready(Some(ClientConfiguratorEvent::decode(buf))),
319 None => std::task::Poll::Ready(None),
320 }
321 }
322}
323
324#[derive(Debug)]
325pub enum ClientConfiguratorEvent {}
326
327impl ClientConfiguratorEvent {
328 fn decode(
330 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
331 ) -> Result<ClientConfiguratorEvent, fidl::Error> {
332 let (bytes, _handles) = buf.split_mut();
333 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
334 debug_assert_eq!(tx_header.tx_id, 0);
335 match tx_header.ordinal {
336 _ => Err(fidl::Error::UnknownOrdinal {
337 ordinal: tx_header.ordinal,
338 protocol_name:
339 <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
340 }),
341 }
342 }
343}
344
345pub struct ClientConfiguratorRequestStream {
347 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
348 is_terminated: bool,
349}
350
351impl std::marker::Unpin for ClientConfiguratorRequestStream {}
352
353impl futures::stream::FusedStream for ClientConfiguratorRequestStream {
354 fn is_terminated(&self) -> bool {
355 self.is_terminated
356 }
357}
358
359impl fidl::endpoints::RequestStream for ClientConfiguratorRequestStream {
360 type Protocol = ClientConfiguratorMarker;
361 type ControlHandle = ClientConfiguratorControlHandle;
362
363 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
364 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
365 }
366
367 fn control_handle(&self) -> Self::ControlHandle {
368 ClientConfiguratorControlHandle { inner: self.inner.clone() }
369 }
370
371 fn into_inner(
372 self,
373 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
374 {
375 (self.inner, self.is_terminated)
376 }
377
378 fn from_inner(
379 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
380 is_terminated: bool,
381 ) -> Self {
382 Self { inner, is_terminated }
383 }
384}
385
386impl futures::Stream for ClientConfiguratorRequestStream {
387 type Item = Result<ClientConfiguratorRequest, fidl::Error>;
388
389 fn poll_next(
390 mut self: std::pin::Pin<&mut Self>,
391 cx: &mut std::task::Context<'_>,
392 ) -> std::task::Poll<Option<Self::Item>> {
393 let this = &mut *self;
394 if this.inner.check_shutdown(cx) {
395 this.is_terminated = true;
396 return std::task::Poll::Ready(None);
397 }
398 if this.is_terminated {
399 panic!("polled ClientConfiguratorRequestStream after completion");
400 }
401 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
402 |bytes, handles| {
403 match this.inner.channel().read_etc(cx, bytes, handles) {
404 std::task::Poll::Ready(Ok(())) => {}
405 std::task::Poll::Pending => return std::task::Poll::Pending,
406 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
407 this.is_terminated = true;
408 return std::task::Poll::Ready(None);
409 }
410 std::task::Poll::Ready(Err(e)) => {
411 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
412 e.into(),
413 ))))
414 }
415 }
416
417 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
419
420 std::task::Poll::Ready(Some(match header.ordinal {
421 0x1e37597b4d247d7b => {
422 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
423 let mut req = fidl::new_empty!(ClientConfiguratorGetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
424 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorGetRequest>(&header, _body_bytes, handles, &mut req)?;
425 let control_handle = ClientConfiguratorControlHandle {
426 inner: this.inner.clone(),
427 };
428 Ok(ClientConfiguratorRequest::Get {client_type: req.client_type,
429
430 responder: ClientConfiguratorGetResponder {
431 control_handle: std::mem::ManuallyDrop::new(control_handle),
432 tx_id: header.tx_id,
433 },
434 })
435 }
436 0x2204fb91b32f6435 => {
437 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
438 let mut req = fidl::new_empty!(ClientConfiguratorSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
439 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorSetRequest>(&header, _body_bytes, handles, &mut req)?;
440 let control_handle = ClientConfiguratorControlHandle {
441 inner: this.inner.clone(),
442 };
443 Ok(ClientConfiguratorRequest::Set {client_type: req.client_type,
444config: req.config,
445
446 responder: ClientConfiguratorSetResponder {
447 control_handle: std::mem::ManuallyDrop::new(control_handle),
448 tx_id: header.tx_id,
449 },
450 })
451 }
452 _ => Err(fidl::Error::UnknownOrdinal {
453 ordinal: header.ordinal,
454 protocol_name: <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
455 }),
456 }))
457 },
458 )
459 }
460}
461
462#[derive(Debug)]
465pub enum ClientConfiguratorRequest {
466 Get {
475 client_type: fidl_fuchsia_power_clientlevel::ClientType,
476 responder: ClientConfiguratorGetResponder,
477 },
478 Set {
504 client_type: fidl_fuchsia_power_clientlevel::ClientType,
505 config: ClientConfig,
506 responder: ClientConfiguratorSetResponder,
507 },
508}
509
510impl ClientConfiguratorRequest {
511 #[allow(irrefutable_let_patterns)]
512 pub fn into_get(
513 self,
514 ) -> Option<(fidl_fuchsia_power_clientlevel::ClientType, ClientConfiguratorGetResponder)> {
515 if let ClientConfiguratorRequest::Get { client_type, responder } = self {
516 Some((client_type, responder))
517 } else {
518 None
519 }
520 }
521
522 #[allow(irrefutable_let_patterns)]
523 pub fn into_set(
524 self,
525 ) -> Option<(
526 fidl_fuchsia_power_clientlevel::ClientType,
527 ClientConfig,
528 ClientConfiguratorSetResponder,
529 )> {
530 if let ClientConfiguratorRequest::Set { client_type, config, responder } = self {
531 Some((client_type, config, responder))
532 } else {
533 None
534 }
535 }
536
537 pub fn method_name(&self) -> &'static str {
539 match *self {
540 ClientConfiguratorRequest::Get { .. } => "get",
541 ClientConfiguratorRequest::Set { .. } => "set",
542 }
543 }
544}
545
546#[derive(Debug, Clone)]
547pub struct ClientConfiguratorControlHandle {
548 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
549}
550
551impl fidl::endpoints::ControlHandle for ClientConfiguratorControlHandle {
552 fn shutdown(&self) {
553 self.inner.shutdown()
554 }
555 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
556 self.inner.shutdown_with_epitaph(status)
557 }
558
559 fn is_closed(&self) -> bool {
560 self.inner.channel().is_closed()
561 }
562 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
563 self.inner.channel().on_closed()
564 }
565
566 #[cfg(target_os = "fuchsia")]
567 fn signal_peer(
568 &self,
569 clear_mask: zx::Signals,
570 set_mask: zx::Signals,
571 ) -> Result<(), zx_status::Status> {
572 use fidl::Peered;
573 self.inner.channel().signal_peer(clear_mask, set_mask)
574 }
575}
576
577impl ClientConfiguratorControlHandle {}
578
579#[must_use = "FIDL methods require a response to be sent"]
580#[derive(Debug)]
581pub struct ClientConfiguratorGetResponder {
582 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
583 tx_id: u32,
584}
585
586impl std::ops::Drop for ClientConfiguratorGetResponder {
590 fn drop(&mut self) {
591 self.control_handle.shutdown();
592 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
594 }
595}
596
597impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
598 type ControlHandle = ClientConfiguratorControlHandle;
599
600 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
601 &self.control_handle
602 }
603
604 fn drop_without_shutdown(mut self) {
605 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
607 std::mem::forget(self);
609 }
610}
611
612impl ClientConfiguratorGetResponder {
613 pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
617 let _result = self.send_raw(config);
618 if _result.is_err() {
619 self.control_handle.shutdown();
620 }
621 self.drop_without_shutdown();
622 _result
623 }
624
625 pub fn send_no_shutdown_on_err(
627 self,
628 mut config: Option<&ClientConfig>,
629 ) -> Result<(), fidl::Error> {
630 let _result = self.send_raw(config);
631 self.drop_without_shutdown();
632 _result
633 }
634
635 fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
636 self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
637 (config,),
638 self.tx_id,
639 0x1e37597b4d247d7b,
640 fidl::encoding::DynamicFlags::empty(),
641 )
642 }
643}
644
645#[must_use = "FIDL methods require a response to be sent"]
646#[derive(Debug)]
647pub struct ClientConfiguratorSetResponder {
648 control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
649 tx_id: u32,
650}
651
652impl std::ops::Drop for ClientConfiguratorSetResponder {
656 fn drop(&mut self) {
657 self.control_handle.shutdown();
658 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
660 }
661}
662
663impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
664 type ControlHandle = ClientConfiguratorControlHandle;
665
666 fn control_handle(&self) -> &ClientConfiguratorControlHandle {
667 &self.control_handle
668 }
669
670 fn drop_without_shutdown(mut self) {
671 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
673 std::mem::forget(self);
675 }
676}
677
678impl ClientConfiguratorSetResponder {
679 pub fn send(self) -> Result<(), fidl::Error> {
683 let _result = self.send_raw();
684 if _result.is_err() {
685 self.control_handle.shutdown();
686 }
687 self.drop_without_shutdown();
688 _result
689 }
690
691 pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
693 let _result = self.send_raw();
694 self.drop_without_shutdown();
695 _result
696 }
697
698 fn send_raw(&self) -> Result<(), fidl::Error> {
699 self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
700 (),
701 self.tx_id,
702 0x2204fb91b32f6435,
703 fidl::encoding::DynamicFlags::empty(),
704 )
705 }
706}
707
708#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
709pub struct RequesterMarker;
710
711impl fidl::endpoints::ProtocolMarker for RequesterMarker {
712 type Proxy = RequesterProxy;
713 type RequestStream = RequesterRequestStream;
714 #[cfg(target_os = "fuchsia")]
715 type SynchronousProxy = RequesterSynchronousProxy;
716
717 const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
718}
719impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
720pub type RequesterRequestResult = Result<(), ModeRequestError>;
721
722pub trait RequesterProxyInterface: Send + Sync {
723 type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
724 + Send;
725 fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
726}
727#[derive(Debug)]
728#[cfg(target_os = "fuchsia")]
729pub struct RequesterSynchronousProxy {
730 client: fidl::client::sync::Client,
731}
732
733#[cfg(target_os = "fuchsia")]
734impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
735 type Proxy = RequesterProxy;
736 type Protocol = RequesterMarker;
737
738 fn from_channel(inner: fidl::Channel) -> Self {
739 Self::new(inner)
740 }
741
742 fn into_channel(self) -> fidl::Channel {
743 self.client.into_channel()
744 }
745
746 fn as_channel(&self) -> &fidl::Channel {
747 self.client.as_channel()
748 }
749}
750
751#[cfg(target_os = "fuchsia")]
752impl RequesterSynchronousProxy {
753 pub fn new(channel: fidl::Channel) -> Self {
754 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
755 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
756 }
757
758 pub fn into_channel(self) -> fidl::Channel {
759 self.client.into_channel()
760 }
761
762 pub fn wait_for_event(
765 &self,
766 deadline: zx::MonotonicInstant,
767 ) -> Result<RequesterEvent, fidl::Error> {
768 RequesterEvent::decode(self.client.wait_for_event(deadline)?)
769 }
770
771 pub fn r#request(
802 &self,
803 mut mode: SystemMode,
804 mut set: bool,
805 ___deadline: zx::MonotonicInstant,
806 ) -> Result<RequesterRequestResult, fidl::Error> {
807 let _response = self.client.send_query::<
808 RequesterRequestRequest,
809 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
810 >(
811 (mode, set,),
812 0x5603afcd4421f425,
813 fidl::encoding::DynamicFlags::empty(),
814 ___deadline,
815 )?;
816 Ok(_response.map(|x| x))
817 }
818}
819
820#[derive(Debug, Clone)]
821pub struct RequesterProxy {
822 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
823}
824
825impl fidl::endpoints::Proxy for RequesterProxy {
826 type Protocol = RequesterMarker;
827
828 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
829 Self::new(inner)
830 }
831
832 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
833 self.client.into_channel().map_err(|client| Self { client })
834 }
835
836 fn as_channel(&self) -> &::fidl::AsyncChannel {
837 self.client.as_channel()
838 }
839}
840
841impl RequesterProxy {
842 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
844 let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
845 Self { client: fidl::client::Client::new(channel, protocol_name) }
846 }
847
848 pub fn take_event_stream(&self) -> RequesterEventStream {
854 RequesterEventStream { event_receiver: self.client.take_event_receiver() }
855 }
856
857 pub fn r#request(
888 &self,
889 mut mode: SystemMode,
890 mut set: bool,
891 ) -> fidl::client::QueryResponseFut<
892 RequesterRequestResult,
893 fidl::encoding::DefaultFuchsiaResourceDialect,
894 > {
895 RequesterProxyInterface::r#request(self, mode, set)
896 }
897}
898
899impl RequesterProxyInterface for RequesterProxy {
900 type RequestResponseFut = fidl::client::QueryResponseFut<
901 RequesterRequestResult,
902 fidl::encoding::DefaultFuchsiaResourceDialect,
903 >;
904 fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
905 fn _decode(
906 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
907 ) -> Result<RequesterRequestResult, fidl::Error> {
908 let _response = fidl::client::decode_transaction_body::<
909 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
910 fidl::encoding::DefaultFuchsiaResourceDialect,
911 0x5603afcd4421f425,
912 >(_buf?)?;
913 Ok(_response.map(|x| x))
914 }
915 self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
916 (mode, set),
917 0x5603afcd4421f425,
918 fidl::encoding::DynamicFlags::empty(),
919 _decode,
920 )
921 }
922}
923
924pub struct RequesterEventStream {
925 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
926}
927
928impl std::marker::Unpin for RequesterEventStream {}
929
930impl futures::stream::FusedStream for RequesterEventStream {
931 fn is_terminated(&self) -> bool {
932 self.event_receiver.is_terminated()
933 }
934}
935
936impl futures::Stream for RequesterEventStream {
937 type Item = Result<RequesterEvent, fidl::Error>;
938
939 fn poll_next(
940 mut self: std::pin::Pin<&mut Self>,
941 cx: &mut std::task::Context<'_>,
942 ) -> std::task::Poll<Option<Self::Item>> {
943 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
944 &mut self.event_receiver,
945 cx
946 )?) {
947 Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
948 None => std::task::Poll::Ready(None),
949 }
950 }
951}
952
953#[derive(Debug)]
954pub enum RequesterEvent {}
955
956impl RequesterEvent {
957 fn decode(
959 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
960 ) -> Result<RequesterEvent, fidl::Error> {
961 let (bytes, _handles) = buf.split_mut();
962 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
963 debug_assert_eq!(tx_header.tx_id, 0);
964 match tx_header.ordinal {
965 _ => Err(fidl::Error::UnknownOrdinal {
966 ordinal: tx_header.ordinal,
967 protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
968 }),
969 }
970 }
971}
972
973pub struct RequesterRequestStream {
975 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
976 is_terminated: bool,
977}
978
979impl std::marker::Unpin for RequesterRequestStream {}
980
981impl futures::stream::FusedStream for RequesterRequestStream {
982 fn is_terminated(&self) -> bool {
983 self.is_terminated
984 }
985}
986
987impl fidl::endpoints::RequestStream for RequesterRequestStream {
988 type Protocol = RequesterMarker;
989 type ControlHandle = RequesterControlHandle;
990
991 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
992 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
993 }
994
995 fn control_handle(&self) -> Self::ControlHandle {
996 RequesterControlHandle { inner: self.inner.clone() }
997 }
998
999 fn into_inner(
1000 self,
1001 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1002 {
1003 (self.inner, self.is_terminated)
1004 }
1005
1006 fn from_inner(
1007 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1008 is_terminated: bool,
1009 ) -> Self {
1010 Self { inner, is_terminated }
1011 }
1012}
1013
1014impl futures::Stream for RequesterRequestStream {
1015 type Item = Result<RequesterRequest, fidl::Error>;
1016
1017 fn poll_next(
1018 mut self: std::pin::Pin<&mut Self>,
1019 cx: &mut std::task::Context<'_>,
1020 ) -> std::task::Poll<Option<Self::Item>> {
1021 let this = &mut *self;
1022 if this.inner.check_shutdown(cx) {
1023 this.is_terminated = true;
1024 return std::task::Poll::Ready(None);
1025 }
1026 if this.is_terminated {
1027 panic!("polled RequesterRequestStream after completion");
1028 }
1029 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1030 |bytes, handles| {
1031 match this.inner.channel().read_etc(cx, bytes, handles) {
1032 std::task::Poll::Ready(Ok(())) => {}
1033 std::task::Poll::Pending => return std::task::Poll::Pending,
1034 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1035 this.is_terminated = true;
1036 return std::task::Poll::Ready(None);
1037 }
1038 std::task::Poll::Ready(Err(e)) => {
1039 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1040 e.into(),
1041 ))))
1042 }
1043 }
1044
1045 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1047
1048 std::task::Poll::Ready(Some(match header.ordinal {
1049 0x5603afcd4421f425 => {
1050 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1051 let mut req = fidl::new_empty!(
1052 RequesterRequestRequest,
1053 fidl::encoding::DefaultFuchsiaResourceDialect
1054 );
1055 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1056 let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1057 Ok(RequesterRequest::Request {
1058 mode: req.mode,
1059 set: req.set,
1060
1061 responder: RequesterRequestResponder {
1062 control_handle: std::mem::ManuallyDrop::new(control_handle),
1063 tx_id: header.tx_id,
1064 },
1065 })
1066 }
1067 _ => Err(fidl::Error::UnknownOrdinal {
1068 ordinal: header.ordinal,
1069 protocol_name:
1070 <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1071 }),
1072 }))
1073 },
1074 )
1075 }
1076}
1077
1078#[derive(Debug)]
1081pub enum RequesterRequest {
1082 Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1113}
1114
1115impl RequesterRequest {
1116 #[allow(irrefutable_let_patterns)]
1117 pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1118 if let RequesterRequest::Request { mode, set, responder } = self {
1119 Some((mode, set, responder))
1120 } else {
1121 None
1122 }
1123 }
1124
1125 pub fn method_name(&self) -> &'static str {
1127 match *self {
1128 RequesterRequest::Request { .. } => "request",
1129 }
1130 }
1131}
1132
1133#[derive(Debug, Clone)]
1134pub struct RequesterControlHandle {
1135 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1136}
1137
1138impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1139 fn shutdown(&self) {
1140 self.inner.shutdown()
1141 }
1142 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1143 self.inner.shutdown_with_epitaph(status)
1144 }
1145
1146 fn is_closed(&self) -> bool {
1147 self.inner.channel().is_closed()
1148 }
1149 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1150 self.inner.channel().on_closed()
1151 }
1152
1153 #[cfg(target_os = "fuchsia")]
1154 fn signal_peer(
1155 &self,
1156 clear_mask: zx::Signals,
1157 set_mask: zx::Signals,
1158 ) -> Result<(), zx_status::Status> {
1159 use fidl::Peered;
1160 self.inner.channel().signal_peer(clear_mask, set_mask)
1161 }
1162}
1163
1164impl RequesterControlHandle {}
1165
1166#[must_use = "FIDL methods require a response to be sent"]
1167#[derive(Debug)]
1168pub struct RequesterRequestResponder {
1169 control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1170 tx_id: u32,
1171}
1172
1173impl std::ops::Drop for RequesterRequestResponder {
1177 fn drop(&mut self) {
1178 self.control_handle.shutdown();
1179 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1181 }
1182}
1183
1184impl fidl::endpoints::Responder for RequesterRequestResponder {
1185 type ControlHandle = RequesterControlHandle;
1186
1187 fn control_handle(&self) -> &RequesterControlHandle {
1188 &self.control_handle
1189 }
1190
1191 fn drop_without_shutdown(mut self) {
1192 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1194 std::mem::forget(self);
1196 }
1197}
1198
1199impl RequesterRequestResponder {
1200 pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1204 let _result = self.send_raw(result);
1205 if _result.is_err() {
1206 self.control_handle.shutdown();
1207 }
1208 self.drop_without_shutdown();
1209 _result
1210 }
1211
1212 pub fn send_no_shutdown_on_err(
1214 self,
1215 mut result: Result<(), ModeRequestError>,
1216 ) -> Result<(), fidl::Error> {
1217 let _result = self.send_raw(result);
1218 self.drop_without_shutdown();
1219 _result
1220 }
1221
1222 fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1223 self.control_handle.inner.send::<fidl::encoding::ResultType<
1224 fidl::encoding::EmptyStruct,
1225 ModeRequestError,
1226 >>(
1227 result,
1228 self.tx_id,
1229 0x5603afcd4421f425,
1230 fidl::encoding::DynamicFlags::empty(),
1231 )
1232 }
1233}
1234
1235mod internal {
1236 use super::*;
1237}