Skip to main content

fidl_fuchsia_session_window/
fidl_fuchsia_session_window.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_session_window_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ManagerMarker;
16
17impl fidl::endpoints::ProtocolMarker for ManagerMarker {
18    type Proxy = ManagerProxy;
19    type RequestStream = ManagerRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ManagerSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.session.window.Manager";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ManagerMarker {}
26
27pub trait ManagerProxyInterface: Send + Sync {
28    type ListResponseFut: std::future::Future<Output = Result<Vec<ListedView>, fidl::Error>> + Send;
29    fn r#list(&self) -> Self::ListResponseFut;
30    type SetOrderResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
31    fn r#set_order(&self, old_position: u64, new_position: u64) -> Self::SetOrderResponseFut;
32    type CycleResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
33    fn r#cycle(&self) -> Self::CycleResponseFut;
34    type FocusResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
35    fn r#focus(&self, position: u64) -> Self::FocusResponseFut;
36}
37#[derive(Debug)]
38#[cfg(target_os = "fuchsia")]
39pub struct ManagerSynchronousProxy {
40    client: fidl::client::sync::Client,
41}
42
43#[cfg(target_os = "fuchsia")]
44impl fidl::endpoints::SynchronousProxy for ManagerSynchronousProxy {
45    type Proxy = ManagerProxy;
46    type Protocol = ManagerMarker;
47
48    fn from_channel(inner: fidl::Channel) -> Self {
49        Self::new(inner)
50    }
51
52    fn into_channel(self) -> fidl::Channel {
53        self.client.into_channel()
54    }
55
56    fn as_channel(&self) -> &fidl::Channel {
57        self.client.as_channel()
58    }
59}
60
61#[cfg(target_os = "fuchsia")]
62impl ManagerSynchronousProxy {
63    pub fn new(channel: fidl::Channel) -> Self {
64        Self { client: fidl::client::sync::Client::new(channel) }
65    }
66
67    pub fn into_channel(self) -> fidl::Channel {
68        self.client.into_channel()
69    }
70
71    /// Waits until an event arrives and returns it. It is safe for other
72    /// threads to make concurrent requests while waiting for an event.
73    pub fn wait_for_event(
74        &self,
75        deadline: zx::MonotonicInstant,
76    ) -> Result<ManagerEvent, fidl::Error> {
77        ManagerEvent::decode(self.client.wait_for_event::<ManagerMarker>(deadline)?)
78    }
79
80    /// List ids of all views in the order they are being presented.
81    pub fn r#list(
82        &self,
83        ___deadline: zx::MonotonicInstant,
84    ) -> Result<Vec<ListedView>, fidl::Error> {
85        let _response = self.client.send_query::<
86            fidl::encoding::EmptyPayload,
87            fidl::encoding::FlexibleType<ManagerListResponse>,
88            ManagerMarker,
89        >(
90            (),
91            0x217177a089d8841b,
92            fidl::encoding::DynamicFlags::FLEXIBLE,
93            ___deadline,
94        )?
95        .into_result::<ManagerMarker>("list")?;
96        Ok(_response.views)
97    }
98
99    /// Moves the view at the given `old_position` to the given `new_position`.
100    /// Items in between are shifted and all other views keep their same relative order.
101    /// Window Manager expects both positions to be within the range of the length of
102    /// views currently presented. If invalid args are provided, the command will not
103    /// execute and an error message will be logged.
104    pub fn r#set_order(
105        &self,
106        mut old_position: u64,
107        mut new_position: u64,
108        ___deadline: zx::MonotonicInstant,
109    ) -> Result<(), fidl::Error> {
110        let _response = self.client.send_query::<
111            ManagerSetOrderRequest,
112            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
113            ManagerMarker,
114        >(
115            (old_position, new_position,),
116            0x1a1478f581f1f3c2,
117            fidl::encoding::DynamicFlags::FLEXIBLE,
118            ___deadline,
119        )?
120        .into_result::<ManagerMarker>("set_order")?;
121        Ok(_response)
122    }
123
124    /// Shifts all views forward by one position, view at position 0 is moved to the end.
125    pub fn r#cycle(&self, ___deadline: zx::MonotonicInstant) -> Result<(), fidl::Error> {
126        let _response = self.client.send_query::<
127            fidl::encoding::EmptyPayload,
128            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
129            ManagerMarker,
130        >(
131            (),
132            0x4211a94117087267,
133            fidl::encoding::DynamicFlags::FLEXIBLE,
134            ___deadline,
135        )?
136        .into_result::<ManagerMarker>("cycle")?;
137        Ok(_response)
138    }
139
140    /// Sets keyboard focus to the view at `position` and makes that view visible.
141    pub fn r#focus(
142        &self,
143        mut position: u64,
144        ___deadline: zx::MonotonicInstant,
145    ) -> Result<(), fidl::Error> {
146        let _response = self.client.send_query::<
147            ManagerFocusRequest,
148            fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
149            ManagerMarker,
150        >(
151            (position,),
152            0x789b0f092eb9551f,
153            fidl::encoding::DynamicFlags::FLEXIBLE,
154            ___deadline,
155        )?
156        .into_result::<ManagerMarker>("focus")?;
157        Ok(_response)
158    }
159}
160
161#[cfg(target_os = "fuchsia")]
162impl From<ManagerSynchronousProxy> for zx::NullableHandle {
163    fn from(value: ManagerSynchronousProxy) -> Self {
164        value.into_channel().into()
165    }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl From<fidl::Channel> for ManagerSynchronousProxy {
170    fn from(value: fidl::Channel) -> Self {
171        Self::new(value)
172    }
173}
174
175#[cfg(target_os = "fuchsia")]
176impl fidl::endpoints::FromClient for ManagerSynchronousProxy {
177    type Protocol = ManagerMarker;
178
179    fn from_client(value: fidl::endpoints::ClientEnd<ManagerMarker>) -> Self {
180        Self::new(value.into_channel())
181    }
182}
183
184#[derive(Debug, Clone)]
185pub struct ManagerProxy {
186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
187}
188
189impl fidl::endpoints::Proxy for ManagerProxy {
190    type Protocol = ManagerMarker;
191
192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
193        Self::new(inner)
194    }
195
196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
197        self.client.into_channel().map_err(|client| Self { client })
198    }
199
200    fn as_channel(&self) -> &::fidl::AsyncChannel {
201        self.client.as_channel()
202    }
203}
204
205impl ManagerProxy {
206    /// Create a new Proxy for fuchsia.session.window/Manager.
207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
208        let protocol_name = <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
209        Self { client: fidl::client::Client::new(channel, protocol_name) }
210    }
211
212    /// Get a Stream of events from the remote end of the protocol.
213    ///
214    /// # Panics
215    ///
216    /// Panics if the event stream was already taken.
217    pub fn take_event_stream(&self) -> ManagerEventStream {
218        ManagerEventStream { event_receiver: self.client.take_event_receiver() }
219    }
220
221    /// List ids of all views in the order they are being presented.
222    pub fn r#list(
223        &self,
224    ) -> fidl::client::QueryResponseFut<
225        Vec<ListedView>,
226        fidl::encoding::DefaultFuchsiaResourceDialect,
227    > {
228        ManagerProxyInterface::r#list(self)
229    }
230
231    /// Moves the view at the given `old_position` to the given `new_position`.
232    /// Items in between are shifted and all other views keep their same relative order.
233    /// Window Manager expects both positions to be within the range of the length of
234    /// views currently presented. If invalid args are provided, the command will not
235    /// execute and an error message will be logged.
236    pub fn r#set_order(
237        &self,
238        mut old_position: u64,
239        mut new_position: u64,
240    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
241        ManagerProxyInterface::r#set_order(self, old_position, new_position)
242    }
243
244    /// Shifts all views forward by one position, view at position 0 is moved to the end.
245    pub fn r#cycle(
246        &self,
247    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
248        ManagerProxyInterface::r#cycle(self)
249    }
250
251    /// Sets keyboard focus to the view at `position` and makes that view visible.
252    pub fn r#focus(
253        &self,
254        mut position: u64,
255    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
256        ManagerProxyInterface::r#focus(self, position)
257    }
258}
259
260impl ManagerProxyInterface for ManagerProxy {
261    type ListResponseFut = fidl::client::QueryResponseFut<
262        Vec<ListedView>,
263        fidl::encoding::DefaultFuchsiaResourceDialect,
264    >;
265    fn r#list(&self) -> Self::ListResponseFut {
266        fn _decode(
267            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
268        ) -> Result<Vec<ListedView>, fidl::Error> {
269            let _response = fidl::client::decode_transaction_body::<
270                fidl::encoding::FlexibleType<ManagerListResponse>,
271                fidl::encoding::DefaultFuchsiaResourceDialect,
272                0x217177a089d8841b,
273            >(_buf?)?
274            .into_result::<ManagerMarker>("list")?;
275            Ok(_response.views)
276        }
277        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<ListedView>>(
278            (),
279            0x217177a089d8841b,
280            fidl::encoding::DynamicFlags::FLEXIBLE,
281            _decode,
282        )
283    }
284
285    type SetOrderResponseFut =
286        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
287    fn r#set_order(
288        &self,
289        mut old_position: u64,
290        mut new_position: u64,
291    ) -> Self::SetOrderResponseFut {
292        fn _decode(
293            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
294        ) -> Result<(), fidl::Error> {
295            let _response = fidl::client::decode_transaction_body::<
296                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
297                fidl::encoding::DefaultFuchsiaResourceDialect,
298                0x1a1478f581f1f3c2,
299            >(_buf?)?
300            .into_result::<ManagerMarker>("set_order")?;
301            Ok(_response)
302        }
303        self.client.send_query_and_decode::<ManagerSetOrderRequest, ()>(
304            (old_position, new_position),
305            0x1a1478f581f1f3c2,
306            fidl::encoding::DynamicFlags::FLEXIBLE,
307            _decode,
308        )
309    }
310
311    type CycleResponseFut =
312        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
313    fn r#cycle(&self) -> Self::CycleResponseFut {
314        fn _decode(
315            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
316        ) -> Result<(), fidl::Error> {
317            let _response = fidl::client::decode_transaction_body::<
318                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
319                fidl::encoding::DefaultFuchsiaResourceDialect,
320                0x4211a94117087267,
321            >(_buf?)?
322            .into_result::<ManagerMarker>("cycle")?;
323            Ok(_response)
324        }
325        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
326            (),
327            0x4211a94117087267,
328            fidl::encoding::DynamicFlags::FLEXIBLE,
329            _decode,
330        )
331    }
332
333    type FocusResponseFut =
334        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
335    fn r#focus(&self, mut position: u64) -> Self::FocusResponseFut {
336        fn _decode(
337            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
338        ) -> Result<(), fidl::Error> {
339            let _response = fidl::client::decode_transaction_body::<
340                fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>,
341                fidl::encoding::DefaultFuchsiaResourceDialect,
342                0x789b0f092eb9551f,
343            >(_buf?)?
344            .into_result::<ManagerMarker>("focus")?;
345            Ok(_response)
346        }
347        self.client.send_query_and_decode::<ManagerFocusRequest, ()>(
348            (position,),
349            0x789b0f092eb9551f,
350            fidl::encoding::DynamicFlags::FLEXIBLE,
351            _decode,
352        )
353    }
354}
355
356pub struct ManagerEventStream {
357    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
358}
359
360impl std::marker::Unpin for ManagerEventStream {}
361
362impl futures::stream::FusedStream for ManagerEventStream {
363    fn is_terminated(&self) -> bool {
364        self.event_receiver.is_terminated()
365    }
366}
367
368impl futures::Stream for ManagerEventStream {
369    type Item = Result<ManagerEvent, fidl::Error>;
370
371    fn poll_next(
372        mut self: std::pin::Pin<&mut Self>,
373        cx: &mut std::task::Context<'_>,
374    ) -> std::task::Poll<Option<Self::Item>> {
375        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
376            &mut self.event_receiver,
377            cx
378        )?) {
379            Some(buf) => std::task::Poll::Ready(Some(ManagerEvent::decode(buf))),
380            None => std::task::Poll::Ready(None),
381        }
382    }
383}
384
385#[derive(Debug)]
386pub enum ManagerEvent {
387    #[non_exhaustive]
388    _UnknownEvent {
389        /// Ordinal of the event that was sent.
390        ordinal: u64,
391    },
392}
393
394impl ManagerEvent {
395    /// Decodes a message buffer as a [`ManagerEvent`].
396    fn decode(
397        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
398    ) -> Result<ManagerEvent, fidl::Error> {
399        let (bytes, _handles) = buf.split_mut();
400        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
401        debug_assert_eq!(tx_header.tx_id, 0);
402        match tx_header.ordinal {
403            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
404                Ok(ManagerEvent::_UnknownEvent { ordinal: tx_header.ordinal })
405            }
406            _ => Err(fidl::Error::UnknownOrdinal {
407                ordinal: tx_header.ordinal,
408                protocol_name: <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
409            }),
410        }
411    }
412}
413
414/// A Stream of incoming requests for fuchsia.session.window/Manager.
415pub struct ManagerRequestStream {
416    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
417    is_terminated: bool,
418}
419
420impl std::marker::Unpin for ManagerRequestStream {}
421
422impl futures::stream::FusedStream for ManagerRequestStream {
423    fn is_terminated(&self) -> bool {
424        self.is_terminated
425    }
426}
427
428impl fidl::endpoints::RequestStream for ManagerRequestStream {
429    type Protocol = ManagerMarker;
430    type ControlHandle = ManagerControlHandle;
431
432    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
433        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
434    }
435
436    fn control_handle(&self) -> Self::ControlHandle {
437        ManagerControlHandle { inner: self.inner.clone() }
438    }
439
440    fn into_inner(
441        self,
442    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
443    {
444        (self.inner, self.is_terminated)
445    }
446
447    fn from_inner(
448        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
449        is_terminated: bool,
450    ) -> Self {
451        Self { inner, is_terminated }
452    }
453}
454
455impl futures::Stream for ManagerRequestStream {
456    type Item = Result<ManagerRequest, fidl::Error>;
457
458    fn poll_next(
459        mut self: std::pin::Pin<&mut Self>,
460        cx: &mut std::task::Context<'_>,
461    ) -> std::task::Poll<Option<Self::Item>> {
462        let this = &mut *self;
463        if this.inner.check_shutdown(cx) {
464            this.is_terminated = true;
465            return std::task::Poll::Ready(None);
466        }
467        if this.is_terminated {
468            panic!("polled ManagerRequestStream after completion");
469        }
470        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
471            |bytes, handles| {
472                match this.inner.channel().read_etc(cx, bytes, handles) {
473                    std::task::Poll::Ready(Ok(())) => {}
474                    std::task::Poll::Pending => return std::task::Poll::Pending,
475                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
476                        this.is_terminated = true;
477                        return std::task::Poll::Ready(None);
478                    }
479                    std::task::Poll::Ready(Err(e)) => {
480                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
481                            e.into(),
482                        ))));
483                    }
484                }
485
486                // A message has been received from the channel
487                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
488
489                std::task::Poll::Ready(Some(match header.ordinal {
490                    0x217177a089d8841b => {
491                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
492                        let mut req = fidl::new_empty!(
493                            fidl::encoding::EmptyPayload,
494                            fidl::encoding::DefaultFuchsiaResourceDialect
495                        );
496                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
497                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
498                        Ok(ManagerRequest::List {
499                            responder: ManagerListResponder {
500                                control_handle: std::mem::ManuallyDrop::new(control_handle),
501                                tx_id: header.tx_id,
502                            },
503                        })
504                    }
505                    0x1a1478f581f1f3c2 => {
506                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
507                        let mut req = fidl::new_empty!(
508                            ManagerSetOrderRequest,
509                            fidl::encoding::DefaultFuchsiaResourceDialect
510                        );
511                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerSetOrderRequest>(&header, _body_bytes, handles, &mut req)?;
512                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
513                        Ok(ManagerRequest::SetOrder {
514                            old_position: req.old_position,
515                            new_position: req.new_position,
516
517                            responder: ManagerSetOrderResponder {
518                                control_handle: std::mem::ManuallyDrop::new(control_handle),
519                                tx_id: header.tx_id,
520                            },
521                        })
522                    }
523                    0x4211a94117087267 => {
524                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
525                        let mut req = fidl::new_empty!(
526                            fidl::encoding::EmptyPayload,
527                            fidl::encoding::DefaultFuchsiaResourceDialect
528                        );
529                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
530                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
531                        Ok(ManagerRequest::Cycle {
532                            responder: ManagerCycleResponder {
533                                control_handle: std::mem::ManuallyDrop::new(control_handle),
534                                tx_id: header.tx_id,
535                            },
536                        })
537                    }
538                    0x789b0f092eb9551f => {
539                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
540                        let mut req = fidl::new_empty!(
541                            ManagerFocusRequest,
542                            fidl::encoding::DefaultFuchsiaResourceDialect
543                        );
544                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ManagerFocusRequest>(&header, _body_bytes, handles, &mut req)?;
545                        let control_handle = ManagerControlHandle { inner: this.inner.clone() };
546                        Ok(ManagerRequest::Focus {
547                            position: req.position,
548
549                            responder: ManagerFocusResponder {
550                                control_handle: std::mem::ManuallyDrop::new(control_handle),
551                                tx_id: header.tx_id,
552                            },
553                        })
554                    }
555                    _ if header.tx_id == 0
556                        && header
557                            .dynamic_flags()
558                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
559                    {
560                        Ok(ManagerRequest::_UnknownMethod {
561                            ordinal: header.ordinal,
562                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
563                            method_type: fidl::MethodType::OneWay,
564                        })
565                    }
566                    _ if header
567                        .dynamic_flags()
568                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
569                    {
570                        this.inner.send_framework_err(
571                            fidl::encoding::FrameworkErr::UnknownMethod,
572                            header.tx_id,
573                            header.ordinal,
574                            header.dynamic_flags(),
575                            (bytes, handles),
576                        )?;
577                        Ok(ManagerRequest::_UnknownMethod {
578                            ordinal: header.ordinal,
579                            control_handle: ManagerControlHandle { inner: this.inner.clone() },
580                            method_type: fidl::MethodType::TwoWay,
581                        })
582                    }
583                    _ => Err(fidl::Error::UnknownOrdinal {
584                        ordinal: header.ordinal,
585                        protocol_name:
586                            <ManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
587                    }),
588                }))
589            },
590        )
591    }
592}
593
594#[derive(Debug)]
595pub enum ManagerRequest {
596    /// List ids of all views in the order they are being presented.
597    List { responder: ManagerListResponder },
598    /// Moves the view at the given `old_position` to the given `new_position`.
599    /// Items in between are shifted and all other views keep their same relative order.
600    /// Window Manager expects both positions to be within the range of the length of
601    /// views currently presented. If invalid args are provided, the command will not
602    /// execute and an error message will be logged.
603    SetOrder { old_position: u64, new_position: u64, responder: ManagerSetOrderResponder },
604    /// Shifts all views forward by one position, view at position 0 is moved to the end.
605    Cycle { responder: ManagerCycleResponder },
606    /// Sets keyboard focus to the view at `position` and makes that view visible.
607    Focus { position: u64, responder: ManagerFocusResponder },
608    /// An interaction was received which does not match any known method.
609    #[non_exhaustive]
610    _UnknownMethod {
611        /// Ordinal of the method that was called.
612        ordinal: u64,
613        control_handle: ManagerControlHandle,
614        method_type: fidl::MethodType,
615    },
616}
617
618impl ManagerRequest {
619    #[allow(irrefutable_let_patterns)]
620    pub fn into_list(self) -> Option<(ManagerListResponder)> {
621        if let ManagerRequest::List { responder } = self { Some((responder)) } else { None }
622    }
623
624    #[allow(irrefutable_let_patterns)]
625    pub fn into_set_order(self) -> Option<(u64, u64, ManagerSetOrderResponder)> {
626        if let ManagerRequest::SetOrder { old_position, new_position, responder } = self {
627            Some((old_position, new_position, responder))
628        } else {
629            None
630        }
631    }
632
633    #[allow(irrefutable_let_patterns)]
634    pub fn into_cycle(self) -> Option<(ManagerCycleResponder)> {
635        if let ManagerRequest::Cycle { responder } = self { Some((responder)) } else { None }
636    }
637
638    #[allow(irrefutable_let_patterns)]
639    pub fn into_focus(self) -> Option<(u64, ManagerFocusResponder)> {
640        if let ManagerRequest::Focus { position, responder } = self {
641            Some((position, responder))
642        } else {
643            None
644        }
645    }
646
647    /// Name of the method defined in FIDL
648    pub fn method_name(&self) -> &'static str {
649        match *self {
650            ManagerRequest::List { .. } => "list",
651            ManagerRequest::SetOrder { .. } => "set_order",
652            ManagerRequest::Cycle { .. } => "cycle",
653            ManagerRequest::Focus { .. } => "focus",
654            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
655                "unknown one-way method"
656            }
657            ManagerRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
658                "unknown two-way method"
659            }
660        }
661    }
662}
663
664#[derive(Debug, Clone)]
665pub struct ManagerControlHandle {
666    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
667}
668
669impl ManagerControlHandle {
670    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
671        self.inner.shutdown_with_epitaph(status.into())
672    }
673}
674
675impl fidl::endpoints::ControlHandle for ManagerControlHandle {
676    fn shutdown(&self) {
677        self.inner.shutdown()
678    }
679
680    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
681        self.inner.shutdown_with_epitaph(status)
682    }
683
684    fn is_closed(&self) -> bool {
685        self.inner.channel().is_closed()
686    }
687    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
688        self.inner.channel().on_closed()
689    }
690
691    #[cfg(target_os = "fuchsia")]
692    fn signal_peer(
693        &self,
694        clear_mask: zx::Signals,
695        set_mask: zx::Signals,
696    ) -> Result<(), zx_status::Status> {
697        use fidl::Peered;
698        self.inner.channel().signal_peer(clear_mask, set_mask)
699    }
700}
701
702impl ManagerControlHandle {}
703
704#[must_use = "FIDL methods require a response to be sent"]
705#[derive(Debug)]
706pub struct ManagerListResponder {
707    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
708    tx_id: u32,
709}
710
711/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
712/// if the responder is dropped without sending a response, so that the client
713/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
714impl std::ops::Drop for ManagerListResponder {
715    fn drop(&mut self) {
716        self.control_handle.shutdown();
717        // Safety: drops once, never accessed again
718        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
719    }
720}
721
722impl fidl::endpoints::Responder for ManagerListResponder {
723    type ControlHandle = ManagerControlHandle;
724
725    fn control_handle(&self) -> &ManagerControlHandle {
726        &self.control_handle
727    }
728
729    fn drop_without_shutdown(mut self) {
730        // Safety: drops once, never accessed again due to mem::forget
731        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
732        // Prevent Drop from running (which would shut down the channel)
733        std::mem::forget(self);
734    }
735}
736
737impl ManagerListResponder {
738    /// Sends a response to the FIDL transaction.
739    ///
740    /// Sets the channel to shutdown if an error occurs.
741    pub fn send(self, mut views: &[ListedView]) -> Result<(), fidl::Error> {
742        let _result = self.send_raw(views);
743        if _result.is_err() {
744            self.control_handle.shutdown();
745        }
746        self.drop_without_shutdown();
747        _result
748    }
749
750    /// Similar to "send" but does not shutdown the channel if an error occurs.
751    pub fn send_no_shutdown_on_err(self, mut views: &[ListedView]) -> Result<(), fidl::Error> {
752        let _result = self.send_raw(views);
753        self.drop_without_shutdown();
754        _result
755    }
756
757    fn send_raw(&self, mut views: &[ListedView]) -> Result<(), fidl::Error> {
758        self.control_handle.inner.send::<fidl::encoding::FlexibleType<ManagerListResponse>>(
759            fidl::encoding::Flexible::new((views,)),
760            self.tx_id,
761            0x217177a089d8841b,
762            fidl::encoding::DynamicFlags::FLEXIBLE,
763        )
764    }
765}
766
767#[must_use = "FIDL methods require a response to be sent"]
768#[derive(Debug)]
769pub struct ManagerSetOrderResponder {
770    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
771    tx_id: u32,
772}
773
774/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
775/// if the responder is dropped without sending a response, so that the client
776/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
777impl std::ops::Drop for ManagerSetOrderResponder {
778    fn drop(&mut self) {
779        self.control_handle.shutdown();
780        // Safety: drops once, never accessed again
781        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
782    }
783}
784
785impl fidl::endpoints::Responder for ManagerSetOrderResponder {
786    type ControlHandle = ManagerControlHandle;
787
788    fn control_handle(&self) -> &ManagerControlHandle {
789        &self.control_handle
790    }
791
792    fn drop_without_shutdown(mut self) {
793        // Safety: drops once, never accessed again due to mem::forget
794        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
795        // Prevent Drop from running (which would shut down the channel)
796        std::mem::forget(self);
797    }
798}
799
800impl ManagerSetOrderResponder {
801    /// Sends a response to the FIDL transaction.
802    ///
803    /// Sets the channel to shutdown if an error occurs.
804    pub fn send(self) -> Result<(), fidl::Error> {
805        let _result = self.send_raw();
806        if _result.is_err() {
807            self.control_handle.shutdown();
808        }
809        self.drop_without_shutdown();
810        _result
811    }
812
813    /// Similar to "send" but does not shutdown the channel if an error occurs.
814    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
815        let _result = self.send_raw();
816        self.drop_without_shutdown();
817        _result
818    }
819
820    fn send_raw(&self) -> Result<(), fidl::Error> {
821        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
822            fidl::encoding::Flexible::new(()),
823            self.tx_id,
824            0x1a1478f581f1f3c2,
825            fidl::encoding::DynamicFlags::FLEXIBLE,
826        )
827    }
828}
829
830#[must_use = "FIDL methods require a response to be sent"]
831#[derive(Debug)]
832pub struct ManagerCycleResponder {
833    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
834    tx_id: u32,
835}
836
837/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
838/// if the responder is dropped without sending a response, so that the client
839/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
840impl std::ops::Drop for ManagerCycleResponder {
841    fn drop(&mut self) {
842        self.control_handle.shutdown();
843        // Safety: drops once, never accessed again
844        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
845    }
846}
847
848impl fidl::endpoints::Responder for ManagerCycleResponder {
849    type ControlHandle = ManagerControlHandle;
850
851    fn control_handle(&self) -> &ManagerControlHandle {
852        &self.control_handle
853    }
854
855    fn drop_without_shutdown(mut self) {
856        // Safety: drops once, never accessed again due to mem::forget
857        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
858        // Prevent Drop from running (which would shut down the channel)
859        std::mem::forget(self);
860    }
861}
862
863impl ManagerCycleResponder {
864    /// Sends a response to the FIDL transaction.
865    ///
866    /// Sets the channel to shutdown if an error occurs.
867    pub fn send(self) -> Result<(), fidl::Error> {
868        let _result = self.send_raw();
869        if _result.is_err() {
870            self.control_handle.shutdown();
871        }
872        self.drop_without_shutdown();
873        _result
874    }
875
876    /// Similar to "send" but does not shutdown the channel if an error occurs.
877    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
878        let _result = self.send_raw();
879        self.drop_without_shutdown();
880        _result
881    }
882
883    fn send_raw(&self) -> Result<(), fidl::Error> {
884        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
885            fidl::encoding::Flexible::new(()),
886            self.tx_id,
887            0x4211a94117087267,
888            fidl::encoding::DynamicFlags::FLEXIBLE,
889        )
890    }
891}
892
893#[must_use = "FIDL methods require a response to be sent"]
894#[derive(Debug)]
895pub struct ManagerFocusResponder {
896    control_handle: std::mem::ManuallyDrop<ManagerControlHandle>,
897    tx_id: u32,
898}
899
900/// Set the the channel to be shutdown (see [`ManagerControlHandle::shutdown`])
901/// if the responder is dropped without sending a response, so that the client
902/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
903impl std::ops::Drop for ManagerFocusResponder {
904    fn drop(&mut self) {
905        self.control_handle.shutdown();
906        // Safety: drops once, never accessed again
907        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
908    }
909}
910
911impl fidl::endpoints::Responder for ManagerFocusResponder {
912    type ControlHandle = ManagerControlHandle;
913
914    fn control_handle(&self) -> &ManagerControlHandle {
915        &self.control_handle
916    }
917
918    fn drop_without_shutdown(mut self) {
919        // Safety: drops once, never accessed again due to mem::forget
920        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
921        // Prevent Drop from running (which would shut down the channel)
922        std::mem::forget(self);
923    }
924}
925
926impl ManagerFocusResponder {
927    /// Sends a response to the FIDL transaction.
928    ///
929    /// Sets the channel to shutdown if an error occurs.
930    pub fn send(self) -> Result<(), fidl::Error> {
931        let _result = self.send_raw();
932        if _result.is_err() {
933            self.control_handle.shutdown();
934        }
935        self.drop_without_shutdown();
936        _result
937    }
938
939    /// Similar to "send" but does not shutdown the channel if an error occurs.
940    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
941        let _result = self.send_raw();
942        self.drop_without_shutdown();
943        _result
944    }
945
946    fn send_raw(&self) -> Result<(), fidl::Error> {
947        self.control_handle.inner.send::<fidl::encoding::FlexibleType<fidl::encoding::EmptyStruct>>(
948            fidl::encoding::Flexible::new(()),
949            self.tx_id,
950            0x789b0f092eb9551f,
951            fidl::encoding::DynamicFlags::FLEXIBLE,
952        )
953    }
954}
955
956#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
957pub struct ScreensaverMarker;
958
959impl fidl::endpoints::ProtocolMarker for ScreensaverMarker {
960    type Proxy = ScreensaverProxy;
961    type RequestStream = ScreensaverRequestStream;
962    #[cfg(target_os = "fuchsia")]
963    type SynchronousProxy = ScreensaverSynchronousProxy;
964
965    const DEBUG_NAME: &'static str = "fuchsia.session.window.Screensaver";
966}
967impl fidl::endpoints::DiscoverableProtocolMarker for ScreensaverMarker {}
968pub type ScreensaverSetResult = Result<(), ScreensaverError>;
969
970pub trait ScreensaverProxyInterface: Send + Sync {
971    type SetResponseFut: std::future::Future<Output = Result<ScreensaverSetResult, fidl::Error>>
972        + Send;
973    fn r#set(&self, screensaver_on: bool) -> Self::SetResponseFut;
974}
975#[derive(Debug)]
976#[cfg(target_os = "fuchsia")]
977pub struct ScreensaverSynchronousProxy {
978    client: fidl::client::sync::Client,
979}
980
981#[cfg(target_os = "fuchsia")]
982impl fidl::endpoints::SynchronousProxy for ScreensaverSynchronousProxy {
983    type Proxy = ScreensaverProxy;
984    type Protocol = ScreensaverMarker;
985
986    fn from_channel(inner: fidl::Channel) -> Self {
987        Self::new(inner)
988    }
989
990    fn into_channel(self) -> fidl::Channel {
991        self.client.into_channel()
992    }
993
994    fn as_channel(&self) -> &fidl::Channel {
995        self.client.as_channel()
996    }
997}
998
999#[cfg(target_os = "fuchsia")]
1000impl ScreensaverSynchronousProxy {
1001    pub fn new(channel: fidl::Channel) -> Self {
1002        Self { client: fidl::client::sync::Client::new(channel) }
1003    }
1004
1005    pub fn into_channel(self) -> fidl::Channel {
1006        self.client.into_channel()
1007    }
1008
1009    /// Waits until an event arrives and returns it. It is safe for other
1010    /// threads to make concurrent requests while waiting for an event.
1011    pub fn wait_for_event(
1012        &self,
1013        deadline: zx::MonotonicInstant,
1014    ) -> Result<ScreensaverEvent, fidl::Error> {
1015        ScreensaverEvent::decode(self.client.wait_for_event::<ScreensaverMarker>(deadline)?)
1016    }
1017
1018    /// Changes Screensaver state.
1019    pub fn r#set(
1020        &self,
1021        mut screensaver_on: bool,
1022        ___deadline: zx::MonotonicInstant,
1023    ) -> Result<ScreensaverSetResult, fidl::Error> {
1024        let _response = self.client.send_query::<
1025            ScreensaverSetRequest,
1026            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreensaverError>,
1027            ScreensaverMarker,
1028        >(
1029            (screensaver_on,),
1030            0x312967391552d3eb,
1031            fidl::encoding::DynamicFlags::empty(),
1032            ___deadline,
1033        )?;
1034        Ok(_response.map(|x| x))
1035    }
1036}
1037
1038#[cfg(target_os = "fuchsia")]
1039impl From<ScreensaverSynchronousProxy> for zx::NullableHandle {
1040    fn from(value: ScreensaverSynchronousProxy) -> Self {
1041        value.into_channel().into()
1042    }
1043}
1044
1045#[cfg(target_os = "fuchsia")]
1046impl From<fidl::Channel> for ScreensaverSynchronousProxy {
1047    fn from(value: fidl::Channel) -> Self {
1048        Self::new(value)
1049    }
1050}
1051
1052#[cfg(target_os = "fuchsia")]
1053impl fidl::endpoints::FromClient for ScreensaverSynchronousProxy {
1054    type Protocol = ScreensaverMarker;
1055
1056    fn from_client(value: fidl::endpoints::ClientEnd<ScreensaverMarker>) -> Self {
1057        Self::new(value.into_channel())
1058    }
1059}
1060
1061#[derive(Debug, Clone)]
1062pub struct ScreensaverProxy {
1063    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1064}
1065
1066impl fidl::endpoints::Proxy for ScreensaverProxy {
1067    type Protocol = ScreensaverMarker;
1068
1069    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1070        Self::new(inner)
1071    }
1072
1073    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1074        self.client.into_channel().map_err(|client| Self { client })
1075    }
1076
1077    fn as_channel(&self) -> &::fidl::AsyncChannel {
1078        self.client.as_channel()
1079    }
1080}
1081
1082impl ScreensaverProxy {
1083    /// Create a new Proxy for fuchsia.session.window/Screensaver.
1084    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1085        let protocol_name = <ScreensaverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1086        Self { client: fidl::client::Client::new(channel, protocol_name) }
1087    }
1088
1089    /// Get a Stream of events from the remote end of the protocol.
1090    ///
1091    /// # Panics
1092    ///
1093    /// Panics if the event stream was already taken.
1094    pub fn take_event_stream(&self) -> ScreensaverEventStream {
1095        ScreensaverEventStream { event_receiver: self.client.take_event_receiver() }
1096    }
1097
1098    /// Changes Screensaver state.
1099    pub fn r#set(
1100        &self,
1101        mut screensaver_on: bool,
1102    ) -> fidl::client::QueryResponseFut<
1103        ScreensaverSetResult,
1104        fidl::encoding::DefaultFuchsiaResourceDialect,
1105    > {
1106        ScreensaverProxyInterface::r#set(self, screensaver_on)
1107    }
1108}
1109
1110impl ScreensaverProxyInterface for ScreensaverProxy {
1111    type SetResponseFut = fidl::client::QueryResponseFut<
1112        ScreensaverSetResult,
1113        fidl::encoding::DefaultFuchsiaResourceDialect,
1114    >;
1115    fn r#set(&self, mut screensaver_on: bool) -> Self::SetResponseFut {
1116        fn _decode(
1117            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1118        ) -> Result<ScreensaverSetResult, fidl::Error> {
1119            let _response = fidl::client::decode_transaction_body::<
1120                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreensaverError>,
1121                fidl::encoding::DefaultFuchsiaResourceDialect,
1122                0x312967391552d3eb,
1123            >(_buf?)?;
1124            Ok(_response.map(|x| x))
1125        }
1126        self.client.send_query_and_decode::<ScreensaverSetRequest, ScreensaverSetResult>(
1127            (screensaver_on,),
1128            0x312967391552d3eb,
1129            fidl::encoding::DynamicFlags::empty(),
1130            _decode,
1131        )
1132    }
1133}
1134
1135pub struct ScreensaverEventStream {
1136    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1137}
1138
1139impl std::marker::Unpin for ScreensaverEventStream {}
1140
1141impl futures::stream::FusedStream for ScreensaverEventStream {
1142    fn is_terminated(&self) -> bool {
1143        self.event_receiver.is_terminated()
1144    }
1145}
1146
1147impl futures::Stream for ScreensaverEventStream {
1148    type Item = Result<ScreensaverEvent, fidl::Error>;
1149
1150    fn poll_next(
1151        mut self: std::pin::Pin<&mut Self>,
1152        cx: &mut std::task::Context<'_>,
1153    ) -> std::task::Poll<Option<Self::Item>> {
1154        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1155            &mut self.event_receiver,
1156            cx
1157        )?) {
1158            Some(buf) => std::task::Poll::Ready(Some(ScreensaverEvent::decode(buf))),
1159            None => std::task::Poll::Ready(None),
1160        }
1161    }
1162}
1163
1164#[derive(Debug)]
1165pub enum ScreensaverEvent {}
1166
1167impl ScreensaverEvent {
1168    /// Decodes a message buffer as a [`ScreensaverEvent`].
1169    fn decode(
1170        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1171    ) -> Result<ScreensaverEvent, fidl::Error> {
1172        let (bytes, _handles) = buf.split_mut();
1173        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1174        debug_assert_eq!(tx_header.tx_id, 0);
1175        match tx_header.ordinal {
1176            _ => Err(fidl::Error::UnknownOrdinal {
1177                ordinal: tx_header.ordinal,
1178                protocol_name: <ScreensaverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1179            }),
1180        }
1181    }
1182}
1183
1184/// A Stream of incoming requests for fuchsia.session.window/Screensaver.
1185pub struct ScreensaverRequestStream {
1186    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1187    is_terminated: bool,
1188}
1189
1190impl std::marker::Unpin for ScreensaverRequestStream {}
1191
1192impl futures::stream::FusedStream for ScreensaverRequestStream {
1193    fn is_terminated(&self) -> bool {
1194        self.is_terminated
1195    }
1196}
1197
1198impl fidl::endpoints::RequestStream for ScreensaverRequestStream {
1199    type Protocol = ScreensaverMarker;
1200    type ControlHandle = ScreensaverControlHandle;
1201
1202    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1203        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1204    }
1205
1206    fn control_handle(&self) -> Self::ControlHandle {
1207        ScreensaverControlHandle { inner: self.inner.clone() }
1208    }
1209
1210    fn into_inner(
1211        self,
1212    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1213    {
1214        (self.inner, self.is_terminated)
1215    }
1216
1217    fn from_inner(
1218        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1219        is_terminated: bool,
1220    ) -> Self {
1221        Self { inner, is_terminated }
1222    }
1223}
1224
1225impl futures::Stream for ScreensaverRequestStream {
1226    type Item = Result<ScreensaverRequest, fidl::Error>;
1227
1228    fn poll_next(
1229        mut self: std::pin::Pin<&mut Self>,
1230        cx: &mut std::task::Context<'_>,
1231    ) -> std::task::Poll<Option<Self::Item>> {
1232        let this = &mut *self;
1233        if this.inner.check_shutdown(cx) {
1234            this.is_terminated = true;
1235            return std::task::Poll::Ready(None);
1236        }
1237        if this.is_terminated {
1238            panic!("polled ScreensaverRequestStream after completion");
1239        }
1240        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1241            |bytes, handles| {
1242                match this.inner.channel().read_etc(cx, bytes, handles) {
1243                    std::task::Poll::Ready(Ok(())) => {}
1244                    std::task::Poll::Pending => return std::task::Poll::Pending,
1245                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1246                        this.is_terminated = true;
1247                        return std::task::Poll::Ready(None);
1248                    }
1249                    std::task::Poll::Ready(Err(e)) => {
1250                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1251                            e.into(),
1252                        ))));
1253                    }
1254                }
1255
1256                // A message has been received from the channel
1257                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1258
1259                std::task::Poll::Ready(Some(match header.ordinal {
1260                    0x312967391552d3eb => {
1261                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1262                        let mut req = fidl::new_empty!(
1263                            ScreensaverSetRequest,
1264                            fidl::encoding::DefaultFuchsiaResourceDialect
1265                        );
1266                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreensaverSetRequest>(&header, _body_bytes, handles, &mut req)?;
1267                        let control_handle = ScreensaverControlHandle { inner: this.inner.clone() };
1268                        Ok(ScreensaverRequest::Set {
1269                            screensaver_on: req.screensaver_on,
1270
1271                            responder: ScreensaverSetResponder {
1272                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1273                                tx_id: header.tx_id,
1274                            },
1275                        })
1276                    }
1277                    _ => Err(fidl::Error::UnknownOrdinal {
1278                        ordinal: header.ordinal,
1279                        protocol_name:
1280                            <ScreensaverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1281                    }),
1282                }))
1283            },
1284        )
1285    }
1286}
1287
1288/// The Screensaver protocol is used to control the screensaver.
1289///
1290/// The client can use this protocol to check if the screensaver is
1291/// supported and to turn the screensaver on or off.
1292#[derive(Debug)]
1293pub enum ScreensaverRequest {
1294    /// Changes Screensaver state.
1295    Set { screensaver_on: bool, responder: ScreensaverSetResponder },
1296}
1297
1298impl ScreensaverRequest {
1299    #[allow(irrefutable_let_patterns)]
1300    pub fn into_set(self) -> Option<(bool, ScreensaverSetResponder)> {
1301        if let ScreensaverRequest::Set { screensaver_on, responder } = self {
1302            Some((screensaver_on, responder))
1303        } else {
1304            None
1305        }
1306    }
1307
1308    /// Name of the method defined in FIDL
1309    pub fn method_name(&self) -> &'static str {
1310        match *self {
1311            ScreensaverRequest::Set { .. } => "set",
1312        }
1313    }
1314}
1315
1316#[derive(Debug, Clone)]
1317pub struct ScreensaverControlHandle {
1318    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1319}
1320
1321impl ScreensaverControlHandle {
1322    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1323        self.inner.shutdown_with_epitaph(status.into())
1324    }
1325}
1326
1327impl fidl::endpoints::ControlHandle for ScreensaverControlHandle {
1328    fn shutdown(&self) {
1329        self.inner.shutdown()
1330    }
1331
1332    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1333        self.inner.shutdown_with_epitaph(status)
1334    }
1335
1336    fn is_closed(&self) -> bool {
1337        self.inner.channel().is_closed()
1338    }
1339    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1340        self.inner.channel().on_closed()
1341    }
1342
1343    #[cfg(target_os = "fuchsia")]
1344    fn signal_peer(
1345        &self,
1346        clear_mask: zx::Signals,
1347        set_mask: zx::Signals,
1348    ) -> Result<(), zx_status::Status> {
1349        use fidl::Peered;
1350        self.inner.channel().signal_peer(clear_mask, set_mask)
1351    }
1352}
1353
1354impl ScreensaverControlHandle {}
1355
1356#[must_use = "FIDL methods require a response to be sent"]
1357#[derive(Debug)]
1358pub struct ScreensaverSetResponder {
1359    control_handle: std::mem::ManuallyDrop<ScreensaverControlHandle>,
1360    tx_id: u32,
1361}
1362
1363/// Set the the channel to be shutdown (see [`ScreensaverControlHandle::shutdown`])
1364/// if the responder is dropped without sending a response, so that the client
1365/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1366impl std::ops::Drop for ScreensaverSetResponder {
1367    fn drop(&mut self) {
1368        self.control_handle.shutdown();
1369        // Safety: drops once, never accessed again
1370        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1371    }
1372}
1373
1374impl fidl::endpoints::Responder for ScreensaverSetResponder {
1375    type ControlHandle = ScreensaverControlHandle;
1376
1377    fn control_handle(&self) -> &ScreensaverControlHandle {
1378        &self.control_handle
1379    }
1380
1381    fn drop_without_shutdown(mut self) {
1382        // Safety: drops once, never accessed again due to mem::forget
1383        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1384        // Prevent Drop from running (which would shut down the channel)
1385        std::mem::forget(self);
1386    }
1387}
1388
1389impl ScreensaverSetResponder {
1390    /// Sends a response to the FIDL transaction.
1391    ///
1392    /// Sets the channel to shutdown if an error occurs.
1393    pub fn send(self, mut result: Result<(), ScreensaverError>) -> Result<(), fidl::Error> {
1394        let _result = self.send_raw(result);
1395        if _result.is_err() {
1396            self.control_handle.shutdown();
1397        }
1398        self.drop_without_shutdown();
1399        _result
1400    }
1401
1402    /// Similar to "send" but does not shutdown the channel if an error occurs.
1403    pub fn send_no_shutdown_on_err(
1404        self,
1405        mut result: Result<(), ScreensaverError>,
1406    ) -> Result<(), fidl::Error> {
1407        let _result = self.send_raw(result);
1408        self.drop_without_shutdown();
1409        _result
1410    }
1411
1412    fn send_raw(&self, mut result: Result<(), ScreensaverError>) -> Result<(), fidl::Error> {
1413        self.control_handle.inner.send::<fidl::encoding::ResultType<
1414            fidl::encoding::EmptyStruct,
1415            ScreensaverError,
1416        >>(
1417            result,
1418            self.tx_id,
1419            0x312967391552d3eb,
1420            fidl::encoding::DynamicFlags::empty(),
1421        )
1422    }
1423}
1424
1425mod internal {
1426    use super::*;
1427}