Skip to main content

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