Skip to main content

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 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    /// Waits until an event arrives and returns it. It is safe for other
68    /// threads to make concurrent requests while waiting for an event.
69    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    /// Set the power state of the default connected display device to `power_mode`.
77    ///
78    /// Errors:
79    ///  - `ZX_ERR_NOT_FOUND`: There is no connected display.
80    ///  - `ZX_ERR_NOT_SUPPORTED`: The default connected display driver or hardware
81    ///    does not support the requested power mode.
82    ///  - `ZX_ERR_INTERNAL`: Operation failed for another reason.
83    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    /// Create a new Proxy for fuchsia.ui.display.singleton/DisplayPower.
149    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    /// Get a Stream of events from the remote end of the protocol.
155    ///
156    /// # Panics
157    ///
158    /// Panics if the event stream was already taken.
159    pub fn take_event_stream(&self) -> DisplayPowerEventStream {
160        DisplayPowerEventStream { event_receiver: self.client.take_event_receiver() }
161    }
162
163    /// Set the power state of the default connected display device to `power_mode`.
164    ///
165    /// Errors:
166    ///  - `ZX_ERR_NOT_FOUND`: There is no connected display.
167    ///  - `ZX_ERR_NOT_SUPPORTED`: The default connected display driver or hardware
168    ///    does not support the requested power mode.
169    ///  - `ZX_ERR_INTERNAL`: Operation failed for another reason.
170    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 of the event that was sent.
244        ordinal: u64,
245    },
246}
247
248impl DisplayPowerEvent {
249    /// Decodes a message buffer as a [`DisplayPowerEvent`].
250    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
268/// A Stream of incoming requests for fuchsia.ui.display.singleton/DisplayPower.
269pub 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                // A message has been received from the channel
341                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/// Controls the power state of the default display device.
402#[derive(Debug)]
403pub enum DisplayPowerRequest {
404    /// Set the power state of the default connected display device to `power_mode`.
405    ///
406    /// Errors:
407    ///  - `ZX_ERR_NOT_FOUND`: There is no connected display.
408    ///  - `ZX_ERR_NOT_SUPPORTED`: The default connected display driver or hardware
409    ///    does not support the requested power mode.
410    ///  - `ZX_ERR_INTERNAL`: Operation failed for another reason.
411    SetPowerMode { power_mode: PowerMode, responder: DisplayPowerSetPowerModeResponder },
412    /// An interaction was received which does not match any known method.
413    #[non_exhaustive]
414    _UnknownMethod {
415        /// Ordinal of the method that was called.
416        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    /// Name of the method defined in FIDL
433    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 DisplayPowerControlHandle {
452    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
453        self.inner.shutdown_with_epitaph(status.into())
454    }
455}
456
457impl fidl::endpoints::ControlHandle for DisplayPowerControlHandle {
458    fn shutdown(&self) {
459        self.inner.shutdown()
460    }
461
462    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
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 DisplayPowerSetPowerModeResponder {
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 DisplayPowerSetPowerModeResponder {
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 DisplayPowerSetPowerModeResponder {
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 DisplayPowerSetPowerModeResponder {
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.inner.send::<fidl::encoding::FlexibleResultType<
541            fidl::encoding::EmptyStruct,
542            i32,
543        >>(
544            fidl::encoding::FlexibleResult::new(result),
545            self.tx_id,
546            0x420dcd07d68e1fbc,
547            fidl::encoding::DynamicFlags::FLEXIBLE,
548        )
549    }
550}
551
552#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
553pub struct InfoMarker;
554
555impl fidl::endpoints::ProtocolMarker for InfoMarker {
556    type Proxy = InfoProxy;
557    type RequestStream = InfoRequestStream;
558    #[cfg(target_os = "fuchsia")]
559    type SynchronousProxy = InfoSynchronousProxy;
560
561    const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.Info";
562}
563impl fidl::endpoints::DiscoverableProtocolMarker for InfoMarker {}
564
565pub trait InfoProxyInterface: Send + Sync {
566    type GetMetricsResponseFut: std::future::Future<Output = Result<Metrics, fidl::Error>> + Send;
567    fn r#get_metrics(&self) -> Self::GetMetricsResponseFut;
568}
569#[derive(Debug)]
570#[cfg(target_os = "fuchsia")]
571pub struct InfoSynchronousProxy {
572    client: fidl::client::sync::Client,
573}
574
575#[cfg(target_os = "fuchsia")]
576impl fidl::endpoints::SynchronousProxy for InfoSynchronousProxy {
577    type Proxy = InfoProxy;
578    type Protocol = InfoMarker;
579
580    fn from_channel(inner: fidl::Channel) -> Self {
581        Self::new(inner)
582    }
583
584    fn into_channel(self) -> fidl::Channel {
585        self.client.into_channel()
586    }
587
588    fn as_channel(&self) -> &fidl::Channel {
589        self.client.as_channel()
590    }
591}
592
593#[cfg(target_os = "fuchsia")]
594impl InfoSynchronousProxy {
595    pub fn new(channel: fidl::Channel) -> Self {
596        Self { client: fidl::client::sync::Client::new(channel) }
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::<InfoMarker>(deadline)?)
607    }
608
609    pub fn r#get_metrics(&self, ___deadline: zx::MonotonicInstant) -> Result<Metrics, fidl::Error> {
610        let _response = self
611            .client
612            .send_query::<fidl::encoding::EmptyPayload, InfoGetMetricsResponse, InfoMarker>(
613                (),
614                0x6d631353834698be,
615                fidl::encoding::DynamicFlags::empty(),
616                ___deadline,
617            )?;
618        Ok(_response.info)
619    }
620}
621
622#[cfg(target_os = "fuchsia")]
623impl From<InfoSynchronousProxy> for zx::NullableHandle {
624    fn from(value: InfoSynchronousProxy) -> Self {
625        value.into_channel().into()
626    }
627}
628
629#[cfg(target_os = "fuchsia")]
630impl From<fidl::Channel> for InfoSynchronousProxy {
631    fn from(value: fidl::Channel) -> Self {
632        Self::new(value)
633    }
634}
635
636#[cfg(target_os = "fuchsia")]
637impl fidl::endpoints::FromClient for InfoSynchronousProxy {
638    type Protocol = InfoMarker;
639
640    fn from_client(value: fidl::endpoints::ClientEnd<InfoMarker>) -> Self {
641        Self::new(value.into_channel())
642    }
643}
644
645#[derive(Debug, Clone)]
646pub struct InfoProxy {
647    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
648}
649
650impl fidl::endpoints::Proxy for InfoProxy {
651    type Protocol = InfoMarker;
652
653    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
654        Self::new(inner)
655    }
656
657    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
658        self.client.into_channel().map_err(|client| Self { client })
659    }
660
661    fn as_channel(&self) -> &::fidl::AsyncChannel {
662        self.client.as_channel()
663    }
664}
665
666impl InfoProxy {
667    /// Create a new Proxy for fuchsia.ui.display.singleton/Info.
668    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
669        let protocol_name = <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
670        Self { client: fidl::client::Client::new(channel, protocol_name) }
671    }
672
673    /// Get a Stream of events from the remote end of the protocol.
674    ///
675    /// # Panics
676    ///
677    /// Panics if the event stream was already taken.
678    pub fn take_event_stream(&self) -> InfoEventStream {
679        InfoEventStream { event_receiver: self.client.take_event_receiver() }
680    }
681
682    pub fn r#get_metrics(
683        &self,
684    ) -> fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>
685    {
686        InfoProxyInterface::r#get_metrics(self)
687    }
688}
689
690impl InfoProxyInterface for InfoProxy {
691    type GetMetricsResponseFut =
692        fidl::client::QueryResponseFut<Metrics, fidl::encoding::DefaultFuchsiaResourceDialect>;
693    fn r#get_metrics(&self) -> Self::GetMetricsResponseFut {
694        fn _decode(
695            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
696        ) -> Result<Metrics, fidl::Error> {
697            let _response = fidl::client::decode_transaction_body::<
698                InfoGetMetricsResponse,
699                fidl::encoding::DefaultFuchsiaResourceDialect,
700                0x6d631353834698be,
701            >(_buf?)?;
702            Ok(_response.info)
703        }
704        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Metrics>(
705            (),
706            0x6d631353834698be,
707            fidl::encoding::DynamicFlags::empty(),
708            _decode,
709        )
710    }
711}
712
713pub struct InfoEventStream {
714    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
715}
716
717impl std::marker::Unpin for InfoEventStream {}
718
719impl futures::stream::FusedStream for InfoEventStream {
720    fn is_terminated(&self) -> bool {
721        self.event_receiver.is_terminated()
722    }
723}
724
725impl futures::Stream for InfoEventStream {
726    type Item = Result<InfoEvent, fidl::Error>;
727
728    fn poll_next(
729        mut self: std::pin::Pin<&mut Self>,
730        cx: &mut std::task::Context<'_>,
731    ) -> std::task::Poll<Option<Self::Item>> {
732        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
733            &mut self.event_receiver,
734            cx
735        )?) {
736            Some(buf) => std::task::Poll::Ready(Some(InfoEvent::decode(buf))),
737            None => std::task::Poll::Ready(None),
738        }
739    }
740}
741
742#[derive(Debug)]
743pub enum InfoEvent {}
744
745impl InfoEvent {
746    /// Decodes a message buffer as a [`InfoEvent`].
747    fn decode(
748        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
749    ) -> Result<InfoEvent, fidl::Error> {
750        let (bytes, _handles) = buf.split_mut();
751        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
752        debug_assert_eq!(tx_header.tx_id, 0);
753        match tx_header.ordinal {
754            _ => Err(fidl::Error::UnknownOrdinal {
755                ordinal: tx_header.ordinal,
756                protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
757            }),
758        }
759    }
760}
761
762/// A Stream of incoming requests for fuchsia.ui.display.singleton/Info.
763pub struct InfoRequestStream {
764    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
765    is_terminated: bool,
766}
767
768impl std::marker::Unpin for InfoRequestStream {}
769
770impl futures::stream::FusedStream for InfoRequestStream {
771    fn is_terminated(&self) -> bool {
772        self.is_terminated
773    }
774}
775
776impl fidl::endpoints::RequestStream for InfoRequestStream {
777    type Protocol = InfoMarker;
778    type ControlHandle = InfoControlHandle;
779
780    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
781        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
782    }
783
784    fn control_handle(&self) -> Self::ControlHandle {
785        InfoControlHandle { inner: self.inner.clone() }
786    }
787
788    fn into_inner(
789        self,
790    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
791    {
792        (self.inner, self.is_terminated)
793    }
794
795    fn from_inner(
796        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
797        is_terminated: bool,
798    ) -> Self {
799        Self { inner, is_terminated }
800    }
801}
802
803impl futures::Stream for InfoRequestStream {
804    type Item = Result<InfoRequest, fidl::Error>;
805
806    fn poll_next(
807        mut self: std::pin::Pin<&mut Self>,
808        cx: &mut std::task::Context<'_>,
809    ) -> std::task::Poll<Option<Self::Item>> {
810        let this = &mut *self;
811        if this.inner.check_shutdown(cx) {
812            this.is_terminated = true;
813            return std::task::Poll::Ready(None);
814        }
815        if this.is_terminated {
816            panic!("polled InfoRequestStream after completion");
817        }
818        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
819            |bytes, handles| {
820                match this.inner.channel().read_etc(cx, bytes, handles) {
821                    std::task::Poll::Ready(Ok(())) => {}
822                    std::task::Poll::Pending => return std::task::Poll::Pending,
823                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
824                        this.is_terminated = true;
825                        return std::task::Poll::Ready(None);
826                    }
827                    std::task::Poll::Ready(Err(e)) => {
828                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
829                            e.into(),
830                        ))));
831                    }
832                }
833
834                // A message has been received from the channel
835                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
836
837                std::task::Poll::Ready(Some(match header.ordinal {
838                    0x6d631353834698be => {
839                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
840                        let mut req = fidl::new_empty!(
841                            fidl::encoding::EmptyPayload,
842                            fidl::encoding::DefaultFuchsiaResourceDialect
843                        );
844                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
845                        let control_handle = InfoControlHandle { inner: this.inner.clone() };
846                        Ok(InfoRequest::GetMetrics {
847                            responder: InfoGetMetricsResponder {
848                                control_handle: std::mem::ManuallyDrop::new(control_handle),
849                                tx_id: header.tx_id,
850                            },
851                        })
852                    }
853                    _ => Err(fidl::Error::UnknownOrdinal {
854                        ordinal: header.ordinal,
855                        protocol_name: <InfoMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
856                    }),
857                }))
858            },
859        )
860    }
861}
862
863/// Get information about Scenic's primary display.
864#[derive(Debug)]
865pub enum InfoRequest {
866    GetMetrics { responder: InfoGetMetricsResponder },
867}
868
869impl InfoRequest {
870    #[allow(irrefutable_let_patterns)]
871    pub fn into_get_metrics(self) -> Option<(InfoGetMetricsResponder)> {
872        if let InfoRequest::GetMetrics { responder } = self { Some((responder)) } else { None }
873    }
874
875    /// Name of the method defined in FIDL
876    pub fn method_name(&self) -> &'static str {
877        match *self {
878            InfoRequest::GetMetrics { .. } => "get_metrics",
879        }
880    }
881}
882
883#[derive(Debug, Clone)]
884pub struct InfoControlHandle {
885    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
886}
887
888impl InfoControlHandle {
889    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
890        self.inner.shutdown_with_epitaph(status.into())
891    }
892}
893
894impl fidl::endpoints::ControlHandle for InfoControlHandle {
895    fn shutdown(&self) {
896        self.inner.shutdown()
897    }
898
899    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
900        self.inner.shutdown_with_epitaph(status)
901    }
902
903    fn is_closed(&self) -> bool {
904        self.inner.channel().is_closed()
905    }
906    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
907        self.inner.channel().on_closed()
908    }
909
910    #[cfg(target_os = "fuchsia")]
911    fn signal_peer(
912        &self,
913        clear_mask: zx::Signals,
914        set_mask: zx::Signals,
915    ) -> Result<(), zx_status::Status> {
916        use fidl::Peered;
917        self.inner.channel().signal_peer(clear_mask, set_mask)
918    }
919}
920
921impl InfoControlHandle {}
922
923#[must_use = "FIDL methods require a response to be sent"]
924#[derive(Debug)]
925pub struct InfoGetMetricsResponder {
926    control_handle: std::mem::ManuallyDrop<InfoControlHandle>,
927    tx_id: u32,
928}
929
930/// Set the the channel to be shutdown (see [`InfoControlHandle::shutdown`])
931/// if the responder is dropped without sending a response, so that the client
932/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
933impl std::ops::Drop for InfoGetMetricsResponder {
934    fn drop(&mut self) {
935        self.control_handle.shutdown();
936        // Safety: drops once, never accessed again
937        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
938    }
939}
940
941impl fidl::endpoints::Responder for InfoGetMetricsResponder {
942    type ControlHandle = InfoControlHandle;
943
944    fn control_handle(&self) -> &InfoControlHandle {
945        &self.control_handle
946    }
947
948    fn drop_without_shutdown(mut self) {
949        // Safety: drops once, never accessed again due to mem::forget
950        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
951        // Prevent Drop from running (which would shut down the channel)
952        std::mem::forget(self);
953    }
954}
955
956impl InfoGetMetricsResponder {
957    /// Sends a response to the FIDL transaction.
958    ///
959    /// Sets the channel to shutdown if an error occurs.
960    pub fn send(self, mut info: &Metrics) -> Result<(), fidl::Error> {
961        let _result = self.send_raw(info);
962        if _result.is_err() {
963            self.control_handle.shutdown();
964        }
965        self.drop_without_shutdown();
966        _result
967    }
968
969    /// Similar to "send" but does not shutdown the channel if an error occurs.
970    pub fn send_no_shutdown_on_err(self, mut info: &Metrics) -> Result<(), fidl::Error> {
971        let _result = self.send_raw(info);
972        self.drop_without_shutdown();
973        _result
974    }
975
976    fn send_raw(&self, mut info: &Metrics) -> Result<(), fidl::Error> {
977        self.control_handle.inner.send::<InfoGetMetricsResponse>(
978            (info,),
979            self.tx_id,
980            0x6d631353834698be,
981            fidl::encoding::DynamicFlags::empty(),
982        )
983    }
984}
985
986#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
987pub struct VsyncSourceMarker;
988
989impl fidl::endpoints::ProtocolMarker for VsyncSourceMarker {
990    type Proxy = VsyncSourceProxy;
991    type RequestStream = VsyncSourceRequestStream;
992    #[cfg(target_os = "fuchsia")]
993    type SynchronousProxy = VsyncSourceSynchronousProxy;
994
995    const DEBUG_NAME: &'static str = "fuchsia.ui.display.singleton.VsyncSource";
996}
997impl fidl::endpoints::DiscoverableProtocolMarker for VsyncSourceMarker {}
998
999pub trait VsyncSourceProxyInterface: Send + Sync {
1000    fn r#set_vsync_enabled(&self, enabled: bool) -> Result<(), fidl::Error>;
1001}
1002#[derive(Debug)]
1003#[cfg(target_os = "fuchsia")]
1004pub struct VsyncSourceSynchronousProxy {
1005    client: fidl::client::sync::Client,
1006}
1007
1008#[cfg(target_os = "fuchsia")]
1009impl fidl::endpoints::SynchronousProxy for VsyncSourceSynchronousProxy {
1010    type Proxy = VsyncSourceProxy;
1011    type Protocol = VsyncSourceMarker;
1012
1013    fn from_channel(inner: fidl::Channel) -> Self {
1014        Self::new(inner)
1015    }
1016
1017    fn into_channel(self) -> fidl::Channel {
1018        self.client.into_channel()
1019    }
1020
1021    fn as_channel(&self) -> &fidl::Channel {
1022        self.client.as_channel()
1023    }
1024}
1025
1026#[cfg(target_os = "fuchsia")]
1027impl VsyncSourceSynchronousProxy {
1028    pub fn new(channel: fidl::Channel) -> Self {
1029        Self { client: fidl::client::sync::Client::new(channel) }
1030    }
1031
1032    pub fn into_channel(self) -> fidl::Channel {
1033        self.client.into_channel()
1034    }
1035
1036    /// Waits until an event arrives and returns it. It is safe for other
1037    /// threads to make concurrent requests while waiting for an event.
1038    pub fn wait_for_event(
1039        &self,
1040        deadline: zx::MonotonicInstant,
1041    ) -> Result<VsyncSourceEvent, fidl::Error> {
1042        VsyncSourceEvent::decode(self.client.wait_for_event::<VsyncSourceMarker>(deadline)?)
1043    }
1044
1045    /// Enables or disables receiving `OnVsync` for the given display.
1046    ///
1047    /// The client receives `OnVsync` callbacks iff this function is called with `enabled=true`.
1048    /// Calling this with `enabled=false` stops generating callbacks. Note that there may be a
1049    /// race with a server receiving this and extra `OnVsync` may be received.
1050    ///
1051    /// By default, the listener is assumed to have called `enabled=false`.
1052    pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1053        self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1054            (enabled,),
1055            0x5aaab140804e1b32,
1056            fidl::encoding::DynamicFlags::empty(),
1057        )
1058    }
1059}
1060
1061#[cfg(target_os = "fuchsia")]
1062impl From<VsyncSourceSynchronousProxy> for zx::NullableHandle {
1063    fn from(value: VsyncSourceSynchronousProxy) -> Self {
1064        value.into_channel().into()
1065    }
1066}
1067
1068#[cfg(target_os = "fuchsia")]
1069impl From<fidl::Channel> for VsyncSourceSynchronousProxy {
1070    fn from(value: fidl::Channel) -> Self {
1071        Self::new(value)
1072    }
1073}
1074
1075#[cfg(target_os = "fuchsia")]
1076impl fidl::endpoints::FromClient for VsyncSourceSynchronousProxy {
1077    type Protocol = VsyncSourceMarker;
1078
1079    fn from_client(value: fidl::endpoints::ClientEnd<VsyncSourceMarker>) -> Self {
1080        Self::new(value.into_channel())
1081    }
1082}
1083
1084#[derive(Debug, Clone)]
1085pub struct VsyncSourceProxy {
1086    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1087}
1088
1089impl fidl::endpoints::Proxy for VsyncSourceProxy {
1090    type Protocol = VsyncSourceMarker;
1091
1092    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1093        Self::new(inner)
1094    }
1095
1096    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1097        self.client.into_channel().map_err(|client| Self { client })
1098    }
1099
1100    fn as_channel(&self) -> &::fidl::AsyncChannel {
1101        self.client.as_channel()
1102    }
1103}
1104
1105impl VsyncSourceProxy {
1106    /// Create a new Proxy for fuchsia.ui.display.singleton/VsyncSource.
1107    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1108        let protocol_name = <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1109        Self { client: fidl::client::Client::new(channel, protocol_name) }
1110    }
1111
1112    /// Get a Stream of events from the remote end of the protocol.
1113    ///
1114    /// # Panics
1115    ///
1116    /// Panics if the event stream was already taken.
1117    pub fn take_event_stream(&self) -> VsyncSourceEventStream {
1118        VsyncSourceEventStream { event_receiver: self.client.take_event_receiver() }
1119    }
1120
1121    /// Enables or disables receiving `OnVsync` for the given display.
1122    ///
1123    /// The client receives `OnVsync` callbacks iff this function is called with `enabled=true`.
1124    /// Calling this with `enabled=false` stops generating callbacks. Note that there may be a
1125    /// race with a server receiving this and extra `OnVsync` may be received.
1126    ///
1127    /// By default, the listener is assumed to have called `enabled=false`.
1128    pub fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1129        VsyncSourceProxyInterface::r#set_vsync_enabled(self, enabled)
1130    }
1131}
1132
1133impl VsyncSourceProxyInterface for VsyncSourceProxy {
1134    fn r#set_vsync_enabled(&self, mut enabled: bool) -> Result<(), fidl::Error> {
1135        self.client.send::<VsyncSourceSetVsyncEnabledRequest>(
1136            (enabled,),
1137            0x5aaab140804e1b32,
1138            fidl::encoding::DynamicFlags::empty(),
1139        )
1140    }
1141}
1142
1143pub struct VsyncSourceEventStream {
1144    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1145}
1146
1147impl std::marker::Unpin for VsyncSourceEventStream {}
1148
1149impl futures::stream::FusedStream for VsyncSourceEventStream {
1150    fn is_terminated(&self) -> bool {
1151        self.event_receiver.is_terminated()
1152    }
1153}
1154
1155impl futures::Stream for VsyncSourceEventStream {
1156    type Item = Result<VsyncSourceEvent, fidl::Error>;
1157
1158    fn poll_next(
1159        mut self: std::pin::Pin<&mut Self>,
1160        cx: &mut std::task::Context<'_>,
1161    ) -> std::task::Poll<Option<Self::Item>> {
1162        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1163            &mut self.event_receiver,
1164            cx
1165        )?) {
1166            Some(buf) => std::task::Poll::Ready(Some(VsyncSourceEvent::decode(buf))),
1167            None => std::task::Poll::Ready(None),
1168        }
1169    }
1170}
1171
1172#[derive(Debug)]
1173pub enum VsyncSourceEvent {
1174    OnVsync { timestamp: i64 },
1175}
1176
1177impl VsyncSourceEvent {
1178    #[allow(irrefutable_let_patterns)]
1179    pub fn into_on_vsync(self) -> Option<i64> {
1180        if let VsyncSourceEvent::OnVsync { timestamp } = self { Some((timestamp)) } else { None }
1181    }
1182
1183    /// Decodes a message buffer as a [`VsyncSourceEvent`].
1184    fn decode(
1185        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1186    ) -> Result<VsyncSourceEvent, fidl::Error> {
1187        let (bytes, _handles) = buf.split_mut();
1188        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1189        debug_assert_eq!(tx_header.tx_id, 0);
1190        match tx_header.ordinal {
1191            0x6677c178c3451448 => {
1192                let mut out = fidl::new_empty!(
1193                    VsyncSourceOnVsyncRequest,
1194                    fidl::encoding::DefaultFuchsiaResourceDialect
1195                );
1196                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceOnVsyncRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
1197                Ok((VsyncSourceEvent::OnVsync { timestamp: out.timestamp }))
1198            }
1199            _ => Err(fidl::Error::UnknownOrdinal {
1200                ordinal: tx_header.ordinal,
1201                protocol_name: <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1202            }),
1203        }
1204    }
1205}
1206
1207/// A Stream of incoming requests for fuchsia.ui.display.singleton/VsyncSource.
1208pub struct VsyncSourceRequestStream {
1209    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1210    is_terminated: bool,
1211}
1212
1213impl std::marker::Unpin for VsyncSourceRequestStream {}
1214
1215impl futures::stream::FusedStream for VsyncSourceRequestStream {
1216    fn is_terminated(&self) -> bool {
1217        self.is_terminated
1218    }
1219}
1220
1221impl fidl::endpoints::RequestStream for VsyncSourceRequestStream {
1222    type Protocol = VsyncSourceMarker;
1223    type ControlHandle = VsyncSourceControlHandle;
1224
1225    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1226        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1227    }
1228
1229    fn control_handle(&self) -> Self::ControlHandle {
1230        VsyncSourceControlHandle { inner: self.inner.clone() }
1231    }
1232
1233    fn into_inner(
1234        self,
1235    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1236    {
1237        (self.inner, self.is_terminated)
1238    }
1239
1240    fn from_inner(
1241        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1242        is_terminated: bool,
1243    ) -> Self {
1244        Self { inner, is_terminated }
1245    }
1246}
1247
1248impl futures::Stream for VsyncSourceRequestStream {
1249    type Item = Result<VsyncSourceRequest, fidl::Error>;
1250
1251    fn poll_next(
1252        mut self: std::pin::Pin<&mut Self>,
1253        cx: &mut std::task::Context<'_>,
1254    ) -> std::task::Poll<Option<Self::Item>> {
1255        let this = &mut *self;
1256        if this.inner.check_shutdown(cx) {
1257            this.is_terminated = true;
1258            return std::task::Poll::Ready(None);
1259        }
1260        if this.is_terminated {
1261            panic!("polled VsyncSourceRequestStream after completion");
1262        }
1263        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1264            |bytes, handles| {
1265                match this.inner.channel().read_etc(cx, bytes, handles) {
1266                    std::task::Poll::Ready(Ok(())) => {}
1267                    std::task::Poll::Pending => return std::task::Poll::Pending,
1268                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1269                        this.is_terminated = true;
1270                        return std::task::Poll::Ready(None);
1271                    }
1272                    std::task::Poll::Ready(Err(e)) => {
1273                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1274                            e.into(),
1275                        ))));
1276                    }
1277                }
1278
1279                // A message has been received from the channel
1280                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1281
1282                std::task::Poll::Ready(Some(match header.ordinal {
1283                    0x5aaab140804e1b32 => {
1284                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1285                        let mut req = fidl::new_empty!(
1286                            VsyncSourceSetVsyncEnabledRequest,
1287                            fidl::encoding::DefaultFuchsiaResourceDialect
1288                        );
1289                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<VsyncSourceSetVsyncEnabledRequest>(&header, _body_bytes, handles, &mut req)?;
1290                        let control_handle = VsyncSourceControlHandle { inner: this.inner.clone() };
1291                        Ok(VsyncSourceRequest::SetVsyncEnabled {
1292                            enabled: req.enabled,
1293
1294                            control_handle,
1295                        })
1296                    }
1297                    _ => Err(fidl::Error::UnknownOrdinal {
1298                        ordinal: header.ordinal,
1299                        protocol_name:
1300                            <VsyncSourceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1301                    }),
1302                }))
1303            },
1304        )
1305    }
1306}
1307
1308#[derive(Debug)]
1309pub enum VsyncSourceRequest {
1310    /// Enables or disables receiving `OnVsync` for the given display.
1311    ///
1312    /// The client receives `OnVsync` callbacks iff this function is called with `enabled=true`.
1313    /// Calling this with `enabled=false` stops generating callbacks. Note that there may be a
1314    /// race with a server receiving this and extra `OnVsync` may be received.
1315    ///
1316    /// By default, the listener is assumed to have called `enabled=false`.
1317    SetVsyncEnabled { enabled: bool, control_handle: VsyncSourceControlHandle },
1318}
1319
1320impl VsyncSourceRequest {
1321    #[allow(irrefutable_let_patterns)]
1322    pub fn into_set_vsync_enabled(self) -> Option<(bool, VsyncSourceControlHandle)> {
1323        if let VsyncSourceRequest::SetVsyncEnabled { enabled, control_handle } = self {
1324            Some((enabled, control_handle))
1325        } else {
1326            None
1327        }
1328    }
1329
1330    /// Name of the method defined in FIDL
1331    pub fn method_name(&self) -> &'static str {
1332        match *self {
1333            VsyncSourceRequest::SetVsyncEnabled { .. } => "set_vsync_enabled",
1334        }
1335    }
1336}
1337
1338#[derive(Debug, Clone)]
1339pub struct VsyncSourceControlHandle {
1340    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1341}
1342
1343impl VsyncSourceControlHandle {
1344    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1345        self.inner.shutdown_with_epitaph(status.into())
1346    }
1347}
1348
1349impl fidl::endpoints::ControlHandle for VsyncSourceControlHandle {
1350    fn shutdown(&self) {
1351        self.inner.shutdown()
1352    }
1353
1354    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1355        self.inner.shutdown_with_epitaph(status)
1356    }
1357
1358    fn is_closed(&self) -> bool {
1359        self.inner.channel().is_closed()
1360    }
1361    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1362        self.inner.channel().on_closed()
1363    }
1364
1365    #[cfg(target_os = "fuchsia")]
1366    fn signal_peer(
1367        &self,
1368        clear_mask: zx::Signals,
1369        set_mask: zx::Signals,
1370    ) -> Result<(), zx_status::Status> {
1371        use fidl::Peered;
1372        self.inner.channel().signal_peer(clear_mask, set_mask)
1373    }
1374}
1375
1376impl VsyncSourceControlHandle {
1377    pub fn send_on_vsync(&self, mut timestamp: i64) -> Result<(), fidl::Error> {
1378        self.inner.send::<VsyncSourceOnVsyncRequest>(
1379            (timestamp,),
1380            0,
1381            0x6677c178c3451448,
1382            fidl::encoding::DynamicFlags::empty(),
1383        )
1384    }
1385}
1386
1387mod internal {
1388    use super::*;
1389}