Skip to main content

fidl_fuchsia_ui_views/
fidl_fuchsia_ui_views.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_views_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FocuserRequestFocusRequest {
16    pub view_ref: ViewRef,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for FocuserRequestFocusRequest
21{
22}
23
24/// Two Flatland instances may be connected in a parent-child relationship. The child endpoint is
25/// held in a View. This view is strongly associated with a ViewRef and other related protocols.
26///
27/// ViewCreationToken is a typed wrapper for a channel, representing the child endpoint of the
28/// connection between two Flatland instances. No messages will be sent over this channel, because
29/// it is only used as an unclonable object with peer.
30#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
31pub struct ViewCreationToken {
32    pub value: fidl::Channel,
33}
34
35impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewCreationToken {}
36
37/// Token that uniquely identifies an attachment point for a `View` in the
38/// global scene graph.  Each `ViewHolderToken` has exactly one corresponding
39/// `ViewToken`.
40///
41/// A Scenic client can reference contents from another client by creating a
42/// `ViewHolder` resource using this token.  The other client must also create
43/// a `View` resource using the corresponding `ViewToken`.
44#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
45pub struct ViewHolderToken {
46    pub value: fidl::EventPair,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewHolderToken {}
50
51/// Convenience data type to self-identify the view, during view creation.
52///
53/// A ViewRef is used to identify the view, and can be freely cloned and
54/// distributed to other components.
55///
56/// A ViewRefControl is used to implement lifecycle notification, and must not
57/// be cloned, and cannot be distributed to other components. Scenic binds the
58/// ViewRefControl object to the view, so when the view is destroyed, the
59/// destruction of the ViewRefControl triggers a `ZX_EVENTPAIR_PEER_CLOSED`
60/// signal to all ViewRef holders, thus notifying view death.
61///
62/// Usage: When creating a view, place a ViewRef and ViewRefControl together in
63/// this struct, so that they travel as a unit to the destination component.
64/// This convenience struct allows a protocol author to describe this traveling
65/// pair as one argument. It improves readability and reduces mishandling.
66#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
67pub struct ViewIdentityOnCreation {
68    /// Stable identifier for the view to be created.
69    pub view_ref: ViewRef,
70    /// A mechanism for lifecycle notification.
71    pub view_ref_control: ViewRefControl,
72}
73
74impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewIdentityOnCreation {}
75
76#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
77pub struct ViewPresentRequest {
78    pub view_token: ViewToken,
79}
80
81impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewPresentRequest {}
82
83/// A ViewRef is a handle to a kernel object which identifies a unique View
84/// across the system. Two ViewRefs to the same View have the same KOID.
85///
86/// Clients use a ViewRef to identify a View, to validate a View, and to
87/// receive a View invalidation signal.
88///
89/// As part of View creation, the client creates a linked
90/// ViewRef/ViewRefControl pair and hands the pair to Scenic (ViewRefControl is
91/// described below).  The client must remove the ViewRef's signal
92/// capabilities; otherwise the View is not created.
93///
94/// The client may freely clone its ViewRef and share it, even before sending
95/// it to Scenic.
96///
97/// Example 1. Accessibility accepts a ViewRef from a client to group the
98/// semantic nodes, and semantic operations, associated with a client's View.
99/// It must validate a client's ViewRef with Scenic.
100///
101/// Example 2. We use ViewRefs to create a FocusChain, which identifies Views
102/// considered as "in-focus" down the View hierarchy. When a View is destroyed,
103/// Scenic signals to all FocusChain holders that the ViewRef is now invalid.
104#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
105pub struct ViewRef {
106    pub reference: fidl::EventPair,
107}
108
109impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewRef {}
110
111/// A ViewRefControl is the peer to a ViewRef. Their `reference`s are linked.
112///
113/// Like ViewRef, a ViewRefControl is a typed handle to an eventpair.  Unlike
114/// ViewRef, a ViewRefControl's handle is unique. Scenic uses this property
115/// when it ties a ViewRefControl to a View, arranged to share fate.  When a
116/// View is destroyed, the associated destruction of its ViewRefControl
117/// triggers an automatic `ZX_EVENTPAIR_PEER_CLOSED` signal sent to all ViewRef
118/// holders; hence ViewRef holders may track View lifetime.
119///
120/// As part of View creation, the client creates a linked
121/// ViewRef/ViewRefControl pair and hands the pair to Scenic (ViewRef is
122/// described above).  The client must not clone the ViewRefControl. It must
123/// not remove or modify the ViewRefControl's capabilities; otherwise the View
124/// is not created.
125#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
126pub struct ViewRefControl {
127    pub reference: fidl::EventPair,
128}
129
130impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewRefControl {}
131
132#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
133pub struct ViewRefInstalledWatchRequest {
134    pub view_ref: ViewRef,
135}
136
137impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
138    for ViewRefInstalledWatchRequest
139{
140}
141
142/// Token that uniquely identifies a `View`, which is the root point for a
143/// subgraph in the global scene graph. Each `ViewToken` has exactly one
144/// corresponding `ViewHolderToken`.
145///
146/// A Scenic client can have its contents referenced from another client by
147/// creating a `View` resource using this token.  The other client must also
148/// create a `ViewHolder` resource using the corresponding `ViewHolderToken`.
149#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
150pub struct ViewToken {
151    pub value: fidl::EventPair,
152}
153
154impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewToken {}
155
156/// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint is
157/// held in a Viewport.
158///
159/// ViewportCreationToken is a typed wrapper for a channel, representing the parent endpoint of the
160/// connection between two Flatlands. No messages will be sent over this channel, because it is only
161/// used as an unclonable object with peer.
162#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
163pub struct ViewportCreationToken {
164    pub value: fidl::Channel,
165}
166
167impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewportCreationToken {}
168
169#[derive(Debug, Default, PartialEq)]
170pub struct FocuserSetAutoFocusRequest {
171    pub view_ref: Option<ViewRef>,
172    #[doc(hidden)]
173    pub __source_breaking: fidl::marker::SourceBreaking,
174}
175
176impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
177    for FocuserSetAutoFocusRequest
178{
179}
180
181#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
182pub struct FocuserMarker;
183
184impl fidl::endpoints::ProtocolMarker for FocuserMarker {
185    type Proxy = FocuserProxy;
186    type RequestStream = FocuserRequestStream;
187    #[cfg(target_os = "fuchsia")]
188    type SynchronousProxy = FocuserSynchronousProxy;
189
190    const DEBUG_NAME: &'static str = "(anonymous) Focuser";
191}
192pub type FocuserRequestFocusResult = Result<(), Error>;
193pub type FocuserSetAutoFocusResult = Result<(), AutoFocusError>;
194
195pub trait FocuserProxyInterface: Send + Sync {
196    type RequestFocusResponseFut: std::future::Future<Output = Result<FocuserRequestFocusResult, fidl::Error>>
197        + Send;
198    fn r#request_focus(&self, view_ref: ViewRef) -> Self::RequestFocusResponseFut;
199    type SetAutoFocusResponseFut: std::future::Future<Output = Result<FocuserSetAutoFocusResult, fidl::Error>>
200        + Send;
201    fn r#set_auto_focus(
202        &self,
203        payload: FocuserSetAutoFocusRequest,
204    ) -> Self::SetAutoFocusResponseFut;
205}
206#[derive(Debug)]
207#[cfg(target_os = "fuchsia")]
208pub struct FocuserSynchronousProxy {
209    client: fidl::client::sync::Client,
210}
211
212#[cfg(target_os = "fuchsia")]
213impl fidl::endpoints::SynchronousProxy for FocuserSynchronousProxy {
214    type Proxy = FocuserProxy;
215    type Protocol = FocuserMarker;
216
217    fn from_channel(inner: fidl::Channel) -> Self {
218        Self::new(inner)
219    }
220
221    fn into_channel(self) -> fidl::Channel {
222        self.client.into_channel()
223    }
224
225    fn as_channel(&self) -> &fidl::Channel {
226        self.client.as_channel()
227    }
228}
229
230#[cfg(target_os = "fuchsia")]
231impl FocuserSynchronousProxy {
232    pub fn new(channel: fidl::Channel) -> Self {
233        Self { client: fidl::client::sync::Client::new(channel) }
234    }
235
236    pub fn into_channel(self) -> fidl::Channel {
237        self.client.into_channel()
238    }
239
240    /// Waits until an event arrives and returns it. It is safe for other
241    /// threads to make concurrent requests while waiting for an event.
242    pub fn wait_for_event(
243        &self,
244        deadline: zx::MonotonicInstant,
245    ) -> Result<FocuserEvent, fidl::Error> {
246        FocuserEvent::decode(self.client.wait_for_event::<FocuserMarker>(deadline)?)
247    }
248
249    /// Asks the server to transfer focus to the View specified by `view_ref`,
250    /// with the authority of the requestor ViewRef. Such a request may be
251    /// honored or denied.
252    ///
253    /// If the request was honored, and it triggers a focus change, a FocusEvent
254    /// (with focused=true) is issued to the newly-focused View, and a
255    /// FocusEvent (with focused=false) is issued to the previous View.
256    ///
257    /// The result callback indicates that the request was received and honored.
258    /// It does not guarantee that the requested View actually received a
259    /// FocusEvent in time.
260    ///
261    /// The request may be denied for many reasons, for example:
262    /// - if `view_ref` is invalid
263    /// - if there is no View backed by `view_ref`
264    /// - if there is no requestor ViewRef accessible to Focuser
265    /// - if the requestor ViewRef lacks authority over `view_ref`'s View
266    /// - if `view_ref`'s View is not hittable or may not receive focus
267    /// etc. A denied request is indicated with a Error.
268    pub fn r#request_focus(
269        &self,
270        mut view_ref: ViewRef,
271        ___deadline: zx::MonotonicInstant,
272    ) -> Result<FocuserRequestFocusResult, fidl::Error> {
273        let _response = self.client.send_query::<
274            FocuserRequestFocusRequest,
275            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
276            FocuserMarker,
277        >(
278            (&mut view_ref,),
279            0x559067eb07097d5,
280            fidl::encoding::DynamicFlags::empty(),
281            ___deadline,
282        )?;
283        Ok(_response.map(|x| x))
284    }
285
286    /// Sets the auto focus target to the View specified by `view_ref`.
287    /// To unset the target, pass in an empty table.
288    ///
289    /// If a target has been set, then whenever the caller's View would receive
290    /// focus, an attempt is made to transfer focus immediately to the target
291    /// instead. If the target is unfocusable, the new target is the first
292    /// focusable ancestor of the target instead. Setting an auto focus target
293    /// places no limitations on simultaneous use of RequestFocus().
294    ///
295    /// An auto focus target is "valid" only while it is a descendant of the
296    /// caller's View in the ViewTree. Specifying an invalid auto focus target is
297    /// allowed, since it may become valid later.
298    /// It is the client's responsibility to ensure the target is a valid
299    /// receiver of auto focus.
300    ///
301    /// If the target is invalid when the auto focus behavior would trigger, then
302    /// the attempt to move focus will silently fail and focus will remain with
303    /// the caller's View.
304    /// A target may become invalid and then become valid again any number of
305    /// times; auto focus will continue to function whenever the target is
306    /// in a valid state, and will continue to ignore the target while it's in an
307    /// invalid state.
308    ///
309    /// If the focus would by some further automatic mechanism return to the
310    /// caller's View (e.g. if the target is unfocusable), then focus will
311    /// remain with the caller's View.
312    ///
313    /// AutoFocusError is currently never returned, and is reserved for possible
314    /// future use.
315    pub fn r#set_auto_focus(
316        &self,
317        mut payload: FocuserSetAutoFocusRequest,
318        ___deadline: zx::MonotonicInstant,
319    ) -> Result<FocuserSetAutoFocusResult, fidl::Error> {
320        let _response = self.client.send_query::<
321            FocuserSetAutoFocusRequest,
322            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AutoFocusError>,
323            FocuserMarker,
324        >(
325            &mut payload,
326            0x480feb5856329509,
327            fidl::encoding::DynamicFlags::empty(),
328            ___deadline,
329        )?;
330        Ok(_response.map(|x| x))
331    }
332}
333
334#[cfg(target_os = "fuchsia")]
335impl From<FocuserSynchronousProxy> for zx::NullableHandle {
336    fn from(value: FocuserSynchronousProxy) -> Self {
337        value.into_channel().into()
338    }
339}
340
341#[cfg(target_os = "fuchsia")]
342impl From<fidl::Channel> for FocuserSynchronousProxy {
343    fn from(value: fidl::Channel) -> Self {
344        Self::new(value)
345    }
346}
347
348#[cfg(target_os = "fuchsia")]
349impl fidl::endpoints::FromClient for FocuserSynchronousProxy {
350    type Protocol = FocuserMarker;
351
352    fn from_client(value: fidl::endpoints::ClientEnd<FocuserMarker>) -> Self {
353        Self::new(value.into_channel())
354    }
355}
356
357#[derive(Debug, Clone)]
358pub struct FocuserProxy {
359    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
360}
361
362impl fidl::endpoints::Proxy for FocuserProxy {
363    type Protocol = FocuserMarker;
364
365    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
366        Self::new(inner)
367    }
368
369    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
370        self.client.into_channel().map_err(|client| Self { client })
371    }
372
373    fn as_channel(&self) -> &::fidl::AsyncChannel {
374        self.client.as_channel()
375    }
376}
377
378impl FocuserProxy {
379    /// Create a new Proxy for fuchsia.ui.views/Focuser.
380    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
381        let protocol_name = <FocuserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
382        Self { client: fidl::client::Client::new(channel, protocol_name) }
383    }
384
385    /// Get a Stream of events from the remote end of the protocol.
386    ///
387    /// # Panics
388    ///
389    /// Panics if the event stream was already taken.
390    pub fn take_event_stream(&self) -> FocuserEventStream {
391        FocuserEventStream { event_receiver: self.client.take_event_receiver() }
392    }
393
394    /// Asks the server to transfer focus to the View specified by `view_ref`,
395    /// with the authority of the requestor ViewRef. Such a request may be
396    /// honored or denied.
397    ///
398    /// If the request was honored, and it triggers a focus change, a FocusEvent
399    /// (with focused=true) is issued to the newly-focused View, and a
400    /// FocusEvent (with focused=false) is issued to the previous View.
401    ///
402    /// The result callback indicates that the request was received and honored.
403    /// It does not guarantee that the requested View actually received a
404    /// FocusEvent in time.
405    ///
406    /// The request may be denied for many reasons, for example:
407    /// - if `view_ref` is invalid
408    /// - if there is no View backed by `view_ref`
409    /// - if there is no requestor ViewRef accessible to Focuser
410    /// - if the requestor ViewRef lacks authority over `view_ref`'s View
411    /// - if `view_ref`'s View is not hittable or may not receive focus
412    /// etc. A denied request is indicated with a Error.
413    pub fn r#request_focus(
414        &self,
415        mut view_ref: ViewRef,
416    ) -> fidl::client::QueryResponseFut<
417        FocuserRequestFocusResult,
418        fidl::encoding::DefaultFuchsiaResourceDialect,
419    > {
420        FocuserProxyInterface::r#request_focus(self, view_ref)
421    }
422
423    /// Sets the auto focus target to the View specified by `view_ref`.
424    /// To unset the target, pass in an empty table.
425    ///
426    /// If a target has been set, then whenever the caller's View would receive
427    /// focus, an attempt is made to transfer focus immediately to the target
428    /// instead. If the target is unfocusable, the new target is the first
429    /// focusable ancestor of the target instead. Setting an auto focus target
430    /// places no limitations on simultaneous use of RequestFocus().
431    ///
432    /// An auto focus target is "valid" only while it is a descendant of the
433    /// caller's View in the ViewTree. Specifying an invalid auto focus target is
434    /// allowed, since it may become valid later.
435    /// It is the client's responsibility to ensure the target is a valid
436    /// receiver of auto focus.
437    ///
438    /// If the target is invalid when the auto focus behavior would trigger, then
439    /// the attempt to move focus will silently fail and focus will remain with
440    /// the caller's View.
441    /// A target may become invalid and then become valid again any number of
442    /// times; auto focus will continue to function whenever the target is
443    /// in a valid state, and will continue to ignore the target while it's in an
444    /// invalid state.
445    ///
446    /// If the focus would by some further automatic mechanism return to the
447    /// caller's View (e.g. if the target is unfocusable), then focus will
448    /// remain with the caller's View.
449    ///
450    /// AutoFocusError is currently never returned, and is reserved for possible
451    /// future use.
452    pub fn r#set_auto_focus(
453        &self,
454        mut payload: FocuserSetAutoFocusRequest,
455    ) -> fidl::client::QueryResponseFut<
456        FocuserSetAutoFocusResult,
457        fidl::encoding::DefaultFuchsiaResourceDialect,
458    > {
459        FocuserProxyInterface::r#set_auto_focus(self, payload)
460    }
461}
462
463impl FocuserProxyInterface for FocuserProxy {
464    type RequestFocusResponseFut = fidl::client::QueryResponseFut<
465        FocuserRequestFocusResult,
466        fidl::encoding::DefaultFuchsiaResourceDialect,
467    >;
468    fn r#request_focus(&self, mut view_ref: ViewRef) -> Self::RequestFocusResponseFut {
469        fn _decode(
470            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
471        ) -> Result<FocuserRequestFocusResult, fidl::Error> {
472            let _response = fidl::client::decode_transaction_body::<
473                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>,
474                fidl::encoding::DefaultFuchsiaResourceDialect,
475                0x559067eb07097d5,
476            >(_buf?)?;
477            Ok(_response.map(|x| x))
478        }
479        self.client.send_query_and_decode::<FocuserRequestFocusRequest, FocuserRequestFocusResult>(
480            (&mut view_ref,),
481            0x559067eb07097d5,
482            fidl::encoding::DynamicFlags::empty(),
483            _decode,
484        )
485    }
486
487    type SetAutoFocusResponseFut = fidl::client::QueryResponseFut<
488        FocuserSetAutoFocusResult,
489        fidl::encoding::DefaultFuchsiaResourceDialect,
490    >;
491    fn r#set_auto_focus(
492        &self,
493        mut payload: FocuserSetAutoFocusRequest,
494    ) -> Self::SetAutoFocusResponseFut {
495        fn _decode(
496            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
497        ) -> Result<FocuserSetAutoFocusResult, fidl::Error> {
498            let _response = fidl::client::decode_transaction_body::<
499                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, AutoFocusError>,
500                fidl::encoding::DefaultFuchsiaResourceDialect,
501                0x480feb5856329509,
502            >(_buf?)?;
503            Ok(_response.map(|x| x))
504        }
505        self.client.send_query_and_decode::<FocuserSetAutoFocusRequest, FocuserSetAutoFocusResult>(
506            &mut payload,
507            0x480feb5856329509,
508            fidl::encoding::DynamicFlags::empty(),
509            _decode,
510        )
511    }
512}
513
514pub struct FocuserEventStream {
515    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
516}
517
518impl std::marker::Unpin for FocuserEventStream {}
519
520impl futures::stream::FusedStream for FocuserEventStream {
521    fn is_terminated(&self) -> bool {
522        self.event_receiver.is_terminated()
523    }
524}
525
526impl futures::Stream for FocuserEventStream {
527    type Item = Result<FocuserEvent, fidl::Error>;
528
529    fn poll_next(
530        mut self: std::pin::Pin<&mut Self>,
531        cx: &mut std::task::Context<'_>,
532    ) -> std::task::Poll<Option<Self::Item>> {
533        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
534            &mut self.event_receiver,
535            cx
536        )?) {
537            Some(buf) => std::task::Poll::Ready(Some(FocuserEvent::decode(buf))),
538            None => std::task::Poll::Ready(None),
539        }
540    }
541}
542
543#[derive(Debug)]
544pub enum FocuserEvent {}
545
546impl FocuserEvent {
547    /// Decodes a message buffer as a [`FocuserEvent`].
548    fn decode(
549        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
550    ) -> Result<FocuserEvent, fidl::Error> {
551        let (bytes, _handles) = buf.split_mut();
552        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
553        debug_assert_eq!(tx_header.tx_id, 0);
554        match tx_header.ordinal {
555            _ => Err(fidl::Error::UnknownOrdinal {
556                ordinal: tx_header.ordinal,
557                protocol_name: <FocuserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
558            }),
559        }
560    }
561}
562
563/// A Stream of incoming requests for fuchsia.ui.views/Focuser.
564pub struct FocuserRequestStream {
565    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
566    is_terminated: bool,
567}
568
569impl std::marker::Unpin for FocuserRequestStream {}
570
571impl futures::stream::FusedStream for FocuserRequestStream {
572    fn is_terminated(&self) -> bool {
573        self.is_terminated
574    }
575}
576
577impl fidl::endpoints::RequestStream for FocuserRequestStream {
578    type Protocol = FocuserMarker;
579    type ControlHandle = FocuserControlHandle;
580
581    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
582        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
583    }
584
585    fn control_handle(&self) -> Self::ControlHandle {
586        FocuserControlHandle { inner: self.inner.clone() }
587    }
588
589    fn into_inner(
590        self,
591    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
592    {
593        (self.inner, self.is_terminated)
594    }
595
596    fn from_inner(
597        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
598        is_terminated: bool,
599    ) -> Self {
600        Self { inner, is_terminated }
601    }
602}
603
604impl futures::Stream for FocuserRequestStream {
605    type Item = Result<FocuserRequest, fidl::Error>;
606
607    fn poll_next(
608        mut self: std::pin::Pin<&mut Self>,
609        cx: &mut std::task::Context<'_>,
610    ) -> std::task::Poll<Option<Self::Item>> {
611        let this = &mut *self;
612        if this.inner.check_shutdown(cx) {
613            this.is_terminated = true;
614            return std::task::Poll::Ready(None);
615        }
616        if this.is_terminated {
617            panic!("polled FocuserRequestStream after completion");
618        }
619        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
620            |bytes, handles| {
621                match this.inner.channel().read_etc(cx, bytes, handles) {
622                    std::task::Poll::Ready(Ok(())) => {}
623                    std::task::Poll::Pending => return std::task::Poll::Pending,
624                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
625                        this.is_terminated = true;
626                        return std::task::Poll::Ready(None);
627                    }
628                    std::task::Poll::Ready(Err(e)) => {
629                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
630                            e.into(),
631                        ))));
632                    }
633                }
634
635                // A message has been received from the channel
636                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
637
638                std::task::Poll::Ready(Some(match header.ordinal {
639                    0x559067eb07097d5 => {
640                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
641                        let mut req = fidl::new_empty!(
642                            FocuserRequestFocusRequest,
643                            fidl::encoding::DefaultFuchsiaResourceDialect
644                        );
645                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FocuserRequestFocusRequest>(&header, _body_bytes, handles, &mut req)?;
646                        let control_handle = FocuserControlHandle { inner: this.inner.clone() };
647                        Ok(FocuserRequest::RequestFocus {
648                            view_ref: req.view_ref,
649
650                            responder: FocuserRequestFocusResponder {
651                                control_handle: std::mem::ManuallyDrop::new(control_handle),
652                                tx_id: header.tx_id,
653                            },
654                        })
655                    }
656                    0x480feb5856329509 => {
657                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
658                        let mut req = fidl::new_empty!(
659                            FocuserSetAutoFocusRequest,
660                            fidl::encoding::DefaultFuchsiaResourceDialect
661                        );
662                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FocuserSetAutoFocusRequest>(&header, _body_bytes, handles, &mut req)?;
663                        let control_handle = FocuserControlHandle { inner: this.inner.clone() };
664                        Ok(FocuserRequest::SetAutoFocus {
665                            payload: req,
666                            responder: FocuserSetAutoFocusResponder {
667                                control_handle: std::mem::ManuallyDrop::new(control_handle),
668                                tx_id: header.tx_id,
669                            },
670                        })
671                    }
672                    _ => Err(fidl::Error::UnknownOrdinal {
673                        ordinal: header.ordinal,
674                        protocol_name:
675                            <FocuserMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
676                    }),
677                }))
678            },
679        )
680    }
681}
682
683/// A method of programmatically transferring View focus.
684///
685/// The protocol client has implicit access to a requestor ViewRef, which is
686/// used as the basis for request authority.
687#[derive(Debug)]
688pub enum FocuserRequest {
689    /// Asks the server to transfer focus to the View specified by `view_ref`,
690    /// with the authority of the requestor ViewRef. Such a request may be
691    /// honored or denied.
692    ///
693    /// If the request was honored, and it triggers a focus change, a FocusEvent
694    /// (with focused=true) is issued to the newly-focused View, and a
695    /// FocusEvent (with focused=false) is issued to the previous View.
696    ///
697    /// The result callback indicates that the request was received and honored.
698    /// It does not guarantee that the requested View actually received a
699    /// FocusEvent in time.
700    ///
701    /// The request may be denied for many reasons, for example:
702    /// - if `view_ref` is invalid
703    /// - if there is no View backed by `view_ref`
704    /// - if there is no requestor ViewRef accessible to Focuser
705    /// - if the requestor ViewRef lacks authority over `view_ref`'s View
706    /// - if `view_ref`'s View is not hittable or may not receive focus
707    /// etc. A denied request is indicated with a Error.
708    RequestFocus { view_ref: ViewRef, responder: FocuserRequestFocusResponder },
709    /// Sets the auto focus target to the View specified by `view_ref`.
710    /// To unset the target, pass in an empty table.
711    ///
712    /// If a target has been set, then whenever the caller's View would receive
713    /// focus, an attempt is made to transfer focus immediately to the target
714    /// instead. If the target is unfocusable, the new target is the first
715    /// focusable ancestor of the target instead. Setting an auto focus target
716    /// places no limitations on simultaneous use of RequestFocus().
717    ///
718    /// An auto focus target is "valid" only while it is a descendant of the
719    /// caller's View in the ViewTree. Specifying an invalid auto focus target is
720    /// allowed, since it may become valid later.
721    /// It is the client's responsibility to ensure the target is a valid
722    /// receiver of auto focus.
723    ///
724    /// If the target is invalid when the auto focus behavior would trigger, then
725    /// the attempt to move focus will silently fail and focus will remain with
726    /// the caller's View.
727    /// A target may become invalid and then become valid again any number of
728    /// times; auto focus will continue to function whenever the target is
729    /// in a valid state, and will continue to ignore the target while it's in an
730    /// invalid state.
731    ///
732    /// If the focus would by some further automatic mechanism return to the
733    /// caller's View (e.g. if the target is unfocusable), then focus will
734    /// remain with the caller's View.
735    ///
736    /// AutoFocusError is currently never returned, and is reserved for possible
737    /// future use.
738    SetAutoFocus { payload: FocuserSetAutoFocusRequest, responder: FocuserSetAutoFocusResponder },
739}
740
741impl FocuserRequest {
742    #[allow(irrefutable_let_patterns)]
743    pub fn into_request_focus(self) -> Option<(ViewRef, FocuserRequestFocusResponder)> {
744        if let FocuserRequest::RequestFocus { view_ref, responder } = self {
745            Some((view_ref, responder))
746        } else {
747            None
748        }
749    }
750
751    #[allow(irrefutable_let_patterns)]
752    pub fn into_set_auto_focus(
753        self,
754    ) -> Option<(FocuserSetAutoFocusRequest, FocuserSetAutoFocusResponder)> {
755        if let FocuserRequest::SetAutoFocus { payload, responder } = self {
756            Some((payload, responder))
757        } else {
758            None
759        }
760    }
761
762    /// Name of the method defined in FIDL
763    pub fn method_name(&self) -> &'static str {
764        match *self {
765            FocuserRequest::RequestFocus { .. } => "request_focus",
766            FocuserRequest::SetAutoFocus { .. } => "set_auto_focus",
767        }
768    }
769}
770
771#[derive(Debug, Clone)]
772pub struct FocuserControlHandle {
773    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
774}
775
776impl FocuserControlHandle {
777    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
778        self.inner.shutdown_with_epitaph(status.into())
779    }
780}
781
782impl fidl::endpoints::ControlHandle for FocuserControlHandle {
783    fn shutdown(&self) {
784        self.inner.shutdown()
785    }
786
787    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
788        self.inner.shutdown_with_epitaph(status)
789    }
790
791    fn is_closed(&self) -> bool {
792        self.inner.channel().is_closed()
793    }
794    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
795        self.inner.channel().on_closed()
796    }
797
798    #[cfg(target_os = "fuchsia")]
799    fn signal_peer(
800        &self,
801        clear_mask: zx::Signals,
802        set_mask: zx::Signals,
803    ) -> Result<(), zx_status::Status> {
804        use fidl::Peered;
805        self.inner.channel().signal_peer(clear_mask, set_mask)
806    }
807}
808
809impl FocuserControlHandle {}
810
811#[must_use = "FIDL methods require a response to be sent"]
812#[derive(Debug)]
813pub struct FocuserRequestFocusResponder {
814    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
815    tx_id: u32,
816}
817
818/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
819/// if the responder is dropped without sending a response, so that the client
820/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
821impl std::ops::Drop for FocuserRequestFocusResponder {
822    fn drop(&mut self) {
823        self.control_handle.shutdown();
824        // Safety: drops once, never accessed again
825        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
826    }
827}
828
829impl fidl::endpoints::Responder for FocuserRequestFocusResponder {
830    type ControlHandle = FocuserControlHandle;
831
832    fn control_handle(&self) -> &FocuserControlHandle {
833        &self.control_handle
834    }
835
836    fn drop_without_shutdown(mut self) {
837        // Safety: drops once, never accessed again due to mem::forget
838        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
839        // Prevent Drop from running (which would shut down the channel)
840        std::mem::forget(self);
841    }
842}
843
844impl FocuserRequestFocusResponder {
845    /// Sends a response to the FIDL transaction.
846    ///
847    /// Sets the channel to shutdown if an error occurs.
848    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
849        let _result = self.send_raw(result);
850        if _result.is_err() {
851            self.control_handle.shutdown();
852        }
853        self.drop_without_shutdown();
854        _result
855    }
856
857    /// Similar to "send" but does not shutdown the channel if an error occurs.
858    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
859        let _result = self.send_raw(result);
860        self.drop_without_shutdown();
861        _result
862    }
863
864    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
865        self.control_handle
866            .inner
867            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
868                result,
869                self.tx_id,
870                0x559067eb07097d5,
871                fidl::encoding::DynamicFlags::empty(),
872            )
873    }
874}
875
876#[must_use = "FIDL methods require a response to be sent"]
877#[derive(Debug)]
878pub struct FocuserSetAutoFocusResponder {
879    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
880    tx_id: u32,
881}
882
883/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
884/// if the responder is dropped without sending a response, so that the client
885/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
886impl std::ops::Drop for FocuserSetAutoFocusResponder {
887    fn drop(&mut self) {
888        self.control_handle.shutdown();
889        // Safety: drops once, never accessed again
890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
891    }
892}
893
894impl fidl::endpoints::Responder for FocuserSetAutoFocusResponder {
895    type ControlHandle = FocuserControlHandle;
896
897    fn control_handle(&self) -> &FocuserControlHandle {
898        &self.control_handle
899    }
900
901    fn drop_without_shutdown(mut self) {
902        // Safety: drops once, never accessed again due to mem::forget
903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
904        // Prevent Drop from running (which would shut down the channel)
905        std::mem::forget(self);
906    }
907}
908
909impl FocuserSetAutoFocusResponder {
910    /// Sends a response to the FIDL transaction.
911    ///
912    /// Sets the channel to shutdown if an error occurs.
913    pub fn send(self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
914        let _result = self.send_raw(result);
915        if _result.is_err() {
916            self.control_handle.shutdown();
917        }
918        self.drop_without_shutdown();
919        _result
920    }
921
922    /// Similar to "send" but does not shutdown the channel if an error occurs.
923    pub fn send_no_shutdown_on_err(
924        self,
925        mut result: Result<(), AutoFocusError>,
926    ) -> Result<(), fidl::Error> {
927        let _result = self.send_raw(result);
928        self.drop_without_shutdown();
929        _result
930    }
931
932    fn send_raw(&self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
933        self.control_handle.inner.send::<fidl::encoding::ResultType<
934            fidl::encoding::EmptyStruct,
935            AutoFocusError,
936        >>(
937            result,
938            self.tx_id,
939            0x480feb5856329509,
940            fidl::encoding::DynamicFlags::empty(),
941        )
942    }
943}
944
945#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
946pub struct ViewMarker;
947
948impl fidl::endpoints::ProtocolMarker for ViewMarker {
949    type Proxy = ViewProxy;
950    type RequestStream = ViewRequestStream;
951    #[cfg(target_os = "fuchsia")]
952    type SynchronousProxy = ViewSynchronousProxy;
953
954    const DEBUG_NAME: &'static str = "fuchsia.ui.views.View";
955}
956impl fidl::endpoints::DiscoverableProtocolMarker for ViewMarker {}
957
958pub trait ViewProxyInterface: Send + Sync {
959    fn r#present(&self, view_token: ViewToken) -> Result<(), fidl::Error>;
960}
961#[derive(Debug)]
962#[cfg(target_os = "fuchsia")]
963pub struct ViewSynchronousProxy {
964    client: fidl::client::sync::Client,
965}
966
967#[cfg(target_os = "fuchsia")]
968impl fidl::endpoints::SynchronousProxy for ViewSynchronousProxy {
969    type Proxy = ViewProxy;
970    type Protocol = ViewMarker;
971
972    fn from_channel(inner: fidl::Channel) -> Self {
973        Self::new(inner)
974    }
975
976    fn into_channel(self) -> fidl::Channel {
977        self.client.into_channel()
978    }
979
980    fn as_channel(&self) -> &fidl::Channel {
981        self.client.as_channel()
982    }
983}
984
985#[cfg(target_os = "fuchsia")]
986impl ViewSynchronousProxy {
987    pub fn new(channel: fidl::Channel) -> Self {
988        Self { client: fidl::client::sync::Client::new(channel) }
989    }
990
991    pub fn into_channel(self) -> fidl::Channel {
992        self.client.into_channel()
993    }
994
995    /// Waits until an event arrives and returns it. It is safe for other
996    /// threads to make concurrent requests while waiting for an event.
997    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<ViewEvent, fidl::Error> {
998        ViewEvent::decode(self.client.wait_for_event::<ViewMarker>(deadline)?)
999    }
1000
1001    /// Provides the View with an attachment point to Scenic's scene graph.
1002    ///
1003    /// When `Present()` is called the View's implementation should create a
1004    /// View resource within Scenic by providing it with the `view_token` (using
1005    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1006    ///
1007    /// Then the implementation should attach its graphical content to the
1008    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1009    ///
1010    /// If the implementation already owns a View resource (because `Present()`
1011    /// had already been called before), then it should terminate the connection
1012    /// with an error.
1013    ///
1014    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1015    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1016        self.client.send::<ViewPresentRequest>(
1017            (&mut view_token,),
1018            0x6e98ebc6c9de6d9e,
1019            fidl::encoding::DynamicFlags::empty(),
1020        )
1021    }
1022}
1023
1024#[cfg(target_os = "fuchsia")]
1025impl From<ViewSynchronousProxy> for zx::NullableHandle {
1026    fn from(value: ViewSynchronousProxy) -> Self {
1027        value.into_channel().into()
1028    }
1029}
1030
1031#[cfg(target_os = "fuchsia")]
1032impl From<fidl::Channel> for ViewSynchronousProxy {
1033    fn from(value: fidl::Channel) -> Self {
1034        Self::new(value)
1035    }
1036}
1037
1038#[cfg(target_os = "fuchsia")]
1039impl fidl::endpoints::FromClient for ViewSynchronousProxy {
1040    type Protocol = ViewMarker;
1041
1042    fn from_client(value: fidl::endpoints::ClientEnd<ViewMarker>) -> Self {
1043        Self::new(value.into_channel())
1044    }
1045}
1046
1047#[derive(Debug, Clone)]
1048pub struct ViewProxy {
1049    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1050}
1051
1052impl fidl::endpoints::Proxy for ViewProxy {
1053    type Protocol = ViewMarker;
1054
1055    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1056        Self::new(inner)
1057    }
1058
1059    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1060        self.client.into_channel().map_err(|client| Self { client })
1061    }
1062
1063    fn as_channel(&self) -> &::fidl::AsyncChannel {
1064        self.client.as_channel()
1065    }
1066}
1067
1068impl ViewProxy {
1069    /// Create a new Proxy for fuchsia.ui.views/View.
1070    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1071        let protocol_name = <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1072        Self { client: fidl::client::Client::new(channel, protocol_name) }
1073    }
1074
1075    /// Get a Stream of events from the remote end of the protocol.
1076    ///
1077    /// # Panics
1078    ///
1079    /// Panics if the event stream was already taken.
1080    pub fn take_event_stream(&self) -> ViewEventStream {
1081        ViewEventStream { event_receiver: self.client.take_event_receiver() }
1082    }
1083
1084    /// Provides the View with an attachment point to Scenic's scene graph.
1085    ///
1086    /// When `Present()` is called the View's implementation should create a
1087    /// View resource within Scenic by providing it with the `view_token` (using
1088    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1089    ///
1090    /// Then the implementation should attach its graphical content to the
1091    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1092    ///
1093    /// If the implementation already owns a View resource (because `Present()`
1094    /// had already been called before), then it should terminate the connection
1095    /// with an error.
1096    ///
1097    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1098    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1099        ViewProxyInterface::r#present(self, view_token)
1100    }
1101}
1102
1103impl ViewProxyInterface for ViewProxy {
1104    fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1105        self.client.send::<ViewPresentRequest>(
1106            (&mut view_token,),
1107            0x6e98ebc6c9de6d9e,
1108            fidl::encoding::DynamicFlags::empty(),
1109        )
1110    }
1111}
1112
1113pub struct ViewEventStream {
1114    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1115}
1116
1117impl std::marker::Unpin for ViewEventStream {}
1118
1119impl futures::stream::FusedStream for ViewEventStream {
1120    fn is_terminated(&self) -> bool {
1121        self.event_receiver.is_terminated()
1122    }
1123}
1124
1125impl futures::Stream for ViewEventStream {
1126    type Item = Result<ViewEvent, fidl::Error>;
1127
1128    fn poll_next(
1129        mut self: std::pin::Pin<&mut Self>,
1130        cx: &mut std::task::Context<'_>,
1131    ) -> std::task::Poll<Option<Self::Item>> {
1132        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1133            &mut self.event_receiver,
1134            cx
1135        )?) {
1136            Some(buf) => std::task::Poll::Ready(Some(ViewEvent::decode(buf))),
1137            None => std::task::Poll::Ready(None),
1138        }
1139    }
1140}
1141
1142#[derive(Debug)]
1143pub enum ViewEvent {}
1144
1145impl ViewEvent {
1146    /// Decodes a message buffer as a [`ViewEvent`].
1147    fn decode(
1148        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1149    ) -> Result<ViewEvent, fidl::Error> {
1150        let (bytes, _handles) = buf.split_mut();
1151        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1152        debug_assert_eq!(tx_header.tx_id, 0);
1153        match tx_header.ordinal {
1154            _ => Err(fidl::Error::UnknownOrdinal {
1155                ordinal: tx_header.ordinal,
1156                protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1157            }),
1158        }
1159    }
1160}
1161
1162/// A Stream of incoming requests for fuchsia.ui.views/View.
1163pub struct ViewRequestStream {
1164    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1165    is_terminated: bool,
1166}
1167
1168impl std::marker::Unpin for ViewRequestStream {}
1169
1170impl futures::stream::FusedStream for ViewRequestStream {
1171    fn is_terminated(&self) -> bool {
1172        self.is_terminated
1173    }
1174}
1175
1176impl fidl::endpoints::RequestStream for ViewRequestStream {
1177    type Protocol = ViewMarker;
1178    type ControlHandle = ViewControlHandle;
1179
1180    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1181        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1182    }
1183
1184    fn control_handle(&self) -> Self::ControlHandle {
1185        ViewControlHandle { inner: self.inner.clone() }
1186    }
1187
1188    fn into_inner(
1189        self,
1190    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1191    {
1192        (self.inner, self.is_terminated)
1193    }
1194
1195    fn from_inner(
1196        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1197        is_terminated: bool,
1198    ) -> Self {
1199        Self { inner, is_terminated }
1200    }
1201}
1202
1203impl futures::Stream for ViewRequestStream {
1204    type Item = Result<ViewRequest, fidl::Error>;
1205
1206    fn poll_next(
1207        mut self: std::pin::Pin<&mut Self>,
1208        cx: &mut std::task::Context<'_>,
1209    ) -> std::task::Poll<Option<Self::Item>> {
1210        let this = &mut *self;
1211        if this.inner.check_shutdown(cx) {
1212            this.is_terminated = true;
1213            return std::task::Poll::Ready(None);
1214        }
1215        if this.is_terminated {
1216            panic!("polled ViewRequestStream after completion");
1217        }
1218        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1219            |bytes, handles| {
1220                match this.inner.channel().read_etc(cx, bytes, handles) {
1221                    std::task::Poll::Ready(Ok(())) => {}
1222                    std::task::Poll::Pending => return std::task::Poll::Pending,
1223                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1224                        this.is_terminated = true;
1225                        return std::task::Poll::Ready(None);
1226                    }
1227                    std::task::Poll::Ready(Err(e)) => {
1228                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1229                            e.into(),
1230                        ))));
1231                    }
1232                }
1233
1234                // A message has been received from the channel
1235                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1236
1237                std::task::Poll::Ready(Some(match header.ordinal {
1238                    0x6e98ebc6c9de6d9e => {
1239                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1240                        let mut req = fidl::new_empty!(
1241                            ViewPresentRequest,
1242                            fidl::encoding::DefaultFuchsiaResourceDialect
1243                        );
1244                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewPresentRequest>(&header, _body_bytes, handles, &mut req)?;
1245                        let control_handle = ViewControlHandle { inner: this.inner.clone() };
1246                        Ok(ViewRequest::Present { view_token: req.view_token, control_handle })
1247                    }
1248                    _ => Err(fidl::Error::UnknownOrdinal {
1249                        ordinal: header.ordinal,
1250                        protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1251                    }),
1252                }))
1253            },
1254        )
1255    }
1256}
1257
1258/// Deprecated API for view creation. DO NOT USE.
1259#[derive(Debug)]
1260pub enum ViewRequest {
1261    /// Provides the View with an attachment point to Scenic's scene graph.
1262    ///
1263    /// When `Present()` is called the View's implementation should create a
1264    /// View resource within Scenic by providing it with the `view_token` (using
1265    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1266    ///
1267    /// Then the implementation should attach its graphical content to the
1268    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1269    ///
1270    /// If the implementation already owns a View resource (because `Present()`
1271    /// had already been called before), then it should terminate the connection
1272    /// with an error.
1273    ///
1274    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1275    Present { view_token: ViewToken, control_handle: ViewControlHandle },
1276}
1277
1278impl ViewRequest {
1279    #[allow(irrefutable_let_patterns)]
1280    pub fn into_present(self) -> Option<(ViewToken, ViewControlHandle)> {
1281        if let ViewRequest::Present { view_token, control_handle } = self {
1282            Some((view_token, control_handle))
1283        } else {
1284            None
1285        }
1286    }
1287
1288    /// Name of the method defined in FIDL
1289    pub fn method_name(&self) -> &'static str {
1290        match *self {
1291            ViewRequest::Present { .. } => "present",
1292        }
1293    }
1294}
1295
1296#[derive(Debug, Clone)]
1297pub struct ViewControlHandle {
1298    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1299}
1300
1301impl ViewControlHandle {
1302    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1303        self.inner.shutdown_with_epitaph(status.into())
1304    }
1305}
1306
1307impl fidl::endpoints::ControlHandle for ViewControlHandle {
1308    fn shutdown(&self) {
1309        self.inner.shutdown()
1310    }
1311
1312    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1313        self.inner.shutdown_with_epitaph(status)
1314    }
1315
1316    fn is_closed(&self) -> bool {
1317        self.inner.channel().is_closed()
1318    }
1319    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1320        self.inner.channel().on_closed()
1321    }
1322
1323    #[cfg(target_os = "fuchsia")]
1324    fn signal_peer(
1325        &self,
1326        clear_mask: zx::Signals,
1327        set_mask: zx::Signals,
1328    ) -> Result<(), zx_status::Status> {
1329        use fidl::Peered;
1330        self.inner.channel().signal_peer(clear_mask, set_mask)
1331    }
1332}
1333
1334impl ViewControlHandle {}
1335
1336#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1337pub struct ViewRefFocusedMarker;
1338
1339impl fidl::endpoints::ProtocolMarker for ViewRefFocusedMarker {
1340    type Proxy = ViewRefFocusedProxy;
1341    type RequestStream = ViewRefFocusedRequestStream;
1342    #[cfg(target_os = "fuchsia")]
1343    type SynchronousProxy = ViewRefFocusedSynchronousProxy;
1344
1345    const DEBUG_NAME: &'static str = "(anonymous) ViewRefFocused";
1346}
1347
1348pub trait ViewRefFocusedProxyInterface: Send + Sync {
1349    type WatchResponseFut: std::future::Future<Output = Result<FocusState, fidl::Error>> + Send;
1350    fn r#watch(&self) -> Self::WatchResponseFut;
1351}
1352#[derive(Debug)]
1353#[cfg(target_os = "fuchsia")]
1354pub struct ViewRefFocusedSynchronousProxy {
1355    client: fidl::client::sync::Client,
1356}
1357
1358#[cfg(target_os = "fuchsia")]
1359impl fidl::endpoints::SynchronousProxy for ViewRefFocusedSynchronousProxy {
1360    type Proxy = ViewRefFocusedProxy;
1361    type Protocol = ViewRefFocusedMarker;
1362
1363    fn from_channel(inner: fidl::Channel) -> Self {
1364        Self::new(inner)
1365    }
1366
1367    fn into_channel(self) -> fidl::Channel {
1368        self.client.into_channel()
1369    }
1370
1371    fn as_channel(&self) -> &fidl::Channel {
1372        self.client.as_channel()
1373    }
1374}
1375
1376#[cfg(target_os = "fuchsia")]
1377impl ViewRefFocusedSynchronousProxy {
1378    pub fn new(channel: fidl::Channel) -> Self {
1379        Self { client: fidl::client::sync::Client::new(channel) }
1380    }
1381
1382    pub fn into_channel(self) -> fidl::Channel {
1383        self.client.into_channel()
1384    }
1385
1386    /// Waits until an event arrives and returns it. It is safe for other
1387    /// threads to make concurrent requests while waiting for an event.
1388    pub fn wait_for_event(
1389        &self,
1390        deadline: zx::MonotonicInstant,
1391    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1392        ViewRefFocusedEvent::decode(self.client.wait_for_event::<ViewRefFocusedMarker>(deadline)?)
1393    }
1394
1395    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1396    /// focus. Typically, focus changes happen at a slow pace, such that every
1397    /// transition is captured by the callback. However, focus changes can
1398    /// happen rapidly, so the callback may "compress" focus change history into
1399    /// just the latest known focus state.
1400    ///
1401    /// The callback reports the last focus change spanning the duration from
1402    /// its issuance to the previous callback's issuance. The client may observe
1403    /// any of the following four transitions:
1404    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1405    ///   focus by the time of callback issuance.
1406    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1407    ///   focus by the time of callback issuance.
1408    /// - false -> true: The ViewRef has gained focus at least once, and has
1409    ///   gained focus by the time of callback issuance.
1410    /// - false -> false: The ViewRef has gained focus at least once, and has
1411    ///   lost focus by the time of callback issuance.
1412    ///
1413    /// The client avoids "focus flapping" and always sees the latest state.
1414    /// Every callback issuance is meaningful, and the client should renegotiate
1415    /// focus-related services appropriately, such as IME.
1416    ///
1417    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1418    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1419    /// returns. Non-compliance results in channel closure.
1420    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<FocusState, fidl::Error> {
1421        let _response = self.client.send_query::<
1422            fidl::encoding::EmptyPayload,
1423            ViewRefFocusedWatchResponse,
1424            ViewRefFocusedMarker,
1425        >(
1426            (),
1427            0x3c5e51096d9299b5,
1428            fidl::encoding::DynamicFlags::empty(),
1429            ___deadline,
1430        )?;
1431        Ok(_response.state)
1432    }
1433}
1434
1435#[cfg(target_os = "fuchsia")]
1436impl From<ViewRefFocusedSynchronousProxy> for zx::NullableHandle {
1437    fn from(value: ViewRefFocusedSynchronousProxy) -> Self {
1438        value.into_channel().into()
1439    }
1440}
1441
1442#[cfg(target_os = "fuchsia")]
1443impl From<fidl::Channel> for ViewRefFocusedSynchronousProxy {
1444    fn from(value: fidl::Channel) -> Self {
1445        Self::new(value)
1446    }
1447}
1448
1449#[cfg(target_os = "fuchsia")]
1450impl fidl::endpoints::FromClient for ViewRefFocusedSynchronousProxy {
1451    type Protocol = ViewRefFocusedMarker;
1452
1453    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefFocusedMarker>) -> Self {
1454        Self::new(value.into_channel())
1455    }
1456}
1457
1458#[derive(Debug, Clone)]
1459pub struct ViewRefFocusedProxy {
1460    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1461}
1462
1463impl fidl::endpoints::Proxy for ViewRefFocusedProxy {
1464    type Protocol = ViewRefFocusedMarker;
1465
1466    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1467        Self::new(inner)
1468    }
1469
1470    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1471        self.client.into_channel().map_err(|client| Self { client })
1472    }
1473
1474    fn as_channel(&self) -> &::fidl::AsyncChannel {
1475        self.client.as_channel()
1476    }
1477}
1478
1479impl ViewRefFocusedProxy {
1480    /// Create a new Proxy for fuchsia.ui.views/ViewRefFocused.
1481    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1482        let protocol_name = <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1483        Self { client: fidl::client::Client::new(channel, protocol_name) }
1484    }
1485
1486    /// Get a Stream of events from the remote end of the protocol.
1487    ///
1488    /// # Panics
1489    ///
1490    /// Panics if the event stream was already taken.
1491    pub fn take_event_stream(&self) -> ViewRefFocusedEventStream {
1492        ViewRefFocusedEventStream { event_receiver: self.client.take_event_receiver() }
1493    }
1494
1495    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1496    /// focus. Typically, focus changes happen at a slow pace, such that every
1497    /// transition is captured by the callback. However, focus changes can
1498    /// happen rapidly, so the callback may "compress" focus change history into
1499    /// just the latest known focus state.
1500    ///
1501    /// The callback reports the last focus change spanning the duration from
1502    /// its issuance to the previous callback's issuance. The client may observe
1503    /// any of the following four transitions:
1504    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1505    ///   focus by the time of callback issuance.
1506    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1507    ///   focus by the time of callback issuance.
1508    /// - false -> true: The ViewRef has gained focus at least once, and has
1509    ///   gained focus by the time of callback issuance.
1510    /// - false -> false: The ViewRef has gained focus at least once, and has
1511    ///   lost focus by the time of callback issuance.
1512    ///
1513    /// The client avoids "focus flapping" and always sees the latest state.
1514    /// Every callback issuance is meaningful, and the client should renegotiate
1515    /// focus-related services appropriately, such as IME.
1516    ///
1517    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1518    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1519    /// returns. Non-compliance results in channel closure.
1520    pub fn r#watch(
1521        &self,
1522    ) -> fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>
1523    {
1524        ViewRefFocusedProxyInterface::r#watch(self)
1525    }
1526}
1527
1528impl ViewRefFocusedProxyInterface for ViewRefFocusedProxy {
1529    type WatchResponseFut =
1530        fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>;
1531    fn r#watch(&self) -> Self::WatchResponseFut {
1532        fn _decode(
1533            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1534        ) -> Result<FocusState, fidl::Error> {
1535            let _response = fidl::client::decode_transaction_body::<
1536                ViewRefFocusedWatchResponse,
1537                fidl::encoding::DefaultFuchsiaResourceDialect,
1538                0x3c5e51096d9299b5,
1539            >(_buf?)?;
1540            Ok(_response.state)
1541        }
1542        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, FocusState>(
1543            (),
1544            0x3c5e51096d9299b5,
1545            fidl::encoding::DynamicFlags::empty(),
1546            _decode,
1547        )
1548    }
1549}
1550
1551pub struct ViewRefFocusedEventStream {
1552    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1553}
1554
1555impl std::marker::Unpin for ViewRefFocusedEventStream {}
1556
1557impl futures::stream::FusedStream for ViewRefFocusedEventStream {
1558    fn is_terminated(&self) -> bool {
1559        self.event_receiver.is_terminated()
1560    }
1561}
1562
1563impl futures::Stream for ViewRefFocusedEventStream {
1564    type Item = Result<ViewRefFocusedEvent, fidl::Error>;
1565
1566    fn poll_next(
1567        mut self: std::pin::Pin<&mut Self>,
1568        cx: &mut std::task::Context<'_>,
1569    ) -> std::task::Poll<Option<Self::Item>> {
1570        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1571            &mut self.event_receiver,
1572            cx
1573        )?) {
1574            Some(buf) => std::task::Poll::Ready(Some(ViewRefFocusedEvent::decode(buf))),
1575            None => std::task::Poll::Ready(None),
1576        }
1577    }
1578}
1579
1580#[derive(Debug)]
1581pub enum ViewRefFocusedEvent {}
1582
1583impl ViewRefFocusedEvent {
1584    /// Decodes a message buffer as a [`ViewRefFocusedEvent`].
1585    fn decode(
1586        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1587    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1588        let (bytes, _handles) = buf.split_mut();
1589        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1590        debug_assert_eq!(tx_header.tx_id, 0);
1591        match tx_header.ordinal {
1592            _ => Err(fidl::Error::UnknownOrdinal {
1593                ordinal: tx_header.ordinal,
1594                protocol_name:
1595                    <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1596            }),
1597        }
1598    }
1599}
1600
1601/// A Stream of incoming requests for fuchsia.ui.views/ViewRefFocused.
1602pub struct ViewRefFocusedRequestStream {
1603    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1604    is_terminated: bool,
1605}
1606
1607impl std::marker::Unpin for ViewRefFocusedRequestStream {}
1608
1609impl futures::stream::FusedStream for ViewRefFocusedRequestStream {
1610    fn is_terminated(&self) -> bool {
1611        self.is_terminated
1612    }
1613}
1614
1615impl fidl::endpoints::RequestStream for ViewRefFocusedRequestStream {
1616    type Protocol = ViewRefFocusedMarker;
1617    type ControlHandle = ViewRefFocusedControlHandle;
1618
1619    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1620        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1621    }
1622
1623    fn control_handle(&self) -> Self::ControlHandle {
1624        ViewRefFocusedControlHandle { inner: self.inner.clone() }
1625    }
1626
1627    fn into_inner(
1628        self,
1629    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1630    {
1631        (self.inner, self.is_terminated)
1632    }
1633
1634    fn from_inner(
1635        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1636        is_terminated: bool,
1637    ) -> Self {
1638        Self { inner, is_terminated }
1639    }
1640}
1641
1642impl futures::Stream for ViewRefFocusedRequestStream {
1643    type Item = Result<ViewRefFocusedRequest, fidl::Error>;
1644
1645    fn poll_next(
1646        mut self: std::pin::Pin<&mut Self>,
1647        cx: &mut std::task::Context<'_>,
1648    ) -> std::task::Poll<Option<Self::Item>> {
1649        let this = &mut *self;
1650        if this.inner.check_shutdown(cx) {
1651            this.is_terminated = true;
1652            return std::task::Poll::Ready(None);
1653        }
1654        if this.is_terminated {
1655            panic!("polled ViewRefFocusedRequestStream after completion");
1656        }
1657        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1658            |bytes, handles| {
1659                match this.inner.channel().read_etc(cx, bytes, handles) {
1660                    std::task::Poll::Ready(Ok(())) => {}
1661                    std::task::Poll::Pending => return std::task::Poll::Pending,
1662                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1663                        this.is_terminated = true;
1664                        return std::task::Poll::Ready(None);
1665                    }
1666                    std::task::Poll::Ready(Err(e)) => {
1667                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1668                            e.into(),
1669                        ))));
1670                    }
1671                }
1672
1673                // A message has been received from the channel
1674                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1675
1676                std::task::Poll::Ready(Some(match header.ordinal {
1677                    0x3c5e51096d9299b5 => {
1678                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1679                        let mut req = fidl::new_empty!(
1680                            fidl::encoding::EmptyPayload,
1681                            fidl::encoding::DefaultFuchsiaResourceDialect
1682                        );
1683                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1684                        let control_handle =
1685                            ViewRefFocusedControlHandle { inner: this.inner.clone() };
1686                        Ok(ViewRefFocusedRequest::Watch {
1687                            responder: ViewRefFocusedWatchResponder {
1688                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1689                                tx_id: header.tx_id,
1690                            },
1691                        })
1692                    }
1693                    _ => Err(fidl::Error::UnknownOrdinal {
1694                        ordinal: header.ordinal,
1695                        protocol_name:
1696                            <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1697                    }),
1698                }))
1699            },
1700        )
1701    }
1702}
1703
1704/// A method of enabling a ViewRef creator to determine if its ViewRef has
1705/// gained or lost focus in the view tree.
1706///
1707/// The protocol client has implicit access to the ViewRef it created; the
1708/// protocol itself does not accept a ViewRef parameter. Clients, both trusted
1709/// or otherwise, need access to view-focus state, so the protocol is
1710/// deliberately minimal. Possession of a ViewRef (and this protocol) does not
1711/// grant the power to learn about a ViewRef's focus state.
1712#[derive(Debug)]
1713pub enum ViewRefFocusedRequest {
1714    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1715    /// focus. Typically, focus changes happen at a slow pace, such that every
1716    /// transition is captured by the callback. However, focus changes can
1717    /// happen rapidly, so the callback may "compress" focus change history into
1718    /// just the latest known focus state.
1719    ///
1720    /// The callback reports the last focus change spanning the duration from
1721    /// its issuance to the previous callback's issuance. The client may observe
1722    /// any of the following four transitions:
1723    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1724    ///   focus by the time of callback issuance.
1725    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1726    ///   focus by the time of callback issuance.
1727    /// - false -> true: The ViewRef has gained focus at least once, and has
1728    ///   gained focus by the time of callback issuance.
1729    /// - false -> false: The ViewRef has gained focus at least once, and has
1730    ///   lost focus by the time of callback issuance.
1731    ///
1732    /// The client avoids "focus flapping" and always sees the latest state.
1733    /// Every callback issuance is meaningful, and the client should renegotiate
1734    /// focus-related services appropriately, such as IME.
1735    ///
1736    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1737    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1738    /// returns. Non-compliance results in channel closure.
1739    Watch { responder: ViewRefFocusedWatchResponder },
1740}
1741
1742impl ViewRefFocusedRequest {
1743    #[allow(irrefutable_let_patterns)]
1744    pub fn into_watch(self) -> Option<(ViewRefFocusedWatchResponder)> {
1745        if let ViewRefFocusedRequest::Watch { responder } = self { Some((responder)) } else { None }
1746    }
1747
1748    /// Name of the method defined in FIDL
1749    pub fn method_name(&self) -> &'static str {
1750        match *self {
1751            ViewRefFocusedRequest::Watch { .. } => "watch",
1752        }
1753    }
1754}
1755
1756#[derive(Debug, Clone)]
1757pub struct ViewRefFocusedControlHandle {
1758    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1759}
1760
1761impl ViewRefFocusedControlHandle {
1762    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1763        self.inner.shutdown_with_epitaph(status.into())
1764    }
1765}
1766
1767impl fidl::endpoints::ControlHandle for ViewRefFocusedControlHandle {
1768    fn shutdown(&self) {
1769        self.inner.shutdown()
1770    }
1771
1772    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1773        self.inner.shutdown_with_epitaph(status)
1774    }
1775
1776    fn is_closed(&self) -> bool {
1777        self.inner.channel().is_closed()
1778    }
1779    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1780        self.inner.channel().on_closed()
1781    }
1782
1783    #[cfg(target_os = "fuchsia")]
1784    fn signal_peer(
1785        &self,
1786        clear_mask: zx::Signals,
1787        set_mask: zx::Signals,
1788    ) -> Result<(), zx_status::Status> {
1789        use fidl::Peered;
1790        self.inner.channel().signal_peer(clear_mask, set_mask)
1791    }
1792}
1793
1794impl ViewRefFocusedControlHandle {}
1795
1796#[must_use = "FIDL methods require a response to be sent"]
1797#[derive(Debug)]
1798pub struct ViewRefFocusedWatchResponder {
1799    control_handle: std::mem::ManuallyDrop<ViewRefFocusedControlHandle>,
1800    tx_id: u32,
1801}
1802
1803/// Set the the channel to be shutdown (see [`ViewRefFocusedControlHandle::shutdown`])
1804/// if the responder is dropped without sending a response, so that the client
1805/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1806impl std::ops::Drop for ViewRefFocusedWatchResponder {
1807    fn drop(&mut self) {
1808        self.control_handle.shutdown();
1809        // Safety: drops once, never accessed again
1810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1811    }
1812}
1813
1814impl fidl::endpoints::Responder for ViewRefFocusedWatchResponder {
1815    type ControlHandle = ViewRefFocusedControlHandle;
1816
1817    fn control_handle(&self) -> &ViewRefFocusedControlHandle {
1818        &self.control_handle
1819    }
1820
1821    fn drop_without_shutdown(mut self) {
1822        // Safety: drops once, never accessed again due to mem::forget
1823        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1824        // Prevent Drop from running (which would shut down the channel)
1825        std::mem::forget(self);
1826    }
1827}
1828
1829impl ViewRefFocusedWatchResponder {
1830    /// Sends a response to the FIDL transaction.
1831    ///
1832    /// Sets the channel to shutdown if an error occurs.
1833    pub fn send(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1834        let _result = self.send_raw(state);
1835        if _result.is_err() {
1836            self.control_handle.shutdown();
1837        }
1838        self.drop_without_shutdown();
1839        _result
1840    }
1841
1842    /// Similar to "send" but does not shutdown the channel if an error occurs.
1843    pub fn send_no_shutdown_on_err(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1844        let _result = self.send_raw(state);
1845        self.drop_without_shutdown();
1846        _result
1847    }
1848
1849    fn send_raw(&self, mut state: &FocusState) -> Result<(), fidl::Error> {
1850        self.control_handle.inner.send::<ViewRefFocusedWatchResponse>(
1851            (state,),
1852            self.tx_id,
1853            0x3c5e51096d9299b5,
1854            fidl::encoding::DynamicFlags::empty(),
1855        )
1856    }
1857}
1858
1859#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1860pub struct ViewRefInstalledMarker;
1861
1862impl fidl::endpoints::ProtocolMarker for ViewRefInstalledMarker {
1863    type Proxy = ViewRefInstalledProxy;
1864    type RequestStream = ViewRefInstalledRequestStream;
1865    #[cfg(target_os = "fuchsia")]
1866    type SynchronousProxy = ViewRefInstalledSynchronousProxy;
1867
1868    const DEBUG_NAME: &'static str = "fuchsia.ui.views.ViewRefInstalled";
1869}
1870impl fidl::endpoints::DiscoverableProtocolMarker for ViewRefInstalledMarker {}
1871pub type ViewRefInstalledWatchResult = Result<(), ViewRefInstalledError>;
1872
1873pub trait ViewRefInstalledProxyInterface: Send + Sync {
1874    type WatchResponseFut: std::future::Future<Output = Result<ViewRefInstalledWatchResult, fidl::Error>>
1875        + Send;
1876    fn r#watch(&self, view_ref: ViewRef) -> Self::WatchResponseFut;
1877}
1878#[derive(Debug)]
1879#[cfg(target_os = "fuchsia")]
1880pub struct ViewRefInstalledSynchronousProxy {
1881    client: fidl::client::sync::Client,
1882}
1883
1884#[cfg(target_os = "fuchsia")]
1885impl fidl::endpoints::SynchronousProxy for ViewRefInstalledSynchronousProxy {
1886    type Proxy = ViewRefInstalledProxy;
1887    type Protocol = ViewRefInstalledMarker;
1888
1889    fn from_channel(inner: fidl::Channel) -> Self {
1890        Self::new(inner)
1891    }
1892
1893    fn into_channel(self) -> fidl::Channel {
1894        self.client.into_channel()
1895    }
1896
1897    fn as_channel(&self) -> &fidl::Channel {
1898        self.client.as_channel()
1899    }
1900}
1901
1902#[cfg(target_os = "fuchsia")]
1903impl ViewRefInstalledSynchronousProxy {
1904    pub fn new(channel: fidl::Channel) -> Self {
1905        Self { client: fidl::client::sync::Client::new(channel) }
1906    }
1907
1908    pub fn into_channel(self) -> fidl::Channel {
1909        self.client.into_channel()
1910    }
1911
1912    /// Waits until an event arrives and returns it. It is safe for other
1913    /// threads to make concurrent requests while waiting for an event.
1914    pub fn wait_for_event(
1915        &self,
1916        deadline: zx::MonotonicInstant,
1917    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
1918        ViewRefInstalledEvent::decode(
1919            self.client.wait_for_event::<ViewRefInstalledMarker>(deadline)?,
1920        )
1921    }
1922
1923    /// Sets up a callback to fire when the requested |view_ref| is installed.
1924    /// - If |view_ref| has not already been installed, the |Watch| response
1925    ///   will fire when it is.
1926    /// - If |view_ref| has already been installed, the |Watch| response will
1927    ///   fire immediately.
1928    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
1929    ///   was destroyed), the |Watch| call returns with an error.  The error is
1930    ///   not guaranteed to be immediate, but a ViewRef holder can itself
1931    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
1932    ///
1933    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
1934    /// ViewRefs. There is at most one response per call back to the client.
1935    ///
1936    /// Note: Prior to installation, this |Watch| call is kept alive as long as
1937    ///       the ViewRef is valid.
1938    pub fn r#watch(
1939        &self,
1940        mut view_ref: ViewRef,
1941        ___deadline: zx::MonotonicInstant,
1942    ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
1943        let _response =
1944            self.client.send_query::<ViewRefInstalledWatchRequest, fidl::encoding::ResultType<
1945                fidl::encoding::EmptyStruct,
1946                ViewRefInstalledError,
1947            >, ViewRefInstalledMarker>(
1948                (&mut view_ref,),
1949                0x7ddec2f4ca687971,
1950                fidl::encoding::DynamicFlags::empty(),
1951                ___deadline,
1952            )?;
1953        Ok(_response.map(|x| x))
1954    }
1955}
1956
1957#[cfg(target_os = "fuchsia")]
1958impl From<ViewRefInstalledSynchronousProxy> for zx::NullableHandle {
1959    fn from(value: ViewRefInstalledSynchronousProxy) -> Self {
1960        value.into_channel().into()
1961    }
1962}
1963
1964#[cfg(target_os = "fuchsia")]
1965impl From<fidl::Channel> for ViewRefInstalledSynchronousProxy {
1966    fn from(value: fidl::Channel) -> Self {
1967        Self::new(value)
1968    }
1969}
1970
1971#[cfg(target_os = "fuchsia")]
1972impl fidl::endpoints::FromClient for ViewRefInstalledSynchronousProxy {
1973    type Protocol = ViewRefInstalledMarker;
1974
1975    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefInstalledMarker>) -> Self {
1976        Self::new(value.into_channel())
1977    }
1978}
1979
1980#[derive(Debug, Clone)]
1981pub struct ViewRefInstalledProxy {
1982    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1983}
1984
1985impl fidl::endpoints::Proxy for ViewRefInstalledProxy {
1986    type Protocol = ViewRefInstalledMarker;
1987
1988    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1989        Self::new(inner)
1990    }
1991
1992    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1993        self.client.into_channel().map_err(|client| Self { client })
1994    }
1995
1996    fn as_channel(&self) -> &::fidl::AsyncChannel {
1997        self.client.as_channel()
1998    }
1999}
2000
2001impl ViewRefInstalledProxy {
2002    /// Create a new Proxy for fuchsia.ui.views/ViewRefInstalled.
2003    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2004        let protocol_name = <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2005        Self { client: fidl::client::Client::new(channel, protocol_name) }
2006    }
2007
2008    /// Get a Stream of events from the remote end of the protocol.
2009    ///
2010    /// # Panics
2011    ///
2012    /// Panics if the event stream was already taken.
2013    pub fn take_event_stream(&self) -> ViewRefInstalledEventStream {
2014        ViewRefInstalledEventStream { event_receiver: self.client.take_event_receiver() }
2015    }
2016
2017    /// Sets up a callback to fire when the requested |view_ref| is installed.
2018    /// - If |view_ref| has not already been installed, the |Watch| response
2019    ///   will fire when it is.
2020    /// - If |view_ref| has already been installed, the |Watch| response will
2021    ///   fire immediately.
2022    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2023    ///   was destroyed), the |Watch| call returns with an error.  The error is
2024    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2025    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2026    ///
2027    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2028    /// ViewRefs. There is at most one response per call back to the client.
2029    ///
2030    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2031    ///       the ViewRef is valid.
2032    pub fn r#watch(
2033        &self,
2034        mut view_ref: ViewRef,
2035    ) -> fidl::client::QueryResponseFut<
2036        ViewRefInstalledWatchResult,
2037        fidl::encoding::DefaultFuchsiaResourceDialect,
2038    > {
2039        ViewRefInstalledProxyInterface::r#watch(self, view_ref)
2040    }
2041}
2042
2043impl ViewRefInstalledProxyInterface for ViewRefInstalledProxy {
2044    type WatchResponseFut = fidl::client::QueryResponseFut<
2045        ViewRefInstalledWatchResult,
2046        fidl::encoding::DefaultFuchsiaResourceDialect,
2047    >;
2048    fn r#watch(&self, mut view_ref: ViewRef) -> Self::WatchResponseFut {
2049        fn _decode(
2050            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2051        ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
2052            let _response = fidl::client::decode_transaction_body::<
2053                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ViewRefInstalledError>,
2054                fidl::encoding::DefaultFuchsiaResourceDialect,
2055                0x7ddec2f4ca687971,
2056            >(_buf?)?;
2057            Ok(_response.map(|x| x))
2058        }
2059        self.client
2060            .send_query_and_decode::<ViewRefInstalledWatchRequest, ViewRefInstalledWatchResult>(
2061                (&mut view_ref,),
2062                0x7ddec2f4ca687971,
2063                fidl::encoding::DynamicFlags::empty(),
2064                _decode,
2065            )
2066    }
2067}
2068
2069pub struct ViewRefInstalledEventStream {
2070    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2071}
2072
2073impl std::marker::Unpin for ViewRefInstalledEventStream {}
2074
2075impl futures::stream::FusedStream for ViewRefInstalledEventStream {
2076    fn is_terminated(&self) -> bool {
2077        self.event_receiver.is_terminated()
2078    }
2079}
2080
2081impl futures::Stream for ViewRefInstalledEventStream {
2082    type Item = Result<ViewRefInstalledEvent, fidl::Error>;
2083
2084    fn poll_next(
2085        mut self: std::pin::Pin<&mut Self>,
2086        cx: &mut std::task::Context<'_>,
2087    ) -> std::task::Poll<Option<Self::Item>> {
2088        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2089            &mut self.event_receiver,
2090            cx
2091        )?) {
2092            Some(buf) => std::task::Poll::Ready(Some(ViewRefInstalledEvent::decode(buf))),
2093            None => std::task::Poll::Ready(None),
2094        }
2095    }
2096}
2097
2098#[derive(Debug)]
2099pub enum ViewRefInstalledEvent {}
2100
2101impl ViewRefInstalledEvent {
2102    /// Decodes a message buffer as a [`ViewRefInstalledEvent`].
2103    fn decode(
2104        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2105    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
2106        let (bytes, _handles) = buf.split_mut();
2107        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2108        debug_assert_eq!(tx_header.tx_id, 0);
2109        match tx_header.ordinal {
2110            _ => Err(fidl::Error::UnknownOrdinal {
2111                ordinal: tx_header.ordinal,
2112                protocol_name:
2113                    <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2114            }),
2115        }
2116    }
2117}
2118
2119/// A Stream of incoming requests for fuchsia.ui.views/ViewRefInstalled.
2120pub struct ViewRefInstalledRequestStream {
2121    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2122    is_terminated: bool,
2123}
2124
2125impl std::marker::Unpin for ViewRefInstalledRequestStream {}
2126
2127impl futures::stream::FusedStream for ViewRefInstalledRequestStream {
2128    fn is_terminated(&self) -> bool {
2129        self.is_terminated
2130    }
2131}
2132
2133impl fidl::endpoints::RequestStream for ViewRefInstalledRequestStream {
2134    type Protocol = ViewRefInstalledMarker;
2135    type ControlHandle = ViewRefInstalledControlHandle;
2136
2137    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2138        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2139    }
2140
2141    fn control_handle(&self) -> Self::ControlHandle {
2142        ViewRefInstalledControlHandle { inner: self.inner.clone() }
2143    }
2144
2145    fn into_inner(
2146        self,
2147    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2148    {
2149        (self.inner, self.is_terminated)
2150    }
2151
2152    fn from_inner(
2153        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2154        is_terminated: bool,
2155    ) -> Self {
2156        Self { inner, is_terminated }
2157    }
2158}
2159
2160impl futures::Stream for ViewRefInstalledRequestStream {
2161    type Item = Result<ViewRefInstalledRequest, fidl::Error>;
2162
2163    fn poll_next(
2164        mut self: std::pin::Pin<&mut Self>,
2165        cx: &mut std::task::Context<'_>,
2166    ) -> std::task::Poll<Option<Self::Item>> {
2167        let this = &mut *self;
2168        if this.inner.check_shutdown(cx) {
2169            this.is_terminated = true;
2170            return std::task::Poll::Ready(None);
2171        }
2172        if this.is_terminated {
2173            panic!("polled ViewRefInstalledRequestStream after completion");
2174        }
2175        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2176            |bytes, handles| {
2177                match this.inner.channel().read_etc(cx, bytes, handles) {
2178                    std::task::Poll::Ready(Ok(())) => {}
2179                    std::task::Poll::Pending => return std::task::Poll::Pending,
2180                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2181                        this.is_terminated = true;
2182                        return std::task::Poll::Ready(None);
2183                    }
2184                    std::task::Poll::Ready(Err(e)) => {
2185                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2186                            e.into(),
2187                        ))));
2188                    }
2189                }
2190
2191                // A message has been received from the channel
2192                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2193
2194                std::task::Poll::Ready(Some(match header.ordinal {
2195                    0x7ddec2f4ca687971 => {
2196                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2197                        let mut req = fidl::new_empty!(
2198                            ViewRefInstalledWatchRequest,
2199                            fidl::encoding::DefaultFuchsiaResourceDialect
2200                        );
2201                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewRefInstalledWatchRequest>(&header, _body_bytes, handles, &mut req)?;
2202                        let control_handle =
2203                            ViewRefInstalledControlHandle { inner: this.inner.clone() };
2204                        Ok(ViewRefInstalledRequest::Watch {
2205                            view_ref: req.view_ref,
2206
2207                            responder: ViewRefInstalledWatchResponder {
2208                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2209                                tx_id: header.tx_id,
2210                            },
2211                        })
2212                    }
2213                    _ => Err(fidl::Error::UnknownOrdinal {
2214                        ordinal: header.ordinal,
2215                        protocol_name:
2216                            <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2217                    }),
2218                }))
2219            },
2220        )
2221    }
2222}
2223
2224/// A method of enabling ViewRef holders to determine if a ViewRef has been
2225/// "installed" in the view tree: the time it is first connected, transitively,
2226/// to the root view.  Typically, after installation, view focus may be
2227/// transferred to that ViewRef.
2228///
2229/// Note: It's important to distinguish between a ViewRef's installed status and
2230///       current connected-to-view-tree status.  The former undergoes a state
2231///       change once, from "no" to "yes".  The latter may change continuously,
2232///       depending on view tree topology.  As such, "installed" cannot imply
2233///       "currently connected to view tree"; even a hypothetical
2234///       "ViewRefConnected" protocol is fundamentally racy.
2235#[derive(Debug)]
2236pub enum ViewRefInstalledRequest {
2237    /// Sets up a callback to fire when the requested |view_ref| is installed.
2238    /// - If |view_ref| has not already been installed, the |Watch| response
2239    ///   will fire when it is.
2240    /// - If |view_ref| has already been installed, the |Watch| response will
2241    ///   fire immediately.
2242    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2243    ///   was destroyed), the |Watch| call returns with an error.  The error is
2244    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2245    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2246    ///
2247    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2248    /// ViewRefs. There is at most one response per call back to the client.
2249    ///
2250    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2251    ///       the ViewRef is valid.
2252    Watch { view_ref: ViewRef, responder: ViewRefInstalledWatchResponder },
2253}
2254
2255impl ViewRefInstalledRequest {
2256    #[allow(irrefutable_let_patterns)]
2257    pub fn into_watch(self) -> Option<(ViewRef, ViewRefInstalledWatchResponder)> {
2258        if let ViewRefInstalledRequest::Watch { view_ref, responder } = self {
2259            Some((view_ref, responder))
2260        } else {
2261            None
2262        }
2263    }
2264
2265    /// Name of the method defined in FIDL
2266    pub fn method_name(&self) -> &'static str {
2267        match *self {
2268            ViewRefInstalledRequest::Watch { .. } => "watch",
2269        }
2270    }
2271}
2272
2273#[derive(Debug, Clone)]
2274pub struct ViewRefInstalledControlHandle {
2275    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2276}
2277
2278impl ViewRefInstalledControlHandle {
2279    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2280        self.inner.shutdown_with_epitaph(status.into())
2281    }
2282}
2283
2284impl fidl::endpoints::ControlHandle for ViewRefInstalledControlHandle {
2285    fn shutdown(&self) {
2286        self.inner.shutdown()
2287    }
2288
2289    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2290        self.inner.shutdown_with_epitaph(status)
2291    }
2292
2293    fn is_closed(&self) -> bool {
2294        self.inner.channel().is_closed()
2295    }
2296    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2297        self.inner.channel().on_closed()
2298    }
2299
2300    #[cfg(target_os = "fuchsia")]
2301    fn signal_peer(
2302        &self,
2303        clear_mask: zx::Signals,
2304        set_mask: zx::Signals,
2305    ) -> Result<(), zx_status::Status> {
2306        use fidl::Peered;
2307        self.inner.channel().signal_peer(clear_mask, set_mask)
2308    }
2309}
2310
2311impl ViewRefInstalledControlHandle {}
2312
2313#[must_use = "FIDL methods require a response to be sent"]
2314#[derive(Debug)]
2315pub struct ViewRefInstalledWatchResponder {
2316    control_handle: std::mem::ManuallyDrop<ViewRefInstalledControlHandle>,
2317    tx_id: u32,
2318}
2319
2320/// Set the the channel to be shutdown (see [`ViewRefInstalledControlHandle::shutdown`])
2321/// if the responder is dropped without sending a response, so that the client
2322/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2323impl std::ops::Drop for ViewRefInstalledWatchResponder {
2324    fn drop(&mut self) {
2325        self.control_handle.shutdown();
2326        // Safety: drops once, never accessed again
2327        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2328    }
2329}
2330
2331impl fidl::endpoints::Responder for ViewRefInstalledWatchResponder {
2332    type ControlHandle = ViewRefInstalledControlHandle;
2333
2334    fn control_handle(&self) -> &ViewRefInstalledControlHandle {
2335        &self.control_handle
2336    }
2337
2338    fn drop_without_shutdown(mut self) {
2339        // Safety: drops once, never accessed again due to mem::forget
2340        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2341        // Prevent Drop from running (which would shut down the channel)
2342        std::mem::forget(self);
2343    }
2344}
2345
2346impl ViewRefInstalledWatchResponder {
2347    /// Sends a response to the FIDL transaction.
2348    ///
2349    /// Sets the channel to shutdown if an error occurs.
2350    pub fn send(self, mut result: Result<(), ViewRefInstalledError>) -> Result<(), fidl::Error> {
2351        let _result = self.send_raw(result);
2352        if _result.is_err() {
2353            self.control_handle.shutdown();
2354        }
2355        self.drop_without_shutdown();
2356        _result
2357    }
2358
2359    /// Similar to "send" but does not shutdown the channel if an error occurs.
2360    pub fn send_no_shutdown_on_err(
2361        self,
2362        mut result: Result<(), ViewRefInstalledError>,
2363    ) -> Result<(), fidl::Error> {
2364        let _result = self.send_raw(result);
2365        self.drop_without_shutdown();
2366        _result
2367    }
2368
2369    fn send_raw(&self, mut result: Result<(), ViewRefInstalledError>) -> Result<(), fidl::Error> {
2370        self.control_handle.inner.send::<fidl::encoding::ResultType<
2371            fidl::encoding::EmptyStruct,
2372            ViewRefInstalledError,
2373        >>(
2374            result,
2375            self.tx_id,
2376            0x7ddec2f4ca687971,
2377            fidl::encoding::DynamicFlags::empty(),
2378        )
2379    }
2380}
2381
2382mod internal {
2383    use super::*;
2384
2385    impl fidl::encoding::ResourceTypeMarker for FocuserRequestFocusRequest {
2386        type Borrowed<'a> = &'a mut Self;
2387        fn take_or_borrow<'a>(
2388            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2389        ) -> Self::Borrowed<'a> {
2390            value
2391        }
2392    }
2393
2394    unsafe impl fidl::encoding::TypeMarker for FocuserRequestFocusRequest {
2395        type Owned = Self;
2396
2397        #[inline(always)]
2398        fn inline_align(_context: fidl::encoding::Context) -> usize {
2399            4
2400        }
2401
2402        #[inline(always)]
2403        fn inline_size(_context: fidl::encoding::Context) -> usize {
2404            4
2405        }
2406    }
2407
2408    unsafe impl
2409        fidl::encoding::Encode<
2410            FocuserRequestFocusRequest,
2411            fidl::encoding::DefaultFuchsiaResourceDialect,
2412        > for &mut FocuserRequestFocusRequest
2413    {
2414        #[inline]
2415        unsafe fn encode(
2416            self,
2417            encoder: &mut fidl::encoding::Encoder<
2418                '_,
2419                fidl::encoding::DefaultFuchsiaResourceDialect,
2420            >,
2421            offset: usize,
2422            _depth: fidl::encoding::Depth,
2423        ) -> fidl::Result<()> {
2424            encoder.debug_check_bounds::<FocuserRequestFocusRequest>(offset);
2425            // Delegate to tuple encoding.
2426            fidl::encoding::Encode::<
2427                FocuserRequestFocusRequest,
2428                fidl::encoding::DefaultFuchsiaResourceDialect,
2429            >::encode(
2430                (<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2431                    &mut self.view_ref,
2432                ),),
2433                encoder,
2434                offset,
2435                _depth,
2436            )
2437        }
2438    }
2439    unsafe impl<T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>>
2440        fidl::encoding::Encode<
2441            FocuserRequestFocusRequest,
2442            fidl::encoding::DefaultFuchsiaResourceDialect,
2443        > for (T0,)
2444    {
2445        #[inline]
2446        unsafe fn encode(
2447            self,
2448            encoder: &mut fidl::encoding::Encoder<
2449                '_,
2450                fidl::encoding::DefaultFuchsiaResourceDialect,
2451            >,
2452            offset: usize,
2453            depth: fidl::encoding::Depth,
2454        ) -> fidl::Result<()> {
2455            encoder.debug_check_bounds::<FocuserRequestFocusRequest>(offset);
2456            // Zero out padding regions. There's no need to apply masks
2457            // because the unmasked parts will be overwritten by fields.
2458            // Write the fields.
2459            self.0.encode(encoder, offset + 0, depth)?;
2460            Ok(())
2461        }
2462    }
2463
2464    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2465        for FocuserRequestFocusRequest
2466    {
2467        #[inline(always)]
2468        fn new_empty() -> Self {
2469            Self {
2470                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
2471            }
2472        }
2473
2474        #[inline]
2475        unsafe fn decode(
2476            &mut self,
2477            decoder: &mut fidl::encoding::Decoder<
2478                '_,
2479                fidl::encoding::DefaultFuchsiaResourceDialect,
2480            >,
2481            offset: usize,
2482            _depth: fidl::encoding::Depth,
2483        ) -> fidl::Result<()> {
2484            decoder.debug_check_bounds::<Self>(offset);
2485            // Verify that padding bytes are zero.
2486            fidl::decode!(
2487                ViewRef,
2488                fidl::encoding::DefaultFuchsiaResourceDialect,
2489                &mut self.view_ref,
2490                decoder,
2491                offset + 0,
2492                _depth
2493            )?;
2494            Ok(())
2495        }
2496    }
2497
2498    impl fidl::encoding::ResourceTypeMarker for ViewCreationToken {
2499        type Borrowed<'a> = &'a mut Self;
2500        fn take_or_borrow<'a>(
2501            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2502        ) -> Self::Borrowed<'a> {
2503            value
2504        }
2505    }
2506
2507    unsafe impl fidl::encoding::TypeMarker for ViewCreationToken {
2508        type Owned = Self;
2509
2510        #[inline(always)]
2511        fn inline_align(_context: fidl::encoding::Context) -> usize {
2512            4
2513        }
2514
2515        #[inline(always)]
2516        fn inline_size(_context: fidl::encoding::Context) -> usize {
2517            4
2518        }
2519    }
2520
2521    unsafe impl
2522        fidl::encoding::Encode<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2523        for &mut ViewCreationToken
2524    {
2525        #[inline]
2526        unsafe fn encode(
2527            self,
2528            encoder: &mut fidl::encoding::Encoder<
2529                '_,
2530                fidl::encoding::DefaultFuchsiaResourceDialect,
2531            >,
2532            offset: usize,
2533            _depth: fidl::encoding::Depth,
2534        ) -> fidl::Result<()> {
2535            encoder.debug_check_bounds::<ViewCreationToken>(offset);
2536            // Delegate to tuple encoding.
2537            fidl::encoding::Encode::<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2538                (
2539                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
2540                ),
2541                encoder, offset, _depth
2542            )
2543        }
2544    }
2545    unsafe impl<
2546        T0: fidl::encoding::Encode<
2547                fidl::encoding::HandleType<
2548                    fidl::Channel,
2549                    { fidl::ObjectType::CHANNEL.into_raw() },
2550                    2147483648,
2551                >,
2552                fidl::encoding::DefaultFuchsiaResourceDialect,
2553            >,
2554    > fidl::encoding::Encode<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2555        for (T0,)
2556    {
2557        #[inline]
2558        unsafe fn encode(
2559            self,
2560            encoder: &mut fidl::encoding::Encoder<
2561                '_,
2562                fidl::encoding::DefaultFuchsiaResourceDialect,
2563            >,
2564            offset: usize,
2565            depth: fidl::encoding::Depth,
2566        ) -> fidl::Result<()> {
2567            encoder.debug_check_bounds::<ViewCreationToken>(offset);
2568            // Zero out padding regions. There's no need to apply masks
2569            // because the unmasked parts will be overwritten by fields.
2570            // Write the fields.
2571            self.0.encode(encoder, offset + 0, depth)?;
2572            Ok(())
2573        }
2574    }
2575
2576    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2577        for ViewCreationToken
2578    {
2579        #[inline(always)]
2580        fn new_empty() -> Self {
2581            Self {
2582                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2583            }
2584        }
2585
2586        #[inline]
2587        unsafe fn decode(
2588            &mut self,
2589            decoder: &mut fidl::encoding::Decoder<
2590                '_,
2591                fidl::encoding::DefaultFuchsiaResourceDialect,
2592            >,
2593            offset: usize,
2594            _depth: fidl::encoding::Depth,
2595        ) -> fidl::Result<()> {
2596            decoder.debug_check_bounds::<Self>(offset);
2597            // Verify that padding bytes are zero.
2598            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2599            Ok(())
2600        }
2601    }
2602
2603    impl fidl::encoding::ResourceTypeMarker for ViewHolderToken {
2604        type Borrowed<'a> = &'a mut Self;
2605        fn take_or_borrow<'a>(
2606            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2607        ) -> Self::Borrowed<'a> {
2608            value
2609        }
2610    }
2611
2612    unsafe impl fidl::encoding::TypeMarker for ViewHolderToken {
2613        type Owned = Self;
2614
2615        #[inline(always)]
2616        fn inline_align(_context: fidl::encoding::Context) -> usize {
2617            4
2618        }
2619
2620        #[inline(always)]
2621        fn inline_size(_context: fidl::encoding::Context) -> usize {
2622            4
2623        }
2624    }
2625
2626    unsafe impl
2627        fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2628        for &mut ViewHolderToken
2629    {
2630        #[inline]
2631        unsafe fn encode(
2632            self,
2633            encoder: &mut fidl::encoding::Encoder<
2634                '_,
2635                fidl::encoding::DefaultFuchsiaResourceDialect,
2636            >,
2637            offset: usize,
2638            _depth: fidl::encoding::Depth,
2639        ) -> fidl::Result<()> {
2640            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2641            // Delegate to tuple encoding.
2642            fidl::encoding::Encode::<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2643                (
2644                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
2645                ),
2646                encoder, offset, _depth
2647            )
2648        }
2649    }
2650    unsafe impl<
2651        T0: fidl::encoding::Encode<
2652                fidl::encoding::HandleType<
2653                    fidl::EventPair,
2654                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2655                    2147483648,
2656                >,
2657                fidl::encoding::DefaultFuchsiaResourceDialect,
2658            >,
2659    > fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2660        for (T0,)
2661    {
2662        #[inline]
2663        unsafe fn encode(
2664            self,
2665            encoder: &mut fidl::encoding::Encoder<
2666                '_,
2667                fidl::encoding::DefaultFuchsiaResourceDialect,
2668            >,
2669            offset: usize,
2670            depth: fidl::encoding::Depth,
2671        ) -> fidl::Result<()> {
2672            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2673            // Zero out padding regions. There's no need to apply masks
2674            // because the unmasked parts will be overwritten by fields.
2675            // Write the fields.
2676            self.0.encode(encoder, offset + 0, depth)?;
2677            Ok(())
2678        }
2679    }
2680
2681    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2682        for ViewHolderToken
2683    {
2684        #[inline(always)]
2685        fn new_empty() -> Self {
2686            Self {
2687                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2688            }
2689        }
2690
2691        #[inline]
2692        unsafe fn decode(
2693            &mut self,
2694            decoder: &mut fidl::encoding::Decoder<
2695                '_,
2696                fidl::encoding::DefaultFuchsiaResourceDialect,
2697            >,
2698            offset: usize,
2699            _depth: fidl::encoding::Depth,
2700        ) -> fidl::Result<()> {
2701            decoder.debug_check_bounds::<Self>(offset);
2702            // Verify that padding bytes are zero.
2703            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2704            Ok(())
2705        }
2706    }
2707
2708    impl fidl::encoding::ResourceTypeMarker for ViewIdentityOnCreation {
2709        type Borrowed<'a> = &'a mut Self;
2710        fn take_or_borrow<'a>(
2711            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2712        ) -> Self::Borrowed<'a> {
2713            value
2714        }
2715    }
2716
2717    unsafe impl fidl::encoding::TypeMarker for ViewIdentityOnCreation {
2718        type Owned = Self;
2719
2720        #[inline(always)]
2721        fn inline_align(_context: fidl::encoding::Context) -> usize {
2722            4
2723        }
2724
2725        #[inline(always)]
2726        fn inline_size(_context: fidl::encoding::Context) -> usize {
2727            8
2728        }
2729    }
2730
2731    unsafe impl
2732        fidl::encoding::Encode<
2733            ViewIdentityOnCreation,
2734            fidl::encoding::DefaultFuchsiaResourceDialect,
2735        > for &mut ViewIdentityOnCreation
2736    {
2737        #[inline]
2738        unsafe fn encode(
2739            self,
2740            encoder: &mut fidl::encoding::Encoder<
2741                '_,
2742                fidl::encoding::DefaultFuchsiaResourceDialect,
2743            >,
2744            offset: usize,
2745            _depth: fidl::encoding::Depth,
2746        ) -> fidl::Result<()> {
2747            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2748            // Delegate to tuple encoding.
2749            fidl::encoding::Encode::<
2750                ViewIdentityOnCreation,
2751                fidl::encoding::DefaultFuchsiaResourceDialect,
2752            >::encode(
2753                (
2754                    <ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2755                        &mut self.view_ref,
2756                    ),
2757                    <ViewRefControl as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2758                        &mut self.view_ref_control,
2759                    ),
2760                ),
2761                encoder,
2762                offset,
2763                _depth,
2764            )
2765        }
2766    }
2767    unsafe impl<
2768        T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>,
2769        T1: fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>,
2770    >
2771        fidl::encoding::Encode<
2772            ViewIdentityOnCreation,
2773            fidl::encoding::DefaultFuchsiaResourceDialect,
2774        > for (T0, T1)
2775    {
2776        #[inline]
2777        unsafe fn encode(
2778            self,
2779            encoder: &mut fidl::encoding::Encoder<
2780                '_,
2781                fidl::encoding::DefaultFuchsiaResourceDialect,
2782            >,
2783            offset: usize,
2784            depth: fidl::encoding::Depth,
2785        ) -> fidl::Result<()> {
2786            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2787            // Zero out padding regions. There's no need to apply masks
2788            // because the unmasked parts will be overwritten by fields.
2789            // Write the fields.
2790            self.0.encode(encoder, offset + 0, depth)?;
2791            self.1.encode(encoder, offset + 4, depth)?;
2792            Ok(())
2793        }
2794    }
2795
2796    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2797        for ViewIdentityOnCreation
2798    {
2799        #[inline(always)]
2800        fn new_empty() -> Self {
2801            Self {
2802                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
2803                view_ref_control: fidl::new_empty!(
2804                    ViewRefControl,
2805                    fidl::encoding::DefaultFuchsiaResourceDialect
2806                ),
2807            }
2808        }
2809
2810        #[inline]
2811        unsafe fn decode(
2812            &mut self,
2813            decoder: &mut fidl::encoding::Decoder<
2814                '_,
2815                fidl::encoding::DefaultFuchsiaResourceDialect,
2816            >,
2817            offset: usize,
2818            _depth: fidl::encoding::Depth,
2819        ) -> fidl::Result<()> {
2820            decoder.debug_check_bounds::<Self>(offset);
2821            // Verify that padding bytes are zero.
2822            fidl::decode!(
2823                ViewRef,
2824                fidl::encoding::DefaultFuchsiaResourceDialect,
2825                &mut self.view_ref,
2826                decoder,
2827                offset + 0,
2828                _depth
2829            )?;
2830            fidl::decode!(
2831                ViewRefControl,
2832                fidl::encoding::DefaultFuchsiaResourceDialect,
2833                &mut self.view_ref_control,
2834                decoder,
2835                offset + 4,
2836                _depth
2837            )?;
2838            Ok(())
2839        }
2840    }
2841
2842    impl fidl::encoding::ResourceTypeMarker for ViewPresentRequest {
2843        type Borrowed<'a> = &'a mut Self;
2844        fn take_or_borrow<'a>(
2845            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2846        ) -> Self::Borrowed<'a> {
2847            value
2848        }
2849    }
2850
2851    unsafe impl fidl::encoding::TypeMarker for ViewPresentRequest {
2852        type Owned = Self;
2853
2854        #[inline(always)]
2855        fn inline_align(_context: fidl::encoding::Context) -> usize {
2856            4
2857        }
2858
2859        #[inline(always)]
2860        fn inline_size(_context: fidl::encoding::Context) -> usize {
2861            4
2862        }
2863    }
2864
2865    unsafe impl
2866        fidl::encoding::Encode<ViewPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2867        for &mut ViewPresentRequest
2868    {
2869        #[inline]
2870        unsafe fn encode(
2871            self,
2872            encoder: &mut fidl::encoding::Encoder<
2873                '_,
2874                fidl::encoding::DefaultFuchsiaResourceDialect,
2875            >,
2876            offset: usize,
2877            _depth: fidl::encoding::Depth,
2878        ) -> fidl::Result<()> {
2879            encoder.debug_check_bounds::<ViewPresentRequest>(offset);
2880            // Delegate to tuple encoding.
2881            fidl::encoding::Encode::<
2882                ViewPresentRequest,
2883                fidl::encoding::DefaultFuchsiaResourceDialect,
2884            >::encode(
2885                (<ViewToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2886                    &mut self.view_token,
2887                ),),
2888                encoder,
2889                offset,
2890                _depth,
2891            )
2892        }
2893    }
2894    unsafe impl<
2895        T0: fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
2896    > fidl::encoding::Encode<ViewPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2897        for (T0,)
2898    {
2899        #[inline]
2900        unsafe fn encode(
2901            self,
2902            encoder: &mut fidl::encoding::Encoder<
2903                '_,
2904                fidl::encoding::DefaultFuchsiaResourceDialect,
2905            >,
2906            offset: usize,
2907            depth: fidl::encoding::Depth,
2908        ) -> fidl::Result<()> {
2909            encoder.debug_check_bounds::<ViewPresentRequest>(offset);
2910            // Zero out padding regions. There's no need to apply masks
2911            // because the unmasked parts will be overwritten by fields.
2912            // Write the fields.
2913            self.0.encode(encoder, offset + 0, depth)?;
2914            Ok(())
2915        }
2916    }
2917
2918    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2919        for ViewPresentRequest
2920    {
2921        #[inline(always)]
2922        fn new_empty() -> Self {
2923            Self {
2924                view_token: fidl::new_empty!(
2925                    ViewToken,
2926                    fidl::encoding::DefaultFuchsiaResourceDialect
2927                ),
2928            }
2929        }
2930
2931        #[inline]
2932        unsafe fn decode(
2933            &mut self,
2934            decoder: &mut fidl::encoding::Decoder<
2935                '_,
2936                fidl::encoding::DefaultFuchsiaResourceDialect,
2937            >,
2938            offset: usize,
2939            _depth: fidl::encoding::Depth,
2940        ) -> fidl::Result<()> {
2941            decoder.debug_check_bounds::<Self>(offset);
2942            // Verify that padding bytes are zero.
2943            fidl::decode!(
2944                ViewToken,
2945                fidl::encoding::DefaultFuchsiaResourceDialect,
2946                &mut self.view_token,
2947                decoder,
2948                offset + 0,
2949                _depth
2950            )?;
2951            Ok(())
2952        }
2953    }
2954
2955    impl fidl::encoding::ResourceTypeMarker for ViewRef {
2956        type Borrowed<'a> = &'a mut Self;
2957        fn take_or_borrow<'a>(
2958            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2959        ) -> Self::Borrowed<'a> {
2960            value
2961        }
2962    }
2963
2964    unsafe impl fidl::encoding::TypeMarker for ViewRef {
2965        type Owned = Self;
2966
2967        #[inline(always)]
2968        fn inline_align(_context: fidl::encoding::Context) -> usize {
2969            4
2970        }
2971
2972        #[inline(always)]
2973        fn inline_size(_context: fidl::encoding::Context) -> usize {
2974            4
2975        }
2976    }
2977
2978    unsafe impl fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>
2979        for &mut ViewRef
2980    {
2981        #[inline]
2982        unsafe fn encode(
2983            self,
2984            encoder: &mut fidl::encoding::Encoder<
2985                '_,
2986                fidl::encoding::DefaultFuchsiaResourceDialect,
2987            >,
2988            offset: usize,
2989            _depth: fidl::encoding::Depth,
2990        ) -> fidl::Result<()> {
2991            encoder.debug_check_bounds::<ViewRef>(offset);
2992            // Delegate to tuple encoding.
2993            fidl::encoding::Encode::<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2994                (<fidl::encoding::HandleType<
2995                    fidl::EventPair,
2996                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2997                    2147483648,
2998                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2999                    &mut self.reference
3000                ),),
3001                encoder,
3002                offset,
3003                _depth,
3004            )
3005        }
3006    }
3007    unsafe impl<
3008        T0: fidl::encoding::Encode<
3009                fidl::encoding::HandleType<
3010                    fidl::EventPair,
3011                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3012                    2147483648,
3013                >,
3014                fidl::encoding::DefaultFuchsiaResourceDialect,
3015            >,
3016    > fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
3017    {
3018        #[inline]
3019        unsafe fn encode(
3020            self,
3021            encoder: &mut fidl::encoding::Encoder<
3022                '_,
3023                fidl::encoding::DefaultFuchsiaResourceDialect,
3024            >,
3025            offset: usize,
3026            depth: fidl::encoding::Depth,
3027        ) -> fidl::Result<()> {
3028            encoder.debug_check_bounds::<ViewRef>(offset);
3029            // Zero out padding regions. There's no need to apply masks
3030            // because the unmasked parts will be overwritten by fields.
3031            // Write the fields.
3032            self.0.encode(encoder, offset + 0, depth)?;
3033            Ok(())
3034        }
3035    }
3036
3037    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewRef {
3038        #[inline(always)]
3039        fn new_empty() -> Self {
3040            Self {
3041                reference: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3042            }
3043        }
3044
3045        #[inline]
3046        unsafe fn decode(
3047            &mut self,
3048            decoder: &mut fidl::encoding::Decoder<
3049                '_,
3050                fidl::encoding::DefaultFuchsiaResourceDialect,
3051            >,
3052            offset: usize,
3053            _depth: fidl::encoding::Depth,
3054        ) -> fidl::Result<()> {
3055            decoder.debug_check_bounds::<Self>(offset);
3056            // Verify that padding bytes are zero.
3057            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference, decoder, offset + 0, _depth)?;
3058            Ok(())
3059        }
3060    }
3061
3062    impl fidl::encoding::ResourceTypeMarker for ViewRefControl {
3063        type Borrowed<'a> = &'a mut Self;
3064        fn take_or_borrow<'a>(
3065            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3066        ) -> Self::Borrowed<'a> {
3067            value
3068        }
3069    }
3070
3071    unsafe impl fidl::encoding::TypeMarker for ViewRefControl {
3072        type Owned = Self;
3073
3074        #[inline(always)]
3075        fn inline_align(_context: fidl::encoding::Context) -> usize {
3076            4
3077        }
3078
3079        #[inline(always)]
3080        fn inline_size(_context: fidl::encoding::Context) -> usize {
3081            4
3082        }
3083    }
3084
3085    unsafe impl
3086        fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>
3087        for &mut ViewRefControl
3088    {
3089        #[inline]
3090        unsafe fn encode(
3091            self,
3092            encoder: &mut fidl::encoding::Encoder<
3093                '_,
3094                fidl::encoding::DefaultFuchsiaResourceDialect,
3095            >,
3096            offset: usize,
3097            _depth: fidl::encoding::Depth,
3098        ) -> fidl::Result<()> {
3099            encoder.debug_check_bounds::<ViewRefControl>(offset);
3100            // Delegate to tuple encoding.
3101            fidl::encoding::Encode::<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3102                (
3103                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reference),
3104                ),
3105                encoder, offset, _depth
3106            )
3107        }
3108    }
3109    unsafe impl<
3110        T0: fidl::encoding::Encode<
3111                fidl::encoding::HandleType<
3112                    fidl::EventPair,
3113                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3114                    2147483648,
3115                >,
3116                fidl::encoding::DefaultFuchsiaResourceDialect,
3117            >,
3118    > fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>
3119        for (T0,)
3120    {
3121        #[inline]
3122        unsafe fn encode(
3123            self,
3124            encoder: &mut fidl::encoding::Encoder<
3125                '_,
3126                fidl::encoding::DefaultFuchsiaResourceDialect,
3127            >,
3128            offset: usize,
3129            depth: fidl::encoding::Depth,
3130        ) -> fidl::Result<()> {
3131            encoder.debug_check_bounds::<ViewRefControl>(offset);
3132            // Zero out padding regions. There's no need to apply masks
3133            // because the unmasked parts will be overwritten by fields.
3134            // Write the fields.
3135            self.0.encode(encoder, offset + 0, depth)?;
3136            Ok(())
3137        }
3138    }
3139
3140    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3141        for ViewRefControl
3142    {
3143        #[inline(always)]
3144        fn new_empty() -> Self {
3145            Self {
3146                reference: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3147            }
3148        }
3149
3150        #[inline]
3151        unsafe fn decode(
3152            &mut self,
3153            decoder: &mut fidl::encoding::Decoder<
3154                '_,
3155                fidl::encoding::DefaultFuchsiaResourceDialect,
3156            >,
3157            offset: usize,
3158            _depth: fidl::encoding::Depth,
3159        ) -> fidl::Result<()> {
3160            decoder.debug_check_bounds::<Self>(offset);
3161            // Verify that padding bytes are zero.
3162            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference, decoder, offset + 0, _depth)?;
3163            Ok(())
3164        }
3165    }
3166
3167    impl fidl::encoding::ResourceTypeMarker for ViewRefInstalledWatchRequest {
3168        type Borrowed<'a> = &'a mut Self;
3169        fn take_or_borrow<'a>(
3170            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3171        ) -> Self::Borrowed<'a> {
3172            value
3173        }
3174    }
3175
3176    unsafe impl fidl::encoding::TypeMarker for ViewRefInstalledWatchRequest {
3177        type Owned = Self;
3178
3179        #[inline(always)]
3180        fn inline_align(_context: fidl::encoding::Context) -> usize {
3181            4
3182        }
3183
3184        #[inline(always)]
3185        fn inline_size(_context: fidl::encoding::Context) -> usize {
3186            4
3187        }
3188    }
3189
3190    unsafe impl
3191        fidl::encoding::Encode<
3192            ViewRefInstalledWatchRequest,
3193            fidl::encoding::DefaultFuchsiaResourceDialect,
3194        > for &mut ViewRefInstalledWatchRequest
3195    {
3196        #[inline]
3197        unsafe fn encode(
3198            self,
3199            encoder: &mut fidl::encoding::Encoder<
3200                '_,
3201                fidl::encoding::DefaultFuchsiaResourceDialect,
3202            >,
3203            offset: usize,
3204            _depth: fidl::encoding::Depth,
3205        ) -> fidl::Result<()> {
3206            encoder.debug_check_bounds::<ViewRefInstalledWatchRequest>(offset);
3207            // Delegate to tuple encoding.
3208            fidl::encoding::Encode::<
3209                ViewRefInstalledWatchRequest,
3210                fidl::encoding::DefaultFuchsiaResourceDialect,
3211            >::encode(
3212                (<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3213                    &mut self.view_ref,
3214                ),),
3215                encoder,
3216                offset,
3217                _depth,
3218            )
3219        }
3220    }
3221    unsafe impl<T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>>
3222        fidl::encoding::Encode<
3223            ViewRefInstalledWatchRequest,
3224            fidl::encoding::DefaultFuchsiaResourceDialect,
3225        > for (T0,)
3226    {
3227        #[inline]
3228        unsafe fn encode(
3229            self,
3230            encoder: &mut fidl::encoding::Encoder<
3231                '_,
3232                fidl::encoding::DefaultFuchsiaResourceDialect,
3233            >,
3234            offset: usize,
3235            depth: fidl::encoding::Depth,
3236        ) -> fidl::Result<()> {
3237            encoder.debug_check_bounds::<ViewRefInstalledWatchRequest>(offset);
3238            // Zero out padding regions. There's no need to apply masks
3239            // because the unmasked parts will be overwritten by fields.
3240            // Write the fields.
3241            self.0.encode(encoder, offset + 0, depth)?;
3242            Ok(())
3243        }
3244    }
3245
3246    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3247        for ViewRefInstalledWatchRequest
3248    {
3249        #[inline(always)]
3250        fn new_empty() -> Self {
3251            Self {
3252                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
3253            }
3254        }
3255
3256        #[inline]
3257        unsafe fn decode(
3258            &mut self,
3259            decoder: &mut fidl::encoding::Decoder<
3260                '_,
3261                fidl::encoding::DefaultFuchsiaResourceDialect,
3262            >,
3263            offset: usize,
3264            _depth: fidl::encoding::Depth,
3265        ) -> fidl::Result<()> {
3266            decoder.debug_check_bounds::<Self>(offset);
3267            // Verify that padding bytes are zero.
3268            fidl::decode!(
3269                ViewRef,
3270                fidl::encoding::DefaultFuchsiaResourceDialect,
3271                &mut self.view_ref,
3272                decoder,
3273                offset + 0,
3274                _depth
3275            )?;
3276            Ok(())
3277        }
3278    }
3279
3280    impl fidl::encoding::ResourceTypeMarker for ViewToken {
3281        type Borrowed<'a> = &'a mut Self;
3282        fn take_or_borrow<'a>(
3283            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3284        ) -> Self::Borrowed<'a> {
3285            value
3286        }
3287    }
3288
3289    unsafe impl fidl::encoding::TypeMarker for ViewToken {
3290        type Owned = Self;
3291
3292        #[inline(always)]
3293        fn inline_align(_context: fidl::encoding::Context) -> usize {
3294            4
3295        }
3296
3297        #[inline(always)]
3298        fn inline_size(_context: fidl::encoding::Context) -> usize {
3299            4
3300        }
3301    }
3302
3303    unsafe impl fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3304        for &mut ViewToken
3305    {
3306        #[inline]
3307        unsafe fn encode(
3308            self,
3309            encoder: &mut fidl::encoding::Encoder<
3310                '_,
3311                fidl::encoding::DefaultFuchsiaResourceDialect,
3312            >,
3313            offset: usize,
3314            _depth: fidl::encoding::Depth,
3315        ) -> fidl::Result<()> {
3316            encoder.debug_check_bounds::<ViewToken>(offset);
3317            // Delegate to tuple encoding.
3318            fidl::encoding::Encode::<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3319                (
3320                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
3321                ),
3322                encoder, offset, _depth
3323            )
3324        }
3325    }
3326    unsafe impl<
3327        T0: fidl::encoding::Encode<
3328                fidl::encoding::HandleType<
3329                    fidl::EventPair,
3330                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3331                    2147483648,
3332                >,
3333                fidl::encoding::DefaultFuchsiaResourceDialect,
3334            >,
3335    > fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
3336    {
3337        #[inline]
3338        unsafe fn encode(
3339            self,
3340            encoder: &mut fidl::encoding::Encoder<
3341                '_,
3342                fidl::encoding::DefaultFuchsiaResourceDialect,
3343            >,
3344            offset: usize,
3345            depth: fidl::encoding::Depth,
3346        ) -> fidl::Result<()> {
3347            encoder.debug_check_bounds::<ViewToken>(offset);
3348            // Zero out padding regions. There's no need to apply masks
3349            // because the unmasked parts will be overwritten by fields.
3350            // Write the fields.
3351            self.0.encode(encoder, offset + 0, depth)?;
3352            Ok(())
3353        }
3354    }
3355
3356    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewToken {
3357        #[inline(always)]
3358        fn new_empty() -> Self {
3359            Self {
3360                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3361            }
3362        }
3363
3364        #[inline]
3365        unsafe fn decode(
3366            &mut self,
3367            decoder: &mut fidl::encoding::Decoder<
3368                '_,
3369                fidl::encoding::DefaultFuchsiaResourceDialect,
3370            >,
3371            offset: usize,
3372            _depth: fidl::encoding::Depth,
3373        ) -> fidl::Result<()> {
3374            decoder.debug_check_bounds::<Self>(offset);
3375            // Verify that padding bytes are zero.
3376            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3377            Ok(())
3378        }
3379    }
3380
3381    impl fidl::encoding::ResourceTypeMarker for ViewportCreationToken {
3382        type Borrowed<'a> = &'a mut Self;
3383        fn take_or_borrow<'a>(
3384            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3385        ) -> Self::Borrowed<'a> {
3386            value
3387        }
3388    }
3389
3390    unsafe impl fidl::encoding::TypeMarker for ViewportCreationToken {
3391        type Owned = Self;
3392
3393        #[inline(always)]
3394        fn inline_align(_context: fidl::encoding::Context) -> usize {
3395            4
3396        }
3397
3398        #[inline(always)]
3399        fn inline_size(_context: fidl::encoding::Context) -> usize {
3400            4
3401        }
3402    }
3403
3404    unsafe impl
3405        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3406        for &mut ViewportCreationToken
3407    {
3408        #[inline]
3409        unsafe fn encode(
3410            self,
3411            encoder: &mut fidl::encoding::Encoder<
3412                '_,
3413                fidl::encoding::DefaultFuchsiaResourceDialect,
3414            >,
3415            offset: usize,
3416            _depth: fidl::encoding::Depth,
3417        ) -> fidl::Result<()> {
3418            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3419            // Delegate to tuple encoding.
3420            fidl::encoding::Encode::<
3421                ViewportCreationToken,
3422                fidl::encoding::DefaultFuchsiaResourceDialect,
3423            >::encode(
3424                (<fidl::encoding::HandleType<
3425                    fidl::Channel,
3426                    { fidl::ObjectType::CHANNEL.into_raw() },
3427                    2147483648,
3428                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3429                    &mut self.value
3430                ),),
3431                encoder,
3432                offset,
3433                _depth,
3434            )
3435        }
3436    }
3437    unsafe impl<
3438        T0: fidl::encoding::Encode<
3439                fidl::encoding::HandleType<
3440                    fidl::Channel,
3441                    { fidl::ObjectType::CHANNEL.into_raw() },
3442                    2147483648,
3443                >,
3444                fidl::encoding::DefaultFuchsiaResourceDialect,
3445            >,
3446    >
3447        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3448        for (T0,)
3449    {
3450        #[inline]
3451        unsafe fn encode(
3452            self,
3453            encoder: &mut fidl::encoding::Encoder<
3454                '_,
3455                fidl::encoding::DefaultFuchsiaResourceDialect,
3456            >,
3457            offset: usize,
3458            depth: fidl::encoding::Depth,
3459        ) -> fidl::Result<()> {
3460            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3461            // Zero out padding regions. There's no need to apply masks
3462            // because the unmasked parts will be overwritten by fields.
3463            // Write the fields.
3464            self.0.encode(encoder, offset + 0, depth)?;
3465            Ok(())
3466        }
3467    }
3468
3469    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3470        for ViewportCreationToken
3471    {
3472        #[inline(always)]
3473        fn new_empty() -> Self {
3474            Self {
3475                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3476            }
3477        }
3478
3479        #[inline]
3480        unsafe fn decode(
3481            &mut self,
3482            decoder: &mut fidl::encoding::Decoder<
3483                '_,
3484                fidl::encoding::DefaultFuchsiaResourceDialect,
3485            >,
3486            offset: usize,
3487            _depth: fidl::encoding::Depth,
3488        ) -> fidl::Result<()> {
3489            decoder.debug_check_bounds::<Self>(offset);
3490            // Verify that padding bytes are zero.
3491            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3492            Ok(())
3493        }
3494    }
3495
3496    impl FocuserSetAutoFocusRequest {
3497        #[inline(always)]
3498        fn max_ordinal_present(&self) -> u64 {
3499            if let Some(_) = self.view_ref {
3500                return 1;
3501            }
3502            0
3503        }
3504    }
3505
3506    impl fidl::encoding::ResourceTypeMarker for FocuserSetAutoFocusRequest {
3507        type Borrowed<'a> = &'a mut Self;
3508        fn take_or_borrow<'a>(
3509            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3510        ) -> Self::Borrowed<'a> {
3511            value
3512        }
3513    }
3514
3515    unsafe impl fidl::encoding::TypeMarker for FocuserSetAutoFocusRequest {
3516        type Owned = Self;
3517
3518        #[inline(always)]
3519        fn inline_align(_context: fidl::encoding::Context) -> usize {
3520            8
3521        }
3522
3523        #[inline(always)]
3524        fn inline_size(_context: fidl::encoding::Context) -> usize {
3525            16
3526        }
3527    }
3528
3529    unsafe impl
3530        fidl::encoding::Encode<
3531            FocuserSetAutoFocusRequest,
3532            fidl::encoding::DefaultFuchsiaResourceDialect,
3533        > for &mut FocuserSetAutoFocusRequest
3534    {
3535        unsafe fn encode(
3536            self,
3537            encoder: &mut fidl::encoding::Encoder<
3538                '_,
3539                fidl::encoding::DefaultFuchsiaResourceDialect,
3540            >,
3541            offset: usize,
3542            mut depth: fidl::encoding::Depth,
3543        ) -> fidl::Result<()> {
3544            encoder.debug_check_bounds::<FocuserSetAutoFocusRequest>(offset);
3545            // Vector header
3546            let max_ordinal: u64 = self.max_ordinal_present();
3547            encoder.write_num(max_ordinal, offset);
3548            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3549            // Calling encoder.out_of_line_offset(0) is not allowed.
3550            if max_ordinal == 0 {
3551                return Ok(());
3552            }
3553            depth.increment()?;
3554            let envelope_size = 8;
3555            let bytes_len = max_ordinal as usize * envelope_size;
3556            #[allow(unused_variables)]
3557            let offset = encoder.out_of_line_offset(bytes_len);
3558            let mut _prev_end_offset: usize = 0;
3559            if 1 > max_ordinal {
3560                return Ok(());
3561            }
3562
3563            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3564            // are envelope_size bytes.
3565            let cur_offset: usize = (1 - 1) * envelope_size;
3566
3567            // Zero reserved fields.
3568            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3569
3570            // Safety:
3571            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3572            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3573            //   envelope_size bytes, there is always sufficient room.
3574            fidl::encoding::encode_in_envelope_optional::<
3575                ViewRef,
3576                fidl::encoding::DefaultFuchsiaResourceDialect,
3577            >(
3578                self.view_ref
3579                    .as_mut()
3580                    .map(<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3581                encoder,
3582                offset + cur_offset,
3583                depth,
3584            )?;
3585
3586            _prev_end_offset = cur_offset + envelope_size;
3587
3588            Ok(())
3589        }
3590    }
3591
3592    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3593        for FocuserSetAutoFocusRequest
3594    {
3595        #[inline(always)]
3596        fn new_empty() -> Self {
3597            Self::default()
3598        }
3599
3600        unsafe fn decode(
3601            &mut self,
3602            decoder: &mut fidl::encoding::Decoder<
3603                '_,
3604                fidl::encoding::DefaultFuchsiaResourceDialect,
3605            >,
3606            offset: usize,
3607            mut depth: fidl::encoding::Depth,
3608        ) -> fidl::Result<()> {
3609            decoder.debug_check_bounds::<Self>(offset);
3610            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3611                None => return Err(fidl::Error::NotNullable),
3612                Some(len) => len,
3613            };
3614            // Calling decoder.out_of_line_offset(0) is not allowed.
3615            if len == 0 {
3616                return Ok(());
3617            };
3618            depth.increment()?;
3619            let envelope_size = 8;
3620            let bytes_len = len * envelope_size;
3621            let offset = decoder.out_of_line_offset(bytes_len)?;
3622            // Decode the envelope for each type.
3623            let mut _next_ordinal_to_read = 0;
3624            let mut next_offset = offset;
3625            let end_offset = offset + bytes_len;
3626            _next_ordinal_to_read += 1;
3627            if next_offset >= end_offset {
3628                return Ok(());
3629            }
3630
3631            // Decode unknown envelopes for gaps in ordinals.
3632            while _next_ordinal_to_read < 1 {
3633                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3634                _next_ordinal_to_read += 1;
3635                next_offset += envelope_size;
3636            }
3637
3638            let next_out_of_line = decoder.next_out_of_line();
3639            let handles_before = decoder.remaining_handles();
3640            if let Some((inlined, num_bytes, num_handles)) =
3641                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3642            {
3643                let member_inline_size =
3644                    <ViewRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3645                if inlined != (member_inline_size <= 4) {
3646                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3647                }
3648                let inner_offset;
3649                let mut inner_depth = depth.clone();
3650                if inlined {
3651                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3652                    inner_offset = next_offset;
3653                } else {
3654                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3655                    inner_depth.increment()?;
3656                }
3657                let val_ref = self.view_ref.get_or_insert_with(|| {
3658                    fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect)
3659                });
3660                fidl::decode!(
3661                    ViewRef,
3662                    fidl::encoding::DefaultFuchsiaResourceDialect,
3663                    val_ref,
3664                    decoder,
3665                    inner_offset,
3666                    inner_depth
3667                )?;
3668                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3669                {
3670                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3671                }
3672                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3673                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3674                }
3675            }
3676
3677            next_offset += envelope_size;
3678
3679            // Decode the remaining unknown envelopes.
3680            while next_offset < end_offset {
3681                _next_ordinal_to_read += 1;
3682                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3683                next_offset += envelope_size;
3684            }
3685
3686            Ok(())
3687        }
3688    }
3689}