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 let protocol_name = <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
61 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
62 }
63
64 pub fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 pub fn wait_for_event(
71 &self,
72 deadline: zx::MonotonicInstant,
73 ) -> Result<DisplayPowerEvent, fidl::Error> {
74 DisplayPowerEvent::decode(self.client.wait_for_event(deadline)?)
75 }
76
77 pub fn r#set_power_mode(
85 &self,
86 mut power_mode: PowerMode,
87 ___deadline: zx::MonotonicInstant,
88 ) -> Result<DisplayPowerSetPowerModeResult, fidl::Error> {
89 let _response = self.client.send_query::<
90 DisplayPowerSetPowerModeRequest,
91 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
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::Handle {
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 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
456 self.inner.shutdown_with_epitaph(status)
457 }
458
459 fn is_closed(&self) -> bool {
460 self.inner.channel().is_closed()
461 }
462 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
463 self.inner.channel().on_closed()
464 }
465
466 #[cfg(target_os = "fuchsia")]
467 fn signal_peer(
468 &self,
469 clear_mask: zx::Signals,
470 set_mask: zx::Signals,
471 ) -> Result<(), zx_status::Status> {
472 use fidl::Peered;
473 self.inner.channel().signal_peer(clear_mask, set_mask)
474 }
475}
476
477impl DisplayPowerControlHandle {}
478
479#[must_use = "FIDL methods require a response to be sent"]
480#[derive(Debug)]
481pub struct DisplayPowerSetPowerModeResponder {
482 control_handle: std::mem::ManuallyDrop<DisplayPowerControlHandle>,
483 tx_id: u32,
484}
485
486impl std::ops::Drop for DisplayPowerSetPowerModeResponder {
490 fn drop(&mut self) {
491 self.control_handle.shutdown();
492 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
494 }
495}
496
497impl fidl::endpoints::Responder for DisplayPowerSetPowerModeResponder {
498 type ControlHandle = DisplayPowerControlHandle;
499
500 fn control_handle(&self) -> &DisplayPowerControlHandle {
501 &self.control_handle
502 }
503
504 fn drop_without_shutdown(mut self) {
505 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
507 std::mem::forget(self);
509 }
510}
511
512impl DisplayPowerSetPowerModeResponder {
513 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
517 let _result = self.send_raw(result);
518 if _result.is_err() {
519 self.control_handle.shutdown();
520 }
521 self.drop_without_shutdown();
522 _result
523 }
524
525 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
527 let _result = self.send_raw(result);
528 self.drop_without_shutdown();
529 _result
530 }
531
532 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
533 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
534 fidl::encoding::EmptyStruct,
535 i32,
536 >>(
537 fidl::encoding::FlexibleResult::new(result),
538 self.tx_id,
539 0x420dcd07d68e1fbc,
540 fidl::encoding::DynamicFlags::FLEXIBLE,
541 )
542 }
543}
544
545#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
546pub struct InfoMarker;
547
548impl fidl::endpoints::ProtocolMarker for InfoMarker {
549 type Proxy = InfoProxy;
550 type RequestStream = InfoRequestStream;
551 #[cfg(target_os = "fuchsia")]
552 type SynchronousProxy = InfoSynchronousProxy;
553
554 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.Info";
555}
556impl fidl::endpoints::DiscoverableProtocolMarker for InfoMarker {}
557
558pub trait InfoProxyInterface: Send + Sync {
559 type GetMetricsResponseFut: std::future::Future<Output = Result<Metrics, fidl::Error>> + Send;
560 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut;
561}
562#[derive(Debug)]
563#[cfg(target_os = "fuchsia")]
564pub struct InfoSynchronousProxy {
565 client: fidl::client::sync::Client,
566}
567
568#[cfg(target_os = "fuchsia")]
569impl fidl::endpoints::SynchronousProxy for InfoSynchronousProxy {
570 type Proxy = InfoProxy;
571 type Protocol = InfoMarker;
572
573 fn from_channel(inner: fidl::Channel) -> Self {
574 Self::new(inner)
575 }
576
577 fn into_channel(self) -> fidl::Channel {
578 self.client.into_channel()
579 }
580
581 fn as_channel(&self) -> &fidl::Channel {
582 self.client.as_channel()
583 }
584}
585
586#[cfg(target_os = "fuchsia")]
587impl InfoSynchronousProxy {
588 pub fn new(channel: fidl::Channel) -> Self {
589 let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
590 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
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(deadline)?)
601 }
602
603 pub fn r#get_metrics(&self, ___deadline: zx::MonotonicInstant) -> Result<Metrics, fidl::Error> {
604 let _response =
605 self.client.send_query::<fidl::encoding::EmptyPayload, InfoGetMetricsResponse>(
606 (),
607 0x6d631353834698be,
608 fidl::encoding::DynamicFlags::empty(),
609 ___deadline,
610 )?;
611 Ok(_response.info)
612 }
613}
614
615#[cfg(target_os = "fuchsia")]
616impl From<InfoSynchronousProxy> for zx::Handle {
617 fn from(value: InfoSynchronousProxy) -> Self {
618 value.into_channel().into()
619 }
620}
621
622#[cfg(target_os = "fuchsia")]
623impl From<fidl::Channel> for InfoSynchronousProxy {
624 fn from(value: fidl::Channel) -> Self {
625 Self::new(value)
626 }
627}
628
629#[cfg(target_os = "fuchsia")]
630impl fidl::endpoints::FromClient for InfoSynchronousProxy {
631 type Protocol = InfoMarker;
632
633 fn from_client(value: fidl::endpoints::ClientEnd<InfoMarker>) -> Self {
634 Self::new(value.into_channel())
635 }
636}
637
638#[derive(Debug, Clone)]
639pub struct InfoProxy {
640 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
641}
642
643impl fidl::endpoints::Proxy for InfoProxy {
644 type Protocol = InfoMarker;
645
646 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
647 Self::new(inner)
648 }
649
650 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
651 self.client.into_channel().map_err(|client| Self { client })
652 }
653
654 fn as_channel(&self) -> &::fidl::AsyncChannel {
655 self.client.as_channel()
656 }
657}
658
659impl InfoProxy {
660 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
662 let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
663 Self { client: fidl::client::Client::new(channel, protocol_name) }
664 }
665
666 pub fn take_event_stream(&self) -> InfoEventStream {
672 InfoEventStream { event_receiver: self.client.take_event_receiver() }
673 }
674
675 pub fn r#get_metrics(
676 &self,
677 ) -> fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>
678 {
679 InfoProxyInterface::r#get_metrics(self)
680 }
681}
682
683impl InfoProxyInterface for InfoProxy {
684 type GetMetricsResponseFut =
685 fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>;
686 fn r#get_metrics(&self) -> Self::GetMetricsResponseFut {
687 fn _decode(
688 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
689 ) -> Result<Metrics, fidl::Error> {
690 let _response = fidl::client::decode_transaction_body::<
691 InfoGetMetricsResponse,
692 fidl::encoding::DefaultFuchsiaResourceDialect,
693 0x6d631353834698be,
694 >(_buf?)?;
695 Ok(_response.info)
696 }
697 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Metrics>(
698 (),
699 0x6d631353834698be,
700 fidl::encoding::DynamicFlags::empty(),
701 _decode,
702 )
703 }
704}
705
706pub struct InfoEventStream {
707 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
708}
709
710impl std::marker::Unpin for InfoEventStream {}
711
712impl futures::stream::FusedStream for InfoEventStream {
713 fn is_terminated(&self) -> bool {
714 self.event_receiver.is_terminated()
715 }
716}
717
718impl futures::Stream for InfoEventStream {
719 type Item = Result<InfoEvent, fidl::Error>;
720
721 fn poll_next(
722 mut self: std::pin::Pin<&mut Self>,
723 cx: &mut std::task::Context<'_>,
724 ) -> std::task::Poll<Option<Self::Item>> {
725 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
726 &mut self.event_receiver,
727 cx
728 )?) {
729 Some(buf) => std::task::Poll::Ready(Some(InfoEvent::decode(buf))),
730 None => std::task::Poll::Ready(None),
731 }
732 }
733}
734
735#[derive(Debug)]
736pub enum InfoEvent {}
737
738impl InfoEvent {
739 fn decode(
741 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
742 ) -> Result<InfoEvent, fidl::Error> {
743 let (bytes, _handles) = buf.split_mut();
744 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
745 debug_assert_eq!(tx_header.tx_id, 0);
746 match tx_header.ordinal {
747 _ => Err(fidl::Error::UnknownOrdinal {
748 ordinal: tx_header.ordinal,
749 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
750 }),
751 }
752 }
753}
754
755pub struct InfoRequestStream {
757 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
758 is_terminated: bool,
759}
760
761impl std::marker::Unpin for InfoRequestStream {}
762
763impl futures::stream::FusedStream for InfoRequestStream {
764 fn is_terminated(&self) -> bool {
765 self.is_terminated
766 }
767}
768
769impl fidl::endpoints::RequestStream for InfoRequestStream {
770 type Protocol = InfoMarker;
771 type ControlHandle = InfoControlHandle;
772
773 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
774 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
775 }
776
777 fn control_handle(&self) -> Self::ControlHandle {
778 InfoControlHandle { inner: self.inner.clone() }
779 }
780
781 fn into_inner(
782 self,
783 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
784 {
785 (self.inner, self.is_terminated)
786 }
787
788 fn from_inner(
789 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
790 is_terminated: bool,
791 ) -> Self {
792 Self { inner, is_terminated }
793 }
794}
795
796impl futures::Stream for InfoRequestStream {
797 type Item = Result<InfoRequest, fidl::Error>;
798
799 fn poll_next(
800 mut self: std::pin::Pin<&mut Self>,
801 cx: &mut std::task::Context<'_>,
802 ) -> std::task::Poll<Option<Self::Item>> {
803 let this = &mut *self;
804 if this.inner.check_shutdown(cx) {
805 this.is_terminated = true;
806 return std::task::Poll::Ready(None);
807 }
808 if this.is_terminated {
809 panic!("polled InfoRequestStream after completion");
810 }
811 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
812 |bytes, handles| {
813 match this.inner.channel().read_etc(cx, bytes, handles) {
814 std::task::Poll::Ready(Ok(())) => {}
815 std::task::Poll::Pending => return std::task::Poll::Pending,
816 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
817 this.is_terminated = true;
818 return std::task::Poll::Ready(None);
819 }
820 std::task::Poll::Ready(Err(e)) => {
821 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
822 e.into(),
823 ))));
824 }
825 }
826
827 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
829
830 std::task::Poll::Ready(Some(match header.ordinal {
831 0x6d631353834698be => {
832 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
833 let mut req = fidl::new_empty!(
834 fidl::encoding::EmptyPayload,
835 fidl::encoding::DefaultFuchsiaResourceDialect
836 );
837 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
838 let control_handle = InfoControlHandle { inner: this.inner.clone() };
839 Ok(InfoRequest::GetMetrics {
840 responder: InfoGetMetricsResponder {
841 control_handle: std::mem::ManuallyDrop::new(control_handle),
842 tx_id: header.tx_id,
843 },
844 })
845 }
846 _ => Err(fidl::Error::UnknownOrdinal {
847 ordinal: header.ordinal,
848 protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
849 }),
850 }))
851 },
852 )
853 }
854}
855
856#[derive(Debug)]
858pub enum InfoRequest {
859 GetMetrics { responder: InfoGetMetricsResponder },
860}
861
862impl InfoRequest {
863 #[allow(irrefutable_let_patterns)]
864 pub fn into_get_metrics(self) -> Option<(InfoGetMetricsResponder)> {
865 if let InfoRequest::GetMetrics { responder } = self { Some((responder)) } else { None }
866 }
867
868 pub fn method_name(&self) -> &'static str {
870 match *self {
871 InfoRequest::GetMetrics { .. } => "get_metrics",
872 }
873 }
874}
875
876#[derive(Debug, Clone)]
877pub struct InfoControlHandle {
878 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
879}
880
881impl fidl::endpoints::ControlHandle for InfoControlHandle {
882 fn shutdown(&self) {
883 self.inner.shutdown()
884 }
885 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
886 self.inner.shutdown_with_epitaph(status)
887 }
888
889 fn is_closed(&self) -> bool {
890 self.inner.channel().is_closed()
891 }
892 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
893 self.inner.channel().on_closed()
894 }
895
896 #[cfg(target_os = "fuchsia")]
897 fn signal_peer(
898 &self,
899 clear_mask: zx::Signals,
900 set_mask: zx::Signals,
901 ) -> Result<(), zx_status::Status> {
902 use fidl::Peered;
903 self.inner.channel().signal_peer(clear_mask, set_mask)
904 }
905}
906
907impl InfoControlHandle {}
908
909#[must_use = "FIDL methods require a response to be sent"]
910#[derive(Debug)]
911pub struct InfoGetMetricsResponder {
912 control_handle: std::mem::ManuallyDrop<InfoControlHandle>,
913 tx_id: u32,
914}
915
916impl std::ops::Drop for InfoGetMetricsResponder {
920 fn drop(&mut self) {
921 self.control_handle.shutdown();
922 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
924 }
925}
926
927impl fidl::endpoints::Responder for InfoGetMetricsResponder {
928 type ControlHandle = InfoControlHandle;
929
930 fn control_handle(&self) -> &InfoControlHandle {
931 &self.control_handle
932 }
933
934 fn drop_without_shutdown(mut self) {
935 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937 std::mem::forget(self);
939 }
940}
941
942impl InfoGetMetricsResponder {
943 pub fn send(self, mut info: &Metrics) -> Result<(), fidl::Error> {
947 let _result = self.send_raw(info);
948 if _result.is_err() {
949 self.control_handle.shutdown();
950 }
951 self.drop_without_shutdown();
952 _result
953 }
954
955 pub fn send_no_shutdown_on_err(self, mut info: &Metrics) -> Result<(), fidl::Error> {
957 let _result = self.send_raw(info);
958 self.drop_without_shutdown();
959 _result
960 }
961
962 fn send_raw(&self, mut info: &Metrics) -> Result<(), fidl::Error> {
963 self.control_handle.inner.send::<InfoGetMetricsResponse>(
964 (info,),
965 self.tx_id,
966 0x6d631353834698be,
967 fidl::encoding::DynamicFlags::empty(),
968 )
969 }
970}
971
972#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
973pub struct VsyncSourceMarker;
974
975impl fidl::endpoints::ProtocolMarker for VsyncSourceMarker {
976 type Proxy = VsyncSourceProxy;
977 type RequestStream = VsyncSourceRequestStream;
978 #[cfg(target_os = "fuchsia")]
979 type SynchronousProxy = VsyncSourceSynchronousProxy;
980
981 const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.VsyncSource";
982}
983impl fidl::endpoints::DiscoverableProtocolMarker for VsyncSourceMarker {}
984
985pub trait VsyncSourceProxyInterface: Send + Sync {
986 fn r#set_vsync_enabled(&self, enabled: bool) -> Result<(), fidl::Error>;
987}
988#[derive(Debug)]
989#[cfg(target_os = "fuchsia")]
990pub struct VsyncSourceSynchronousProxy {
991 client: fidl::client::sync::Client,
992}
993
994#[cfg(target_os = "fuchsia")]
995impl fidl::endpoints::SynchronousProxy for VsyncSourceSynchronousProxy {
996 type Proxy = VsyncSourceProxy;
997 type Protocol = VsyncSourceMarker;
998
999 fn from_channel(inner: fidl::Channel) -> Self {
1000 Self::new(inner)
1001 }
1002
1003 fn into_channel(self) -> fidl::Channel {
1004 self.client.into_channel()
1005 }
1006
1007 fn as_channel(&self) -> &fidl::Channel {
1008 self.client.as_channel()
1009 }
1010}
1011
1012#[cfg(target_os = "fuchsia")]
1013impl VsyncSourceSynchronousProxy {
1014 pub fn new(channel: fidl::Channel) -> Self {
1015 let protocol_name = <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1016 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1017 }
1018
1019 pub fn into_channel(self) -> fidl::Channel {
1020 self.client.into_channel()
1021 }
1022
1023 pub fn wait_for_event(
1026 &self,
1027 deadline: zx::MonotonicInstant,
1028 ) -> Result<VsyncSourceEvent, fidl::Error> {
1029 VsyncSourceEvent::decode(self.client.wait_for_event(deadline)?)
1030 }
1031
1032 pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1040 self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1041 (enabled,),
1042 0x5aaab140804e1b32,
1043 fidl::encoding::DynamicFlags::empty(),
1044 )
1045 }
1046}
1047
1048#[cfg(target_os = "fuchsia")]
1049impl From<VsyncSourceSynchronousProxy> for zx::Handle {
1050 fn from(value: VsyncSourceSynchronousProxy) -> Self {
1051 value.into_channel().into()
1052 }
1053}
1054
1055#[cfg(target_os = "fuchsia")]
1056impl From<fidl::Channel> for VsyncSourceSynchronousProxy {
1057 fn from(value: fidl::Channel) -> Self {
1058 Self::new(value)
1059 }
1060}
1061
1062#[cfg(target_os = "fuchsia")]
1063impl fidl::endpoints::FromClient for VsyncSourceSynchronousProxy {
1064 type Protocol = VsyncSourceMarker;
1065
1066 fn from_client(value: fidl::endpoints::ClientEnd<VsyncSourceMarker>) -> Self {
1067 Self::new(value.into_channel())
1068 }
1069}
1070
1071#[derive(Debug, Clone)]
1072pub struct VsyncSourceProxy {
1073 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1074}
1075
1076impl fidl::endpoints::Proxy for VsyncSourceProxy {
1077 type Protocol = VsyncSourceMarker;
1078
1079 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1080 Self::new(inner)
1081 }
1082
1083 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1084 self.client.into_channel().map_err(|client| Self { client })
1085 }
1086
1087 fn as_channel(&self) -> &::fidl::AsyncChannel {
1088 self.client.as_channel()
1089 }
1090}
1091
1092impl VsyncSourceProxy {
1093 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1095 let protocol_name = <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1096 Self { client: fidl::client::Client::new(channel, protocol_name) }
1097 }
1098
1099 pub fn take_event_stream(&self) -> VsyncSourceEventStream {
1105 VsyncSourceEventStream { event_receiver: self.client.take_event_receiver() }
1106 }
1107
1108 pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1116 VsyncSourceProxyInterface::r#set_vsync_enabled(self, enabled)
1117 }
1118}
1119
1120impl VsyncSourceProxyInterface for VsyncSourceProxy {
1121 fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1122 self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1123 (enabled,),
1124 0x5aaab140804e1b32,
1125 fidl::encoding::DynamicFlags::empty(),
1126 )
1127 }
1128}
1129
1130pub struct VsyncSourceEventStream {
1131 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1132}
1133
1134impl std::marker::Unpin for VsyncSourceEventStream {}
1135
1136impl futures::stream::FusedStream for VsyncSourceEventStream {
1137 fn is_terminated(&self) -> bool {
1138 self.event_receiver.is_terminated()
1139 }
1140}
1141
1142impl futures::Stream for VsyncSourceEventStream {
1143 type Item = Result<VsyncSourceEvent, fidl::Error>;
1144
1145 fn poll_next(
1146 mut self: std::pin::Pin<&mut Self>,
1147 cx: &mut std::task::Context<'_>,
1148 ) -> std::task::Poll<Option<Self::Item>> {
1149 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1150 &mut self.event_receiver,
1151 cx
1152 )?) {
1153 Some(buf) => std::task::Poll::Ready(Some(VsyncSourceEvent::decode(buf))),
1154 None => std::task::Poll::Ready(None),
1155 }
1156 }
1157}
1158
1159#[derive(Debug)]
1160pub enum VsyncSourceEvent {
1161 OnVsync { timestamp: i64 },
1162}
1163
1164impl VsyncSourceEvent {
1165 #[allow(irrefutable_let_patterns)]
1166 pub fn into_on_vsync(self) -> Option<i64> {
1167 if let VsyncSourceEvent::OnVsync { timestamp } = self { Some((timestamp)) } else { None }
1168 }
1169
1170 fn decode(
1172 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1173 ) -> Result<VsyncSourceEvent, fidl::Error> {
1174 let (bytes, _handles) = buf.split_mut();
1175 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1176 debug_assert_eq!(tx_header.tx_id, 0);
1177 match tx_header.ordinal {
1178 0x6677c178c3451448 => {
1179 let mut out = fidl::new_empty!(
1180 VsyncSourceOnVsyncRequest,
1181 fidl::encoding::DefaultFuchsiaResourceDialect
1182 );
1183 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceOnVsyncRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1184 Ok((VsyncSourceEvent::OnVsync { timestamp: out.timestamp }))
1185 }
1186 _ => Err(fidl::Error::UnknownOrdinal {
1187 ordinal: tx_header.ordinal,
1188 protocol_name: <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1189 }),
1190 }
1191 }
1192}
1193
1194pub struct VsyncSourceRequestStream {
1196 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1197 is_terminated: bool,
1198}
1199
1200impl std::marker::Unpin for VsyncSourceRequestStream {}
1201
1202impl futures::stream::FusedStream for VsyncSourceRequestStream {
1203 fn is_terminated(&self) -> bool {
1204 self.is_terminated
1205 }
1206}
1207
1208impl fidl::endpoints::RequestStream for VsyncSourceRequestStream {
1209 type Protocol = VsyncSourceMarker;
1210 type ControlHandle = VsyncSourceControlHandle;
1211
1212 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1213 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1214 }
1215
1216 fn control_handle(&self) -> Self::ControlHandle {
1217 VsyncSourceControlHandle { inner: self.inner.clone() }
1218 }
1219
1220 fn into_inner(
1221 self,
1222 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1223 {
1224 (self.inner, self.is_terminated)
1225 }
1226
1227 fn from_inner(
1228 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1229 is_terminated: bool,
1230 ) -> Self {
1231 Self { inner, is_terminated }
1232 }
1233}
1234
1235impl futures::Stream for VsyncSourceRequestStream {
1236 type Item = Result<VsyncSourceRequest, fidl::Error>;
1237
1238 fn poll_next(
1239 mut self: std::pin::Pin<&mut Self>,
1240 cx: &mut std::task::Context<'_>,
1241 ) -> std::task::Poll<Option<Self::Item>> {
1242 let this = &mut *self;
1243 if this.inner.check_shutdown(cx) {
1244 this.is_terminated = true;
1245 return std::task::Poll::Ready(None);
1246 }
1247 if this.is_terminated {
1248 panic!("polled VsyncSourceRequestStream after completion");
1249 }
1250 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1251 |bytes, handles| {
1252 match this.inner.channel().read_etc(cx, bytes, handles) {
1253 std::task::Poll::Ready(Ok(())) => {}
1254 std::task::Poll::Pending => return std::task::Poll::Pending,
1255 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1256 this.is_terminated = true;
1257 return std::task::Poll::Ready(None);
1258 }
1259 std::task::Poll::Ready(Err(e)) => {
1260 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1261 e.into(),
1262 ))));
1263 }
1264 }
1265
1266 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1268
1269 std::task::Poll::Ready(Some(match header.ordinal {
1270 0x5aaab140804e1b32 => {
1271 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1272 let mut req = fidl::new_empty!(
1273 VsyncSourceSetVsyncEnabledRequest,
1274 fidl::encoding::DefaultFuchsiaResourceDialect
1275 );
1276 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceSetVsyncEnabledRequest>(&header, _body_bytes, handles, &mut req)?;
1277 let control_handle = VsyncSourceControlHandle { inner: this.inner.clone() };
1278 Ok(VsyncSourceRequest::SetVsyncEnabled {
1279 enabled: req.enabled,
1280
1281 control_handle,
1282 })
1283 }
1284 _ => Err(fidl::Error::UnknownOrdinal {
1285 ordinal: header.ordinal,
1286 protocol_name:
1287 <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1288 }),
1289 }))
1290 },
1291 )
1292 }
1293}
1294
1295#[derive(Debug)]
1296pub enum VsyncSourceRequest {
1297 SetVsyncEnabled { enabled: bool, control_handle: VsyncSourceControlHandle },
1305}
1306
1307impl VsyncSourceRequest {
1308 #[allow(irrefutable_let_patterns)]
1309 pub fn into_set_vsync_enabled(self) -> Option<(bool, VsyncSourceControlHandle)> {
1310 if let VsyncSourceRequest::SetVsyncEnabled { enabled, control_handle } = self {
1311 Some((enabled, control_handle))
1312 } else {
1313 None
1314 }
1315 }
1316
1317 pub fn method_name(&self) -> &'static str {
1319 match *self {
1320 VsyncSourceRequest::SetVsyncEnabled { .. } => "set_vsync_enabled",
1321 }
1322 }
1323}
1324
1325#[derive(Debug, Clone)]
1326pub struct VsyncSourceControlHandle {
1327 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1328}
1329
1330impl fidl::endpoints::ControlHandle for VsyncSourceControlHandle {
1331 fn shutdown(&self) {
1332 self.inner.shutdown()
1333 }
1334 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1335 self.inner.shutdown_with_epitaph(status)
1336 }
1337
1338 fn is_closed(&self) -> bool {
1339 self.inner.channel().is_closed()
1340 }
1341 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1342 self.inner.channel().on_closed()
1343 }
1344
1345 #[cfg(target_os = "fuchsia")]
1346 fn signal_peer(
1347 &self,
1348 clear_mask: zx::Signals,
1349 set_mask: zx::Signals,
1350 ) -> Result<(), zx_status::Status> {
1351 use fidl::Peered;
1352 self.inner.channel().signal_peer(clear_mask, set_mask)
1353 }
1354}
1355
1356impl VsyncSourceControlHandle {
1357 pub fn send_on_vsync(&self, mut timestamp: i64) -> Result<(), fidl::Error> {
1358 self.inner.send::<VsyncSourceOnVsyncRequest>(
1359 (timestamp,),
1360 0,
1361 0x6677c178c3451448,
1362 fidl::encoding::DynamicFlags::empty(),
1363 )
1364 }
1365}
1366
1367mod internal {
1368 use super::*;
1369}