fidl_fuchsia_ui_focus/
fidl_fuchsia_ui_focus.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_focus__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct FocusChainListenerOnFocusChangeRequest {
16    pub focus_chain: FocusChain,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for FocusChainListenerOnFocusChangeRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct FocusChainListenerRegistryRegisterRequest {
26    pub listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for FocusChainListenerRegistryRegisterRequest
31{
32}
33
34/// A FocusChain tracks the status of the View hierarchy as View focus changes.
35///
36/// Reception. Only certain components may receive a FocusChain, as it
37/// captures global information about the scene graph.
38#[derive(Debug, Default, PartialEq)]
39pub struct FocusChain {
40    /// The `focus_chain` is reported in order of dominance in the View
41    /// hierarchy; each adjacent pair of elements represents a
42    /// parent-child relationship.
43    ///
44    /// The `focus_chain` MAY be unset when `FocusChain` message is received, if
45    /// the message is sent very early in the scene setup, before the first
46    /// view is available.
47    ///
48    /// When `focus_chain` is set, however, the root View is always present
49    /// and occupies slot 0 in the `focus_chain`.  The newly-focused View
50    /// receives a `fuchsia.ui.input.FocusEvent` and occupies the final slot
51    /// in the vector.
52    ///
53    /// If a View gets destroyed, a `FocusChain` holder that listens will
54    /// receive a `ZX_EVENTPAIR_PEER_CLOSED` signal on the corresponding
55    /// `ViewRef`.
56    ///
57    /// ## Invalidation.
58    ///
59    /// A FocusChain is invalid if any one if its ViewRefs is
60    /// invalid.
61    pub focus_chain: Option<Vec<fidl_fuchsia_ui_views::ViewRef>>,
62    #[doc(hidden)]
63    pub __source_breaking: fidl::marker::SourceBreaking,
64}
65
66impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FocusChain {}
67
68#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
69pub struct FocusChainListenerMarker;
70
71impl fidl::endpoints::ProtocolMarker for FocusChainListenerMarker {
72    type Proxy = FocusChainListenerProxy;
73    type RequestStream = FocusChainListenerRequestStream;
74    #[cfg(target_os = "fuchsia")]
75    type SynchronousProxy = FocusChainListenerSynchronousProxy;
76
77    const DEBUG_NAME: &'static str = "(anonymous) FocusChainListener";
78}
79
80pub trait FocusChainListenerProxyInterface: Send + Sync {
81    type OnFocusChangeResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
82    fn r#on_focus_change(&self, focus_chain: FocusChain) -> Self::OnFocusChangeResponseFut;
83}
84#[derive(Debug)]
85#[cfg(target_os = "fuchsia")]
86pub struct FocusChainListenerSynchronousProxy {
87    client: fidl::client::sync::Client,
88}
89
90#[cfg(target_os = "fuchsia")]
91impl fidl::endpoints::SynchronousProxy for FocusChainListenerSynchronousProxy {
92    type Proxy = FocusChainListenerProxy;
93    type Protocol = FocusChainListenerMarker;
94
95    fn from_channel(inner: fidl::Channel) -> Self {
96        Self::new(inner)
97    }
98
99    fn into_channel(self) -> fidl::Channel {
100        self.client.into_channel()
101    }
102
103    fn as_channel(&self) -> &fidl::Channel {
104        self.client.as_channel()
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl FocusChainListenerSynchronousProxy {
110    pub fn new(channel: fidl::Channel) -> Self {
111        let protocol_name =
112            <FocusChainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
113        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
114    }
115
116    pub fn into_channel(self) -> fidl::Channel {
117        self.client.into_channel()
118    }
119
120    /// Waits until an event arrives and returns it. It is safe for other
121    /// threads to make concurrent requests while waiting for an event.
122    pub fn wait_for_event(
123        &self,
124        deadline: zx::MonotonicInstant,
125    ) -> Result<FocusChainListenerEvent, fidl::Error> {
126        FocusChainListenerEvent::decode(self.client.wait_for_event(deadline)?)
127    }
128
129    /// Sent when a focus change occurs.  Since `focus_chain` may contain an
130    /// empty update, every handler MUST respond to the message even
131    /// if its contents are not immediately useful.
132    pub fn r#on_focus_change(
133        &self,
134        mut focus_chain: FocusChain,
135        ___deadline: zx::MonotonicInstant,
136    ) -> Result<(), fidl::Error> {
137        let _response = self
138            .client
139            .send_query::<FocusChainListenerOnFocusChangeRequest, fidl::encoding::EmptyPayload>(
140                (&mut focus_chain,),
141                0x2ffe3dec9ff7a04a,
142                fidl::encoding::DynamicFlags::empty(),
143                ___deadline,
144            )?;
145        Ok(_response)
146    }
147}
148
149#[cfg(target_os = "fuchsia")]
150impl From<FocusChainListenerSynchronousProxy> for zx::Handle {
151    fn from(value: FocusChainListenerSynchronousProxy) -> Self {
152        value.into_channel().into()
153    }
154}
155
156#[cfg(target_os = "fuchsia")]
157impl From<fidl::Channel> for FocusChainListenerSynchronousProxy {
158    fn from(value: fidl::Channel) -> Self {
159        Self::new(value)
160    }
161}
162
163#[cfg(target_os = "fuchsia")]
164impl fidl::endpoints::FromClient for FocusChainListenerSynchronousProxy {
165    type Protocol = FocusChainListenerMarker;
166
167    fn from_client(value: fidl::endpoints::ClientEnd<FocusChainListenerMarker>) -> Self {
168        Self::new(value.into_channel())
169    }
170}
171
172#[derive(Debug, Clone)]
173pub struct FocusChainListenerProxy {
174    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
175}
176
177impl fidl::endpoints::Proxy for FocusChainListenerProxy {
178    type Protocol = FocusChainListenerMarker;
179
180    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
181        Self::new(inner)
182    }
183
184    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
185        self.client.into_channel().map_err(|client| Self { client })
186    }
187
188    fn as_channel(&self) -> &::fidl::AsyncChannel {
189        self.client.as_channel()
190    }
191}
192
193impl FocusChainListenerProxy {
194    /// Create a new Proxy for fuchsia.ui.focus/FocusChainListener.
195    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
196        let protocol_name =
197            <FocusChainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
198        Self { client: fidl::client::Client::new(channel, protocol_name) }
199    }
200
201    /// Get a Stream of events from the remote end of the protocol.
202    ///
203    /// # Panics
204    ///
205    /// Panics if the event stream was already taken.
206    pub fn take_event_stream(&self) -> FocusChainListenerEventStream {
207        FocusChainListenerEventStream { event_receiver: self.client.take_event_receiver() }
208    }
209
210    /// Sent when a focus change occurs.  Since `focus_chain` may contain an
211    /// empty update, every handler MUST respond to the message even
212    /// if its contents are not immediately useful.
213    pub fn r#on_focus_change(
214        &self,
215        mut focus_chain: FocusChain,
216    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
217        FocusChainListenerProxyInterface::r#on_focus_change(self, focus_chain)
218    }
219}
220
221impl FocusChainListenerProxyInterface for FocusChainListenerProxy {
222    type OnFocusChangeResponseFut =
223        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
224    fn r#on_focus_change(&self, mut focus_chain: FocusChain) -> Self::OnFocusChangeResponseFut {
225        fn _decode(
226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
227        ) -> Result<(), fidl::Error> {
228            let _response = fidl::client::decode_transaction_body::<
229                fidl::encoding::EmptyPayload,
230                fidl::encoding::DefaultFuchsiaResourceDialect,
231                0x2ffe3dec9ff7a04a,
232            >(_buf?)?;
233            Ok(_response)
234        }
235        self.client.send_query_and_decode::<FocusChainListenerOnFocusChangeRequest, ()>(
236            (&mut focus_chain,),
237            0x2ffe3dec9ff7a04a,
238            fidl::encoding::DynamicFlags::empty(),
239            _decode,
240        )
241    }
242}
243
244pub struct FocusChainListenerEventStream {
245    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
246}
247
248impl std::marker::Unpin for FocusChainListenerEventStream {}
249
250impl futures::stream::FusedStream for FocusChainListenerEventStream {
251    fn is_terminated(&self) -> bool {
252        self.event_receiver.is_terminated()
253    }
254}
255
256impl futures::Stream for FocusChainListenerEventStream {
257    type Item = Result<FocusChainListenerEvent, fidl::Error>;
258
259    fn poll_next(
260        mut self: std::pin::Pin<&mut Self>,
261        cx: &mut std::task::Context<'_>,
262    ) -> std::task::Poll<Option<Self::Item>> {
263        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
264            &mut self.event_receiver,
265            cx
266        )?) {
267            Some(buf) => std::task::Poll::Ready(Some(FocusChainListenerEvent::decode(buf))),
268            None => std::task::Poll::Ready(None),
269        }
270    }
271}
272
273#[derive(Debug)]
274pub enum FocusChainListenerEvent {}
275
276impl FocusChainListenerEvent {
277    /// Decodes a message buffer as a [`FocusChainListenerEvent`].
278    fn decode(
279        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
280    ) -> Result<FocusChainListenerEvent, fidl::Error> {
281        let (bytes, _handles) = buf.split_mut();
282        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
283        debug_assert_eq!(tx_header.tx_id, 0);
284        match tx_header.ordinal {
285            _ => Err(fidl::Error::UnknownOrdinal {
286                ordinal: tx_header.ordinal,
287                protocol_name:
288                    <FocusChainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
289            }),
290        }
291    }
292}
293
294/// A Stream of incoming requests for fuchsia.ui.focus/FocusChainListener.
295pub struct FocusChainListenerRequestStream {
296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297    is_terminated: bool,
298}
299
300impl std::marker::Unpin for FocusChainListenerRequestStream {}
301
302impl futures::stream::FusedStream for FocusChainListenerRequestStream {
303    fn is_terminated(&self) -> bool {
304        self.is_terminated
305    }
306}
307
308impl fidl::endpoints::RequestStream for FocusChainListenerRequestStream {
309    type Protocol = FocusChainListenerMarker;
310    type ControlHandle = FocusChainListenerControlHandle;
311
312    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
313        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
314    }
315
316    fn control_handle(&self) -> Self::ControlHandle {
317        FocusChainListenerControlHandle { inner: self.inner.clone() }
318    }
319
320    fn into_inner(
321        self,
322    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
323    {
324        (self.inner, self.is_terminated)
325    }
326
327    fn from_inner(
328        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
329        is_terminated: bool,
330    ) -> Self {
331        Self { inner, is_terminated }
332    }
333}
334
335impl futures::Stream for FocusChainListenerRequestStream {
336    type Item = Result<FocusChainListenerRequest, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        let this = &mut *self;
343        if this.inner.check_shutdown(cx) {
344            this.is_terminated = true;
345            return std::task::Poll::Ready(None);
346        }
347        if this.is_terminated {
348            panic!("polled FocusChainListenerRequestStream after completion");
349        }
350        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
351            |bytes, handles| {
352                match this.inner.channel().read_etc(cx, bytes, handles) {
353                    std::task::Poll::Ready(Ok(())) => {}
354                    std::task::Poll::Pending => return std::task::Poll::Pending,
355                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
356                        this.is_terminated = true;
357                        return std::task::Poll::Ready(None);
358                    }
359                    std::task::Poll::Ready(Err(e)) => {
360                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
361                            e.into(),
362                        ))))
363                    }
364                }
365
366                // A message has been received from the channel
367                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
368
369                std::task::Poll::Ready(Some(match header.ordinal {
370                0x2ffe3dec9ff7a04a => {
371                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
372                    let mut req = fidl::new_empty!(FocusChainListenerOnFocusChangeRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
373                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FocusChainListenerOnFocusChangeRequest>(&header, _body_bytes, handles, &mut req)?;
374                    let control_handle = FocusChainListenerControlHandle {
375                        inner: this.inner.clone(),
376                    };
377                    Ok(FocusChainListenerRequest::OnFocusChange {focus_chain: req.focus_chain,
378
379                        responder: FocusChainListenerOnFocusChangeResponder {
380                            control_handle: std::mem::ManuallyDrop::new(control_handle),
381                            tx_id: header.tx_id,
382                        },
383                    })
384                }
385                _ => Err(fidl::Error::UnknownOrdinal {
386                    ordinal: header.ordinal,
387                    protocol_name: <FocusChainListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
388                }),
389            }))
390            },
391        )
392    }
393}
394
395/// A FocusChainListener receives an updated FocusChain when focus changes.
396#[derive(Debug)]
397pub enum FocusChainListenerRequest {
398    /// Sent when a focus change occurs.  Since `focus_chain` may contain an
399    /// empty update, every handler MUST respond to the message even
400    /// if its contents are not immediately useful.
401    OnFocusChange { focus_chain: FocusChain, responder: FocusChainListenerOnFocusChangeResponder },
402}
403
404impl FocusChainListenerRequest {
405    #[allow(irrefutable_let_patterns)]
406    pub fn into_on_focus_change(
407        self,
408    ) -> Option<(FocusChain, FocusChainListenerOnFocusChangeResponder)> {
409        if let FocusChainListenerRequest::OnFocusChange { focus_chain, responder } = self {
410            Some((focus_chain, responder))
411        } else {
412            None
413        }
414    }
415
416    /// Name of the method defined in FIDL
417    pub fn method_name(&self) -> &'static str {
418        match *self {
419            FocusChainListenerRequest::OnFocusChange { .. } => "on_focus_change",
420        }
421    }
422}
423
424#[derive(Debug, Clone)]
425pub struct FocusChainListenerControlHandle {
426    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
427}
428
429impl fidl::endpoints::ControlHandle for FocusChainListenerControlHandle {
430    fn shutdown(&self) {
431        self.inner.shutdown()
432    }
433    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
434        self.inner.shutdown_with_epitaph(status)
435    }
436
437    fn is_closed(&self) -> bool {
438        self.inner.channel().is_closed()
439    }
440    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
441        self.inner.channel().on_closed()
442    }
443
444    #[cfg(target_os = "fuchsia")]
445    fn signal_peer(
446        &self,
447        clear_mask: zx::Signals,
448        set_mask: zx::Signals,
449    ) -> Result<(), zx_status::Status> {
450        use fidl::Peered;
451        self.inner.channel().signal_peer(clear_mask, set_mask)
452    }
453}
454
455impl FocusChainListenerControlHandle {}
456
457#[must_use = "FIDL methods require a response to be sent"]
458#[derive(Debug)]
459pub struct FocusChainListenerOnFocusChangeResponder {
460    control_handle: std::mem::ManuallyDrop<FocusChainListenerControlHandle>,
461    tx_id: u32,
462}
463
464/// Set the the channel to be shutdown (see [`FocusChainListenerControlHandle::shutdown`])
465/// if the responder is dropped without sending a response, so that the client
466/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
467impl std::ops::Drop for FocusChainListenerOnFocusChangeResponder {
468    fn drop(&mut self) {
469        self.control_handle.shutdown();
470        // Safety: drops once, never accessed again
471        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
472    }
473}
474
475impl fidl::endpoints::Responder for FocusChainListenerOnFocusChangeResponder {
476    type ControlHandle = FocusChainListenerControlHandle;
477
478    fn control_handle(&self) -> &FocusChainListenerControlHandle {
479        &self.control_handle
480    }
481
482    fn drop_without_shutdown(mut self) {
483        // Safety: drops once, never accessed again due to mem::forget
484        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
485        // Prevent Drop from running (which would shut down the channel)
486        std::mem::forget(self);
487    }
488}
489
490impl FocusChainListenerOnFocusChangeResponder {
491    /// Sends a response to the FIDL transaction.
492    ///
493    /// Sets the channel to shutdown if an error occurs.
494    pub fn send(self) -> Result<(), fidl::Error> {
495        let _result = self.send_raw();
496        if _result.is_err() {
497            self.control_handle.shutdown();
498        }
499        self.drop_without_shutdown();
500        _result
501    }
502
503    /// Similar to "send" but does not shutdown the channel if an error occurs.
504    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
505        let _result = self.send_raw();
506        self.drop_without_shutdown();
507        _result
508    }
509
510    fn send_raw(&self) -> Result<(), fidl::Error> {
511        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
512            (),
513            self.tx_id,
514            0x2ffe3dec9ff7a04a,
515            fidl::encoding::DynamicFlags::empty(),
516        )
517    }
518}
519
520#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
521pub struct FocusChainListenerRegistryMarker;
522
523impl fidl::endpoints::ProtocolMarker for FocusChainListenerRegistryMarker {
524    type Proxy = FocusChainListenerRegistryProxy;
525    type RequestStream = FocusChainListenerRegistryRequestStream;
526    #[cfg(target_os = "fuchsia")]
527    type SynchronousProxy = FocusChainListenerRegistrySynchronousProxy;
528
529    const DEBUG_NAME: &'static str = "fuchsia.ui.focus.FocusChainListenerRegistry";
530}
531impl fidl::endpoints::DiscoverableProtocolMarker for FocusChainListenerRegistryMarker {}
532
533pub trait FocusChainListenerRegistryProxyInterface: Send + Sync {
534    fn r#register(
535        &self,
536        listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
537    ) -> Result<(), fidl::Error>;
538}
539#[derive(Debug)]
540#[cfg(target_os = "fuchsia")]
541pub struct FocusChainListenerRegistrySynchronousProxy {
542    client: fidl::client::sync::Client,
543}
544
545#[cfg(target_os = "fuchsia")]
546impl fidl::endpoints::SynchronousProxy for FocusChainListenerRegistrySynchronousProxy {
547    type Proxy = FocusChainListenerRegistryProxy;
548    type Protocol = FocusChainListenerRegistryMarker;
549
550    fn from_channel(inner: fidl::Channel) -> Self {
551        Self::new(inner)
552    }
553
554    fn into_channel(self) -> fidl::Channel {
555        self.client.into_channel()
556    }
557
558    fn as_channel(&self) -> &fidl::Channel {
559        self.client.as_channel()
560    }
561}
562
563#[cfg(target_os = "fuchsia")]
564impl FocusChainListenerRegistrySynchronousProxy {
565    pub fn new(channel: fidl::Channel) -> Self {
566        let protocol_name =
567            <FocusChainListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
568        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
569    }
570
571    pub fn into_channel(self) -> fidl::Channel {
572        self.client.into_channel()
573    }
574
575    /// Waits until an event arrives and returns it. It is safe for other
576    /// threads to make concurrent requests while waiting for an event.
577    pub fn wait_for_event(
578        &self,
579        deadline: zx::MonotonicInstant,
580    ) -> Result<FocusChainListenerRegistryEvent, fidl::Error> {
581        FocusChainListenerRegistryEvent::decode(self.client.wait_for_event(deadline)?)
582    }
583
584    pub fn r#register(
585        &self,
586        mut listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
587    ) -> Result<(), fidl::Error> {
588        self.client.send::<FocusChainListenerRegistryRegisterRequest>(
589            (listener,),
590            0x177be5ba0da6faa3,
591            fidl::encoding::DynamicFlags::empty(),
592        )
593    }
594}
595
596#[cfg(target_os = "fuchsia")]
597impl From<FocusChainListenerRegistrySynchronousProxy> for zx::Handle {
598    fn from(value: FocusChainListenerRegistrySynchronousProxy) -> Self {
599        value.into_channel().into()
600    }
601}
602
603#[cfg(target_os = "fuchsia")]
604impl From<fidl::Channel> for FocusChainListenerRegistrySynchronousProxy {
605    fn from(value: fidl::Channel) -> Self {
606        Self::new(value)
607    }
608}
609
610#[cfg(target_os = "fuchsia")]
611impl fidl::endpoints::FromClient for FocusChainListenerRegistrySynchronousProxy {
612    type Protocol = FocusChainListenerRegistryMarker;
613
614    fn from_client(value: fidl::endpoints::ClientEnd<FocusChainListenerRegistryMarker>) -> Self {
615        Self::new(value.into_channel())
616    }
617}
618
619#[derive(Debug, Clone)]
620pub struct FocusChainListenerRegistryProxy {
621    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
622}
623
624impl fidl::endpoints::Proxy for FocusChainListenerRegistryProxy {
625    type Protocol = FocusChainListenerRegistryMarker;
626
627    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
628        Self::new(inner)
629    }
630
631    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
632        self.client.into_channel().map_err(|client| Self { client })
633    }
634
635    fn as_channel(&self) -> &::fidl::AsyncChannel {
636        self.client.as_channel()
637    }
638}
639
640impl FocusChainListenerRegistryProxy {
641    /// Create a new Proxy for fuchsia.ui.focus/FocusChainListenerRegistry.
642    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
643        let protocol_name =
644            <FocusChainListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
645        Self { client: fidl::client::Client::new(channel, protocol_name) }
646    }
647
648    /// Get a Stream of events from the remote end of the protocol.
649    ///
650    /// # Panics
651    ///
652    /// Panics if the event stream was already taken.
653    pub fn take_event_stream(&self) -> FocusChainListenerRegistryEventStream {
654        FocusChainListenerRegistryEventStream { event_receiver: self.client.take_event_receiver() }
655    }
656
657    pub fn r#register(
658        &self,
659        mut listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
660    ) -> Result<(), fidl::Error> {
661        FocusChainListenerRegistryProxyInterface::r#register(self, listener)
662    }
663}
664
665impl FocusChainListenerRegistryProxyInterface for FocusChainListenerRegistryProxy {
666    fn r#register(
667        &self,
668        mut listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
669    ) -> Result<(), fidl::Error> {
670        self.client.send::<FocusChainListenerRegistryRegisterRequest>(
671            (listener,),
672            0x177be5ba0da6faa3,
673            fidl::encoding::DynamicFlags::empty(),
674        )
675    }
676}
677
678pub struct FocusChainListenerRegistryEventStream {
679    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
680}
681
682impl std::marker::Unpin for FocusChainListenerRegistryEventStream {}
683
684impl futures::stream::FusedStream for FocusChainListenerRegistryEventStream {
685    fn is_terminated(&self) -> bool {
686        self.event_receiver.is_terminated()
687    }
688}
689
690impl futures::Stream for FocusChainListenerRegistryEventStream {
691    type Item = Result<FocusChainListenerRegistryEvent, fidl::Error>;
692
693    fn poll_next(
694        mut self: std::pin::Pin<&mut Self>,
695        cx: &mut std::task::Context<'_>,
696    ) -> std::task::Poll<Option<Self::Item>> {
697        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
698            &mut self.event_receiver,
699            cx
700        )?) {
701            Some(buf) => std::task::Poll::Ready(Some(FocusChainListenerRegistryEvent::decode(buf))),
702            None => std::task::Poll::Ready(None),
703        }
704    }
705}
706
707#[derive(Debug)]
708pub enum FocusChainListenerRegistryEvent {}
709
710impl FocusChainListenerRegistryEvent {
711    /// Decodes a message buffer as a [`FocusChainListenerRegistryEvent`].
712    fn decode(
713        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
714    ) -> Result<FocusChainListenerRegistryEvent, fidl::Error> {
715        let (bytes, _handles) = buf.split_mut();
716        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
717        debug_assert_eq!(tx_header.tx_id, 0);
718        match tx_header.ordinal {
719            _ => Err(fidl::Error::UnknownOrdinal {
720                ordinal: tx_header.ordinal,
721                protocol_name: <FocusChainListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
722            })
723        }
724    }
725}
726
727/// A Stream of incoming requests for fuchsia.ui.focus/FocusChainListenerRegistry.
728pub struct FocusChainListenerRegistryRequestStream {
729    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
730    is_terminated: bool,
731}
732
733impl std::marker::Unpin for FocusChainListenerRegistryRequestStream {}
734
735impl futures::stream::FusedStream for FocusChainListenerRegistryRequestStream {
736    fn is_terminated(&self) -> bool {
737        self.is_terminated
738    }
739}
740
741impl fidl::endpoints::RequestStream for FocusChainListenerRegistryRequestStream {
742    type Protocol = FocusChainListenerRegistryMarker;
743    type ControlHandle = FocusChainListenerRegistryControlHandle;
744
745    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
746        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
747    }
748
749    fn control_handle(&self) -> Self::ControlHandle {
750        FocusChainListenerRegistryControlHandle { inner: self.inner.clone() }
751    }
752
753    fn into_inner(
754        self,
755    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
756    {
757        (self.inner, self.is_terminated)
758    }
759
760    fn from_inner(
761        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
762        is_terminated: bool,
763    ) -> Self {
764        Self { inner, is_terminated }
765    }
766}
767
768impl futures::Stream for FocusChainListenerRegistryRequestStream {
769    type Item = Result<FocusChainListenerRegistryRequest, fidl::Error>;
770
771    fn poll_next(
772        mut self: std::pin::Pin<&mut Self>,
773        cx: &mut std::task::Context<'_>,
774    ) -> std::task::Poll<Option<Self::Item>> {
775        let this = &mut *self;
776        if this.inner.check_shutdown(cx) {
777            this.is_terminated = true;
778            return std::task::Poll::Ready(None);
779        }
780        if this.is_terminated {
781            panic!("polled FocusChainListenerRegistryRequestStream after completion");
782        }
783        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
784            |bytes, handles| {
785                match this.inner.channel().read_etc(cx, bytes, handles) {
786                    std::task::Poll::Ready(Ok(())) => {}
787                    std::task::Poll::Pending => return std::task::Poll::Pending,
788                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
789                        this.is_terminated = true;
790                        return std::task::Poll::Ready(None);
791                    }
792                    std::task::Poll::Ready(Err(e)) => {
793                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
794                            e.into(),
795                        ))))
796                    }
797                }
798
799                // A message has been received from the channel
800                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
801
802                std::task::Poll::Ready(Some(match header.ordinal {
803                0x177be5ba0da6faa3 => {
804                    header.validate_request_tx_id(fidl::MethodType::OneWay)?;
805                    let mut req = fidl::new_empty!(FocusChainListenerRegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
806                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FocusChainListenerRegistryRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
807                    let control_handle = FocusChainListenerRegistryControlHandle {
808                        inner: this.inner.clone(),
809                    };
810                    Ok(FocusChainListenerRegistryRequest::Register {listener: req.listener,
811
812                        control_handle,
813                    })
814                }
815                _ => Err(fidl::Error::UnknownOrdinal {
816                    ordinal: header.ordinal,
817                    protocol_name: <FocusChainListenerRegistryMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
818                }),
819            }))
820            },
821        )
822    }
823}
824
825/// A FocusChainListenerRegistry allows listening to FocusChain updates.
826#[derive(Debug)]
827pub enum FocusChainListenerRegistryRequest {
828    Register {
829        listener: fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
830        control_handle: FocusChainListenerRegistryControlHandle,
831    },
832}
833
834impl FocusChainListenerRegistryRequest {
835    #[allow(irrefutable_let_patterns)]
836    pub fn into_register(
837        self,
838    ) -> Option<(
839        fidl::endpoints::ClientEnd<FocusChainListenerMarker>,
840        FocusChainListenerRegistryControlHandle,
841    )> {
842        if let FocusChainListenerRegistryRequest::Register { listener, control_handle } = self {
843            Some((listener, control_handle))
844        } else {
845            None
846        }
847    }
848
849    /// Name of the method defined in FIDL
850    pub fn method_name(&self) -> &'static str {
851        match *self {
852            FocusChainListenerRegistryRequest::Register { .. } => "register",
853        }
854    }
855}
856
857#[derive(Debug, Clone)]
858pub struct FocusChainListenerRegistryControlHandle {
859    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
860}
861
862impl fidl::endpoints::ControlHandle for FocusChainListenerRegistryControlHandle {
863    fn shutdown(&self) {
864        self.inner.shutdown()
865    }
866    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
867        self.inner.shutdown_with_epitaph(status)
868    }
869
870    fn is_closed(&self) -> bool {
871        self.inner.channel().is_closed()
872    }
873    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
874        self.inner.channel().on_closed()
875    }
876
877    #[cfg(target_os = "fuchsia")]
878    fn signal_peer(
879        &self,
880        clear_mask: zx::Signals,
881        set_mask: zx::Signals,
882    ) -> Result<(), zx_status::Status> {
883        use fidl::Peered;
884        self.inner.channel().signal_peer(clear_mask, set_mask)
885    }
886}
887
888impl FocusChainListenerRegistryControlHandle {}
889
890#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
891pub struct FocusChainProviderMarker;
892
893impl fidl::endpoints::ProtocolMarker for FocusChainProviderMarker {
894    type Proxy = FocusChainProviderProxy;
895    type RequestStream = FocusChainProviderRequestStream;
896    #[cfg(target_os = "fuchsia")]
897    type SynchronousProxy = FocusChainProviderSynchronousProxy;
898
899    const DEBUG_NAME: &'static str = "fuchsia.ui.focus.FocusChainProvider";
900}
901impl fidl::endpoints::DiscoverableProtocolMarker for FocusChainProviderMarker {}
902
903pub trait FocusChainProviderProxyInterface: Send + Sync {
904    type WatchFocusKoidChainResponseFut: std::future::Future<Output = Result<FocusKoidChain, fidl::Error>>
905        + Send;
906    fn r#watch_focus_koid_chain(
907        &self,
908        payload: &FocusChainProviderWatchFocusKoidChainRequest,
909    ) -> Self::WatchFocusKoidChainResponseFut;
910}
911#[derive(Debug)]
912#[cfg(target_os = "fuchsia")]
913pub struct FocusChainProviderSynchronousProxy {
914    client: fidl::client::sync::Client,
915}
916
917#[cfg(target_os = "fuchsia")]
918impl fidl::endpoints::SynchronousProxy for FocusChainProviderSynchronousProxy {
919    type Proxy = FocusChainProviderProxy;
920    type Protocol = FocusChainProviderMarker;
921
922    fn from_channel(inner: fidl::Channel) -> Self {
923        Self::new(inner)
924    }
925
926    fn into_channel(self) -> fidl::Channel {
927        self.client.into_channel()
928    }
929
930    fn as_channel(&self) -> &fidl::Channel {
931        self.client.as_channel()
932    }
933}
934
935#[cfg(target_os = "fuchsia")]
936impl FocusChainProviderSynchronousProxy {
937    pub fn new(channel: fidl::Channel) -> Self {
938        let protocol_name =
939            <FocusChainProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
940        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
941    }
942
943    pub fn into_channel(self) -> fidl::Channel {
944        self.client.into_channel()
945    }
946
947    /// Waits until an event arrives and returns it. It is safe for other
948    /// threads to make concurrent requests while waiting for an event.
949    pub fn wait_for_event(
950        &self,
951        deadline: zx::MonotonicInstant,
952    ) -> Result<FocusChainProviderEvent, fidl::Error> {
953        FocusChainProviderEvent::decode(self.client.wait_for_event(deadline)?)
954    }
955
956    /// Subscribe to changes in the focus chain (koids only) with a hanging-get
957    /// pattern.
958    ///
959    /// The server responds immediately with the initial state, and afterwards
960    /// whenever a change occurs. Updates are not queued up for slow clients;
961    /// only the latest state is sent.
962    ///
963    /// It is invalid to call this method while a previous call is pending.
964    /// Doing so will cause the server end of the protocol to be closed.
965    pub fn r#watch_focus_koid_chain(
966        &self,
967        mut payload: &FocusChainProviderWatchFocusKoidChainRequest,
968        ___deadline: zx::MonotonicInstant,
969    ) -> Result<FocusKoidChain, fidl::Error> {
970        let _response = self
971            .client
972            .send_query::<FocusChainProviderWatchFocusKoidChainRequest, FocusKoidChain>(
973                payload,
974                0x726d2fdae53c1ab7,
975                fidl::encoding::DynamicFlags::empty(),
976                ___deadline,
977            )?;
978        Ok(_response)
979    }
980}
981
982#[cfg(target_os = "fuchsia")]
983impl From<FocusChainProviderSynchronousProxy> for zx::Handle {
984    fn from(value: FocusChainProviderSynchronousProxy) -> Self {
985        value.into_channel().into()
986    }
987}
988
989#[cfg(target_os = "fuchsia")]
990impl From<fidl::Channel> for FocusChainProviderSynchronousProxy {
991    fn from(value: fidl::Channel) -> Self {
992        Self::new(value)
993    }
994}
995
996#[cfg(target_os = "fuchsia")]
997impl fidl::endpoints::FromClient for FocusChainProviderSynchronousProxy {
998    type Protocol = FocusChainProviderMarker;
999
1000    fn from_client(value: fidl::endpoints::ClientEnd<FocusChainProviderMarker>) -> Self {
1001        Self::new(value.into_channel())
1002    }
1003}
1004
1005#[derive(Debug, Clone)]
1006pub struct FocusChainProviderProxy {
1007    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1008}
1009
1010impl fidl::endpoints::Proxy for FocusChainProviderProxy {
1011    type Protocol = FocusChainProviderMarker;
1012
1013    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1014        Self::new(inner)
1015    }
1016
1017    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1018        self.client.into_channel().map_err(|client| Self { client })
1019    }
1020
1021    fn as_channel(&self) -> &::fidl::AsyncChannel {
1022        self.client.as_channel()
1023    }
1024}
1025
1026impl FocusChainProviderProxy {
1027    /// Create a new Proxy for fuchsia.ui.focus/FocusChainProvider.
1028    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1029        let protocol_name =
1030            <FocusChainProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1031        Self { client: fidl::client::Client::new(channel, protocol_name) }
1032    }
1033
1034    /// Get a Stream of events from the remote end of the protocol.
1035    ///
1036    /// # Panics
1037    ///
1038    /// Panics if the event stream was already taken.
1039    pub fn take_event_stream(&self) -> FocusChainProviderEventStream {
1040        FocusChainProviderEventStream { event_receiver: self.client.take_event_receiver() }
1041    }
1042
1043    /// Subscribe to changes in the focus chain (koids only) with a hanging-get
1044    /// pattern.
1045    ///
1046    /// The server responds immediately with the initial state, and afterwards
1047    /// whenever a change occurs. Updates are not queued up for slow clients;
1048    /// only the latest state is sent.
1049    ///
1050    /// It is invalid to call this method while a previous call is pending.
1051    /// Doing so will cause the server end of the protocol to be closed.
1052    pub fn r#watch_focus_koid_chain(
1053        &self,
1054        mut payload: &FocusChainProviderWatchFocusKoidChainRequest,
1055    ) -> fidl::client::QueryResponseFut<FocusKoidChain, fidl::encoding::DefaultFuchsiaResourceDialect>
1056    {
1057        FocusChainProviderProxyInterface::r#watch_focus_koid_chain(self, payload)
1058    }
1059}
1060
1061impl FocusChainProviderProxyInterface for FocusChainProviderProxy {
1062    type WatchFocusKoidChainResponseFut = fidl::client::QueryResponseFut<
1063        FocusKoidChain,
1064        fidl::encoding::DefaultFuchsiaResourceDialect,
1065    >;
1066    fn r#watch_focus_koid_chain(
1067        &self,
1068        mut payload: &FocusChainProviderWatchFocusKoidChainRequest,
1069    ) -> Self::WatchFocusKoidChainResponseFut {
1070        fn _decode(
1071            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1072        ) -> Result<FocusKoidChain, fidl::Error> {
1073            let _response = fidl::client::decode_transaction_body::<
1074                FocusKoidChain,
1075                fidl::encoding::DefaultFuchsiaResourceDialect,
1076                0x726d2fdae53c1ab7,
1077            >(_buf?)?;
1078            Ok(_response)
1079        }
1080        self.client
1081            .send_query_and_decode::<FocusChainProviderWatchFocusKoidChainRequest, FocusKoidChain>(
1082                payload,
1083                0x726d2fdae53c1ab7,
1084                fidl::encoding::DynamicFlags::empty(),
1085                _decode,
1086            )
1087    }
1088}
1089
1090pub struct FocusChainProviderEventStream {
1091    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1092}
1093
1094impl std::marker::Unpin for FocusChainProviderEventStream {}
1095
1096impl futures::stream::FusedStream for FocusChainProviderEventStream {
1097    fn is_terminated(&self) -> bool {
1098        self.event_receiver.is_terminated()
1099    }
1100}
1101
1102impl futures::Stream for FocusChainProviderEventStream {
1103    type Item = Result<FocusChainProviderEvent, fidl::Error>;
1104
1105    fn poll_next(
1106        mut self: std::pin::Pin<&mut Self>,
1107        cx: &mut std::task::Context<'_>,
1108    ) -> std::task::Poll<Option<Self::Item>> {
1109        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1110            &mut self.event_receiver,
1111            cx
1112        )?) {
1113            Some(buf) => std::task::Poll::Ready(Some(FocusChainProviderEvent::decode(buf))),
1114            None => std::task::Poll::Ready(None),
1115        }
1116    }
1117}
1118
1119#[derive(Debug)]
1120pub enum FocusChainProviderEvent {}
1121
1122impl FocusChainProviderEvent {
1123    /// Decodes a message buffer as a [`FocusChainProviderEvent`].
1124    fn decode(
1125        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1126    ) -> Result<FocusChainProviderEvent, fidl::Error> {
1127        let (bytes, _handles) = buf.split_mut();
1128        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1129        debug_assert_eq!(tx_header.tx_id, 0);
1130        match tx_header.ordinal {
1131            _ => Err(fidl::Error::UnknownOrdinal {
1132                ordinal: tx_header.ordinal,
1133                protocol_name:
1134                    <FocusChainProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1135            }),
1136        }
1137    }
1138}
1139
1140/// A Stream of incoming requests for fuchsia.ui.focus/FocusChainProvider.
1141pub struct FocusChainProviderRequestStream {
1142    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1143    is_terminated: bool,
1144}
1145
1146impl std::marker::Unpin for FocusChainProviderRequestStream {}
1147
1148impl futures::stream::FusedStream for FocusChainProviderRequestStream {
1149    fn is_terminated(&self) -> bool {
1150        self.is_terminated
1151    }
1152}
1153
1154impl fidl::endpoints::RequestStream for FocusChainProviderRequestStream {
1155    type Protocol = FocusChainProviderMarker;
1156    type ControlHandle = FocusChainProviderControlHandle;
1157
1158    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1159        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1160    }
1161
1162    fn control_handle(&self) -> Self::ControlHandle {
1163        FocusChainProviderControlHandle { inner: self.inner.clone() }
1164    }
1165
1166    fn into_inner(
1167        self,
1168    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1169    {
1170        (self.inner, self.is_terminated)
1171    }
1172
1173    fn from_inner(
1174        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1175        is_terminated: bool,
1176    ) -> Self {
1177        Self { inner, is_terminated }
1178    }
1179}
1180
1181impl futures::Stream for FocusChainProviderRequestStream {
1182    type Item = Result<FocusChainProviderRequest, fidl::Error>;
1183
1184    fn poll_next(
1185        mut self: std::pin::Pin<&mut Self>,
1186        cx: &mut std::task::Context<'_>,
1187    ) -> std::task::Poll<Option<Self::Item>> {
1188        let this = &mut *self;
1189        if this.inner.check_shutdown(cx) {
1190            this.is_terminated = true;
1191            return std::task::Poll::Ready(None);
1192        }
1193        if this.is_terminated {
1194            panic!("polled FocusChainProviderRequestStream after completion");
1195        }
1196        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1197            |bytes, handles| {
1198                match this.inner.channel().read_etc(cx, bytes, handles) {
1199                    std::task::Poll::Ready(Ok(())) => {}
1200                    std::task::Poll::Pending => return std::task::Poll::Pending,
1201                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1202                        this.is_terminated = true;
1203                        return std::task::Poll::Ready(None);
1204                    }
1205                    std::task::Poll::Ready(Err(e)) => {
1206                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1207                            e.into(),
1208                        ))))
1209                    }
1210                }
1211
1212                // A message has been received from the channel
1213                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1214
1215                std::task::Poll::Ready(Some(match header.ordinal {
1216                0x726d2fdae53c1ab7 => {
1217                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1218                    let mut req = fidl::new_empty!(FocusChainProviderWatchFocusKoidChainRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
1219                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FocusChainProviderWatchFocusKoidChainRequest>(&header, _body_bytes, handles, &mut req)?;
1220                    let control_handle = FocusChainProviderControlHandle {
1221                        inner: this.inner.clone(),
1222                    };
1223                    Ok(FocusChainProviderRequest::WatchFocusKoidChain {payload: req,
1224                        responder: FocusChainProviderWatchFocusKoidChainResponder {
1225                            control_handle: std::mem::ManuallyDrop::new(control_handle),
1226                            tx_id: header.tx_id,
1227                        },
1228                    })
1229                }
1230                _ => Err(fidl::Error::UnknownOrdinal {
1231                    ordinal: header.ordinal,
1232                    protocol_name: <FocusChainProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1233                }),
1234            }))
1235            },
1236        )
1237    }
1238}
1239
1240/// The `FocusChainProvider` protocol allows privileged clients to watch for
1241/// focus chain updates.
1242///
1243/// It is intended as an experimental solution for providing focus information
1244/// to the clipboard.
1245#[derive(Debug)]
1246pub enum FocusChainProviderRequest {
1247    /// Subscribe to changes in the focus chain (koids only) with a hanging-get
1248    /// pattern.
1249    ///
1250    /// The server responds immediately with the initial state, and afterwards
1251    /// whenever a change occurs. Updates are not queued up for slow clients;
1252    /// only the latest state is sent.
1253    ///
1254    /// It is invalid to call this method while a previous call is pending.
1255    /// Doing so will cause the server end of the protocol to be closed.
1256    WatchFocusKoidChain {
1257        payload: FocusChainProviderWatchFocusKoidChainRequest,
1258        responder: FocusChainProviderWatchFocusKoidChainResponder,
1259    },
1260}
1261
1262impl FocusChainProviderRequest {
1263    #[allow(irrefutable_let_patterns)]
1264    pub fn into_watch_focus_koid_chain(
1265        self,
1266    ) -> Option<(
1267        FocusChainProviderWatchFocusKoidChainRequest,
1268        FocusChainProviderWatchFocusKoidChainResponder,
1269    )> {
1270        if let FocusChainProviderRequest::WatchFocusKoidChain { payload, responder } = self {
1271            Some((payload, responder))
1272        } else {
1273            None
1274        }
1275    }
1276
1277    /// Name of the method defined in FIDL
1278    pub fn method_name(&self) -> &'static str {
1279        match *self {
1280            FocusChainProviderRequest::WatchFocusKoidChain { .. } => "watch_focus_koid_chain",
1281        }
1282    }
1283}
1284
1285#[derive(Debug, Clone)]
1286pub struct FocusChainProviderControlHandle {
1287    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1288}
1289
1290impl fidl::endpoints::ControlHandle for FocusChainProviderControlHandle {
1291    fn shutdown(&self) {
1292        self.inner.shutdown()
1293    }
1294    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1295        self.inner.shutdown_with_epitaph(status)
1296    }
1297
1298    fn is_closed(&self) -> bool {
1299        self.inner.channel().is_closed()
1300    }
1301    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1302        self.inner.channel().on_closed()
1303    }
1304
1305    #[cfg(target_os = "fuchsia")]
1306    fn signal_peer(
1307        &self,
1308        clear_mask: zx::Signals,
1309        set_mask: zx::Signals,
1310    ) -> Result<(), zx_status::Status> {
1311        use fidl::Peered;
1312        self.inner.channel().signal_peer(clear_mask, set_mask)
1313    }
1314}
1315
1316impl FocusChainProviderControlHandle {}
1317
1318#[must_use = "FIDL methods require a response to be sent"]
1319#[derive(Debug)]
1320pub struct FocusChainProviderWatchFocusKoidChainResponder {
1321    control_handle: std::mem::ManuallyDrop<FocusChainProviderControlHandle>,
1322    tx_id: u32,
1323}
1324
1325/// Set the the channel to be shutdown (see [`FocusChainProviderControlHandle::shutdown`])
1326/// if the responder is dropped without sending a response, so that the client
1327/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1328impl std::ops::Drop for FocusChainProviderWatchFocusKoidChainResponder {
1329    fn drop(&mut self) {
1330        self.control_handle.shutdown();
1331        // Safety: drops once, never accessed again
1332        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1333    }
1334}
1335
1336impl fidl::endpoints::Responder for FocusChainProviderWatchFocusKoidChainResponder {
1337    type ControlHandle = FocusChainProviderControlHandle;
1338
1339    fn control_handle(&self) -> &FocusChainProviderControlHandle {
1340        &self.control_handle
1341    }
1342
1343    fn drop_without_shutdown(mut self) {
1344        // Safety: drops once, never accessed again due to mem::forget
1345        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1346        // Prevent Drop from running (which would shut down the channel)
1347        std::mem::forget(self);
1348    }
1349}
1350
1351impl FocusChainProviderWatchFocusKoidChainResponder {
1352    /// Sends a response to the FIDL transaction.
1353    ///
1354    /// Sets the channel to shutdown if an error occurs.
1355    pub fn send(self, mut payload: &FocusKoidChain) -> Result<(), fidl::Error> {
1356        let _result = self.send_raw(payload);
1357        if _result.is_err() {
1358            self.control_handle.shutdown();
1359        }
1360        self.drop_without_shutdown();
1361        _result
1362    }
1363
1364    /// Similar to "send" but does not shutdown the channel if an error occurs.
1365    pub fn send_no_shutdown_on_err(self, mut payload: &FocusKoidChain) -> Result<(), fidl::Error> {
1366        let _result = self.send_raw(payload);
1367        self.drop_without_shutdown();
1368        _result
1369    }
1370
1371    fn send_raw(&self, mut payload: &FocusKoidChain) -> Result<(), fidl::Error> {
1372        self.control_handle.inner.send::<FocusKoidChain>(
1373            payload,
1374            self.tx_id,
1375            0x726d2fdae53c1ab7,
1376            fidl::encoding::DynamicFlags::empty(),
1377        )
1378    }
1379}
1380
1381mod internal {
1382    use super::*;
1383
1384    impl fidl::encoding::ResourceTypeMarker for FocusChainListenerOnFocusChangeRequest {
1385        type Borrowed<'a> = &'a mut Self;
1386        fn take_or_borrow<'a>(
1387            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1388        ) -> Self::Borrowed<'a> {
1389            value
1390        }
1391    }
1392
1393    unsafe impl fidl::encoding::TypeMarker for FocusChainListenerOnFocusChangeRequest {
1394        type Owned = Self;
1395
1396        #[inline(always)]
1397        fn inline_align(_context: fidl::encoding::Context) -> usize {
1398            8
1399        }
1400
1401        #[inline(always)]
1402        fn inline_size(_context: fidl::encoding::Context) -> usize {
1403            16
1404        }
1405    }
1406
1407    unsafe impl
1408        fidl::encoding::Encode<
1409            FocusChainListenerOnFocusChangeRequest,
1410            fidl::encoding::DefaultFuchsiaResourceDialect,
1411        > for &mut FocusChainListenerOnFocusChangeRequest
1412    {
1413        #[inline]
1414        unsafe fn encode(
1415            self,
1416            encoder: &mut fidl::encoding::Encoder<
1417                '_,
1418                fidl::encoding::DefaultFuchsiaResourceDialect,
1419            >,
1420            offset: usize,
1421            _depth: fidl::encoding::Depth,
1422        ) -> fidl::Result<()> {
1423            encoder.debug_check_bounds::<FocusChainListenerOnFocusChangeRequest>(offset);
1424            // Delegate to tuple encoding.
1425            fidl::encoding::Encode::<
1426                FocusChainListenerOnFocusChangeRequest,
1427                fidl::encoding::DefaultFuchsiaResourceDialect,
1428            >::encode(
1429                (<FocusChain as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1430                    &mut self.focus_chain,
1431                ),),
1432                encoder,
1433                offset,
1434                _depth,
1435            )
1436        }
1437    }
1438    unsafe impl<T0: fidl::encoding::Encode<FocusChain, fidl::encoding::DefaultFuchsiaResourceDialect>>
1439        fidl::encoding::Encode<
1440            FocusChainListenerOnFocusChangeRequest,
1441            fidl::encoding::DefaultFuchsiaResourceDialect,
1442        > for (T0,)
1443    {
1444        #[inline]
1445        unsafe fn encode(
1446            self,
1447            encoder: &mut fidl::encoding::Encoder<
1448                '_,
1449                fidl::encoding::DefaultFuchsiaResourceDialect,
1450            >,
1451            offset: usize,
1452            depth: fidl::encoding::Depth,
1453        ) -> fidl::Result<()> {
1454            encoder.debug_check_bounds::<FocusChainListenerOnFocusChangeRequest>(offset);
1455            // Zero out padding regions. There's no need to apply masks
1456            // because the unmasked parts will be overwritten by fields.
1457            // Write the fields.
1458            self.0.encode(encoder, offset + 0, depth)?;
1459            Ok(())
1460        }
1461    }
1462
1463    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1464        for FocusChainListenerOnFocusChangeRequest
1465    {
1466        #[inline(always)]
1467        fn new_empty() -> Self {
1468            Self {
1469                focus_chain: fidl::new_empty!(
1470                    FocusChain,
1471                    fidl::encoding::DefaultFuchsiaResourceDialect
1472                ),
1473            }
1474        }
1475
1476        #[inline]
1477        unsafe fn decode(
1478            &mut self,
1479            decoder: &mut fidl::encoding::Decoder<
1480                '_,
1481                fidl::encoding::DefaultFuchsiaResourceDialect,
1482            >,
1483            offset: usize,
1484            _depth: fidl::encoding::Depth,
1485        ) -> fidl::Result<()> {
1486            decoder.debug_check_bounds::<Self>(offset);
1487            // Verify that padding bytes are zero.
1488            fidl::decode!(
1489                FocusChain,
1490                fidl::encoding::DefaultFuchsiaResourceDialect,
1491                &mut self.focus_chain,
1492                decoder,
1493                offset + 0,
1494                _depth
1495            )?;
1496            Ok(())
1497        }
1498    }
1499
1500    impl fidl::encoding::ResourceTypeMarker for FocusChainListenerRegistryRegisterRequest {
1501        type Borrowed<'a> = &'a mut Self;
1502        fn take_or_borrow<'a>(
1503            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1504        ) -> Self::Borrowed<'a> {
1505            value
1506        }
1507    }
1508
1509    unsafe impl fidl::encoding::TypeMarker for FocusChainListenerRegistryRegisterRequest {
1510        type Owned = Self;
1511
1512        #[inline(always)]
1513        fn inline_align(_context: fidl::encoding::Context) -> usize {
1514            4
1515        }
1516
1517        #[inline(always)]
1518        fn inline_size(_context: fidl::encoding::Context) -> usize {
1519            4
1520        }
1521    }
1522
1523    unsafe impl
1524        fidl::encoding::Encode<
1525            FocusChainListenerRegistryRegisterRequest,
1526            fidl::encoding::DefaultFuchsiaResourceDialect,
1527        > for &mut FocusChainListenerRegistryRegisterRequest
1528    {
1529        #[inline]
1530        unsafe fn encode(
1531            self,
1532            encoder: &mut fidl::encoding::Encoder<
1533                '_,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535            >,
1536            offset: usize,
1537            _depth: fidl::encoding::Depth,
1538        ) -> fidl::Result<()> {
1539            encoder.debug_check_bounds::<FocusChainListenerRegistryRegisterRequest>(offset);
1540            // Delegate to tuple encoding.
1541            fidl::encoding::Encode::<FocusChainListenerRegistryRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1542                (
1543                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FocusChainListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
1544                ),
1545                encoder, offset, _depth
1546            )
1547        }
1548    }
1549    unsafe impl<
1550            T0: fidl::encoding::Encode<
1551                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FocusChainListenerMarker>>,
1552                fidl::encoding::DefaultFuchsiaResourceDialect,
1553            >,
1554        >
1555        fidl::encoding::Encode<
1556            FocusChainListenerRegistryRegisterRequest,
1557            fidl::encoding::DefaultFuchsiaResourceDialect,
1558        > for (T0,)
1559    {
1560        #[inline]
1561        unsafe fn encode(
1562            self,
1563            encoder: &mut fidl::encoding::Encoder<
1564                '_,
1565                fidl::encoding::DefaultFuchsiaResourceDialect,
1566            >,
1567            offset: usize,
1568            depth: fidl::encoding::Depth,
1569        ) -> fidl::Result<()> {
1570            encoder.debug_check_bounds::<FocusChainListenerRegistryRegisterRequest>(offset);
1571            // Zero out padding regions. There's no need to apply masks
1572            // because the unmasked parts will be overwritten by fields.
1573            // Write the fields.
1574            self.0.encode(encoder, offset + 0, depth)?;
1575            Ok(())
1576        }
1577    }
1578
1579    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1580        for FocusChainListenerRegistryRegisterRequest
1581    {
1582        #[inline(always)]
1583        fn new_empty() -> Self {
1584            Self {
1585                listener: fidl::new_empty!(
1586                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FocusChainListenerMarker>>,
1587                    fidl::encoding::DefaultFuchsiaResourceDialect
1588                ),
1589            }
1590        }
1591
1592        #[inline]
1593        unsafe fn decode(
1594            &mut self,
1595            decoder: &mut fidl::encoding::Decoder<
1596                '_,
1597                fidl::encoding::DefaultFuchsiaResourceDialect,
1598            >,
1599            offset: usize,
1600            _depth: fidl::encoding::Depth,
1601        ) -> fidl::Result<()> {
1602            decoder.debug_check_bounds::<Self>(offset);
1603            // Verify that padding bytes are zero.
1604            fidl::decode!(
1605                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FocusChainListenerMarker>>,
1606                fidl::encoding::DefaultFuchsiaResourceDialect,
1607                &mut self.listener,
1608                decoder,
1609                offset + 0,
1610                _depth
1611            )?;
1612            Ok(())
1613        }
1614    }
1615
1616    impl FocusChain {
1617        #[inline(always)]
1618        fn max_ordinal_present(&self) -> u64 {
1619            if let Some(_) = self.focus_chain {
1620                return 1;
1621            }
1622            0
1623        }
1624    }
1625
1626    impl fidl::encoding::ResourceTypeMarker for FocusChain {
1627        type Borrowed<'a> = &'a mut Self;
1628        fn take_or_borrow<'a>(
1629            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1630        ) -> Self::Borrowed<'a> {
1631            value
1632        }
1633    }
1634
1635    unsafe impl fidl::encoding::TypeMarker for FocusChain {
1636        type Owned = Self;
1637
1638        #[inline(always)]
1639        fn inline_align(_context: fidl::encoding::Context) -> usize {
1640            8
1641        }
1642
1643        #[inline(always)]
1644        fn inline_size(_context: fidl::encoding::Context) -> usize {
1645            16
1646        }
1647    }
1648
1649    unsafe impl fidl::encoding::Encode<FocusChain, fidl::encoding::DefaultFuchsiaResourceDialect>
1650        for &mut FocusChain
1651    {
1652        unsafe fn encode(
1653            self,
1654            encoder: &mut fidl::encoding::Encoder<
1655                '_,
1656                fidl::encoding::DefaultFuchsiaResourceDialect,
1657            >,
1658            offset: usize,
1659            mut depth: fidl::encoding::Depth,
1660        ) -> fidl::Result<()> {
1661            encoder.debug_check_bounds::<FocusChain>(offset);
1662            // Vector header
1663            let max_ordinal: u64 = self.max_ordinal_present();
1664            encoder.write_num(max_ordinal, offset);
1665            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1666            // Calling encoder.out_of_line_offset(0) is not allowed.
1667            if max_ordinal == 0 {
1668                return Ok(());
1669            }
1670            depth.increment()?;
1671            let envelope_size = 8;
1672            let bytes_len = max_ordinal as usize * envelope_size;
1673            #[allow(unused_variables)]
1674            let offset = encoder.out_of_line_offset(bytes_len);
1675            let mut _prev_end_offset: usize = 0;
1676            if 1 > max_ordinal {
1677                return Ok(());
1678            }
1679
1680            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1681            // are envelope_size bytes.
1682            let cur_offset: usize = (1 - 1) * envelope_size;
1683
1684            // Zero reserved fields.
1685            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1686
1687            // Safety:
1688            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1689            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1690            //   envelope_size bytes, there is always sufficient room.
1691            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<fidl_fuchsia_ui_views::ViewRef>, fidl::encoding::DefaultFuchsiaResourceDialect>(
1692            self.focus_chain.as_mut().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_ui_views::ViewRef> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1693            encoder, offset + cur_offset, depth
1694        )?;
1695
1696            _prev_end_offset = cur_offset + envelope_size;
1697
1698            Ok(())
1699        }
1700    }
1701
1702    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FocusChain {
1703        #[inline(always)]
1704        fn new_empty() -> Self {
1705            Self::default()
1706        }
1707
1708        unsafe fn decode(
1709            &mut self,
1710            decoder: &mut fidl::encoding::Decoder<
1711                '_,
1712                fidl::encoding::DefaultFuchsiaResourceDialect,
1713            >,
1714            offset: usize,
1715            mut depth: fidl::encoding::Depth,
1716        ) -> fidl::Result<()> {
1717            decoder.debug_check_bounds::<Self>(offset);
1718            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1719                None => return Err(fidl::Error::NotNullable),
1720                Some(len) => len,
1721            };
1722            // Calling decoder.out_of_line_offset(0) is not allowed.
1723            if len == 0 {
1724                return Ok(());
1725            };
1726            depth.increment()?;
1727            let envelope_size = 8;
1728            let bytes_len = len * envelope_size;
1729            let offset = decoder.out_of_line_offset(bytes_len)?;
1730            // Decode the envelope for each type.
1731            let mut _next_ordinal_to_read = 0;
1732            let mut next_offset = offset;
1733            let end_offset = offset + bytes_len;
1734            _next_ordinal_to_read += 1;
1735            if next_offset >= end_offset {
1736                return Ok(());
1737            }
1738
1739            // Decode unknown envelopes for gaps in ordinals.
1740            while _next_ordinal_to_read < 1 {
1741                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1742                _next_ordinal_to_read += 1;
1743                next_offset += envelope_size;
1744            }
1745
1746            let next_out_of_line = decoder.next_out_of_line();
1747            let handles_before = decoder.remaining_handles();
1748            if let Some((inlined, num_bytes, num_handles)) =
1749                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1750            {
1751                let member_inline_size = <fidl::encoding::UnboundedVector<
1752                    fidl_fuchsia_ui_views::ViewRef,
1753                > as fidl::encoding::TypeMarker>::inline_size(
1754                    decoder.context
1755                );
1756                if inlined != (member_inline_size <= 4) {
1757                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1758                }
1759                let inner_offset;
1760                let mut inner_depth = depth.clone();
1761                if inlined {
1762                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1763                    inner_offset = next_offset;
1764                } else {
1765                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1766                    inner_depth.increment()?;
1767                }
1768                let val_ref = self.focus_chain.get_or_insert_with(|| {
1769                    fidl::new_empty!(
1770                        fidl::encoding::UnboundedVector<fidl_fuchsia_ui_views::ViewRef>,
1771                        fidl::encoding::DefaultFuchsiaResourceDialect
1772                    )
1773                });
1774                fidl::decode!(
1775                    fidl::encoding::UnboundedVector<fidl_fuchsia_ui_views::ViewRef>,
1776                    fidl::encoding::DefaultFuchsiaResourceDialect,
1777                    val_ref,
1778                    decoder,
1779                    inner_offset,
1780                    inner_depth
1781                )?;
1782                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1783                {
1784                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1785                }
1786                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1787                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1788                }
1789            }
1790
1791            next_offset += envelope_size;
1792
1793            // Decode the remaining unknown envelopes.
1794            while next_offset < end_offset {
1795                _next_ordinal_to_read += 1;
1796                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1797                next_offset += envelope_size;
1798            }
1799
1800            Ok(())
1801        }
1802    }
1803}