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