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