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 fidl::endpoints::ControlHandle for FocuserControlHandle {
777    fn shutdown(&self) {
778        self.inner.shutdown()
779    }
780
781    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
782        self.inner.shutdown_with_epitaph(status)
783    }
784
785    fn is_closed(&self) -> bool {
786        self.inner.channel().is_closed()
787    }
788    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
789        self.inner.channel().on_closed()
790    }
791
792    #[cfg(target_os = "fuchsia")]
793    fn signal_peer(
794        &self,
795        clear_mask: zx::Signals,
796        set_mask: zx::Signals,
797    ) -> Result<(), zx_status::Status> {
798        use fidl::Peered;
799        self.inner.channel().signal_peer(clear_mask, set_mask)
800    }
801}
802
803impl FocuserControlHandle {}
804
805#[must_use = "FIDL methods require a response to be sent"]
806#[derive(Debug)]
807pub struct FocuserRequestFocusResponder {
808    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
809    tx_id: u32,
810}
811
812/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
813/// if the responder is dropped without sending a response, so that the client
814/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
815impl std::ops::Drop for FocuserRequestFocusResponder {
816    fn drop(&mut self) {
817        self.control_handle.shutdown();
818        // Safety: drops once, never accessed again
819        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
820    }
821}
822
823impl fidl::endpoints::Responder for FocuserRequestFocusResponder {
824    type ControlHandle = FocuserControlHandle;
825
826    fn control_handle(&self) -> &FocuserControlHandle {
827        &self.control_handle
828    }
829
830    fn drop_without_shutdown(mut self) {
831        // Safety: drops once, never accessed again due to mem::forget
832        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
833        // Prevent Drop from running (which would shut down the channel)
834        std::mem::forget(self);
835    }
836}
837
838impl FocuserRequestFocusResponder {
839    /// Sends a response to the FIDL transaction.
840    ///
841    /// Sets the channel to shutdown if an error occurs.
842    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
843        let _result = self.send_raw(result);
844        if _result.is_err() {
845            self.control_handle.shutdown();
846        }
847        self.drop_without_shutdown();
848        _result
849    }
850
851    /// Similar to "send" but does not shutdown the channel if an error occurs.
852    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
853        let _result = self.send_raw(result);
854        self.drop_without_shutdown();
855        _result
856    }
857
858    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
859        self.control_handle
860            .inner
861            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
862                result,
863                self.tx_id,
864                0x559067eb07097d5,
865                fidl::encoding::DynamicFlags::empty(),
866            )
867    }
868}
869
870#[must_use = "FIDL methods require a response to be sent"]
871#[derive(Debug)]
872pub struct FocuserSetAutoFocusResponder {
873    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
874    tx_id: u32,
875}
876
877/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
878/// if the responder is dropped without sending a response, so that the client
879/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
880impl std::ops::Drop for FocuserSetAutoFocusResponder {
881    fn drop(&mut self) {
882        self.control_handle.shutdown();
883        // Safety: drops once, never accessed again
884        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
885    }
886}
887
888impl fidl::endpoints::Responder for FocuserSetAutoFocusResponder {
889    type ControlHandle = FocuserControlHandle;
890
891    fn control_handle(&self) -> &FocuserControlHandle {
892        &self.control_handle
893    }
894
895    fn drop_without_shutdown(mut self) {
896        // Safety: drops once, never accessed again due to mem::forget
897        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
898        // Prevent Drop from running (which would shut down the channel)
899        std::mem::forget(self);
900    }
901}
902
903impl FocuserSetAutoFocusResponder {
904    /// Sends a response to the FIDL transaction.
905    ///
906    /// Sets the channel to shutdown if an error occurs.
907    pub fn send(self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
908        let _result = self.send_raw(result);
909        if _result.is_err() {
910            self.control_handle.shutdown();
911        }
912        self.drop_without_shutdown();
913        _result
914    }
915
916    /// Similar to "send" but does not shutdown the channel if an error occurs.
917    pub fn send_no_shutdown_on_err(
918        self,
919        mut result: Result<(), AutoFocusError>,
920    ) -> Result<(), fidl::Error> {
921        let _result = self.send_raw(result);
922        self.drop_without_shutdown();
923        _result
924    }
925
926    fn send_raw(&self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
927        self.control_handle.inner.send::<fidl::encoding::ResultType<
928            fidl::encoding::EmptyStruct,
929            AutoFocusError,
930        >>(
931            result,
932            self.tx_id,
933            0x480feb5856329509,
934            fidl::encoding::DynamicFlags::empty(),
935        )
936    }
937}
938
939#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
940pub struct ViewMarker;
941
942impl fidl::endpoints::ProtocolMarker for ViewMarker {
943    type Proxy = ViewProxy;
944    type RequestStream = ViewRequestStream;
945    #[cfg(target_os = "fuchsia")]
946    type SynchronousProxy = ViewSynchronousProxy;
947
948    const DEBUG_NAME: &'static str = "fuchsia.ui.views.View";
949}
950impl fidl::endpoints::DiscoverableProtocolMarker for ViewMarker {}
951
952pub trait ViewProxyInterface: Send + Sync {
953    fn r#present(&self, view_token: ViewToken) -> Result<(), fidl::Error>;
954}
955#[derive(Debug)]
956#[cfg(target_os = "fuchsia")]
957pub struct ViewSynchronousProxy {
958    client: fidl::client::sync::Client,
959}
960
961#[cfg(target_os = "fuchsia")]
962impl fidl::endpoints::SynchronousProxy for ViewSynchronousProxy {
963    type Proxy = ViewProxy;
964    type Protocol = ViewMarker;
965
966    fn from_channel(inner: fidl::Channel) -> Self {
967        Self::new(inner)
968    }
969
970    fn into_channel(self) -> fidl::Channel {
971        self.client.into_channel()
972    }
973
974    fn as_channel(&self) -> &fidl::Channel {
975        self.client.as_channel()
976    }
977}
978
979#[cfg(target_os = "fuchsia")]
980impl ViewSynchronousProxy {
981    pub fn new(channel: fidl::Channel) -> Self {
982        Self { client: fidl::client::sync::Client::new(channel) }
983    }
984
985    pub fn into_channel(self) -> fidl::Channel {
986        self.client.into_channel()
987    }
988
989    /// Waits until an event arrives and returns it. It is safe for other
990    /// threads to make concurrent requests while waiting for an event.
991    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<ViewEvent, fidl::Error> {
992        ViewEvent::decode(self.client.wait_for_event::<ViewMarker>(deadline)?)
993    }
994
995    /// Provides the View with an attachment point to Scenic's scene graph.
996    ///
997    /// When `Present()` is called the View's implementation should create a
998    /// View resource within Scenic by providing it with the `view_token` (using
999    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1000    ///
1001    /// Then the implementation should attach its graphical content to the
1002    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1003    ///
1004    /// If the implementation already owns a View resource (because `Present()`
1005    /// had already been called before), then it should terminate the connection
1006    /// with an error.
1007    ///
1008    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1009    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1010        self.client.send::<ViewPresentRequest>(
1011            (&mut view_token,),
1012            0x6e98ebc6c9de6d9e,
1013            fidl::encoding::DynamicFlags::empty(),
1014        )
1015    }
1016}
1017
1018#[cfg(target_os = "fuchsia")]
1019impl From<ViewSynchronousProxy> for zx::NullableHandle {
1020    fn from(value: ViewSynchronousProxy) -> Self {
1021        value.into_channel().into()
1022    }
1023}
1024
1025#[cfg(target_os = "fuchsia")]
1026impl From<fidl::Channel> for ViewSynchronousProxy {
1027    fn from(value: fidl::Channel) -> Self {
1028        Self::new(value)
1029    }
1030}
1031
1032#[cfg(target_os = "fuchsia")]
1033impl fidl::endpoints::FromClient for ViewSynchronousProxy {
1034    type Protocol = ViewMarker;
1035
1036    fn from_client(value: fidl::endpoints::ClientEnd<ViewMarker>) -> Self {
1037        Self::new(value.into_channel())
1038    }
1039}
1040
1041#[derive(Debug, Clone)]
1042pub struct ViewProxy {
1043    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1044}
1045
1046impl fidl::endpoints::Proxy for ViewProxy {
1047    type Protocol = ViewMarker;
1048
1049    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1050        Self::new(inner)
1051    }
1052
1053    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1054        self.client.into_channel().map_err(|client| Self { client })
1055    }
1056
1057    fn as_channel(&self) -> &::fidl::AsyncChannel {
1058        self.client.as_channel()
1059    }
1060}
1061
1062impl ViewProxy {
1063    /// Create a new Proxy for fuchsia.ui.views/View.
1064    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1065        let protocol_name = <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1066        Self { client: fidl::client::Client::new(channel, protocol_name) }
1067    }
1068
1069    /// Get a Stream of events from the remote end of the protocol.
1070    ///
1071    /// # Panics
1072    ///
1073    /// Panics if the event stream was already taken.
1074    pub fn take_event_stream(&self) -> ViewEventStream {
1075        ViewEventStream { event_receiver: self.client.take_event_receiver() }
1076    }
1077
1078    /// Provides the View with an attachment point to Scenic's scene graph.
1079    ///
1080    /// When `Present()` is called the View's implementation should create a
1081    /// View resource within Scenic by providing it with the `view_token` (using
1082    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1083    ///
1084    /// Then the implementation should attach its graphical content to the
1085    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1086    ///
1087    /// If the implementation already owns a View resource (because `Present()`
1088    /// had already been called before), then it should terminate the connection
1089    /// with an error.
1090    ///
1091    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1092    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1093        ViewProxyInterface::r#present(self, view_token)
1094    }
1095}
1096
1097impl ViewProxyInterface for ViewProxy {
1098    fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1099        self.client.send::<ViewPresentRequest>(
1100            (&mut view_token,),
1101            0x6e98ebc6c9de6d9e,
1102            fidl::encoding::DynamicFlags::empty(),
1103        )
1104    }
1105}
1106
1107pub struct ViewEventStream {
1108    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1109}
1110
1111impl std::marker::Unpin for ViewEventStream {}
1112
1113impl futures::stream::FusedStream for ViewEventStream {
1114    fn is_terminated(&self) -> bool {
1115        self.event_receiver.is_terminated()
1116    }
1117}
1118
1119impl futures::Stream for ViewEventStream {
1120    type Item = Result<ViewEvent, fidl::Error>;
1121
1122    fn poll_next(
1123        mut self: std::pin::Pin<&mut Self>,
1124        cx: &mut std::task::Context<'_>,
1125    ) -> std::task::Poll<Option<Self::Item>> {
1126        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1127            &mut self.event_receiver,
1128            cx
1129        )?) {
1130            Some(buf) => std::task::Poll::Ready(Some(ViewEvent::decode(buf))),
1131            None => std::task::Poll::Ready(None),
1132        }
1133    }
1134}
1135
1136#[derive(Debug)]
1137pub enum ViewEvent {}
1138
1139impl ViewEvent {
1140    /// Decodes a message buffer as a [`ViewEvent`].
1141    fn decode(
1142        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1143    ) -> Result<ViewEvent, fidl::Error> {
1144        let (bytes, _handles) = buf.split_mut();
1145        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1146        debug_assert_eq!(tx_header.tx_id, 0);
1147        match tx_header.ordinal {
1148            _ => Err(fidl::Error::UnknownOrdinal {
1149                ordinal: tx_header.ordinal,
1150                protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1151            }),
1152        }
1153    }
1154}
1155
1156/// A Stream of incoming requests for fuchsia.ui.views/View.
1157pub struct ViewRequestStream {
1158    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1159    is_terminated: bool,
1160}
1161
1162impl std::marker::Unpin for ViewRequestStream {}
1163
1164impl futures::stream::FusedStream for ViewRequestStream {
1165    fn is_terminated(&self) -> bool {
1166        self.is_terminated
1167    }
1168}
1169
1170impl fidl::endpoints::RequestStream for ViewRequestStream {
1171    type Protocol = ViewMarker;
1172    type ControlHandle = ViewControlHandle;
1173
1174    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1175        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1176    }
1177
1178    fn control_handle(&self) -> Self::ControlHandle {
1179        ViewControlHandle { inner: self.inner.clone() }
1180    }
1181
1182    fn into_inner(
1183        self,
1184    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1185    {
1186        (self.inner, self.is_terminated)
1187    }
1188
1189    fn from_inner(
1190        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1191        is_terminated: bool,
1192    ) -> Self {
1193        Self { inner, is_terminated }
1194    }
1195}
1196
1197impl futures::Stream for ViewRequestStream {
1198    type Item = Result<ViewRequest, fidl::Error>;
1199
1200    fn poll_next(
1201        mut self: std::pin::Pin<&mut Self>,
1202        cx: &mut std::task::Context<'_>,
1203    ) -> std::task::Poll<Option<Self::Item>> {
1204        let this = &mut *self;
1205        if this.inner.check_shutdown(cx) {
1206            this.is_terminated = true;
1207            return std::task::Poll::Ready(None);
1208        }
1209        if this.is_terminated {
1210            panic!("polled ViewRequestStream after completion");
1211        }
1212        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1213            |bytes, handles| {
1214                match this.inner.channel().read_etc(cx, bytes, handles) {
1215                    std::task::Poll::Ready(Ok(())) => {}
1216                    std::task::Poll::Pending => return std::task::Poll::Pending,
1217                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1218                        this.is_terminated = true;
1219                        return std::task::Poll::Ready(None);
1220                    }
1221                    std::task::Poll::Ready(Err(e)) => {
1222                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1223                            e.into(),
1224                        ))));
1225                    }
1226                }
1227
1228                // A message has been received from the channel
1229                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1230
1231                std::task::Poll::Ready(Some(match header.ordinal {
1232                    0x6e98ebc6c9de6d9e => {
1233                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1234                        let mut req = fidl::new_empty!(
1235                            ViewPresentRequest,
1236                            fidl::encoding::DefaultFuchsiaResourceDialect
1237                        );
1238                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewPresentRequest>(&header, _body_bytes, handles, &mut req)?;
1239                        let control_handle = ViewControlHandle { inner: this.inner.clone() };
1240                        Ok(ViewRequest::Present { view_token: req.view_token, control_handle })
1241                    }
1242                    _ => Err(fidl::Error::UnknownOrdinal {
1243                        ordinal: header.ordinal,
1244                        protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1245                    }),
1246                }))
1247            },
1248        )
1249    }
1250}
1251
1252/// Deprecated API for view creation. DO NOT USE.
1253#[derive(Debug)]
1254pub enum ViewRequest {
1255    /// Provides the View with an attachment point to Scenic's scene graph.
1256    ///
1257    /// When `Present()` is called the View's implementation should create a
1258    /// View resource within Scenic by providing it with the `view_token` (using
1259    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1260    ///
1261    /// Then the implementation should attach its graphical content to the
1262    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1263    ///
1264    /// If the implementation already owns a View resource (because `Present()`
1265    /// had already been called before), then it should terminate the connection
1266    /// with an error.
1267    ///
1268    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1269    Present { view_token: ViewToken, control_handle: ViewControlHandle },
1270}
1271
1272impl ViewRequest {
1273    #[allow(irrefutable_let_patterns)]
1274    pub fn into_present(self) -> Option<(ViewToken, ViewControlHandle)> {
1275        if let ViewRequest::Present { view_token, control_handle } = self {
1276            Some((view_token, control_handle))
1277        } else {
1278            None
1279        }
1280    }
1281
1282    /// Name of the method defined in FIDL
1283    pub fn method_name(&self) -> &'static str {
1284        match *self {
1285            ViewRequest::Present { .. } => "present",
1286        }
1287    }
1288}
1289
1290#[derive(Debug, Clone)]
1291pub struct ViewControlHandle {
1292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1293}
1294
1295impl fidl::endpoints::ControlHandle for ViewControlHandle {
1296    fn shutdown(&self) {
1297        self.inner.shutdown()
1298    }
1299
1300    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1301        self.inner.shutdown_with_epitaph(status)
1302    }
1303
1304    fn is_closed(&self) -> bool {
1305        self.inner.channel().is_closed()
1306    }
1307    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1308        self.inner.channel().on_closed()
1309    }
1310
1311    #[cfg(target_os = "fuchsia")]
1312    fn signal_peer(
1313        &self,
1314        clear_mask: zx::Signals,
1315        set_mask: zx::Signals,
1316    ) -> Result<(), zx_status::Status> {
1317        use fidl::Peered;
1318        self.inner.channel().signal_peer(clear_mask, set_mask)
1319    }
1320}
1321
1322impl ViewControlHandle {}
1323
1324#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1325pub struct ViewRefFocusedMarker;
1326
1327impl fidl::endpoints::ProtocolMarker for ViewRefFocusedMarker {
1328    type Proxy = ViewRefFocusedProxy;
1329    type RequestStream = ViewRefFocusedRequestStream;
1330    #[cfg(target_os = "fuchsia")]
1331    type SynchronousProxy = ViewRefFocusedSynchronousProxy;
1332
1333    const DEBUG_NAME: &'static str = "(anonymous) ViewRefFocused";
1334}
1335
1336pub trait ViewRefFocusedProxyInterface: Send + Sync {
1337    type WatchResponseFut: std::future::Future<Output = Result<FocusState, fidl::Error>> + Send;
1338    fn r#watch(&self) -> Self::WatchResponseFut;
1339}
1340#[derive(Debug)]
1341#[cfg(target_os = "fuchsia")]
1342pub struct ViewRefFocusedSynchronousProxy {
1343    client: fidl::client::sync::Client,
1344}
1345
1346#[cfg(target_os = "fuchsia")]
1347impl fidl::endpoints::SynchronousProxy for ViewRefFocusedSynchronousProxy {
1348    type Proxy = ViewRefFocusedProxy;
1349    type Protocol = ViewRefFocusedMarker;
1350
1351    fn from_channel(inner: fidl::Channel) -> Self {
1352        Self::new(inner)
1353    }
1354
1355    fn into_channel(self) -> fidl::Channel {
1356        self.client.into_channel()
1357    }
1358
1359    fn as_channel(&self) -> &fidl::Channel {
1360        self.client.as_channel()
1361    }
1362}
1363
1364#[cfg(target_os = "fuchsia")]
1365impl ViewRefFocusedSynchronousProxy {
1366    pub fn new(channel: fidl::Channel) -> Self {
1367        Self { client: fidl::client::sync::Client::new(channel) }
1368    }
1369
1370    pub fn into_channel(self) -> fidl::Channel {
1371        self.client.into_channel()
1372    }
1373
1374    /// Waits until an event arrives and returns it. It is safe for other
1375    /// threads to make concurrent requests while waiting for an event.
1376    pub fn wait_for_event(
1377        &self,
1378        deadline: zx::MonotonicInstant,
1379    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1380        ViewRefFocusedEvent::decode(self.client.wait_for_event::<ViewRefFocusedMarker>(deadline)?)
1381    }
1382
1383    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1384    /// focus. Typically, focus changes happen at a slow pace, such that every
1385    /// transition is captured by the callback. However, focus changes can
1386    /// happen rapidly, so the callback may "compress" focus change history into
1387    /// just the latest known focus state.
1388    ///
1389    /// The callback reports the last focus change spanning the duration from
1390    /// its issuance to the previous callback's issuance. The client may observe
1391    /// any of the following four transitions:
1392    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1393    ///   focus by the time of callback issuance.
1394    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1395    ///   focus by the time of callback issuance.
1396    /// - false -> true: The ViewRef has gained focus at least once, and has
1397    ///   gained focus by the time of callback issuance.
1398    /// - false -> false: The ViewRef has gained focus at least once, and has
1399    ///   lost focus by the time of callback issuance.
1400    ///
1401    /// The client avoids "focus flapping" and always sees the latest state.
1402    /// Every callback issuance is meaningful, and the client should renegotiate
1403    /// focus-related services appropriately, such as IME.
1404    ///
1405    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1406    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1407    /// returns. Non-compliance results in channel closure.
1408    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<FocusState, fidl::Error> {
1409        let _response = self.client.send_query::<
1410            fidl::encoding::EmptyPayload,
1411            ViewRefFocusedWatchResponse,
1412            ViewRefFocusedMarker,
1413        >(
1414            (),
1415            0x3c5e51096d9299b5,
1416            fidl::encoding::DynamicFlags::empty(),
1417            ___deadline,
1418        )?;
1419        Ok(_response.state)
1420    }
1421}
1422
1423#[cfg(target_os = "fuchsia")]
1424impl From<ViewRefFocusedSynchronousProxy> for zx::NullableHandle {
1425    fn from(value: ViewRefFocusedSynchronousProxy) -> Self {
1426        value.into_channel().into()
1427    }
1428}
1429
1430#[cfg(target_os = "fuchsia")]
1431impl From<fidl::Channel> for ViewRefFocusedSynchronousProxy {
1432    fn from(value: fidl::Channel) -> Self {
1433        Self::new(value)
1434    }
1435}
1436
1437#[cfg(target_os = "fuchsia")]
1438impl fidl::endpoints::FromClient for ViewRefFocusedSynchronousProxy {
1439    type Protocol = ViewRefFocusedMarker;
1440
1441    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefFocusedMarker>) -> Self {
1442        Self::new(value.into_channel())
1443    }
1444}
1445
1446#[derive(Debug, Clone)]
1447pub struct ViewRefFocusedProxy {
1448    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1449}
1450
1451impl fidl::endpoints::Proxy for ViewRefFocusedProxy {
1452    type Protocol = ViewRefFocusedMarker;
1453
1454    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1455        Self::new(inner)
1456    }
1457
1458    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1459        self.client.into_channel().map_err(|client| Self { client })
1460    }
1461
1462    fn as_channel(&self) -> &::fidl::AsyncChannel {
1463        self.client.as_channel()
1464    }
1465}
1466
1467impl ViewRefFocusedProxy {
1468    /// Create a new Proxy for fuchsia.ui.views/ViewRefFocused.
1469    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1470        let protocol_name = <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1471        Self { client: fidl::client::Client::new(channel, protocol_name) }
1472    }
1473
1474    /// Get a Stream of events from the remote end of the protocol.
1475    ///
1476    /// # Panics
1477    ///
1478    /// Panics if the event stream was already taken.
1479    pub fn take_event_stream(&self) -> ViewRefFocusedEventStream {
1480        ViewRefFocusedEventStream { event_receiver: self.client.take_event_receiver() }
1481    }
1482
1483    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1484    /// focus. Typically, focus changes happen at a slow pace, such that every
1485    /// transition is captured by the callback. However, focus changes can
1486    /// happen rapidly, so the callback may "compress" focus change history into
1487    /// just the latest known focus state.
1488    ///
1489    /// The callback reports the last focus change spanning the duration from
1490    /// its issuance to the previous callback's issuance. The client may observe
1491    /// any of the following four transitions:
1492    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1493    ///   focus by the time of callback issuance.
1494    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1495    ///   focus by the time of callback issuance.
1496    /// - false -> true: The ViewRef has gained focus at least once, and has
1497    ///   gained focus by the time of callback issuance.
1498    /// - false -> false: The ViewRef has gained focus at least once, and has
1499    ///   lost focus by the time of callback issuance.
1500    ///
1501    /// The client avoids "focus flapping" and always sees the latest state.
1502    /// Every callback issuance is meaningful, and the client should renegotiate
1503    /// focus-related services appropriately, such as IME.
1504    ///
1505    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1506    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1507    /// returns. Non-compliance results in channel closure.
1508    pub fn r#watch(
1509        &self,
1510    ) -> fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>
1511    {
1512        ViewRefFocusedProxyInterface::r#watch(self)
1513    }
1514}
1515
1516impl ViewRefFocusedProxyInterface for ViewRefFocusedProxy {
1517    type WatchResponseFut =
1518        fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>;
1519    fn r#watch(&self) -> Self::WatchResponseFut {
1520        fn _decode(
1521            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1522        ) -> Result<FocusState, fidl::Error> {
1523            let _response = fidl::client::decode_transaction_body::<
1524                ViewRefFocusedWatchResponse,
1525                fidl::encoding::DefaultFuchsiaResourceDialect,
1526                0x3c5e51096d9299b5,
1527            >(_buf?)?;
1528            Ok(_response.state)
1529        }
1530        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, FocusState>(
1531            (),
1532            0x3c5e51096d9299b5,
1533            fidl::encoding::DynamicFlags::empty(),
1534            _decode,
1535        )
1536    }
1537}
1538
1539pub struct ViewRefFocusedEventStream {
1540    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1541}
1542
1543impl std::marker::Unpin for ViewRefFocusedEventStream {}
1544
1545impl futures::stream::FusedStream for ViewRefFocusedEventStream {
1546    fn is_terminated(&self) -> bool {
1547        self.event_receiver.is_terminated()
1548    }
1549}
1550
1551impl futures::Stream for ViewRefFocusedEventStream {
1552    type Item = Result<ViewRefFocusedEvent, fidl::Error>;
1553
1554    fn poll_next(
1555        mut self: std::pin::Pin<&mut Self>,
1556        cx: &mut std::task::Context<'_>,
1557    ) -> std::task::Poll<Option<Self::Item>> {
1558        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1559            &mut self.event_receiver,
1560            cx
1561        )?) {
1562            Some(buf) => std::task::Poll::Ready(Some(ViewRefFocusedEvent::decode(buf))),
1563            None => std::task::Poll::Ready(None),
1564        }
1565    }
1566}
1567
1568#[derive(Debug)]
1569pub enum ViewRefFocusedEvent {}
1570
1571impl ViewRefFocusedEvent {
1572    /// Decodes a message buffer as a [`ViewRefFocusedEvent`].
1573    fn decode(
1574        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1575    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1576        let (bytes, _handles) = buf.split_mut();
1577        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1578        debug_assert_eq!(tx_header.tx_id, 0);
1579        match tx_header.ordinal {
1580            _ => Err(fidl::Error::UnknownOrdinal {
1581                ordinal: tx_header.ordinal,
1582                protocol_name:
1583                    <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1584            }),
1585        }
1586    }
1587}
1588
1589/// A Stream of incoming requests for fuchsia.ui.views/ViewRefFocused.
1590pub struct ViewRefFocusedRequestStream {
1591    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1592    is_terminated: bool,
1593}
1594
1595impl std::marker::Unpin for ViewRefFocusedRequestStream {}
1596
1597impl futures::stream::FusedStream for ViewRefFocusedRequestStream {
1598    fn is_terminated(&self) -> bool {
1599        self.is_terminated
1600    }
1601}
1602
1603impl fidl::endpoints::RequestStream for ViewRefFocusedRequestStream {
1604    type Protocol = ViewRefFocusedMarker;
1605    type ControlHandle = ViewRefFocusedControlHandle;
1606
1607    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1608        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1609    }
1610
1611    fn control_handle(&self) -> Self::ControlHandle {
1612        ViewRefFocusedControlHandle { inner: self.inner.clone() }
1613    }
1614
1615    fn into_inner(
1616        self,
1617    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1618    {
1619        (self.inner, self.is_terminated)
1620    }
1621
1622    fn from_inner(
1623        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1624        is_terminated: bool,
1625    ) -> Self {
1626        Self { inner, is_terminated }
1627    }
1628}
1629
1630impl futures::Stream for ViewRefFocusedRequestStream {
1631    type Item = Result<ViewRefFocusedRequest, fidl::Error>;
1632
1633    fn poll_next(
1634        mut self: std::pin::Pin<&mut Self>,
1635        cx: &mut std::task::Context<'_>,
1636    ) -> std::task::Poll<Option<Self::Item>> {
1637        let this = &mut *self;
1638        if this.inner.check_shutdown(cx) {
1639            this.is_terminated = true;
1640            return std::task::Poll::Ready(None);
1641        }
1642        if this.is_terminated {
1643            panic!("polled ViewRefFocusedRequestStream after completion");
1644        }
1645        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1646            |bytes, handles| {
1647                match this.inner.channel().read_etc(cx, bytes, handles) {
1648                    std::task::Poll::Ready(Ok(())) => {}
1649                    std::task::Poll::Pending => return std::task::Poll::Pending,
1650                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1651                        this.is_terminated = true;
1652                        return std::task::Poll::Ready(None);
1653                    }
1654                    std::task::Poll::Ready(Err(e)) => {
1655                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1656                            e.into(),
1657                        ))));
1658                    }
1659                }
1660
1661                // A message has been received from the channel
1662                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1663
1664                std::task::Poll::Ready(Some(match header.ordinal {
1665                    0x3c5e51096d9299b5 => {
1666                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1667                        let mut req = fidl::new_empty!(
1668                            fidl::encoding::EmptyPayload,
1669                            fidl::encoding::DefaultFuchsiaResourceDialect
1670                        );
1671                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1672                        let control_handle =
1673                            ViewRefFocusedControlHandle { inner: this.inner.clone() };
1674                        Ok(ViewRefFocusedRequest::Watch {
1675                            responder: ViewRefFocusedWatchResponder {
1676                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1677                                tx_id: header.tx_id,
1678                            },
1679                        })
1680                    }
1681                    _ => Err(fidl::Error::UnknownOrdinal {
1682                        ordinal: header.ordinal,
1683                        protocol_name:
1684                            <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1685                    }),
1686                }))
1687            },
1688        )
1689    }
1690}
1691
1692/// A method of enabling a ViewRef creator to determine if its ViewRef has
1693/// gained or lost focus in the view tree.
1694///
1695/// The protocol client has implicit access to the ViewRef it created; the
1696/// protocol itself does not accept a ViewRef parameter. Clients, both trusted
1697/// or otherwise, need access to view-focus state, so the protocol is
1698/// deliberately minimal. Possession of a ViewRef (and this protocol) does not
1699/// grant the power to learn about a ViewRef's focus state.
1700#[derive(Debug)]
1701pub enum ViewRefFocusedRequest {
1702    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1703    /// focus. Typically, focus changes happen at a slow pace, such that every
1704    /// transition is captured by the callback. However, focus changes can
1705    /// happen rapidly, so the callback may "compress" focus change history into
1706    /// just the latest known focus state.
1707    ///
1708    /// The callback reports the last focus change spanning the duration from
1709    /// its issuance to the previous callback's issuance. The client may observe
1710    /// any of the following four transitions:
1711    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1712    ///   focus by the time of callback issuance.
1713    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1714    ///   focus by the time of callback issuance.
1715    /// - false -> true: The ViewRef has gained focus at least once, and has
1716    ///   gained focus by the time of callback issuance.
1717    /// - false -> false: The ViewRef has gained focus at least once, and has
1718    ///   lost focus by the time of callback issuance.
1719    ///
1720    /// The client avoids "focus flapping" and always sees the latest state.
1721    /// Every callback issuance is meaningful, and the client should renegotiate
1722    /// focus-related services appropriately, such as IME.
1723    ///
1724    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1725    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1726    /// returns. Non-compliance results in channel closure.
1727    Watch { responder: ViewRefFocusedWatchResponder },
1728}
1729
1730impl ViewRefFocusedRequest {
1731    #[allow(irrefutable_let_patterns)]
1732    pub fn into_watch(self) -> Option<(ViewRefFocusedWatchResponder)> {
1733        if let ViewRefFocusedRequest::Watch { responder } = self { Some((responder)) } else { None }
1734    }
1735
1736    /// Name of the method defined in FIDL
1737    pub fn method_name(&self) -> &'static str {
1738        match *self {
1739            ViewRefFocusedRequest::Watch { .. } => "watch",
1740        }
1741    }
1742}
1743
1744#[derive(Debug, Clone)]
1745pub struct ViewRefFocusedControlHandle {
1746    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1747}
1748
1749impl fidl::endpoints::ControlHandle for ViewRefFocusedControlHandle {
1750    fn shutdown(&self) {
1751        self.inner.shutdown()
1752    }
1753
1754    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1755        self.inner.shutdown_with_epitaph(status)
1756    }
1757
1758    fn is_closed(&self) -> bool {
1759        self.inner.channel().is_closed()
1760    }
1761    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1762        self.inner.channel().on_closed()
1763    }
1764
1765    #[cfg(target_os = "fuchsia")]
1766    fn signal_peer(
1767        &self,
1768        clear_mask: zx::Signals,
1769        set_mask: zx::Signals,
1770    ) -> Result<(), zx_status::Status> {
1771        use fidl::Peered;
1772        self.inner.channel().signal_peer(clear_mask, set_mask)
1773    }
1774}
1775
1776impl ViewRefFocusedControlHandle {}
1777
1778#[must_use = "FIDL methods require a response to be sent"]
1779#[derive(Debug)]
1780pub struct ViewRefFocusedWatchResponder {
1781    control_handle: std::mem::ManuallyDrop<ViewRefFocusedControlHandle>,
1782    tx_id: u32,
1783}
1784
1785/// Set the the channel to be shutdown (see [`ViewRefFocusedControlHandle::shutdown`])
1786/// if the responder is dropped without sending a response, so that the client
1787/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1788impl std::ops::Drop for ViewRefFocusedWatchResponder {
1789    fn drop(&mut self) {
1790        self.control_handle.shutdown();
1791        // Safety: drops once, never accessed again
1792        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1793    }
1794}
1795
1796impl fidl::endpoints::Responder for ViewRefFocusedWatchResponder {
1797    type ControlHandle = ViewRefFocusedControlHandle;
1798
1799    fn control_handle(&self) -> &ViewRefFocusedControlHandle {
1800        &self.control_handle
1801    }
1802
1803    fn drop_without_shutdown(mut self) {
1804        // Safety: drops once, never accessed again due to mem::forget
1805        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1806        // Prevent Drop from running (which would shut down the channel)
1807        std::mem::forget(self);
1808    }
1809}
1810
1811impl ViewRefFocusedWatchResponder {
1812    /// Sends a response to the FIDL transaction.
1813    ///
1814    /// Sets the channel to shutdown if an error occurs.
1815    pub fn send(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1816        let _result = self.send_raw(state);
1817        if _result.is_err() {
1818            self.control_handle.shutdown();
1819        }
1820        self.drop_without_shutdown();
1821        _result
1822    }
1823
1824    /// Similar to "send" but does not shutdown the channel if an error occurs.
1825    pub fn send_no_shutdown_on_err(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1826        let _result = self.send_raw(state);
1827        self.drop_without_shutdown();
1828        _result
1829    }
1830
1831    fn send_raw(&self, mut state: &FocusState) -> Result<(), fidl::Error> {
1832        self.control_handle.inner.send::<ViewRefFocusedWatchResponse>(
1833            (state,),
1834            self.tx_id,
1835            0x3c5e51096d9299b5,
1836            fidl::encoding::DynamicFlags::empty(),
1837        )
1838    }
1839}
1840
1841#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1842pub struct ViewRefInstalledMarker;
1843
1844impl fidl::endpoints::ProtocolMarker for ViewRefInstalledMarker {
1845    type Proxy = ViewRefInstalledProxy;
1846    type RequestStream = ViewRefInstalledRequestStream;
1847    #[cfg(target_os = "fuchsia")]
1848    type SynchronousProxy = ViewRefInstalledSynchronousProxy;
1849
1850    const DEBUG_NAME: &'static str = "fuchsia.ui.views.ViewRefInstalled";
1851}
1852impl fidl::endpoints::DiscoverableProtocolMarker for ViewRefInstalledMarker {}
1853pub type ViewRefInstalledWatchResult = Result<(), ViewRefInstalledError>;
1854
1855pub trait ViewRefInstalledProxyInterface: Send + Sync {
1856    type WatchResponseFut: std::future::Future<Output = Result<ViewRefInstalledWatchResult, fidl::Error>>
1857        + Send;
1858    fn r#watch(&self, view_ref: ViewRef) -> Self::WatchResponseFut;
1859}
1860#[derive(Debug)]
1861#[cfg(target_os = "fuchsia")]
1862pub struct ViewRefInstalledSynchronousProxy {
1863    client: fidl::client::sync::Client,
1864}
1865
1866#[cfg(target_os = "fuchsia")]
1867impl fidl::endpoints::SynchronousProxy for ViewRefInstalledSynchronousProxy {
1868    type Proxy = ViewRefInstalledProxy;
1869    type Protocol = ViewRefInstalledMarker;
1870
1871    fn from_channel(inner: fidl::Channel) -> Self {
1872        Self::new(inner)
1873    }
1874
1875    fn into_channel(self) -> fidl::Channel {
1876        self.client.into_channel()
1877    }
1878
1879    fn as_channel(&self) -> &fidl::Channel {
1880        self.client.as_channel()
1881    }
1882}
1883
1884#[cfg(target_os = "fuchsia")]
1885impl ViewRefInstalledSynchronousProxy {
1886    pub fn new(channel: fidl::Channel) -> Self {
1887        Self { client: fidl::client::sync::Client::new(channel) }
1888    }
1889
1890    pub fn into_channel(self) -> fidl::Channel {
1891        self.client.into_channel()
1892    }
1893
1894    /// Waits until an event arrives and returns it. It is safe for other
1895    /// threads to make concurrent requests while waiting for an event.
1896    pub fn wait_for_event(
1897        &self,
1898        deadline: zx::MonotonicInstant,
1899    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
1900        ViewRefInstalledEvent::decode(
1901            self.client.wait_for_event::<ViewRefInstalledMarker>(deadline)?,
1902        )
1903    }
1904
1905    /// Sets up a callback to fire when the requested |view_ref| is installed.
1906    /// - If |view_ref| has not already been installed, the |Watch| response
1907    ///   will fire when it is.
1908    /// - If |view_ref| has already been installed, the |Watch| response will
1909    ///   fire immediately.
1910    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
1911    ///   was destroyed), the |Watch| call returns with an error.  The error is
1912    ///   not guaranteed to be immediate, but a ViewRef holder can itself
1913    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
1914    ///
1915    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
1916    /// ViewRefs. There is at most one response per call back to the client.
1917    ///
1918    /// Note: Prior to installation, this |Watch| call is kept alive as long as
1919    ///       the ViewRef is valid.
1920    pub fn r#watch(
1921        &self,
1922        mut view_ref: ViewRef,
1923        ___deadline: zx::MonotonicInstant,
1924    ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
1925        let _response =
1926            self.client.send_query::<ViewRefInstalledWatchRequest, fidl::encoding::ResultType<
1927                fidl::encoding::EmptyStruct,
1928                ViewRefInstalledError,
1929            >, ViewRefInstalledMarker>(
1930                (&mut view_ref,),
1931                0x7ddec2f4ca687971,
1932                fidl::encoding::DynamicFlags::empty(),
1933                ___deadline,
1934            )?;
1935        Ok(_response.map(|x| x))
1936    }
1937}
1938
1939#[cfg(target_os = "fuchsia")]
1940impl From<ViewRefInstalledSynchronousProxy> for zx::NullableHandle {
1941    fn from(value: ViewRefInstalledSynchronousProxy) -> Self {
1942        value.into_channel().into()
1943    }
1944}
1945
1946#[cfg(target_os = "fuchsia")]
1947impl From<fidl::Channel> for ViewRefInstalledSynchronousProxy {
1948    fn from(value: fidl::Channel) -> Self {
1949        Self::new(value)
1950    }
1951}
1952
1953#[cfg(target_os = "fuchsia")]
1954impl fidl::endpoints::FromClient for ViewRefInstalledSynchronousProxy {
1955    type Protocol = ViewRefInstalledMarker;
1956
1957    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefInstalledMarker>) -> Self {
1958        Self::new(value.into_channel())
1959    }
1960}
1961
1962#[derive(Debug, Clone)]
1963pub struct ViewRefInstalledProxy {
1964    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1965}
1966
1967impl fidl::endpoints::Proxy for ViewRefInstalledProxy {
1968    type Protocol = ViewRefInstalledMarker;
1969
1970    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1971        Self::new(inner)
1972    }
1973
1974    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1975        self.client.into_channel().map_err(|client| Self { client })
1976    }
1977
1978    fn as_channel(&self) -> &::fidl::AsyncChannel {
1979        self.client.as_channel()
1980    }
1981}
1982
1983impl ViewRefInstalledProxy {
1984    /// Create a new Proxy for fuchsia.ui.views/ViewRefInstalled.
1985    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1986        let protocol_name = <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1987        Self { client: fidl::client::Client::new(channel, protocol_name) }
1988    }
1989
1990    /// Get a Stream of events from the remote end of the protocol.
1991    ///
1992    /// # Panics
1993    ///
1994    /// Panics if the event stream was already taken.
1995    pub fn take_event_stream(&self) -> ViewRefInstalledEventStream {
1996        ViewRefInstalledEventStream { event_receiver: self.client.take_event_receiver() }
1997    }
1998
1999    /// Sets up a callback to fire when the requested |view_ref| is installed.
2000    /// - If |view_ref| has not already been installed, the |Watch| response
2001    ///   will fire when it is.
2002    /// - If |view_ref| has already been installed, the |Watch| response will
2003    ///   fire immediately.
2004    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2005    ///   was destroyed), the |Watch| call returns with an error.  The error is
2006    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2007    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2008    ///
2009    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2010    /// ViewRefs. There is at most one response per call back to the client.
2011    ///
2012    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2013    ///       the ViewRef is valid.
2014    pub fn r#watch(
2015        &self,
2016        mut view_ref: ViewRef,
2017    ) -> fidl::client::QueryResponseFut<
2018        ViewRefInstalledWatchResult,
2019        fidl::encoding::DefaultFuchsiaResourceDialect,
2020    > {
2021        ViewRefInstalledProxyInterface::r#watch(self, view_ref)
2022    }
2023}
2024
2025impl ViewRefInstalledProxyInterface for ViewRefInstalledProxy {
2026    type WatchResponseFut = fidl::client::QueryResponseFut<
2027        ViewRefInstalledWatchResult,
2028        fidl::encoding::DefaultFuchsiaResourceDialect,
2029    >;
2030    fn r#watch(&self, mut view_ref: ViewRef) -> Self::WatchResponseFut {
2031        fn _decode(
2032            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2033        ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
2034            let _response = fidl::client::decode_transaction_body::<
2035                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ViewRefInstalledError>,
2036                fidl::encoding::DefaultFuchsiaResourceDialect,
2037                0x7ddec2f4ca687971,
2038            >(_buf?)?;
2039            Ok(_response.map(|x| x))
2040        }
2041        self.client
2042            .send_query_and_decode::<ViewRefInstalledWatchRequest, ViewRefInstalledWatchResult>(
2043                (&mut view_ref,),
2044                0x7ddec2f4ca687971,
2045                fidl::encoding::DynamicFlags::empty(),
2046                _decode,
2047            )
2048    }
2049}
2050
2051pub struct ViewRefInstalledEventStream {
2052    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2053}
2054
2055impl std::marker::Unpin for ViewRefInstalledEventStream {}
2056
2057impl futures::stream::FusedStream for ViewRefInstalledEventStream {
2058    fn is_terminated(&self) -> bool {
2059        self.event_receiver.is_terminated()
2060    }
2061}
2062
2063impl futures::Stream for ViewRefInstalledEventStream {
2064    type Item = Result<ViewRefInstalledEvent, fidl::Error>;
2065
2066    fn poll_next(
2067        mut self: std::pin::Pin<&mut Self>,
2068        cx: &mut std::task::Context<'_>,
2069    ) -> std::task::Poll<Option<Self::Item>> {
2070        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2071            &mut self.event_receiver,
2072            cx
2073        )?) {
2074            Some(buf) => std::task::Poll::Ready(Some(ViewRefInstalledEvent::decode(buf))),
2075            None => std::task::Poll::Ready(None),
2076        }
2077    }
2078}
2079
2080#[derive(Debug)]
2081pub enum ViewRefInstalledEvent {}
2082
2083impl ViewRefInstalledEvent {
2084    /// Decodes a message buffer as a [`ViewRefInstalledEvent`].
2085    fn decode(
2086        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2087    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
2088        let (bytes, _handles) = buf.split_mut();
2089        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2090        debug_assert_eq!(tx_header.tx_id, 0);
2091        match tx_header.ordinal {
2092            _ => Err(fidl::Error::UnknownOrdinal {
2093                ordinal: tx_header.ordinal,
2094                protocol_name:
2095                    <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2096            }),
2097        }
2098    }
2099}
2100
2101/// A Stream of incoming requests for fuchsia.ui.views/ViewRefInstalled.
2102pub struct ViewRefInstalledRequestStream {
2103    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2104    is_terminated: bool,
2105}
2106
2107impl std::marker::Unpin for ViewRefInstalledRequestStream {}
2108
2109impl futures::stream::FusedStream for ViewRefInstalledRequestStream {
2110    fn is_terminated(&self) -> bool {
2111        self.is_terminated
2112    }
2113}
2114
2115impl fidl::endpoints::RequestStream for ViewRefInstalledRequestStream {
2116    type Protocol = ViewRefInstalledMarker;
2117    type ControlHandle = ViewRefInstalledControlHandle;
2118
2119    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2120        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2121    }
2122
2123    fn control_handle(&self) -> Self::ControlHandle {
2124        ViewRefInstalledControlHandle { inner: self.inner.clone() }
2125    }
2126
2127    fn into_inner(
2128        self,
2129    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2130    {
2131        (self.inner, self.is_terminated)
2132    }
2133
2134    fn from_inner(
2135        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2136        is_terminated: bool,
2137    ) -> Self {
2138        Self { inner, is_terminated }
2139    }
2140}
2141
2142impl futures::Stream for ViewRefInstalledRequestStream {
2143    type Item = Result<ViewRefInstalledRequest, fidl::Error>;
2144
2145    fn poll_next(
2146        mut self: std::pin::Pin<&mut Self>,
2147        cx: &mut std::task::Context<'_>,
2148    ) -> std::task::Poll<Option<Self::Item>> {
2149        let this = &mut *self;
2150        if this.inner.check_shutdown(cx) {
2151            this.is_terminated = true;
2152            return std::task::Poll::Ready(None);
2153        }
2154        if this.is_terminated {
2155            panic!("polled ViewRefInstalledRequestStream after completion");
2156        }
2157        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2158            |bytes, handles| {
2159                match this.inner.channel().read_etc(cx, bytes, handles) {
2160                    std::task::Poll::Ready(Ok(())) => {}
2161                    std::task::Poll::Pending => return std::task::Poll::Pending,
2162                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2163                        this.is_terminated = true;
2164                        return std::task::Poll::Ready(None);
2165                    }
2166                    std::task::Poll::Ready(Err(e)) => {
2167                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2168                            e.into(),
2169                        ))));
2170                    }
2171                }
2172
2173                // A message has been received from the channel
2174                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2175
2176                std::task::Poll::Ready(Some(match header.ordinal {
2177                    0x7ddec2f4ca687971 => {
2178                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2179                        let mut req = fidl::new_empty!(
2180                            ViewRefInstalledWatchRequest,
2181                            fidl::encoding::DefaultFuchsiaResourceDialect
2182                        );
2183                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewRefInstalledWatchRequest>(&header, _body_bytes, handles, &mut req)?;
2184                        let control_handle =
2185                            ViewRefInstalledControlHandle { inner: this.inner.clone() };
2186                        Ok(ViewRefInstalledRequest::Watch {
2187                            view_ref: req.view_ref,
2188
2189                            responder: ViewRefInstalledWatchResponder {
2190                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2191                                tx_id: header.tx_id,
2192                            },
2193                        })
2194                    }
2195                    _ => Err(fidl::Error::UnknownOrdinal {
2196                        ordinal: header.ordinal,
2197                        protocol_name:
2198                            <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2199                    }),
2200                }))
2201            },
2202        )
2203    }
2204}
2205
2206/// A method of enabling ViewRef holders to determine if a ViewRef has been
2207/// "installed" in the view tree: the time it is first connected, transitively,
2208/// to the root view.  Typically, after installation, view focus may be
2209/// transferred to that ViewRef.
2210///
2211/// Note: It's important to distinguish between a ViewRef's installed status and
2212///       current connected-to-view-tree status.  The former undergoes a state
2213///       change once, from "no" to "yes".  The latter may change continuously,
2214///       depending on view tree topology.  As such, "installed" cannot imply
2215///       "currently connected to view tree"; even a hypothetical
2216///       "ViewRefConnected" protocol is fundamentally racy.
2217#[derive(Debug)]
2218pub enum ViewRefInstalledRequest {
2219    /// Sets up a callback to fire when the requested |view_ref| is installed.
2220    /// - If |view_ref| has not already been installed, the |Watch| response
2221    ///   will fire when it is.
2222    /// - If |view_ref| has already been installed, the |Watch| response will
2223    ///   fire immediately.
2224    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2225    ///   was destroyed), the |Watch| call returns with an error.  The error is
2226    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2227    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2228    ///
2229    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2230    /// ViewRefs. There is at most one response per call back to the client.
2231    ///
2232    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2233    ///       the ViewRef is valid.
2234    Watch { view_ref: ViewRef, responder: ViewRefInstalledWatchResponder },
2235}
2236
2237impl ViewRefInstalledRequest {
2238    #[allow(irrefutable_let_patterns)]
2239    pub fn into_watch(self) -> Option<(ViewRef, ViewRefInstalledWatchResponder)> {
2240        if let ViewRefInstalledRequest::Watch { view_ref, responder } = self {
2241            Some((view_ref, responder))
2242        } else {
2243            None
2244        }
2245    }
2246
2247    /// Name of the method defined in FIDL
2248    pub fn method_name(&self) -> &'static str {
2249        match *self {
2250            ViewRefInstalledRequest::Watch { .. } => "watch",
2251        }
2252    }
2253}
2254
2255#[derive(Debug, Clone)]
2256pub struct ViewRefInstalledControlHandle {
2257    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2258}
2259
2260impl fidl::endpoints::ControlHandle for ViewRefInstalledControlHandle {
2261    fn shutdown(&self) {
2262        self.inner.shutdown()
2263    }
2264
2265    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2266        self.inner.shutdown_with_epitaph(status)
2267    }
2268
2269    fn is_closed(&self) -> bool {
2270        self.inner.channel().is_closed()
2271    }
2272    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2273        self.inner.channel().on_closed()
2274    }
2275
2276    #[cfg(target_os = "fuchsia")]
2277    fn signal_peer(
2278        &self,
2279        clear_mask: zx::Signals,
2280        set_mask: zx::Signals,
2281    ) -> Result<(), zx_status::Status> {
2282        use fidl::Peered;
2283        self.inner.channel().signal_peer(clear_mask, set_mask)
2284    }
2285}
2286
2287impl ViewRefInstalledControlHandle {}
2288
2289#[must_use = "FIDL methods require a response to be sent"]
2290#[derive(Debug)]
2291pub struct ViewRefInstalledWatchResponder {
2292    control_handle: std::mem::ManuallyDrop<ViewRefInstalledControlHandle>,
2293    tx_id: u32,
2294}
2295
2296/// Set the the channel to be shutdown (see [`ViewRefInstalledControlHandle::shutdown`])
2297/// if the responder is dropped without sending a response, so that the client
2298/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2299impl std::ops::Drop for ViewRefInstalledWatchResponder {
2300    fn drop(&mut self) {
2301        self.control_handle.shutdown();
2302        // Safety: drops once, never accessed again
2303        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2304    }
2305}
2306
2307impl fidl::endpoints::Responder for ViewRefInstalledWatchResponder {
2308    type ControlHandle = ViewRefInstalledControlHandle;
2309
2310    fn control_handle(&self) -> &ViewRefInstalledControlHandle {
2311        &self.control_handle
2312    }
2313
2314    fn drop_without_shutdown(mut self) {
2315        // Safety: drops once, never accessed again due to mem::forget
2316        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2317        // Prevent Drop from running (which would shut down the channel)
2318        std::mem::forget(self);
2319    }
2320}
2321
2322impl ViewRefInstalledWatchResponder {
2323    /// Sends a response to the FIDL transaction.
2324    ///
2325    /// Sets the channel to shutdown if an error occurs.
2326    pub fn send(self, mut result: Result<(), ViewRefInstalledError>) -> Result<(), fidl::Error> {
2327        let _result = self.send_raw(result);
2328        if _result.is_err() {
2329            self.control_handle.shutdown();
2330        }
2331        self.drop_without_shutdown();
2332        _result
2333    }
2334
2335    /// Similar to "send" but does not shutdown the channel if an error occurs.
2336    pub fn send_no_shutdown_on_err(
2337        self,
2338        mut result: Result<(), ViewRefInstalledError>,
2339    ) -> Result<(), fidl::Error> {
2340        let _result = self.send_raw(result);
2341        self.drop_without_shutdown();
2342        _result
2343    }
2344
2345    fn send_raw(&self, mut result: Result<(), ViewRefInstalledError>) -> Result<(), fidl::Error> {
2346        self.control_handle.inner.send::<fidl::encoding::ResultType<
2347            fidl::encoding::EmptyStruct,
2348            ViewRefInstalledError,
2349        >>(
2350            result,
2351            self.tx_id,
2352            0x7ddec2f4ca687971,
2353            fidl::encoding::DynamicFlags::empty(),
2354        )
2355    }
2356}
2357
2358mod internal {
2359    use super::*;
2360
2361    impl fidl::encoding::ResourceTypeMarker for FocuserRequestFocusRequest {
2362        type Borrowed<'a> = &'a mut Self;
2363        fn take_or_borrow<'a>(
2364            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2365        ) -> Self::Borrowed<'a> {
2366            value
2367        }
2368    }
2369
2370    unsafe impl fidl::encoding::TypeMarker for FocuserRequestFocusRequest {
2371        type Owned = Self;
2372
2373        #[inline(always)]
2374        fn inline_align(_context: fidl::encoding::Context) -> usize {
2375            4
2376        }
2377
2378        #[inline(always)]
2379        fn inline_size(_context: fidl::encoding::Context) -> usize {
2380            4
2381        }
2382    }
2383
2384    unsafe impl
2385        fidl::encoding::Encode<
2386            FocuserRequestFocusRequest,
2387            fidl::encoding::DefaultFuchsiaResourceDialect,
2388        > for &mut FocuserRequestFocusRequest
2389    {
2390        #[inline]
2391        unsafe fn encode(
2392            self,
2393            encoder: &mut fidl::encoding::Encoder<
2394                '_,
2395                fidl::encoding::DefaultFuchsiaResourceDialect,
2396            >,
2397            offset: usize,
2398            _depth: fidl::encoding::Depth,
2399        ) -> fidl::Result<()> {
2400            encoder.debug_check_bounds::<FocuserRequestFocusRequest>(offset);
2401            // Delegate to tuple encoding.
2402            fidl::encoding::Encode::<
2403                FocuserRequestFocusRequest,
2404                fidl::encoding::DefaultFuchsiaResourceDialect,
2405            >::encode(
2406                (<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2407                    &mut self.view_ref,
2408                ),),
2409                encoder,
2410                offset,
2411                _depth,
2412            )
2413        }
2414    }
2415    unsafe impl<T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>>
2416        fidl::encoding::Encode<
2417            FocuserRequestFocusRequest,
2418            fidl::encoding::DefaultFuchsiaResourceDialect,
2419        > for (T0,)
2420    {
2421        #[inline]
2422        unsafe fn encode(
2423            self,
2424            encoder: &mut fidl::encoding::Encoder<
2425                '_,
2426                fidl::encoding::DefaultFuchsiaResourceDialect,
2427            >,
2428            offset: usize,
2429            depth: fidl::encoding::Depth,
2430        ) -> fidl::Result<()> {
2431            encoder.debug_check_bounds::<FocuserRequestFocusRequest>(offset);
2432            // Zero out padding regions. There's no need to apply masks
2433            // because the unmasked parts will be overwritten by fields.
2434            // Write the fields.
2435            self.0.encode(encoder, offset + 0, depth)?;
2436            Ok(())
2437        }
2438    }
2439
2440    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2441        for FocuserRequestFocusRequest
2442    {
2443        #[inline(always)]
2444        fn new_empty() -> Self {
2445            Self {
2446                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
2447            }
2448        }
2449
2450        #[inline]
2451        unsafe fn decode(
2452            &mut self,
2453            decoder: &mut fidl::encoding::Decoder<
2454                '_,
2455                fidl::encoding::DefaultFuchsiaResourceDialect,
2456            >,
2457            offset: usize,
2458            _depth: fidl::encoding::Depth,
2459        ) -> fidl::Result<()> {
2460            decoder.debug_check_bounds::<Self>(offset);
2461            // Verify that padding bytes are zero.
2462            fidl::decode!(
2463                ViewRef,
2464                fidl::encoding::DefaultFuchsiaResourceDialect,
2465                &mut self.view_ref,
2466                decoder,
2467                offset + 0,
2468                _depth
2469            )?;
2470            Ok(())
2471        }
2472    }
2473
2474    impl fidl::encoding::ResourceTypeMarker for ViewCreationToken {
2475        type Borrowed<'a> = &'a mut Self;
2476        fn take_or_borrow<'a>(
2477            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2478        ) -> Self::Borrowed<'a> {
2479            value
2480        }
2481    }
2482
2483    unsafe impl fidl::encoding::TypeMarker for ViewCreationToken {
2484        type Owned = Self;
2485
2486        #[inline(always)]
2487        fn inline_align(_context: fidl::encoding::Context) -> usize {
2488            4
2489        }
2490
2491        #[inline(always)]
2492        fn inline_size(_context: fidl::encoding::Context) -> usize {
2493            4
2494        }
2495    }
2496
2497    unsafe impl
2498        fidl::encoding::Encode<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2499        for &mut ViewCreationToken
2500    {
2501        #[inline]
2502        unsafe fn encode(
2503            self,
2504            encoder: &mut fidl::encoding::Encoder<
2505                '_,
2506                fidl::encoding::DefaultFuchsiaResourceDialect,
2507            >,
2508            offset: usize,
2509            _depth: fidl::encoding::Depth,
2510        ) -> fidl::Result<()> {
2511            encoder.debug_check_bounds::<ViewCreationToken>(offset);
2512            // Delegate to tuple encoding.
2513            fidl::encoding::Encode::<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2514                (
2515                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
2516                ),
2517                encoder, offset, _depth
2518            )
2519        }
2520    }
2521    unsafe impl<
2522        T0: fidl::encoding::Encode<
2523                fidl::encoding::HandleType<
2524                    fidl::Channel,
2525                    { fidl::ObjectType::CHANNEL.into_raw() },
2526                    2147483648,
2527                >,
2528                fidl::encoding::DefaultFuchsiaResourceDialect,
2529            >,
2530    > fidl::encoding::Encode<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2531        for (T0,)
2532    {
2533        #[inline]
2534        unsafe fn encode(
2535            self,
2536            encoder: &mut fidl::encoding::Encoder<
2537                '_,
2538                fidl::encoding::DefaultFuchsiaResourceDialect,
2539            >,
2540            offset: usize,
2541            depth: fidl::encoding::Depth,
2542        ) -> fidl::Result<()> {
2543            encoder.debug_check_bounds::<ViewCreationToken>(offset);
2544            // Zero out padding regions. There's no need to apply masks
2545            // because the unmasked parts will be overwritten by fields.
2546            // Write the fields.
2547            self.0.encode(encoder, offset + 0, depth)?;
2548            Ok(())
2549        }
2550    }
2551
2552    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2553        for ViewCreationToken
2554    {
2555        #[inline(always)]
2556        fn new_empty() -> Self {
2557            Self {
2558                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2559            }
2560        }
2561
2562        #[inline]
2563        unsafe fn decode(
2564            &mut self,
2565            decoder: &mut fidl::encoding::Decoder<
2566                '_,
2567                fidl::encoding::DefaultFuchsiaResourceDialect,
2568            >,
2569            offset: usize,
2570            _depth: fidl::encoding::Depth,
2571        ) -> fidl::Result<()> {
2572            decoder.debug_check_bounds::<Self>(offset);
2573            // Verify that padding bytes are zero.
2574            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2575            Ok(())
2576        }
2577    }
2578
2579    impl fidl::encoding::ResourceTypeMarker for ViewHolderToken {
2580        type Borrowed<'a> = &'a mut Self;
2581        fn take_or_borrow<'a>(
2582            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2583        ) -> Self::Borrowed<'a> {
2584            value
2585        }
2586    }
2587
2588    unsafe impl fidl::encoding::TypeMarker for ViewHolderToken {
2589        type Owned = Self;
2590
2591        #[inline(always)]
2592        fn inline_align(_context: fidl::encoding::Context) -> usize {
2593            4
2594        }
2595
2596        #[inline(always)]
2597        fn inline_size(_context: fidl::encoding::Context) -> usize {
2598            4
2599        }
2600    }
2601
2602    unsafe impl
2603        fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2604        for &mut ViewHolderToken
2605    {
2606        #[inline]
2607        unsafe fn encode(
2608            self,
2609            encoder: &mut fidl::encoding::Encoder<
2610                '_,
2611                fidl::encoding::DefaultFuchsiaResourceDialect,
2612            >,
2613            offset: usize,
2614            _depth: fidl::encoding::Depth,
2615        ) -> fidl::Result<()> {
2616            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2617            // Delegate to tuple encoding.
2618            fidl::encoding::Encode::<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2619                (
2620                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
2621                ),
2622                encoder, offset, _depth
2623            )
2624        }
2625    }
2626    unsafe impl<
2627        T0: fidl::encoding::Encode<
2628                fidl::encoding::HandleType<
2629                    fidl::EventPair,
2630                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2631                    2147483648,
2632                >,
2633                fidl::encoding::DefaultFuchsiaResourceDialect,
2634            >,
2635    > fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2636        for (T0,)
2637    {
2638        #[inline]
2639        unsafe fn encode(
2640            self,
2641            encoder: &mut fidl::encoding::Encoder<
2642                '_,
2643                fidl::encoding::DefaultFuchsiaResourceDialect,
2644            >,
2645            offset: usize,
2646            depth: fidl::encoding::Depth,
2647        ) -> fidl::Result<()> {
2648            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2649            // Zero out padding regions. There's no need to apply masks
2650            // because the unmasked parts will be overwritten by fields.
2651            // Write the fields.
2652            self.0.encode(encoder, offset + 0, depth)?;
2653            Ok(())
2654        }
2655    }
2656
2657    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2658        for ViewHolderToken
2659    {
2660        #[inline(always)]
2661        fn new_empty() -> Self {
2662            Self {
2663                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2664            }
2665        }
2666
2667        #[inline]
2668        unsafe fn decode(
2669            &mut self,
2670            decoder: &mut fidl::encoding::Decoder<
2671                '_,
2672                fidl::encoding::DefaultFuchsiaResourceDialect,
2673            >,
2674            offset: usize,
2675            _depth: fidl::encoding::Depth,
2676        ) -> fidl::Result<()> {
2677            decoder.debug_check_bounds::<Self>(offset);
2678            // Verify that padding bytes are zero.
2679            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2680            Ok(())
2681        }
2682    }
2683
2684    impl fidl::encoding::ResourceTypeMarker for ViewIdentityOnCreation {
2685        type Borrowed<'a> = &'a mut Self;
2686        fn take_or_borrow<'a>(
2687            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2688        ) -> Self::Borrowed<'a> {
2689            value
2690        }
2691    }
2692
2693    unsafe impl fidl::encoding::TypeMarker for ViewIdentityOnCreation {
2694        type Owned = Self;
2695
2696        #[inline(always)]
2697        fn inline_align(_context: fidl::encoding::Context) -> usize {
2698            4
2699        }
2700
2701        #[inline(always)]
2702        fn inline_size(_context: fidl::encoding::Context) -> usize {
2703            8
2704        }
2705    }
2706
2707    unsafe impl
2708        fidl::encoding::Encode<
2709            ViewIdentityOnCreation,
2710            fidl::encoding::DefaultFuchsiaResourceDialect,
2711        > for &mut ViewIdentityOnCreation
2712    {
2713        #[inline]
2714        unsafe fn encode(
2715            self,
2716            encoder: &mut fidl::encoding::Encoder<
2717                '_,
2718                fidl::encoding::DefaultFuchsiaResourceDialect,
2719            >,
2720            offset: usize,
2721            _depth: fidl::encoding::Depth,
2722        ) -> fidl::Result<()> {
2723            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2724            // Delegate to tuple encoding.
2725            fidl::encoding::Encode::<
2726                ViewIdentityOnCreation,
2727                fidl::encoding::DefaultFuchsiaResourceDialect,
2728            >::encode(
2729                (
2730                    <ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2731                        &mut self.view_ref,
2732                    ),
2733                    <ViewRefControl as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2734                        &mut self.view_ref_control,
2735                    ),
2736                ),
2737                encoder,
2738                offset,
2739                _depth,
2740            )
2741        }
2742    }
2743    unsafe impl<
2744        T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>,
2745        T1: fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>,
2746    >
2747        fidl::encoding::Encode<
2748            ViewIdentityOnCreation,
2749            fidl::encoding::DefaultFuchsiaResourceDialect,
2750        > for (T0, T1)
2751    {
2752        #[inline]
2753        unsafe fn encode(
2754            self,
2755            encoder: &mut fidl::encoding::Encoder<
2756                '_,
2757                fidl::encoding::DefaultFuchsiaResourceDialect,
2758            >,
2759            offset: usize,
2760            depth: fidl::encoding::Depth,
2761        ) -> fidl::Result<()> {
2762            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2763            // Zero out padding regions. There's no need to apply masks
2764            // because the unmasked parts will be overwritten by fields.
2765            // Write the fields.
2766            self.0.encode(encoder, offset + 0, depth)?;
2767            self.1.encode(encoder, offset + 4, depth)?;
2768            Ok(())
2769        }
2770    }
2771
2772    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2773        for ViewIdentityOnCreation
2774    {
2775        #[inline(always)]
2776        fn new_empty() -> Self {
2777            Self {
2778                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
2779                view_ref_control: fidl::new_empty!(
2780                    ViewRefControl,
2781                    fidl::encoding::DefaultFuchsiaResourceDialect
2782                ),
2783            }
2784        }
2785
2786        #[inline]
2787        unsafe fn decode(
2788            &mut self,
2789            decoder: &mut fidl::encoding::Decoder<
2790                '_,
2791                fidl::encoding::DefaultFuchsiaResourceDialect,
2792            >,
2793            offset: usize,
2794            _depth: fidl::encoding::Depth,
2795        ) -> fidl::Result<()> {
2796            decoder.debug_check_bounds::<Self>(offset);
2797            // Verify that padding bytes are zero.
2798            fidl::decode!(
2799                ViewRef,
2800                fidl::encoding::DefaultFuchsiaResourceDialect,
2801                &mut self.view_ref,
2802                decoder,
2803                offset + 0,
2804                _depth
2805            )?;
2806            fidl::decode!(
2807                ViewRefControl,
2808                fidl::encoding::DefaultFuchsiaResourceDialect,
2809                &mut self.view_ref_control,
2810                decoder,
2811                offset + 4,
2812                _depth
2813            )?;
2814            Ok(())
2815        }
2816    }
2817
2818    impl fidl::encoding::ResourceTypeMarker for ViewPresentRequest {
2819        type Borrowed<'a> = &'a mut Self;
2820        fn take_or_borrow<'a>(
2821            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2822        ) -> Self::Borrowed<'a> {
2823            value
2824        }
2825    }
2826
2827    unsafe impl fidl::encoding::TypeMarker for ViewPresentRequest {
2828        type Owned = Self;
2829
2830        #[inline(always)]
2831        fn inline_align(_context: fidl::encoding::Context) -> usize {
2832            4
2833        }
2834
2835        #[inline(always)]
2836        fn inline_size(_context: fidl::encoding::Context) -> usize {
2837            4
2838        }
2839    }
2840
2841    unsafe impl
2842        fidl::encoding::Encode<ViewPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2843        for &mut ViewPresentRequest
2844    {
2845        #[inline]
2846        unsafe fn encode(
2847            self,
2848            encoder: &mut fidl::encoding::Encoder<
2849                '_,
2850                fidl::encoding::DefaultFuchsiaResourceDialect,
2851            >,
2852            offset: usize,
2853            _depth: fidl::encoding::Depth,
2854        ) -> fidl::Result<()> {
2855            encoder.debug_check_bounds::<ViewPresentRequest>(offset);
2856            // Delegate to tuple encoding.
2857            fidl::encoding::Encode::<
2858                ViewPresentRequest,
2859                fidl::encoding::DefaultFuchsiaResourceDialect,
2860            >::encode(
2861                (<ViewToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2862                    &mut self.view_token,
2863                ),),
2864                encoder,
2865                offset,
2866                _depth,
2867            )
2868        }
2869    }
2870    unsafe impl<
2871        T0: fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>,
2872    > fidl::encoding::Encode<ViewPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2873        for (T0,)
2874    {
2875        #[inline]
2876        unsafe fn encode(
2877            self,
2878            encoder: &mut fidl::encoding::Encoder<
2879                '_,
2880                fidl::encoding::DefaultFuchsiaResourceDialect,
2881            >,
2882            offset: usize,
2883            depth: fidl::encoding::Depth,
2884        ) -> fidl::Result<()> {
2885            encoder.debug_check_bounds::<ViewPresentRequest>(offset);
2886            // Zero out padding regions. There's no need to apply masks
2887            // because the unmasked parts will be overwritten by fields.
2888            // Write the fields.
2889            self.0.encode(encoder, offset + 0, depth)?;
2890            Ok(())
2891        }
2892    }
2893
2894    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2895        for ViewPresentRequest
2896    {
2897        #[inline(always)]
2898        fn new_empty() -> Self {
2899            Self {
2900                view_token: fidl::new_empty!(
2901                    ViewToken,
2902                    fidl::encoding::DefaultFuchsiaResourceDialect
2903                ),
2904            }
2905        }
2906
2907        #[inline]
2908        unsafe fn decode(
2909            &mut self,
2910            decoder: &mut fidl::encoding::Decoder<
2911                '_,
2912                fidl::encoding::DefaultFuchsiaResourceDialect,
2913            >,
2914            offset: usize,
2915            _depth: fidl::encoding::Depth,
2916        ) -> fidl::Result<()> {
2917            decoder.debug_check_bounds::<Self>(offset);
2918            // Verify that padding bytes are zero.
2919            fidl::decode!(
2920                ViewToken,
2921                fidl::encoding::DefaultFuchsiaResourceDialect,
2922                &mut self.view_token,
2923                decoder,
2924                offset + 0,
2925                _depth
2926            )?;
2927            Ok(())
2928        }
2929    }
2930
2931    impl fidl::encoding::ResourceTypeMarker for ViewRef {
2932        type Borrowed<'a> = &'a mut Self;
2933        fn take_or_borrow<'a>(
2934            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2935        ) -> Self::Borrowed<'a> {
2936            value
2937        }
2938    }
2939
2940    unsafe impl fidl::encoding::TypeMarker for ViewRef {
2941        type Owned = Self;
2942
2943        #[inline(always)]
2944        fn inline_align(_context: fidl::encoding::Context) -> usize {
2945            4
2946        }
2947
2948        #[inline(always)]
2949        fn inline_size(_context: fidl::encoding::Context) -> usize {
2950            4
2951        }
2952    }
2953
2954    unsafe impl fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>
2955        for &mut ViewRef
2956    {
2957        #[inline]
2958        unsafe fn encode(
2959            self,
2960            encoder: &mut fidl::encoding::Encoder<
2961                '_,
2962                fidl::encoding::DefaultFuchsiaResourceDialect,
2963            >,
2964            offset: usize,
2965            _depth: fidl::encoding::Depth,
2966        ) -> fidl::Result<()> {
2967            encoder.debug_check_bounds::<ViewRef>(offset);
2968            // Delegate to tuple encoding.
2969            fidl::encoding::Encode::<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2970                (<fidl::encoding::HandleType<
2971                    fidl::EventPair,
2972                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2973                    2147483648,
2974                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2975                    &mut self.reference
2976                ),),
2977                encoder,
2978                offset,
2979                _depth,
2980            )
2981        }
2982    }
2983    unsafe impl<
2984        T0: fidl::encoding::Encode<
2985                fidl::encoding::HandleType<
2986                    fidl::EventPair,
2987                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2988                    2147483648,
2989                >,
2990                fidl::encoding::DefaultFuchsiaResourceDialect,
2991            >,
2992    > fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
2993    {
2994        #[inline]
2995        unsafe fn encode(
2996            self,
2997            encoder: &mut fidl::encoding::Encoder<
2998                '_,
2999                fidl::encoding::DefaultFuchsiaResourceDialect,
3000            >,
3001            offset: usize,
3002            depth: fidl::encoding::Depth,
3003        ) -> fidl::Result<()> {
3004            encoder.debug_check_bounds::<ViewRef>(offset);
3005            // Zero out padding regions. There's no need to apply masks
3006            // because the unmasked parts will be overwritten by fields.
3007            // Write the fields.
3008            self.0.encode(encoder, offset + 0, depth)?;
3009            Ok(())
3010        }
3011    }
3012
3013    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewRef {
3014        #[inline(always)]
3015        fn new_empty() -> Self {
3016            Self {
3017                reference: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3018            }
3019        }
3020
3021        #[inline]
3022        unsafe fn decode(
3023            &mut self,
3024            decoder: &mut fidl::encoding::Decoder<
3025                '_,
3026                fidl::encoding::DefaultFuchsiaResourceDialect,
3027            >,
3028            offset: usize,
3029            _depth: fidl::encoding::Depth,
3030        ) -> fidl::Result<()> {
3031            decoder.debug_check_bounds::<Self>(offset);
3032            // Verify that padding bytes are zero.
3033            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference, decoder, offset + 0, _depth)?;
3034            Ok(())
3035        }
3036    }
3037
3038    impl fidl::encoding::ResourceTypeMarker for ViewRefControl {
3039        type Borrowed<'a> = &'a mut Self;
3040        fn take_or_borrow<'a>(
3041            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3042        ) -> Self::Borrowed<'a> {
3043            value
3044        }
3045    }
3046
3047    unsafe impl fidl::encoding::TypeMarker for ViewRefControl {
3048        type Owned = Self;
3049
3050        #[inline(always)]
3051        fn inline_align(_context: fidl::encoding::Context) -> usize {
3052            4
3053        }
3054
3055        #[inline(always)]
3056        fn inline_size(_context: fidl::encoding::Context) -> usize {
3057            4
3058        }
3059    }
3060
3061    unsafe impl
3062        fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>
3063        for &mut ViewRefControl
3064    {
3065        #[inline]
3066        unsafe fn encode(
3067            self,
3068            encoder: &mut fidl::encoding::Encoder<
3069                '_,
3070                fidl::encoding::DefaultFuchsiaResourceDialect,
3071            >,
3072            offset: usize,
3073            _depth: fidl::encoding::Depth,
3074        ) -> fidl::Result<()> {
3075            encoder.debug_check_bounds::<ViewRefControl>(offset);
3076            // Delegate to tuple encoding.
3077            fidl::encoding::Encode::<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3078                (
3079                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.reference),
3080                ),
3081                encoder, offset, _depth
3082            )
3083        }
3084    }
3085    unsafe impl<
3086        T0: fidl::encoding::Encode<
3087                fidl::encoding::HandleType<
3088                    fidl::EventPair,
3089                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3090                    2147483648,
3091                >,
3092                fidl::encoding::DefaultFuchsiaResourceDialect,
3093            >,
3094    > fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>
3095        for (T0,)
3096    {
3097        #[inline]
3098        unsafe fn encode(
3099            self,
3100            encoder: &mut fidl::encoding::Encoder<
3101                '_,
3102                fidl::encoding::DefaultFuchsiaResourceDialect,
3103            >,
3104            offset: usize,
3105            depth: fidl::encoding::Depth,
3106        ) -> fidl::Result<()> {
3107            encoder.debug_check_bounds::<ViewRefControl>(offset);
3108            // Zero out padding regions. There's no need to apply masks
3109            // because the unmasked parts will be overwritten by fields.
3110            // Write the fields.
3111            self.0.encode(encoder, offset + 0, depth)?;
3112            Ok(())
3113        }
3114    }
3115
3116    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3117        for ViewRefControl
3118    {
3119        #[inline(always)]
3120        fn new_empty() -> Self {
3121            Self {
3122                reference: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3123            }
3124        }
3125
3126        #[inline]
3127        unsafe fn decode(
3128            &mut self,
3129            decoder: &mut fidl::encoding::Decoder<
3130                '_,
3131                fidl::encoding::DefaultFuchsiaResourceDialect,
3132            >,
3133            offset: usize,
3134            _depth: fidl::encoding::Depth,
3135        ) -> fidl::Result<()> {
3136            decoder.debug_check_bounds::<Self>(offset);
3137            // Verify that padding bytes are zero.
3138            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.reference, decoder, offset + 0, _depth)?;
3139            Ok(())
3140        }
3141    }
3142
3143    impl fidl::encoding::ResourceTypeMarker for ViewRefInstalledWatchRequest {
3144        type Borrowed<'a> = &'a mut Self;
3145        fn take_or_borrow<'a>(
3146            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3147        ) -> Self::Borrowed<'a> {
3148            value
3149        }
3150    }
3151
3152    unsafe impl fidl::encoding::TypeMarker for ViewRefInstalledWatchRequest {
3153        type Owned = Self;
3154
3155        #[inline(always)]
3156        fn inline_align(_context: fidl::encoding::Context) -> usize {
3157            4
3158        }
3159
3160        #[inline(always)]
3161        fn inline_size(_context: fidl::encoding::Context) -> usize {
3162            4
3163        }
3164    }
3165
3166    unsafe impl
3167        fidl::encoding::Encode<
3168            ViewRefInstalledWatchRequest,
3169            fidl::encoding::DefaultFuchsiaResourceDialect,
3170        > for &mut ViewRefInstalledWatchRequest
3171    {
3172        #[inline]
3173        unsafe fn encode(
3174            self,
3175            encoder: &mut fidl::encoding::Encoder<
3176                '_,
3177                fidl::encoding::DefaultFuchsiaResourceDialect,
3178            >,
3179            offset: usize,
3180            _depth: fidl::encoding::Depth,
3181        ) -> fidl::Result<()> {
3182            encoder.debug_check_bounds::<ViewRefInstalledWatchRequest>(offset);
3183            // Delegate to tuple encoding.
3184            fidl::encoding::Encode::<
3185                ViewRefInstalledWatchRequest,
3186                fidl::encoding::DefaultFuchsiaResourceDialect,
3187            >::encode(
3188                (<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3189                    &mut self.view_ref,
3190                ),),
3191                encoder,
3192                offset,
3193                _depth,
3194            )
3195        }
3196    }
3197    unsafe impl<T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>>
3198        fidl::encoding::Encode<
3199            ViewRefInstalledWatchRequest,
3200            fidl::encoding::DefaultFuchsiaResourceDialect,
3201        > for (T0,)
3202    {
3203        #[inline]
3204        unsafe fn encode(
3205            self,
3206            encoder: &mut fidl::encoding::Encoder<
3207                '_,
3208                fidl::encoding::DefaultFuchsiaResourceDialect,
3209            >,
3210            offset: usize,
3211            depth: fidl::encoding::Depth,
3212        ) -> fidl::Result<()> {
3213            encoder.debug_check_bounds::<ViewRefInstalledWatchRequest>(offset);
3214            // Zero out padding regions. There's no need to apply masks
3215            // because the unmasked parts will be overwritten by fields.
3216            // Write the fields.
3217            self.0.encode(encoder, offset + 0, depth)?;
3218            Ok(())
3219        }
3220    }
3221
3222    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3223        for ViewRefInstalledWatchRequest
3224    {
3225        #[inline(always)]
3226        fn new_empty() -> Self {
3227            Self {
3228                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
3229            }
3230        }
3231
3232        #[inline]
3233        unsafe fn decode(
3234            &mut self,
3235            decoder: &mut fidl::encoding::Decoder<
3236                '_,
3237                fidl::encoding::DefaultFuchsiaResourceDialect,
3238            >,
3239            offset: usize,
3240            _depth: fidl::encoding::Depth,
3241        ) -> fidl::Result<()> {
3242            decoder.debug_check_bounds::<Self>(offset);
3243            // Verify that padding bytes are zero.
3244            fidl::decode!(
3245                ViewRef,
3246                fidl::encoding::DefaultFuchsiaResourceDialect,
3247                &mut self.view_ref,
3248                decoder,
3249                offset + 0,
3250                _depth
3251            )?;
3252            Ok(())
3253        }
3254    }
3255
3256    impl fidl::encoding::ResourceTypeMarker for ViewToken {
3257        type Borrowed<'a> = &'a mut Self;
3258        fn take_or_borrow<'a>(
3259            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3260        ) -> Self::Borrowed<'a> {
3261            value
3262        }
3263    }
3264
3265    unsafe impl fidl::encoding::TypeMarker for ViewToken {
3266        type Owned = Self;
3267
3268        #[inline(always)]
3269        fn inline_align(_context: fidl::encoding::Context) -> usize {
3270            4
3271        }
3272
3273        #[inline(always)]
3274        fn inline_size(_context: fidl::encoding::Context) -> usize {
3275            4
3276        }
3277    }
3278
3279    unsafe impl fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3280        for &mut ViewToken
3281    {
3282        #[inline]
3283        unsafe fn encode(
3284            self,
3285            encoder: &mut fidl::encoding::Encoder<
3286                '_,
3287                fidl::encoding::DefaultFuchsiaResourceDialect,
3288            >,
3289            offset: usize,
3290            _depth: fidl::encoding::Depth,
3291        ) -> fidl::Result<()> {
3292            encoder.debug_check_bounds::<ViewToken>(offset);
3293            // Delegate to tuple encoding.
3294            fidl::encoding::Encode::<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3295                (
3296                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
3297                ),
3298                encoder, offset, _depth
3299            )
3300        }
3301    }
3302    unsafe impl<
3303        T0: fidl::encoding::Encode<
3304                fidl::encoding::HandleType<
3305                    fidl::EventPair,
3306                    { fidl::ObjectType::EVENTPAIR.into_raw() },
3307                    2147483648,
3308                >,
3309                fidl::encoding::DefaultFuchsiaResourceDialect,
3310            >,
3311    > fidl::encoding::Encode<ViewToken, fidl::encoding::DefaultFuchsiaResourceDialect> for (T0,)
3312    {
3313        #[inline]
3314        unsafe fn encode(
3315            self,
3316            encoder: &mut fidl::encoding::Encoder<
3317                '_,
3318                fidl::encoding::DefaultFuchsiaResourceDialect,
3319            >,
3320            offset: usize,
3321            depth: fidl::encoding::Depth,
3322        ) -> fidl::Result<()> {
3323            encoder.debug_check_bounds::<ViewToken>(offset);
3324            // Zero out padding regions. There's no need to apply masks
3325            // because the unmasked parts will be overwritten by fields.
3326            // Write the fields.
3327            self.0.encode(encoder, offset + 0, depth)?;
3328            Ok(())
3329        }
3330    }
3331
3332    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewToken {
3333        #[inline(always)]
3334        fn new_empty() -> Self {
3335            Self {
3336                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3337            }
3338        }
3339
3340        #[inline]
3341        unsafe fn decode(
3342            &mut self,
3343            decoder: &mut fidl::encoding::Decoder<
3344                '_,
3345                fidl::encoding::DefaultFuchsiaResourceDialect,
3346            >,
3347            offset: usize,
3348            _depth: fidl::encoding::Depth,
3349        ) -> fidl::Result<()> {
3350            decoder.debug_check_bounds::<Self>(offset);
3351            // Verify that padding bytes are zero.
3352            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3353            Ok(())
3354        }
3355    }
3356
3357    impl fidl::encoding::ResourceTypeMarker for ViewportCreationToken {
3358        type Borrowed<'a> = &'a mut Self;
3359        fn take_or_borrow<'a>(
3360            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3361        ) -> Self::Borrowed<'a> {
3362            value
3363        }
3364    }
3365
3366    unsafe impl fidl::encoding::TypeMarker for ViewportCreationToken {
3367        type Owned = Self;
3368
3369        #[inline(always)]
3370        fn inline_align(_context: fidl::encoding::Context) -> usize {
3371            4
3372        }
3373
3374        #[inline(always)]
3375        fn inline_size(_context: fidl::encoding::Context) -> usize {
3376            4
3377        }
3378    }
3379
3380    unsafe impl
3381        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3382        for &mut ViewportCreationToken
3383    {
3384        #[inline]
3385        unsafe fn encode(
3386            self,
3387            encoder: &mut fidl::encoding::Encoder<
3388                '_,
3389                fidl::encoding::DefaultFuchsiaResourceDialect,
3390            >,
3391            offset: usize,
3392            _depth: fidl::encoding::Depth,
3393        ) -> fidl::Result<()> {
3394            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3395            // Delegate to tuple encoding.
3396            fidl::encoding::Encode::<
3397                ViewportCreationToken,
3398                fidl::encoding::DefaultFuchsiaResourceDialect,
3399            >::encode(
3400                (<fidl::encoding::HandleType<
3401                    fidl::Channel,
3402                    { fidl::ObjectType::CHANNEL.into_raw() },
3403                    2147483648,
3404                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3405                    &mut self.value
3406                ),),
3407                encoder,
3408                offset,
3409                _depth,
3410            )
3411        }
3412    }
3413    unsafe impl<
3414        T0: fidl::encoding::Encode<
3415                fidl::encoding::HandleType<
3416                    fidl::Channel,
3417                    { fidl::ObjectType::CHANNEL.into_raw() },
3418                    2147483648,
3419                >,
3420                fidl::encoding::DefaultFuchsiaResourceDialect,
3421            >,
3422    >
3423        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3424        for (T0,)
3425    {
3426        #[inline]
3427        unsafe fn encode(
3428            self,
3429            encoder: &mut fidl::encoding::Encoder<
3430                '_,
3431                fidl::encoding::DefaultFuchsiaResourceDialect,
3432            >,
3433            offset: usize,
3434            depth: fidl::encoding::Depth,
3435        ) -> fidl::Result<()> {
3436            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3437            // Zero out padding regions. There's no need to apply masks
3438            // because the unmasked parts will be overwritten by fields.
3439            // Write the fields.
3440            self.0.encode(encoder, offset + 0, depth)?;
3441            Ok(())
3442        }
3443    }
3444
3445    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3446        for ViewportCreationToken
3447    {
3448        #[inline(always)]
3449        fn new_empty() -> Self {
3450            Self {
3451                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3452            }
3453        }
3454
3455        #[inline]
3456        unsafe fn decode(
3457            &mut self,
3458            decoder: &mut fidl::encoding::Decoder<
3459                '_,
3460                fidl::encoding::DefaultFuchsiaResourceDialect,
3461            >,
3462            offset: usize,
3463            _depth: fidl::encoding::Depth,
3464        ) -> fidl::Result<()> {
3465            decoder.debug_check_bounds::<Self>(offset);
3466            // Verify that padding bytes are zero.
3467            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3468            Ok(())
3469        }
3470    }
3471
3472    impl FocuserSetAutoFocusRequest {
3473        #[inline(always)]
3474        fn max_ordinal_present(&self) -> u64 {
3475            if let Some(_) = self.view_ref {
3476                return 1;
3477            }
3478            0
3479        }
3480    }
3481
3482    impl fidl::encoding::ResourceTypeMarker for FocuserSetAutoFocusRequest {
3483        type Borrowed<'a> = &'a mut Self;
3484        fn take_or_borrow<'a>(
3485            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3486        ) -> Self::Borrowed<'a> {
3487            value
3488        }
3489    }
3490
3491    unsafe impl fidl::encoding::TypeMarker for FocuserSetAutoFocusRequest {
3492        type Owned = Self;
3493
3494        #[inline(always)]
3495        fn inline_align(_context: fidl::encoding::Context) -> usize {
3496            8
3497        }
3498
3499        #[inline(always)]
3500        fn inline_size(_context: fidl::encoding::Context) -> usize {
3501            16
3502        }
3503    }
3504
3505    unsafe impl
3506        fidl::encoding::Encode<
3507            FocuserSetAutoFocusRequest,
3508            fidl::encoding::DefaultFuchsiaResourceDialect,
3509        > for &mut FocuserSetAutoFocusRequest
3510    {
3511        unsafe fn encode(
3512            self,
3513            encoder: &mut fidl::encoding::Encoder<
3514                '_,
3515                fidl::encoding::DefaultFuchsiaResourceDialect,
3516            >,
3517            offset: usize,
3518            mut depth: fidl::encoding::Depth,
3519        ) -> fidl::Result<()> {
3520            encoder.debug_check_bounds::<FocuserSetAutoFocusRequest>(offset);
3521            // Vector header
3522            let max_ordinal: u64 = self.max_ordinal_present();
3523            encoder.write_num(max_ordinal, offset);
3524            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3525            // Calling encoder.out_of_line_offset(0) is not allowed.
3526            if max_ordinal == 0 {
3527                return Ok(());
3528            }
3529            depth.increment()?;
3530            let envelope_size = 8;
3531            let bytes_len = max_ordinal as usize * envelope_size;
3532            #[allow(unused_variables)]
3533            let offset = encoder.out_of_line_offset(bytes_len);
3534            let mut _prev_end_offset: usize = 0;
3535            if 1 > max_ordinal {
3536                return Ok(());
3537            }
3538
3539            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3540            // are envelope_size bytes.
3541            let cur_offset: usize = (1 - 1) * envelope_size;
3542
3543            // Zero reserved fields.
3544            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3545
3546            // Safety:
3547            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3548            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3549            //   envelope_size bytes, there is always sufficient room.
3550            fidl::encoding::encode_in_envelope_optional::<
3551                ViewRef,
3552                fidl::encoding::DefaultFuchsiaResourceDialect,
3553            >(
3554                self.view_ref
3555                    .as_mut()
3556                    .map(<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3557                encoder,
3558                offset + cur_offset,
3559                depth,
3560            )?;
3561
3562            _prev_end_offset = cur_offset + envelope_size;
3563
3564            Ok(())
3565        }
3566    }
3567
3568    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3569        for FocuserSetAutoFocusRequest
3570    {
3571        #[inline(always)]
3572        fn new_empty() -> Self {
3573            Self::default()
3574        }
3575
3576        unsafe fn decode(
3577            &mut self,
3578            decoder: &mut fidl::encoding::Decoder<
3579                '_,
3580                fidl::encoding::DefaultFuchsiaResourceDialect,
3581            >,
3582            offset: usize,
3583            mut depth: fidl::encoding::Depth,
3584        ) -> fidl::Result<()> {
3585            decoder.debug_check_bounds::<Self>(offset);
3586            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3587                None => return Err(fidl::Error::NotNullable),
3588                Some(len) => len,
3589            };
3590            // Calling decoder.out_of_line_offset(0) is not allowed.
3591            if len == 0 {
3592                return Ok(());
3593            };
3594            depth.increment()?;
3595            let envelope_size = 8;
3596            let bytes_len = len * envelope_size;
3597            let offset = decoder.out_of_line_offset(bytes_len)?;
3598            // Decode the envelope for each type.
3599            let mut _next_ordinal_to_read = 0;
3600            let mut next_offset = offset;
3601            let end_offset = offset + bytes_len;
3602            _next_ordinal_to_read += 1;
3603            if next_offset >= end_offset {
3604                return Ok(());
3605            }
3606
3607            // Decode unknown envelopes for gaps in ordinals.
3608            while _next_ordinal_to_read < 1 {
3609                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3610                _next_ordinal_to_read += 1;
3611                next_offset += envelope_size;
3612            }
3613
3614            let next_out_of_line = decoder.next_out_of_line();
3615            let handles_before = decoder.remaining_handles();
3616            if let Some((inlined, num_bytes, num_handles)) =
3617                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3618            {
3619                let member_inline_size =
3620                    <ViewRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3621                if inlined != (member_inline_size <= 4) {
3622                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3623                }
3624                let inner_offset;
3625                let mut inner_depth = depth.clone();
3626                if inlined {
3627                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3628                    inner_offset = next_offset;
3629                } else {
3630                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3631                    inner_depth.increment()?;
3632                }
3633                let val_ref = self.view_ref.get_or_insert_with(|| {
3634                    fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect)
3635                });
3636                fidl::decode!(
3637                    ViewRef,
3638                    fidl::encoding::DefaultFuchsiaResourceDialect,
3639                    val_ref,
3640                    decoder,
3641                    inner_offset,
3642                    inner_depth
3643                )?;
3644                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3645                {
3646                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3647                }
3648                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3649                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3650                }
3651            }
3652
3653            next_offset += envelope_size;
3654
3655            // Decode the remaining unknown envelopes.
3656            while next_offset < end_offset {
3657                _next_ordinal_to_read += 1;
3658                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3659                next_offset += envelope_size;
3660            }
3661
3662            Ok(())
3663        }
3664    }
3665}