fidl_fuchsia_ui_display_singleton/
fidl_fuchsia_ui_display_singleton.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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 DisplayPowerSetDisplayPowerResult = Result<(), i32>;
27
28pub trait DisplayPowerProxyInterface: Send + Sync {
29    type SetDisplayPowerResponseFut: std::future::Future<Output = Result<DisplayPowerSetDisplayPowerResult, fidl::Error>>
30        + Send;
31    fn r#set_display_power(&self, power_on: bool) -> Self::SetDisplayPowerResponseFut;
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    /// Waits until an event arrives and returns it. It is safe for other
69    /// threads to make concurrent requests while waiting for an event.
70    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    /// Set the power state of the default connected display device to `power_on`.
78    ///
79    /// When successfull, the connected display is turned on or off. Once the
80    /// display device is turned off, [`fuchsia.hardware.display/Coordinator`]
81    /// clients will not receive `OnVsync` events anymore until the display device is
82    /// turned on again.
83    ///
84    /// Fails with ZX_ERR_NOT_SUPPORTED if the connected display fails to turn on/off.
85    ///
86    /// All display devices are turned on by default.
87    pub fn r#set_display_power(
88        &self,
89        mut power_on: bool,
90        ___deadline: zx::MonotonicInstant,
91    ) -> Result<DisplayPowerSetDisplayPowerResult, fidl::Error> {
92        let _response = self.client.send_query::<
93            DisplayPowerSetDisplayPowerRequest,
94            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
95        >(
96            (power_on,),
97            0x59f31b10e74ce66f,
98            fidl::encoding::DynamicFlags::empty(),
99            ___deadline,
100        )?;
101        Ok(_response.map(|x| x))
102    }
103}
104
105#[cfg(target_os = "fuchsia")]
106impl From<DisplayPowerSynchronousProxy> for zx::Handle {
107    fn from(value: DisplayPowerSynchronousProxy) -> Self {
108        value.into_channel().into()
109    }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<fidl::Channel> for DisplayPowerSynchronousProxy {
114    fn from(value: fidl::Channel) -> Self {
115        Self::new(value)
116    }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl fidl::endpoints::FromClient for DisplayPowerSynchronousProxy {
121    type Protocol = DisplayPowerMarker;
122
123    fn from_client(value: fidl::endpoints::ClientEnd<DisplayPowerMarker>) -> Self {
124        Self::new(value.into_channel())
125    }
126}
127
128#[derive(Debug, Clone)]
129pub struct DisplayPowerProxy {
130    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
131}
132
133impl fidl::endpoints::Proxy for DisplayPowerProxy {
134    type Protocol = DisplayPowerMarker;
135
136    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
137        Self::new(inner)
138    }
139
140    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
141        self.client.into_channel().map_err(|client| Self { client })
142    }
143
144    fn as_channel(&self) -> &::fidl::AsyncChannel {
145        self.client.as_channel()
146    }
147}
148
149impl DisplayPowerProxy {
150    /// Create a new Proxy for fuchsia.ui.display.singleton/DisplayPower.
151    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
152        let protocol_name = <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
153        Self { client: fidl::client::Client::new(channel, protocol_name) }
154    }
155
156    /// Get a Stream of events from the remote end of the protocol.
157    ///
158    /// # Panics
159    ///
160    /// Panics if the event stream was already taken.
161    pub fn take_event_stream(&self) -> DisplayPowerEventStream {
162        DisplayPowerEventStream { event_receiver: self.client.take_event_receiver() }
163    }
164
165    /// Set the power state of the default connected display device to `power_on`.
166    ///
167    /// When successfull, the connected display is turned on or off. Once the
168    /// display device is turned off, [`fuchsia.hardware.display/Coordinator`]
169    /// clients will not receive `OnVsync` events anymore until the display device is
170    /// turned on again.
171    ///
172    /// Fails with ZX_ERR_NOT_SUPPORTED if the connected display fails to turn on/off.
173    ///
174    /// All display devices are turned on by default.
175    pub fn r#set_display_power(
176        &self,
177        mut power_on: bool,
178    ) -> fidl::client::QueryResponseFut<
179        DisplayPowerSetDisplayPowerResult,
180        fidl::encoding::DefaultFuchsiaResourceDialect,
181    > {
182        DisplayPowerProxyInterface::r#set_display_power(self, power_on)
183    }
184}
185
186impl DisplayPowerProxyInterface for DisplayPowerProxy {
187    type SetDisplayPowerResponseFut = fidl::client::QueryResponseFut<
188        DisplayPowerSetDisplayPowerResult,
189        fidl::encoding::DefaultFuchsiaResourceDialect,
190    >;
191    fn r#set_display_power(&self, mut power_on: bool) -> Self::SetDisplayPowerResponseFut {
192        fn _decode(
193            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
194        ) -> Result<DisplayPowerSetDisplayPowerResult, fidl::Error> {
195            let _response = fidl::client::decode_transaction_body::<
196                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
197                fidl::encoding::DefaultFuchsiaResourceDialect,
198                0x59f31b10e74ce66f,
199            >(_buf?)?;
200            Ok(_response.map(|x| x))
201        }
202        self.client.send_query_and_decode::<
203            DisplayPowerSetDisplayPowerRequest,
204            DisplayPowerSetDisplayPowerResult,
205        >(
206            (power_on,),
207            0x59f31b10e74ce66f,
208            fidl::encoding::DynamicFlags::empty(),
209            _decode,
210        )
211    }
212}
213
214pub struct DisplayPowerEventStream {
215    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
216}
217
218impl std::marker::Unpin for DisplayPowerEventStream {}
219
220impl futures::stream::FusedStream for DisplayPowerEventStream {
221    fn is_terminated(&self) -> bool {
222        self.event_receiver.is_terminated()
223    }
224}
225
226impl futures::Stream for DisplayPowerEventStream {
227    type Item = Result<DisplayPowerEvent, fidl::Error>;
228
229    fn poll_next(
230        mut self: std::pin::Pin<&mut Self>,
231        cx: &mut std::task::Context<'_>,
232    ) -> std::task::Poll<Option<Self::Item>> {
233        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
234            &mut self.event_receiver,
235            cx
236        )?) {
237            Some(buf) => std::task::Poll::Ready(Some(DisplayPowerEvent::decode(buf))),
238            None => std::task::Poll::Ready(None),
239        }
240    }
241}
242
243#[derive(Debug)]
244pub enum DisplayPowerEvent {
245    #[non_exhaustive]
246    _UnknownEvent {
247        /// Ordinal of the event that was sent.
248        ordinal: u64,
249    },
250}
251
252impl DisplayPowerEvent {
253    /// Decodes a message buffer as a [`DisplayPowerEvent`].
254    fn decode(
255        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
256    ) -> Result<DisplayPowerEvent, fidl::Error> {
257        let (bytes, _handles) = buf.split_mut();
258        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
259        debug_assert_eq!(tx_header.tx_id, 0);
260        match tx_header.ordinal {
261            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
262                Ok(DisplayPowerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
263            }
264            _ => Err(fidl::Error::UnknownOrdinal {
265                ordinal: tx_header.ordinal,
266                protocol_name: <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
267            }),
268        }
269    }
270}
271
272/// A Stream of incoming requests for fuchsia.ui.display.singleton/DisplayPower.
273pub struct DisplayPowerRequestStream {
274    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
275    is_terminated: bool,
276}
277
278impl std::marker::Unpin for DisplayPowerRequestStream {}
279
280impl futures::stream::FusedStream for DisplayPowerRequestStream {
281    fn is_terminated(&self) -> bool {
282        self.is_terminated
283    }
284}
285
286impl fidl::endpoints::RequestStream for DisplayPowerRequestStream {
287    type Protocol = DisplayPowerMarker;
288    type ControlHandle = DisplayPowerControlHandle;
289
290    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
291        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
292    }
293
294    fn control_handle(&self) -> Self::ControlHandle {
295        DisplayPowerControlHandle { inner: self.inner.clone() }
296    }
297
298    fn into_inner(
299        self,
300    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
301    {
302        (self.inner, self.is_terminated)
303    }
304
305    fn from_inner(
306        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
307        is_terminated: bool,
308    ) -> Self {
309        Self { inner, is_terminated }
310    }
311}
312
313impl futures::Stream for DisplayPowerRequestStream {
314    type Item = Result<DisplayPowerRequest, fidl::Error>;
315
316    fn poll_next(
317        mut self: std::pin::Pin<&mut Self>,
318        cx: &mut std::task::Context<'_>,
319    ) -> std::task::Poll<Option<Self::Item>> {
320        let this = &mut *self;
321        if this.inner.check_shutdown(cx) {
322            this.is_terminated = true;
323            return std::task::Poll::Ready(None);
324        }
325        if this.is_terminated {
326            panic!("polled DisplayPowerRequestStream after completion");
327        }
328        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
329            |bytes, handles| {
330                match this.inner.channel().read_etc(cx, bytes, handles) {
331                    std::task::Poll::Ready(Ok(())) => {}
332                    std::task::Poll::Pending => return std::task::Poll::Pending,
333                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
334                        this.is_terminated = true;
335                        return std::task::Poll::Ready(None);
336                    }
337                    std::task::Poll::Ready(Err(e)) => {
338                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
339                            e.into(),
340                        ))))
341                    }
342                }
343
344                // A message has been received from the channel
345                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
346
347                std::task::Poll::Ready(Some(match header.ordinal {
348                    0x59f31b10e74ce66f => {
349                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
350                        let mut req = fidl::new_empty!(
351                            DisplayPowerSetDisplayPowerRequest,
352                            fidl::encoding::DefaultFuchsiaResourceDialect
353                        );
354                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DisplayPowerSetDisplayPowerRequest>(&header, _body_bytes, handles, &mut req)?;
355                        let control_handle =
356                            DisplayPowerControlHandle { inner: this.inner.clone() };
357                        Ok(DisplayPowerRequest::SetDisplayPower {
358                            power_on: req.power_on,
359
360                            responder: DisplayPowerSetDisplayPowerResponder {
361                                control_handle: std::mem::ManuallyDrop::new(control_handle),
362                                tx_id: header.tx_id,
363                            },
364                        })
365                    }
366                    _ if header.tx_id == 0
367                        && header
368                            .dynamic_flags()
369                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
370                    {
371                        Ok(DisplayPowerRequest::_UnknownMethod {
372                            ordinal: header.ordinal,
373                            control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
374                            method_type: fidl::MethodType::OneWay,
375                        })
376                    }
377                    _ if header
378                        .dynamic_flags()
379                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
380                    {
381                        this.inner.send_framework_err(
382                            fidl::encoding::FrameworkErr::UnknownMethod,
383                            header.tx_id,
384                            header.ordinal,
385                            header.dynamic_flags(),
386                            (bytes, handles),
387                        )?;
388                        Ok(DisplayPowerRequest::_UnknownMethod {
389                            ordinal: header.ordinal,
390                            control_handle: DisplayPowerControlHandle { inner: this.inner.clone() },
391                            method_type: fidl::MethodType::TwoWay,
392                        })
393                    }
394                    _ => Err(fidl::Error::UnknownOrdinal {
395                        ordinal: header.ordinal,
396                        protocol_name:
397                            <DisplayPowerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
398                    }),
399                }))
400            },
401        )
402    }
403}
404
405/// Controls the power state of the default display device.
406#[derive(Debug)]
407pub enum DisplayPowerRequest {
408    /// Set the power state of the default connected display device to `power_on`.
409    ///
410    /// When successfull, the connected display is turned on or off. Once the
411    /// display device is turned off, [`fuchsia.hardware.display/Coordinator`]
412    /// clients will not receive `OnVsync` events anymore until the display device is
413    /// turned on again.
414    ///
415    /// Fails with ZX_ERR_NOT_SUPPORTED if the connected display fails to turn on/off.
416    ///
417    /// All display devices are turned on by default.
418    SetDisplayPower { power_on: bool, responder: DisplayPowerSetDisplayPowerResponder },
419    /// An interaction was received which does not match any known method.
420    #[non_exhaustive]
421    _UnknownMethod {
422        /// Ordinal of the method that was called.
423        ordinal: u64,
424        control_handle: DisplayPowerControlHandle,
425        method_type: fidl::MethodType,
426    },
427}
428
429impl DisplayPowerRequest {
430    #[allow(irrefutable_let_patterns)]
431    pub fn into_set_display_power(self) -> Option<(bool, DisplayPowerSetDisplayPowerResponder)> {
432        if let DisplayPowerRequest::SetDisplayPower { power_on, responder } = self {
433            Some((power_on, responder))
434        } else {
435            None
436        }
437    }
438
439    /// Name of the method defined in FIDL
440    pub fn method_name(&self) -> &'static str {
441        match *self {
442            DisplayPowerRequest::SetDisplayPower { .. } => "set_display_power",
443            DisplayPowerRequest::_UnknownMethod {
444                method_type: fidl::MethodType::OneWay, ..
445            } => "unknown one-way method",
446            DisplayPowerRequest::_UnknownMethod {
447                method_type: fidl::MethodType::TwoWay, ..
448            } => "unknown two-way method",
449        }
450    }
451}
452
453#[derive(Debug, Clone)]
454pub struct DisplayPowerControlHandle {
455    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
456}
457
458impl fidl::endpoints::ControlHandle for DisplayPowerControlHandle {
459    fn shutdown(&self) {
460        self.inner.shutdown()
461    }
462    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
463        self.inner.shutdown_with_epitaph(status)
464    }
465
466    fn is_closed(&self) -> bool {
467        self.inner.channel().is_closed()
468    }
469    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
470        self.inner.channel().on_closed()
471    }
472
473    #[cfg(target_os = "fuchsia")]
474    fn signal_peer(
475        &self,
476        clear_mask: zx::Signals,
477        set_mask: zx::Signals,
478    ) -> Result<(), zx_status::Status> {
479        use fidl::Peered;
480        self.inner.channel().signal_peer(clear_mask, set_mask)
481    }
482}
483
484impl DisplayPowerControlHandle {}
485
486#[must_use = "FIDL methods require a response to be sent"]
487#[derive(Debug)]
488pub struct DisplayPowerSetDisplayPowerResponder {
489    control_handle: std::mem::ManuallyDrop<DisplayPowerControlHandle>,
490    tx_id: u32,
491}
492
493/// Set the the channel to be shutdown (see [`DisplayPowerControlHandle::shutdown`])
494/// if the responder is dropped without sending a response, so that the client
495/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
496impl std::ops::Drop for DisplayPowerSetDisplayPowerResponder {
497    fn drop(&mut self) {
498        self.control_handle.shutdown();
499        // Safety: drops once, never accessed again
500        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
501    }
502}
503
504impl fidl::endpoints::Responder for DisplayPowerSetDisplayPowerResponder {
505    type ControlHandle = DisplayPowerControlHandle;
506
507    fn control_handle(&self) -> &DisplayPowerControlHandle {
508        &self.control_handle
509    }
510
511    fn drop_without_shutdown(mut self) {
512        // Safety: drops once, never accessed again due to mem::forget
513        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
514        // Prevent Drop from running (which would shut down the channel)
515        std::mem::forget(self);
516    }
517}
518
519impl DisplayPowerSetDisplayPowerResponder {
520    /// Sends a response to the FIDL transaction.
521    ///
522    /// Sets the channel to shutdown if an error occurs.
523    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
524        let _result = self.send_raw(result);
525        if _result.is_err() {
526            self.control_handle.shutdown();
527        }
528        self.drop_without_shutdown();
529        _result
530    }
531
532    /// Similar to "send" but does not shutdown the channel if an error occurs.
533    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
534        let _result = self.send_raw(result);
535        self.drop_without_shutdown();
536        _result
537    }
538
539    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
540        self.control_handle
541            .inner
542            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
543                result,
544                self.tx_id,
545                0x59f31b10e74ce66f,
546                fidl::encoding::DynamicFlags::empty(),
547            )
548    }
549}
550
551#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
552pub struct InfoMarker;
553
554impl fidl::endpoints::ProtocolMarker for InfoMarker {
555    type Proxy = InfoProxy;
556    type RequestStream = InfoRequestStream;
557    #[cfg(target_os = "fuchsia")]
558    type SynchronousProxy = InfoSynchronousProxy;
559
560    const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.Info";
561}
562impl fidl::endpoints::DiscoverableProtocolMarker for InfoMarker {}
563
564pub trait InfoProxyInterface: Send + Sync {
565    type GetMetricsResponseFut: std::future::Future<Output = Result<Metrics, fidl::Error>> + Send;
566    fn r#get_metrics(&self) -> Self::GetMetricsResponseFut;
567}
568#[derive(Debug)]
569#[cfg(target_os = "fuchsia")]
570pub struct InfoSynchronousProxy {
571    client: fidl::client::sync::Client,
572}
573
574#[cfg(target_os = "fuchsia")]
575impl fidl::endpoints::SynchronousProxy for InfoSynchronousProxy {
576    type Proxy = InfoProxy;
577    type Protocol = InfoMarker;
578
579    fn from_channel(inner: fidl::Channel) -> Self {
580        Self::new(inner)
581    }
582
583    fn into_channel(self) -> fidl::Channel {
584        self.client.into_channel()
585    }
586
587    fn as_channel(&self) -> &fidl::Channel {
588        self.client.as_channel()
589    }
590}
591
592#[cfg(target_os = "fuchsia")]
593impl InfoSynchronousProxy {
594    pub fn new(channel: fidl::Channel) -> Self {
595        let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
596        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
597    }
598
599    pub fn into_channel(self) -> fidl::Channel {
600        self.client.into_channel()
601    }
602
603    /// Waits until an event arrives and returns it. It is safe for other
604    /// threads to make concurrent requests while waiting for an event.
605    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<InfoEvent, fidl::Error> {
606        InfoEvent::decode(self.client.wait_for_event(deadline)?)
607    }
608
609    pub fn r#get_metrics(&self, ___deadline: zx::MonotonicInstant) -> Result<Metrics, fidl::Error> {
610        let _response =
611            self.client.send_query::<fidl::encoding::EmptyPayload, InfoGetMetricsResponse>(
612                (),
613                0x6d631353834698be,
614                fidl::encoding::DynamicFlags::empty(),
615                ___deadline,
616            )?;
617        Ok(_response.info)
618    }
619}
620
621#[cfg(target_os = "fuchsia")]
622impl From<InfoSynchronousProxy> for zx::Handle {
623    fn from(value: InfoSynchronousProxy) -> Self {
624        value.into_channel().into()
625    }
626}
627
628#[cfg(target_os = "fuchsia")]
629impl From<fidl::Channel> for InfoSynchronousProxy {
630    fn from(value: fidl::Channel) -> Self {
631        Self::new(value)
632    }
633}
634
635#[cfg(target_os = "fuchsia")]
636impl fidl::endpoints::FromClient for InfoSynchronousProxy {
637    type Protocol = InfoMarker;
638
639    fn from_client(value: fidl::endpoints::ClientEnd<InfoMarker>) -> Self {
640        Self::new(value.into_channel())
641    }
642}
643
644#[derive(Debug, Clone)]
645pub struct InfoProxy {
646    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
647}
648
649impl fidl::endpoints::Proxy for InfoProxy {
650    type Protocol = InfoMarker;
651
652    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
653        Self::new(inner)
654    }
655
656    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
657        self.client.into_channel().map_err(|client| Self { client })
658    }
659
660    fn as_channel(&self) -> &::fidl::AsyncChannel {
661        self.client.as_channel()
662    }
663}
664
665impl InfoProxy {
666    /// Create a new Proxy for fuchsia.ui.display.singleton/Info.
667    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
668        let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
669        Self { client: fidl::client::Client::new(channel, protocol_name) }
670    }
671
672    /// Get a Stream of events from the remote end of the protocol.
673    ///
674    /// # Panics
675    ///
676    /// Panics if the event stream was already taken.
677    pub fn take_event_stream(&self) -> InfoEventStream {
678        InfoEventStream { event_receiver: self.client.take_event_receiver() }
679    }
680
681    pub fn r#get_metrics(
682        &self,
683    ) -> fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>
684    {
685        InfoProxyInterface::r#get_metrics(self)
686    }
687}
688
689impl InfoProxyInterface for InfoProxy {
690    type GetMetricsResponseFut =
691        fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>;
692    fn r#get_metrics(&self) -> Self::GetMetricsResponseFut {
693        fn _decode(
694            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
695        ) -> Result<Metrics, fidl::Error> {
696            let _response = fidl::client::decode_transaction_body::<
697                InfoGetMetricsResponse,
698                fidl::encoding::DefaultFuchsiaResourceDialect,
699                0x6d631353834698be,
700            >(_buf?)?;
701            Ok(_response.info)
702        }
703        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Metrics>(
704            (),
705            0x6d631353834698be,
706            fidl::encoding::DynamicFlags::empty(),
707            _decode,
708        )
709    }
710}
711
712pub struct InfoEventStream {
713    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
714}
715
716impl std::marker::Unpin for InfoEventStream {}
717
718impl futures::stream::FusedStream for InfoEventStream {
719    fn is_terminated(&self) -> bool {
720        self.event_receiver.is_terminated()
721    }
722}
723
724impl futures::Stream for InfoEventStream {
725    type Item = Result<InfoEvent, fidl::Error>;
726
727    fn poll_next(
728        mut self: std::pin::Pin<&mut Self>,
729        cx: &mut std::task::Context<'_>,
730    ) -> std::task::Poll<Option<Self::Item>> {
731        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
732            &mut self.event_receiver,
733            cx
734        )?) {
735            Some(buf) => std::task::Poll::Ready(Some(InfoEvent::decode(buf))),
736            None => std::task::Poll::Ready(None),
737        }
738    }
739}
740
741#[derive(Debug)]
742pub enum InfoEvent {}
743
744impl InfoEvent {
745    /// Decodes a message buffer as a [`InfoEvent`].
746    fn decode(
747        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
748    ) -> Result<InfoEvent, fidl::Error> {
749        let (bytes, _handles) = buf.split_mut();
750        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
751        debug_assert_eq!(tx_header.tx_id, 0);
752        match tx_header.ordinal {
753            _ => Err(fidl::Error::UnknownOrdinal {
754                ordinal: tx_header.ordinal,
755                protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
756            }),
757        }
758    }
759}
760
761/// A Stream of incoming requests for fuchsia.ui.display.singleton/Info.
762pub struct InfoRequestStream {
763    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
764    is_terminated: bool,
765}
766
767impl std::marker::Unpin for InfoRequestStream {}
768
769impl futures::stream::FusedStream for InfoRequestStream {
770    fn is_terminated(&self) -> bool {
771        self.is_terminated
772    }
773}
774
775impl fidl::endpoints::RequestStream for InfoRequestStream {
776    type Protocol = InfoMarker;
777    type ControlHandle = InfoControlHandle;
778
779    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
780        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
781    }
782
783    fn control_handle(&self) -> Self::ControlHandle {
784        InfoControlHandle { inner: self.inner.clone() }
785    }
786
787    fn into_inner(
788        self,
789    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
790    {
791        (self.inner, self.is_terminated)
792    }
793
794    fn from_inner(
795        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
796        is_terminated: bool,
797    ) -> Self {
798        Self { inner, is_terminated }
799    }
800}
801
802impl futures::Stream for InfoRequestStream {
803    type Item = Result<InfoRequest, fidl::Error>;
804
805    fn poll_next(
806        mut self: std::pin::Pin<&mut Self>,
807        cx: &mut std::task::Context<'_>,
808    ) -> std::task::Poll<Option<Self::Item>> {
809        let this = &mut *self;
810        if this.inner.check_shutdown(cx) {
811            this.is_terminated = true;
812            return std::task::Poll::Ready(None);
813        }
814        if this.is_terminated {
815            panic!("polled InfoRequestStream after completion");
816        }
817        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
818            |bytes, handles| {
819                match this.inner.channel().read_etc(cx, bytes, handles) {
820                    std::task::Poll::Ready(Ok(())) => {}
821                    std::task::Poll::Pending => return std::task::Poll::Pending,
822                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
823                        this.is_terminated = true;
824                        return std::task::Poll::Ready(None);
825                    }
826                    std::task::Poll::Ready(Err(e)) => {
827                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
828                            e.into(),
829                        ))))
830                    }
831                }
832
833                // A message has been received from the channel
834                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
835
836                std::task::Poll::Ready(Some(match header.ordinal {
837                    0x6d631353834698be => {
838                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
839                        let mut req = fidl::new_empty!(
840                            fidl::encoding::EmptyPayload,
841                            fidl::encoding::DefaultFuchsiaResourceDialect
842                        );
843                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
844                        let control_handle = InfoControlHandle { inner: this.inner.clone() };
845                        Ok(InfoRequest::GetMetrics {
846                            responder: InfoGetMetricsResponder {
847                                control_handle: std::mem::ManuallyDrop::new(control_handle),
848                                tx_id: header.tx_id,
849                            },
850                        })
851                    }
852                    _ => Err(fidl::Error::UnknownOrdinal {
853                        ordinal: header.ordinal,
854                        protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
855                    }),
856                }))
857            },
858        )
859    }
860}
861
862/// Get information about Scenic's primary display.
863#[derive(Debug)]
864pub enum InfoRequest {
865    GetMetrics { responder: InfoGetMetricsResponder },
866}
867
868impl InfoRequest {
869    #[allow(irrefutable_let_patterns)]
870    pub fn into_get_metrics(self) -> Option<(InfoGetMetricsResponder)> {
871        if let InfoRequest::GetMetrics { responder } = self {
872            Some((responder))
873        } else {
874            None
875        }
876    }
877
878    /// Name of the method defined in FIDL
879    pub fn method_name(&self) -> &'static str {
880        match *self {
881            InfoRequest::GetMetrics { .. } => "get_metrics",
882        }
883    }
884}
885
886#[derive(Debug, Clone)]
887pub struct InfoControlHandle {
888    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
889}
890
891impl fidl::endpoints::ControlHandle for InfoControlHandle {
892    fn shutdown(&self) {
893        self.inner.shutdown()
894    }
895    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
896        self.inner.shutdown_with_epitaph(status)
897    }
898
899    fn is_closed(&self) -> bool {
900        self.inner.channel().is_closed()
901    }
902    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
903        self.inner.channel().on_closed()
904    }
905
906    #[cfg(target_os = "fuchsia")]
907    fn signal_peer(
908        &self,
909        clear_mask: zx::Signals,
910        set_mask: zx::Signals,
911    ) -> Result<(), zx_status::Status> {
912        use fidl::Peered;
913        self.inner.channel().signal_peer(clear_mask, set_mask)
914    }
915}
916
917impl InfoControlHandle {}
918
919#[must_use = "FIDL methods require a response to be sent"]
920#[derive(Debug)]
921pub struct InfoGetMetricsResponder {
922    control_handle: std::mem::ManuallyDrop<InfoControlHandle>,
923    tx_id: u32,
924}
925
926/// Set the the channel to be shutdown (see [`InfoControlHandle::shutdown`])
927/// if the responder is dropped without sending a response, so that the client
928/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
929impl std::ops::Drop for InfoGetMetricsResponder {
930    fn drop(&mut self) {
931        self.control_handle.shutdown();
932        // Safety: drops once, never accessed again
933        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
934    }
935}
936
937impl fidl::endpoints::Responder for InfoGetMetricsResponder {
938    type ControlHandle = InfoControlHandle;
939
940    fn control_handle(&self) -> &InfoControlHandle {
941        &self.control_handle
942    }
943
944    fn drop_without_shutdown(mut self) {
945        // Safety: drops once, never accessed again due to mem::forget
946        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
947        // Prevent Drop from running (which would shut down the channel)
948        std::mem::forget(self);
949    }
950}
951
952impl InfoGetMetricsResponder {
953    /// Sends a response to the FIDL transaction.
954    ///
955    /// Sets the channel to shutdown if an error occurs.
956    pub fn send(self, mut info: &Metrics) -> Result<(), fidl::Error> {
957        let _result = self.send_raw(info);
958        if _result.is_err() {
959            self.control_handle.shutdown();
960        }
961        self.drop_without_shutdown();
962        _result
963    }
964
965    /// Similar to "send" but does not shutdown the channel if an error occurs.
966    pub fn send_no_shutdown_on_err(self, mut info: &Metrics) -> Result<(), fidl::Error> {
967        let _result = self.send_raw(info);
968        self.drop_without_shutdown();
969        _result
970    }
971
972    fn send_raw(&self, mut info: &Metrics) -> Result<(), fidl::Error> {
973        self.control_handle.inner.send::<InfoGetMetricsResponse>(
974            (info,),
975            self.tx_id,
976            0x6d631353834698be,
977            fidl::encoding::DynamicFlags::empty(),
978        )
979    }
980}
981
982mod internal {
983    use super::*;
984}