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