fidl_fuchsia_ui_focus/
fidl_fuchsia_ui_focus.rs

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