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_ui_display_singleton__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DisplayPowerMarker;
16
17impl fidl::endpoints::ProtocolMarker for DisplayPowerMarker {
18 type Proxy = DisplayPowerProxy;
19 type RequestStream = DisplayPowerRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DisplayPowerSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.DisplayPower";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DisplayPowerMarker {}
26pub type DisplayPowerSetPowerModeResult = Result<(), i32>;
27
28pub trait DisplayPowerProxyInterface: Send + Sync {
29 type SetPowerModeResponseFut: std::future::Future<Output = Result<DisplayPowerSetPowerModeResult, fidl::Error>>
30 + Send;
31 fn r#set_power_mode(&self, power_mode: PowerMode) -> Self::SetPowerModeResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct DisplayPowerSynchronousProxy {
36 client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for DisplayPowerSynchronousProxy {
41 type Proxy = DisplayPowerProxy;
42 type Protocol = DisplayPowerMarker;
43
44 fn from_channel(inner: fidl::Channel) -> Self {
45 Self::new(inner)
46 }
47
48 fn into_channel(self) -> fidl::Channel {
49 self.client.into_channel()
50 }
51
52 fn as_channel(&self) -> &fidl::Channel {
53 self.client.as_channel()
54 }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl DisplayPowerSynchronousProxy {
59 pub fn new(channel: fidl::Channel) -> Self {
60 Self { client: fidl::client::sync::Client::new(channel) }
61 }
62
63 pub fn into_channel(self) -> fidl::Channel {
64 self.client.into_channel()
65 }
66
67 pub fn wait_for_event(
70 &self,
71 deadline: zx::MonotonicInstant,
72 ) -> Result<DisplayPowerEvent, fidl::Error> {
73 DisplayPowerEvent::decode(self.client.wait_for_event::<DisplayPowerMarker>(deadline)?)
74 }
75
76 pub fn r#set_power_mode(
84 &self,
85 mut power_mode: PowerMode,
86 ___deadline: zx::MonotonicInstant,
87 ) -> Result<DisplayPowerSetPowerModeResult, fidl::Error> {
88 let _response = self.client.send_query::<
89 DisplayPowerSetPowerModeRequest,
90 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
91 DisplayPowerMarker,
92 >(
93 (power_mode,),
94 0x420dcd07d68e1fbc,
95 fidl::encoding::DynamicFlags::FLEXIBLE,
96 ___deadline,
97 )?
98 .into_result::<DisplayPowerMarker>("set_power_mode")?;
99 Ok(_response.map(|x| x))
100 }
101}
102
103#[cfg(target_os = "fuchsia")]
104impl From<DisplayPowerSynchronousProxy> for zx::NullableHandle {
105 fn from(value: DisplayPowerSynchronousProxy) -> Self {
106 value.into_channel().into()
107 }
108}
109
110#[cfg(target_os = "fuchsia")]
111impl From<fidl::Channel> for DisplayPowerSynchronousProxy {
112 fn from(value: fidl::Channel) -> Self {
113 Self::new(value)
114 }
115}
116
117#[cfg(target_os = "fuchsia")]
118impl fidl::endpoints::FromClient for DisplayPowerSynchronousProxy {
119 type Protocol = DisplayPowerMarker;
120
121 fn from_client(value: fidl::endpoints::ClientEnd<DisplayPowerMarker>) -> Self {
122 Self::new(value.into_channel())
123 }
124}
125
126#[derive(Debug, Clone)]
127pub struct DisplayPowerProxy {
128 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
129}
130
131impl fidl::endpoints::Proxy for DisplayPowerProxy {
132 type Protocol = DisplayPowerMarker;
133
134 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
135 Self::new(inner)
136 }
137
138 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
139 self.client.into_channel().map_err(|client| Self { client })
140 }
141
142 fn as_channel(&self) -> &::fidl::AsyncChannel {
143 self.client.as_channel()
144 }
145}
146
147impl DisplayPowerProxy {
148 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
150 let protocol_name = <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
151 Self { client: fidl::client::Client::new(channel, protocol_name) }
152 }
153
154 pub fn take_event_stream(&self) -> DisplayPowerEventStream {
160 DisplayPowerEventStream { event_receiver: self.client.take_event_receiver() }
161 }
162
163 pub fn r#set_power_mode(
171 &self,
172 mut power_mode: PowerMode,
173 ) -> fidl::client::QueryResponseFut<
174 DisplayPowerSetPowerModeResult,
175 fidl::encoding::DefaultFuchsiaResourceDialect,
176 > {
177 DisplayPowerProxyInterface::r#set_power_mode(self, power_mode)
178 }
179}
180
181impl DisplayPowerProxyInterface for DisplayPowerProxy {
182 type SetPowerModeResponseFut = fidl::client::QueryResponseFut<
183 DisplayPowerSetPowerModeResult,
184 fidl::encoding::DefaultFuchsiaResourceDialect,
185 >;
186 fn r#set_power_mode(&self, mut power_mode: PowerMode) -> Self::SetPowerModeResponseFut {
187 fn _decode(
188 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
189 ) -> Result<DisplayPowerSetPowerModeResult, fidl::Error> {
190 let _response = fidl::client::decode_transaction_body::<
191 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
192 fidl::encoding::DefaultFuchsiaResourceDialect,
193 0x420dcd07d68e1fbc,
194 >(_buf?)?
195 .into_result::<DisplayPowerMarker>("set_power_mode")?;
196 Ok(_response.map(|x| x))
197 }
198 self.client.send_query_and_decode::<
199 DisplayPowerSetPowerModeRequest,
200 DisplayPowerSetPowerModeResult,
201 >(
202 (power_mode,),
203 0x420dcd07d68e1fbc,
204 fidl::encoding::DynamicFlags::FLEXIBLE,
205 _decode,
206 )
207 }
208}
209
210pub struct DisplayPowerEventStream {
211 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
212}
213
214impl std::marker::Unpin for DisplayPowerEventStream {}
215
216impl futures::stream::FusedStream for DisplayPowerEventStream {
217 fn is_terminated(&self) -> bool {
218 self.event_receiver.is_terminated()
219 }
220}
221
222impl futures::Stream for DisplayPowerEventStream {
223 type Item = Result<DisplayPowerEvent, fidl::Error>;
224
225 fn poll_next(
226 mut self: std::pin::Pin<&mut Self>,
227 cx: &mut std::task::Context<'_>,
228 ) -> std::task::Poll<Option<Self::Item>> {
229 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
230 &mut self.event_receiver,
231 cx
232 )?) {
233 Some(buf) => std::task::Poll::Ready(Some(DisplayPowerEvent::decode(buf))),
234 None => std::task::Poll::Ready(None),
235 }
236 }
237}
238
239#[derive(Debug)]
240pub enum DisplayPowerEvent {
241 #[non_exhaustive]
242 _UnknownEvent {
243 ordinal: u64,
245 },
246}
247
248impl DisplayPowerEvent {
249 fn decode(
251 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
252 ) -> Result<DisplayPowerEvent, fidl::Error> {
253 let (bytes, _handles) = buf.split_mut();
254 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
255 debug_assert_eq!(tx_header.tx_id, 0);
256 match tx_header.ordinal {
257 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
258 Ok(DisplayPowerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
259 }
260 _ => Err(fidl::Error::UnknownOrdinal {
261 ordinal: tx_header.ordinal,
262 protocol_name: <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
263 }),
264 }
265 }
266}
267
268pub struct DisplayPowerRequestStream {
270 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
271 is_terminated: bool,
272}
273
274impl std::marker::Unpin for DisplayPowerRequestStream {}
275
276impl futures::stream::FusedStream for DisplayPowerRequestStream {
277 fn is_terminated(&self) -> bool {
278 self.is_terminated
279 }
280}
281
282impl fidl::endpoints::RequestStream for DisplayPowerRequestStream {
283 type Protocol = DisplayPowerMarker;
284 type ControlHandle = DisplayPowerControlHandle;
285
286 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
287 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
288 }
289
290 fn control_handle(&self) -> Self::ControlHandle {
291 DisplayPowerControlHandle { inner: self.inner.clone() }
292 }
293
294 fn into_inner(
295 self,
296 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
297 {
298 (self.inner, self.is_terminated)
299 }
300
301 fn from_inner(
302 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
303 is_terminated: bool,
304 ) -> Self {
305 Self { inner, is_terminated }
306 }
307}
308
309impl futures::Stream for DisplayPowerRequestStream {
310 type Item = Result<DisplayPowerRequest, fidl::Error>;
311
312 fn poll_next(
313 mut self: std::pin::Pin<&mut Self>,
314 cx: &mut std::task::Context<'_>,
315 ) -> std::task::Poll<Option<Self::Item>> {
316 let this = &mut *self;
317 if this.inner.check_shutdown(cx) {
318 this.is_terminated = true;
319 return std::task::Poll::Ready(None);
320 }
321 if this.is_terminated {
322 panic!("polled DisplayPowerRequestStream after completion");
323 }
324 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
325 |bytes, handles| {
326 match this.inner.channel().read_etc(cx, bytes, handles) {
327 std::task::Poll::Ready(Ok(())) => {}
328 std::task::Poll::Pending => return std::task::Poll::Pending,
329 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
330 this.is_terminated = true;
331 return std::task::Poll::Ready(None);
332 }
333 std::task::Poll::Ready(Err(e)) => {
334 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
335 e.into(),
336 ))));
337 }
338 }
339
340 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
342
343 std::task::Poll::Ready(Some(match header.ordinal {
344 0x420dcd07d68e1fbc => {
345 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
346 let mut req = fidl::new_empty!(
347 DisplayPowerSetPowerModeRequest,
348 fidl::encoding::DefaultFuchsiaResourceDialect
349 );
350 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayPowerSetPowerModeRequest>(&header, _body_bytes, handles, &mut req)?;
351 let control_handle =
352 DisplayPowerControlHandle { inner: this.inner.clone() };
353 Ok(DisplayPowerRequest::SetPowerMode {
354 power_mode: req.power_mode,
355
356 responder: DisplayPowerSetPowerModeResponder {
357 control_handle: std::mem::ManuallyDrop::new(control_handle),
358 tx_id: header.tx_id,
359 },
360 })
361 }
362 _ if header.tx_id == 0
363 && header
364 .dynamic_flags()
365 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
366 {
367 Ok(DisplayPowerRequest::_UnknownMethod {
368 ordinal: header.ordinal,
369 control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
370 method_type: fidl::MethodType::OneWay,
371 })
372 }
373 _ if header
374 .dynamic_flags()
375 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
376 {
377 this.inner.send_framework_err(
378 fidl::encoding::FrameworkErr::UnknownMethod,
379 header.tx_id,
380 header.ordinal,
381 header.dynamic_flags(),
382 (bytes, handles),
383 )?;
384 Ok(DisplayPowerRequest::_UnknownMethod {
385 ordinal: header.ordinal,
386 control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
387 method_type: fidl::MethodType::TwoWay,
388 })
389 }
390 _ => Err(fidl::Error::UnknownOrdinal {
391 ordinal: header.ordinal,
392 protocol_name:
393 <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
394 }),
395 }))
396 },
397 )
398 }
399}
400
401#[derive(Debug)]
403pub enum DisplayPowerRequest {
404 SetPowerMode { power_mode: PowerMode, responder: DisplayPowerSetPowerModeResponder },
412 #[non_exhaustive]
414 _UnknownMethod {
415 ordinal: u64,
417 control_handle: DisplayPowerControlHandle,
418 method_type: fidl::MethodType,
419 },
420}
421
422impl DisplayPowerRequest {
423 #[allow(irrefutable_let_patterns)]
424 pub fn into_set_power_mode(self) -> Option<(PowerMode, DisplayPowerSetPowerModeResponder)> {
425 if let DisplayPowerRequest::SetPowerMode { power_mode, responder } = self {
426 Some((power_mode, responder))
427 } else {
428 None
429 }
430 }
431
432 pub fn method_name(&self) -> &'static str {
434 match *self {
435 DisplayPowerRequest::SetPowerMode { .. } => "set_power_mode",
436 DisplayPowerRequest::_UnknownMethod {
437 method_type: fidl::MethodType::OneWay, ..
438 } => "unknown one-way method",
439 DisplayPowerRequest::_UnknownMethod {
440 method_type: fidl::MethodType::TwoWay, ..
441 } => "unknown two-way method",
442 }
443 }
444}
445
446#[derive(Debug, Clone)]
447pub struct DisplayPowerControlHandle {
448 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
449}
450
451impl fidl::endpoints::ControlHandle for DisplayPowerControlHandle {
452 fn shutdown(&self) {
453 self.inner.shutdown()
454 }
455
456 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
457 self.inner.shutdown_with_epitaph(status)
458 }
459
460 fn is_closed(&self) -> bool {
461 self.inner.channel().is_closed()
462 }
463 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
464 self.inner.channel().on_closed()
465 }
466
467 #[cfg(target_os = "fuchsia")]
468 fn signal_peer(
469 &self,
470 clear_mask: zx::Signals,
471 set_mask: zx::Signals,
472 ) -> Result<(), zx_status::Status> {
473 use fidl::Peered;
474 self.inner.channel().signal_peer(clear_mask, set_mask)
475 }
476}
477
478impl DisplayPowerControlHandle {}
479
480#[must_use = "FIDL methods require a response to be sent"]
481#[derive(Debug)]
482pub struct DisplayPowerSetPowerModeResponder {
483 control_handle: std::mem::ManuallyDrop<DisplayPowerControlHandle>,
484 tx_id: u32,
485}
486
487impl std::ops::Drop for DisplayPowerSetPowerModeResponder {
491 fn drop(&mut self) {
492 self.control_handle.shutdown();
493 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
495 }
496}
497
498impl fidl::endpoints::Responder for DisplayPowerSetPowerModeResponder {
499 type ControlHandle = DisplayPowerControlHandle;
500
501 fn control_handle(&self) -> &DisplayPowerControlHandle {
502 &self.control_handle
503 }
504
505 fn drop_without_shutdown(mut self) {
506 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
508 std::mem::forget(self);
510 }
511}
512
513impl DisplayPowerSetPowerModeResponder {
514 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
518 let _result = self.send_raw(result);
519 if _result.is_err() {
520 self.control_handle.shutdown();
521 }
522 self.drop_without_shutdown();
523 _result
524 }
525
526 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
528 let _result = self.send_raw(result);
529 self.drop_without_shutdown();
530 _result
531 }
532
533 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
534 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
535 fidl::encoding::EmptyStruct,
536 i32,
537 >>(
538 fidl::encoding::FlexibleResult::new(result),
539 self.tx_id,
540 0x420dcd07d68e1fbc,
541 fidl::encoding::DynamicFlags::FLEXIBLE,
542 )
543 }
544}
545
546#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
547pub struct InfoMarker;
548
549impl fidl::endpoints::ProtocolMarker for InfoMarker {
550 type Proxy = InfoProxy;
551 type RequestStream = InfoRequestStream;
552 #[cfg(target_os = "fuchsia")]
553 type SynchronousProxy = InfoSynchronousProxy;
554
555 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.Info";
556}
557impl fidl::endpoints::DiscoverableProtocolMarker for InfoMarker {}
558
559pub trait InfoProxyInterface: Send + Sync {
560 type GetMetricsResponseFut: std::future::Future<Output = Result<Metrics, fidl::Error>> + Send;
561 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut;
562}
563#[derive(Debug)]
564#[cfg(target_os = "fuchsia")]
565pub struct InfoSynchronousProxy {
566 client: fidl::client::sync::Client,
567}
568
569#[cfg(target_os = "fuchsia")]
570impl fidl::endpoints::SynchronousProxy for InfoSynchronousProxy {
571 type Proxy = InfoProxy;
572 type Protocol = InfoMarker;
573
574 fn from_channel(inner: fidl::Channel) -> Self {
575 Self::new(inner)
576 }
577
578 fn into_channel(self) -> fidl::Channel {
579 self.client.into_channel()
580 }
581
582 fn as_channel(&self) -> &fidl::Channel {
583 self.client.as_channel()
584 }
585}
586
587#[cfg(target_os = "fuchsia")]
588impl InfoSynchronousProxy {
589 pub fn new(channel: fidl::Channel) -> Self {
590 Self { client: fidl::client::sync::Client::new(channel) }
591 }
592
593 pub fn into_channel(self) -> fidl::Channel {
594 self.client.into_channel()
595 }
596
597 pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<InfoEvent, fidl::Error> {
600 InfoEvent::decode(self.client.wait_for_event::<InfoMarker>(deadline)?)
601 }
602
603 pub fn r#get_metrics(&self, ___deadline: zx::MonotonicInstant) -> Result<Metrics, fidl::Error> {
604 let _response = self
605 .client
606 .send_query::<fidl::encoding::EmptyPayload, InfoGetMetricsResponse, InfoMarker>(
607 (),
608 0x6d631353834698be,
609 fidl::encoding::DynamicFlags::empty(),
610 ___deadline,
611 )?;
612 Ok(_response.info)
613 }
614}
615
616#[cfg(target_os = "fuchsia")]
617impl From<InfoSynchronousProxy> for zx::NullableHandle {
618 fn from(value: InfoSynchronousProxy) -> Self {
619 value.into_channel().into()
620 }
621}
622
623#[cfg(target_os = "fuchsia")]
624impl From<fidl::Channel> for InfoSynchronousProxy {
625 fn from(value: fidl::Channel) -> Self {
626 Self::new(value)
627 }
628}
629
630#[cfg(target_os = "fuchsia")]
631impl fidl::endpoints::FromClient for InfoSynchronousProxy {
632 type Protocol = InfoMarker;
633
634 fn from_client(value: fidl::endpoints::ClientEnd<InfoMarker>) -> Self {
635 Self::new(value.into_channel())
636 }
637}
638
639#[derive(Debug, Clone)]
640pub struct InfoProxy {
641 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
642}
643
644impl fidl::endpoints::Proxy for InfoProxy {
645 type Protocol = InfoMarker;
646
647 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
648 Self::new(inner)
649 }
650
651 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
652 self.client.into_channel().map_err(|client| Self { client })
653 }
654
655 fn as_channel(&self) -> &::fidl::AsyncChannel {
656 self.client.as_channel()
657 }
658}
659
660impl InfoProxy {
661 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
663 let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
664 Self { client: fidl::client::Client::new(channel, protocol_name) }
665 }
666
667 pub fn take_event_stream(&self) -> InfoEventStream {
673 InfoEventStream { event_receiver: self.client.take_event_receiver() }
674 }
675
676 pub fn r#get_metrics(
677 &self,
678 ) -> fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>
679 {
680 InfoProxyInterface::r#get_metrics(self)
681 }
682}
683
684impl InfoProxyInterface for InfoProxy {
685 type GetMetricsResponseFut =
686 fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>;
687 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut {
688 fn _decode(
689 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
690 ) -> Result<Metrics, fidl::Error> {
691 let _response = fidl::client::decode_transaction_body::<
692 InfoGetMetricsResponse,
693 fidl::encoding::DefaultFuchsiaResourceDialect,
694 0x6d631353834698be,
695 >(_buf?)?;
696 Ok(_response.info)
697 }
698 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Metrics>(
699 (),
700 0x6d631353834698be,
701 fidl::encoding::DynamicFlags::empty(),
702 _decode,
703 )
704 }
705}
706
707pub struct InfoEventStream {
708 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
709}
710
711impl std::marker::Unpin for InfoEventStream {}
712
713impl futures::stream::FusedStream for InfoEventStream {
714 fn is_terminated(&self) -> bool {
715 self.event_receiver.is_terminated()
716 }
717}
718
719impl futures::Stream for InfoEventStream {
720 type Item = Result<InfoEvent, fidl::Error>;
721
722 fn poll_next(
723 mut self: std::pin::Pin<&mut Self>,
724 cx: &mut std::task::Context<'_>,
725 ) -> std::task::Poll<Option<Self::Item>> {
726 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
727 &mut self.event_receiver,
728 cx
729 )?) {
730 Some(buf) => std::task::Poll::Ready(Some(InfoEvent::decode(buf))),
731 None => std::task::Poll::Ready(None),
732 }
733 }
734}
735
736#[derive(Debug)]
737pub enum InfoEvent {}
738
739impl InfoEvent {
740 fn decode(
742 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
743 ) -> Result<InfoEvent, fidl::Error> {
744 let (bytes, _handles) = buf.split_mut();
745 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
746 debug_assert_eq!(tx_header.tx_id, 0);
747 match tx_header.ordinal {
748 _ => Err(fidl::Error::UnknownOrdinal {
749 ordinal: tx_header.ordinal,
750 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
751 }),
752 }
753 }
754}
755
756pub struct InfoRequestStream {
758 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
759 is_terminated: bool,
760}
761
762impl std::marker::Unpin for InfoRequestStream {}
763
764impl futures::stream::FusedStream for InfoRequestStream {
765 fn is_terminated(&self) -> bool {
766 self.is_terminated
767 }
768}
769
770impl fidl::endpoints::RequestStream for InfoRequestStream {
771 type Protocol = InfoMarker;
772 type ControlHandle = InfoControlHandle;
773
774 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
775 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
776 }
777
778 fn control_handle(&self) -> Self::ControlHandle {
779 InfoControlHandle { inner: self.inner.clone() }
780 }
781
782 fn into_inner(
783 self,
784 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
785 {
786 (self.inner, self.is_terminated)
787 }
788
789 fn from_inner(
790 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
791 is_terminated: bool,
792 ) -> Self {
793 Self { inner, is_terminated }
794 }
795}
796
797impl futures::Stream for InfoRequestStream {
798 type Item = Result<InfoRequest, fidl::Error>;
799
800 fn poll_next(
801 mut self: std::pin::Pin<&mut Self>,
802 cx: &mut std::task::Context<'_>,
803 ) -> std::task::Poll<Option<Self::Item>> {
804 let this = &mut *self;
805 if this.inner.check_shutdown(cx) {
806 this.is_terminated = true;
807 return std::task::Poll::Ready(None);
808 }
809 if this.is_terminated {
810 panic!("polled InfoRequestStream after completion");
811 }
812 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
813 |bytes, handles| {
814 match this.inner.channel().read_etc(cx, bytes, handles) {
815 std::task::Poll::Ready(Ok(())) => {}
816 std::task::Poll::Pending => return std::task::Poll::Pending,
817 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
818 this.is_terminated = true;
819 return std::task::Poll::Ready(None);
820 }
821 std::task::Poll::Ready(Err(e)) => {
822 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
823 e.into(),
824 ))));
825 }
826 }
827
828 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
830
831 std::task::Poll::Ready(Some(match header.ordinal {
832 0x6d631353834698be => {
833 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
834 let mut req = fidl::new_empty!(
835 fidl::encoding::EmptyPayload,
836 fidl::encoding::DefaultFuchsiaResourceDialect
837 );
838 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
839 let control_handle = InfoControlHandle { inner: this.inner.clone() };
840 Ok(InfoRequest::GetMetrics {
841 responder: InfoGetMetricsResponder {
842 control_handle: std::mem::ManuallyDrop::new(control_handle),
843 tx_id: header.tx_id,
844 },
845 })
846 }
847 _ => Err(fidl::Error::UnknownOrdinal {
848 ordinal: header.ordinal,
849 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
850 }),
851 }))
852 },
853 )
854 }
855}
856
857#[derive(Debug)]
859pub enum InfoRequest {
860 GetMetrics { responder: InfoGetMetricsResponder },
861}
862
863impl InfoRequest {
864 #[allow(irrefutable_let_patterns)]
865 pub fn into_get_metrics(self) -> Option<(InfoGetMetricsResponder)> {
866 if let InfoRequest::GetMetrics { responder } = self { Some((responder)) } else { None }
867 }
868
869 pub fn method_name(&self) -> &'static str {
871 match *self {
872 InfoRequest::GetMetrics { .. } => "get_metrics",
873 }
874 }
875}
876
877#[derive(Debug, Clone)]
878pub struct InfoControlHandle {
879 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
880}
881
882impl fidl::endpoints::ControlHandle for InfoControlHandle {
883 fn shutdown(&self) {
884 self.inner.shutdown()
885 }
886
887 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
888 self.inner.shutdown_with_epitaph(status)
889 }
890
891 fn is_closed(&self) -> bool {
892 self.inner.channel().is_closed()
893 }
894 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
895 self.inner.channel().on_closed()
896 }
897
898 #[cfg(target_os = "fuchsia")]
899 fn signal_peer(
900 &self,
901 clear_mask: zx::Signals,
902 set_mask: zx::Signals,
903 ) -> Result<(), zx_status::Status> {
904 use fidl::Peered;
905 self.inner.channel().signal_peer(clear_mask, set_mask)
906 }
907}
908
909impl InfoControlHandle {}
910
911#[must_use = "FIDL methods require a response to be sent"]
912#[derive(Debug)]
913pub struct InfoGetMetricsResponder {
914 control_handle: std::mem::ManuallyDrop<InfoControlHandle>,
915 tx_id: u32,
916}
917
918impl std::ops::Drop for InfoGetMetricsResponder {
922 fn drop(&mut self) {
923 self.control_handle.shutdown();
924 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
926 }
927}
928
929impl fidl::endpoints::Responder for InfoGetMetricsResponder {
930 type ControlHandle = InfoControlHandle;
931
932 fn control_handle(&self) -> &InfoControlHandle {
933 &self.control_handle
934 }
935
936 fn drop_without_shutdown(mut self) {
937 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
939 std::mem::forget(self);
941 }
942}
943
944impl InfoGetMetricsResponder {
945 pub fn send(self, mut info: &Metrics) -> Result<(), fidl::Error> {
949 let _result = self.send_raw(info);
950 if _result.is_err() {
951 self.control_handle.shutdown();
952 }
953 self.drop_without_shutdown();
954 _result
955 }
956
957 pub fn send_no_shutdown_on_err(self, mut info: &Metrics) -> Result<(), fidl::Error> {
959 let _result = self.send_raw(info);
960 self.drop_without_shutdown();
961 _result
962 }
963
964 fn send_raw(&self, mut info: &Metrics) -> Result<(), fidl::Error> {
965 self.control_handle.inner.send::<InfoGetMetricsResponse>(
966 (info,),
967 self.tx_id,
968 0x6d631353834698be,
969 fidl::encoding::DynamicFlags::empty(),
970 )
971 }
972}
973
974#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
975pub struct VsyncSourceMarker;
976
977impl fidl::endpoints::ProtocolMarker for VsyncSourceMarker {
978 type Proxy = VsyncSourceProxy;
979 type RequestStream = VsyncSourceRequestStream;
980 #[cfg(target_os = "fuchsia")]
981 type SynchronousProxy = VsyncSourceSynchronousProxy;
982
983 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.VsyncSource";
984}
985impl fidl::endpoints::DiscoverableProtocolMarker for VsyncSourceMarker {}
986
987pub trait VsyncSourceProxyInterface: Send + Sync {
988 fn r#set_vsync_enabled(&self, enabled: bool) -> Result<(), fidl::Error>;
989}
990#[derive(Debug)]
991#[cfg(target_os = "fuchsia")]
992pub struct VsyncSourceSynchronousProxy {
993 client: fidl::client::sync::Client,
994}
995
996#[cfg(target_os = "fuchsia")]
997impl fidl::endpoints::SynchronousProxy for VsyncSourceSynchronousProxy {
998 type Proxy = VsyncSourceProxy;
999 type Protocol = VsyncSourceMarker;
1000
1001 fn from_channel(inner: fidl::Channel) -> Self {
1002 Self::new(inner)
1003 }
1004
1005 fn into_channel(self) -> fidl::Channel {
1006 self.client.into_channel()
1007 }
1008
1009 fn as_channel(&self) -> &fidl::Channel {
1010 self.client.as_channel()
1011 }
1012}
1013
1014#[cfg(target_os = "fuchsia")]
1015impl VsyncSourceSynchronousProxy {
1016 pub fn new(channel: fidl::Channel) -> Self {
1017 Self { client: fidl::client::sync::Client::new(channel) }
1018 }
1019
1020 pub fn into_channel(self) -> fidl::Channel {
1021 self.client.into_channel()
1022 }
1023
1024 pub fn wait_for_event(
1027 &self,
1028 deadline: zx::MonotonicInstant,
1029 ) -> Result<VsyncSourceEvent, fidl::Error> {
1030 VsyncSourceEvent::decode(self.client.wait_for_event::<VsyncSourceMarker>(deadline)?)
1031 }
1032
1033 pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1041 self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1042 (enabled,),
1043 0x5aaab140804e1b32,
1044 fidl::encoding::DynamicFlags::empty(),
1045 )
1046 }
1047}
1048
1049#[cfg(target_os = "fuchsia")]
1050impl From<VsyncSourceSynchronousProxy> for zx::NullableHandle {
1051 fn from(value: VsyncSourceSynchronousProxy) -> Self {
1052 value.into_channel().into()
1053 }
1054}
1055
1056#[cfg(target_os = "fuchsia")]
1057impl From<fidl::Channel> for VsyncSourceSynchronousProxy {
1058 fn from(value: fidl::Channel) -> Self {
1059 Self::new(value)
1060 }
1061}
1062
1063#[cfg(target_os = "fuchsia")]
1064impl fidl::endpoints::FromClient for VsyncSourceSynchronousProxy {
1065 type Protocol = VsyncSourceMarker;
1066
1067 fn from_client(value: fidl::endpoints::ClientEnd<VsyncSourceMarker>) -> Self {
1068 Self::new(value.into_channel())
1069 }
1070}
1071
1072#[derive(Debug, Clone)]
1073pub struct VsyncSourceProxy {
1074 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1075}
1076
1077impl fidl::endpoints::Proxy for VsyncSourceProxy {
1078 type Protocol = VsyncSourceMarker;
1079
1080 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1081 Self::new(inner)
1082 }
1083
1084 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1085 self.client.into_channel().map_err(|client| Self { client })
1086 }
1087
1088 fn as_channel(&self) -> &::fidl::AsyncChannel {
1089 self.client.as_channel()
1090 }
1091}
1092
1093impl VsyncSourceProxy {
1094 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1096 let protocol_name = <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1097 Self { client: fidl::client::Client::new(channel, protocol_name) }
1098 }
1099
1100 pub fn take_event_stream(&self) -> VsyncSourceEventStream {
1106 VsyncSourceEventStream { event_receiver: self.client.take_event_receiver() }
1107 }
1108
1109 pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1117 VsyncSourceProxyInterface::r#set_vsync_enabled(self, enabled)
1118 }
1119}
1120
1121impl VsyncSourceProxyInterface for VsyncSourceProxy {
1122 fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1123 self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1124 (enabled,),
1125 0x5aaab140804e1b32,
1126 fidl::encoding::DynamicFlags::empty(),
1127 )
1128 }
1129}
1130
1131pub struct VsyncSourceEventStream {
1132 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1133}
1134
1135impl std::marker::Unpin for VsyncSourceEventStream {}
1136
1137impl futures::stream::FusedStream for VsyncSourceEventStream {
1138 fn is_terminated(&self) -> bool {
1139 self.event_receiver.is_terminated()
1140 }
1141}
1142
1143impl futures::Stream for VsyncSourceEventStream {
1144 type Item = Result<VsyncSourceEvent, fidl::Error>;
1145
1146 fn poll_next(
1147 mut self: std::pin::Pin<&mut Self>,
1148 cx: &mut std::task::Context<'_>,
1149 ) -> std::task::Poll<Option<Self::Item>> {
1150 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1151 &mut self.event_receiver,
1152 cx
1153 )?) {
1154 Some(buf) => std::task::Poll::Ready(Some(VsyncSourceEvent::decode(buf))),
1155 None => std::task::Poll::Ready(None),
1156 }
1157 }
1158}
1159
1160#[derive(Debug)]
1161pub enum VsyncSourceEvent {
1162 OnVsync { timestamp: i64 },
1163}
1164
1165impl VsyncSourceEvent {
1166 #[allow(irrefutable_let_patterns)]
1167 pub fn into_on_vsync(self) -> Option<i64> {
1168 if let VsyncSourceEvent::OnVsync { timestamp } = self { Some((timestamp)) } else { None }
1169 }
1170
1171 fn decode(
1173 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1174 ) -> Result<VsyncSourceEvent, fidl::Error> {
1175 let (bytes, _handles) = buf.split_mut();
1176 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1177 debug_assert_eq!(tx_header.tx_id, 0);
1178 match tx_header.ordinal {
1179 0x6677c178c3451448 => {
1180 let mut out = fidl::new_empty!(
1181 VsyncSourceOnVsyncRequest,
1182 fidl::encoding::DefaultFuchsiaResourceDialect
1183 );
1184 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceOnVsyncRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1185 Ok((VsyncSourceEvent::OnVsync { timestamp: out.timestamp }))
1186 }
1187 _ => Err(fidl::Error::UnknownOrdinal {
1188 ordinal: tx_header.ordinal,
1189 protocol_name: <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1190 }),
1191 }
1192 }
1193}
1194
1195pub struct VsyncSourceRequestStream {
1197 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1198 is_terminated: bool,
1199}
1200
1201impl std::marker::Unpin for VsyncSourceRequestStream {}
1202
1203impl futures::stream::FusedStream for VsyncSourceRequestStream {
1204 fn is_terminated(&self) -> bool {
1205 self.is_terminated
1206 }
1207}
1208
1209impl fidl::endpoints::RequestStream for VsyncSourceRequestStream {
1210 type Protocol = VsyncSourceMarker;
1211 type ControlHandle = VsyncSourceControlHandle;
1212
1213 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1214 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1215 }
1216
1217 fn control_handle(&self) -> Self::ControlHandle {
1218 VsyncSourceControlHandle { inner: self.inner.clone() }
1219 }
1220
1221 fn into_inner(
1222 self,
1223 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1224 {
1225 (self.inner, self.is_terminated)
1226 }
1227
1228 fn from_inner(
1229 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1230 is_terminated: bool,
1231 ) -> Self {
1232 Self { inner, is_terminated }
1233 }
1234}
1235
1236impl futures::Stream for VsyncSourceRequestStream {
1237 type Item = Result<VsyncSourceRequest, fidl::Error>;
1238
1239 fn poll_next(
1240 mut self: std::pin::Pin<&mut Self>,
1241 cx: &mut std::task::Context<'_>,
1242 ) -> std::task::Poll<Option<Self::Item>> {
1243 let this = &mut *self;
1244 if this.inner.check_shutdown(cx) {
1245 this.is_terminated = true;
1246 return std::task::Poll::Ready(None);
1247 }
1248 if this.is_terminated {
1249 panic!("polled VsyncSourceRequestStream after completion");
1250 }
1251 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1252 |bytes, handles| {
1253 match this.inner.channel().read_etc(cx, bytes, handles) {
1254 std::task::Poll::Ready(Ok(())) => {}
1255 std::task::Poll::Pending => return std::task::Poll::Pending,
1256 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1257 this.is_terminated = true;
1258 return std::task::Poll::Ready(None);
1259 }
1260 std::task::Poll::Ready(Err(e)) => {
1261 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1262 e.into(),
1263 ))));
1264 }
1265 }
1266
1267 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1269
1270 std::task::Poll::Ready(Some(match header.ordinal {
1271 0x5aaab140804e1b32 => {
1272 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1273 let mut req = fidl::new_empty!(
1274 VsyncSourceSetVsyncEnabledRequest,
1275 fidl::encoding::DefaultFuchsiaResourceDialect
1276 );
1277 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceSetVsyncEnabledRequest>(&header, _body_bytes, handles, &mut req)?;
1278 let control_handle = VsyncSourceControlHandle { inner: this.inner.clone() };
1279 Ok(VsyncSourceRequest::SetVsyncEnabled {
1280 enabled: req.enabled,
1281
1282 control_handle,
1283 })
1284 }
1285 _ => Err(fidl::Error::UnknownOrdinal {
1286 ordinal: header.ordinal,
1287 protocol_name:
1288 <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1289 }),
1290 }))
1291 },
1292 )
1293 }
1294}
1295
1296#[derive(Debug)]
1297pub enum VsyncSourceRequest {
1298 SetVsyncEnabled { enabled: bool, control_handle: VsyncSourceControlHandle },
1306}
1307
1308impl VsyncSourceRequest {
1309 #[allow(irrefutable_let_patterns)]
1310 pub fn into_set_vsync_enabled(self) -> Option<(bool, VsyncSourceControlHandle)> {
1311 if let VsyncSourceRequest::SetVsyncEnabled { enabled, control_handle } = self {
1312 Some((enabled, control_handle))
1313 } else {
1314 None
1315 }
1316 }
1317
1318 pub fn method_name(&self) -> &'static str {
1320 match *self {
1321 VsyncSourceRequest::SetVsyncEnabled { .. } => "set_vsync_enabled",
1322 }
1323 }
1324}
1325
1326#[derive(Debug, Clone)]
1327pub struct VsyncSourceControlHandle {
1328 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1329}
1330
1331impl fidl::endpoints::ControlHandle for VsyncSourceControlHandle {
1332 fn shutdown(&self) {
1333 self.inner.shutdown()
1334 }
1335
1336 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1337 self.inner.shutdown_with_epitaph(status)
1338 }
1339
1340 fn is_closed(&self) -> bool {
1341 self.inner.channel().is_closed()
1342 }
1343 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1344 self.inner.channel().on_closed()
1345 }
1346
1347 #[cfg(target_os = "fuchsia")]
1348 fn signal_peer(
1349 &self,
1350 clear_mask: zx::Signals,
1351 set_mask: zx::Signals,
1352 ) -> Result<(), zx_status::Status> {
1353 use fidl::Peered;
1354 self.inner.channel().signal_peer(clear_mask, set_mask)
1355 }
1356}
1357
1358impl VsyncSourceControlHandle {
1359 pub fn send_on_vsync(&self, mut timestamp: i64) -> Result<(), fidl::Error> {
1360 self.inner.send::<VsyncSourceOnVsyncRequest>(
1361 (timestamp,),
1362 0,
1363 0x6677c178c3451448,
1364 fidl::encoding::DynamicFlags::empty(),
1365 )
1366 }
1367}
1368
1369mod internal {
1370 use super::*;
1371}