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::NullableHandle {
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
780    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
781        self.inner.shutdown_with_epitaph(status)
782    }
783
784    fn is_closed(&self) -> bool {
785        self.inner.channel().is_closed()
786    }
787    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
788        self.inner.channel().on_closed()
789    }
790
791    #[cfg(target_os = "fuchsia")]
792    fn signal_peer(
793        &self,
794        clear_mask: zx::Signals,
795        set_mask: zx::Signals,
796    ) -> Result<(), zx_status::Status> {
797        use fidl::Peered;
798        self.inner.channel().signal_peer(clear_mask, set_mask)
799    }
800}
801
802impl FocuserControlHandle {}
803
804#[must_use = "FIDL methods require a response to be sent"]
805#[derive(Debug)]
806pub struct FocuserRequestFocusResponder {
807    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
808    tx_id: u32,
809}
810
811/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
812/// if the responder is dropped without sending a response, so that the client
813/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
814impl std::ops::Drop for FocuserRequestFocusResponder {
815    fn drop(&mut self) {
816        self.control_handle.shutdown();
817        // Safety: drops once, never accessed again
818        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
819    }
820}
821
822impl fidl::endpoints::Responder for FocuserRequestFocusResponder {
823    type ControlHandle = FocuserControlHandle;
824
825    fn control_handle(&self) -> &FocuserControlHandle {
826        &self.control_handle
827    }
828
829    fn drop_without_shutdown(mut self) {
830        // Safety: drops once, never accessed again due to mem::forget
831        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
832        // Prevent Drop from running (which would shut down the channel)
833        std::mem::forget(self);
834    }
835}
836
837impl FocuserRequestFocusResponder {
838    /// Sends a response to the FIDL transaction.
839    ///
840    /// Sets the channel to shutdown if an error occurs.
841    pub fn send(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
842        let _result = self.send_raw(result);
843        if _result.is_err() {
844            self.control_handle.shutdown();
845        }
846        self.drop_without_shutdown();
847        _result
848    }
849
850    /// Similar to "send" but does not shutdown the channel if an error occurs.
851    pub fn send_no_shutdown_on_err(self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
852        let _result = self.send_raw(result);
853        self.drop_without_shutdown();
854        _result
855    }
856
857    fn send_raw(&self, mut result: Result<(), Error>) -> Result<(), fidl::Error> {
858        self.control_handle
859            .inner
860            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, Error>>(
861                result,
862                self.tx_id,
863                0x559067eb07097d5,
864                fidl::encoding::DynamicFlags::empty(),
865            )
866    }
867}
868
869#[must_use = "FIDL methods require a response to be sent"]
870#[derive(Debug)]
871pub struct FocuserSetAutoFocusResponder {
872    control_handle: std::mem::ManuallyDrop<FocuserControlHandle>,
873    tx_id: u32,
874}
875
876/// Set the the channel to be shutdown (see [`FocuserControlHandle::shutdown`])
877/// if the responder is dropped without sending a response, so that the client
878/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
879impl std::ops::Drop for FocuserSetAutoFocusResponder {
880    fn drop(&mut self) {
881        self.control_handle.shutdown();
882        // Safety: drops once, never accessed again
883        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
884    }
885}
886
887impl fidl::endpoints::Responder for FocuserSetAutoFocusResponder {
888    type ControlHandle = FocuserControlHandle;
889
890    fn control_handle(&self) -> &FocuserControlHandle {
891        &self.control_handle
892    }
893
894    fn drop_without_shutdown(mut self) {
895        // Safety: drops once, never accessed again due to mem::forget
896        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
897        // Prevent Drop from running (which would shut down the channel)
898        std::mem::forget(self);
899    }
900}
901
902impl FocuserSetAutoFocusResponder {
903    /// Sends a response to the FIDL transaction.
904    ///
905    /// Sets the channel to shutdown if an error occurs.
906    pub fn send(self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
907        let _result = self.send_raw(result);
908        if _result.is_err() {
909            self.control_handle.shutdown();
910        }
911        self.drop_without_shutdown();
912        _result
913    }
914
915    /// Similar to "send" but does not shutdown the channel if an error occurs.
916    pub fn send_no_shutdown_on_err(
917        self,
918        mut result: Result<(), AutoFocusError>,
919    ) -> Result<(), fidl::Error> {
920        let _result = self.send_raw(result);
921        self.drop_without_shutdown();
922        _result
923    }
924
925    fn send_raw(&self, mut result: Result<(), AutoFocusError>) -> Result<(), fidl::Error> {
926        self.control_handle.inner.send::<fidl::encoding::ResultType<
927            fidl::encoding::EmptyStruct,
928            AutoFocusError,
929        >>(
930            result,
931            self.tx_id,
932            0x480feb5856329509,
933            fidl::encoding::DynamicFlags::empty(),
934        )
935    }
936}
937
938#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
939pub struct ViewMarker;
940
941impl fidl::endpoints::ProtocolMarker for ViewMarker {
942    type Proxy = ViewProxy;
943    type RequestStream = ViewRequestStream;
944    #[cfg(target_os = "fuchsia")]
945    type SynchronousProxy = ViewSynchronousProxy;
946
947    const DEBUG_NAME: &'static str = "fuchsia.ui.views.View";
948}
949impl fidl::endpoints::DiscoverableProtocolMarker for ViewMarker {}
950
951pub trait ViewProxyInterface: Send + Sync {
952    fn r#present(&self, view_token: ViewToken) -> Result<(), fidl::Error>;
953}
954#[derive(Debug)]
955#[cfg(target_os = "fuchsia")]
956pub struct ViewSynchronousProxy {
957    client: fidl::client::sync::Client,
958}
959
960#[cfg(target_os = "fuchsia")]
961impl fidl::endpoints::SynchronousProxy for ViewSynchronousProxy {
962    type Proxy = ViewProxy;
963    type Protocol = ViewMarker;
964
965    fn from_channel(inner: fidl::Channel) -> Self {
966        Self::new(inner)
967    }
968
969    fn into_channel(self) -> fidl::Channel {
970        self.client.into_channel()
971    }
972
973    fn as_channel(&self) -> &fidl::Channel {
974        self.client.as_channel()
975    }
976}
977
978#[cfg(target_os = "fuchsia")]
979impl ViewSynchronousProxy {
980    pub fn new(channel: fidl::Channel) -> Self {
981        let protocol_name = <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
982        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
983    }
984
985    pub fn into_channel(self) -> fidl::Channel {
986        self.client.into_channel()
987    }
988
989    /// Waits until an event arrives and returns it. It is safe for other
990    /// threads to make concurrent requests while waiting for an event.
991    pub fn wait_for_event(&self, deadline: zx::MonotonicInstant) -> Result<ViewEvent, fidl::Error> {
992        ViewEvent::decode(self.client.wait_for_event(deadline)?)
993    }
994
995    /// Provides the View with an attachment point to Scenic's scene graph.
996    ///
997    /// When `Present()` is called the View's implementation should create a
998    /// View resource within Scenic by providing it with the `view_token` (using
999    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1000    ///
1001    /// Then the implementation should attach its graphical content to the
1002    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1003    ///
1004    /// If the implementation already owns a View resource (because `Present()`
1005    /// had already been called before), then it should terminate the connection
1006    /// with an error.
1007    ///
1008    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1009    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1010        self.client.send::<ViewPresentRequest>(
1011            (&mut view_token,),
1012            0x6e98ebc6c9de6d9e,
1013            fidl::encoding::DynamicFlags::empty(),
1014        )
1015    }
1016}
1017
1018#[cfg(target_os = "fuchsia")]
1019impl From<ViewSynchronousProxy> for zx::NullableHandle {
1020    fn from(value: ViewSynchronousProxy) -> Self {
1021        value.into_channel().into()
1022    }
1023}
1024
1025#[cfg(target_os = "fuchsia")]
1026impl From<fidl::Channel> for ViewSynchronousProxy {
1027    fn from(value: fidl::Channel) -> Self {
1028        Self::new(value)
1029    }
1030}
1031
1032#[cfg(target_os = "fuchsia")]
1033impl fidl::endpoints::FromClient for ViewSynchronousProxy {
1034    type Protocol = ViewMarker;
1035
1036    fn from_client(value: fidl::endpoints::ClientEnd<ViewMarker>) -> Self {
1037        Self::new(value.into_channel())
1038    }
1039}
1040
1041#[derive(Debug, Clone)]
1042pub struct ViewProxy {
1043    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1044}
1045
1046impl fidl::endpoints::Proxy for ViewProxy {
1047    type Protocol = ViewMarker;
1048
1049    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1050        Self::new(inner)
1051    }
1052
1053    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1054        self.client.into_channel().map_err(|client| Self { client })
1055    }
1056
1057    fn as_channel(&self) -> &::fidl::AsyncChannel {
1058        self.client.as_channel()
1059    }
1060}
1061
1062impl ViewProxy {
1063    /// Create a new Proxy for fuchsia.ui.views/View.
1064    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1065        let protocol_name = <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1066        Self { client: fidl::client::Client::new(channel, protocol_name) }
1067    }
1068
1069    /// Get a Stream of events from the remote end of the protocol.
1070    ///
1071    /// # Panics
1072    ///
1073    /// Panics if the event stream was already taken.
1074    pub fn take_event_stream(&self) -> ViewEventStream {
1075        ViewEventStream { event_receiver: self.client.take_event_receiver() }
1076    }
1077
1078    /// Provides the View with an attachment point to Scenic's scene graph.
1079    ///
1080    /// When `Present()` is called the View's implementation should create a
1081    /// View resource within Scenic by providing it with the `view_token` (using
1082    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1083    ///
1084    /// Then the implementation should attach its graphical content to the
1085    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1086    ///
1087    /// If the implementation already owns a View resource (because `Present()`
1088    /// had already been called before), then it should terminate the connection
1089    /// with an error.
1090    ///
1091    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1092    pub fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1093        ViewProxyInterface::r#present(self, view_token)
1094    }
1095}
1096
1097impl ViewProxyInterface for ViewProxy {
1098    fn r#present(&self, mut view_token: ViewToken) -> Result<(), fidl::Error> {
1099        self.client.send::<ViewPresentRequest>(
1100            (&mut view_token,),
1101            0x6e98ebc6c9de6d9e,
1102            fidl::encoding::DynamicFlags::empty(),
1103        )
1104    }
1105}
1106
1107pub struct ViewEventStream {
1108    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1109}
1110
1111impl std::marker::Unpin for ViewEventStream {}
1112
1113impl futures::stream::FusedStream for ViewEventStream {
1114    fn is_terminated(&self) -> bool {
1115        self.event_receiver.is_terminated()
1116    }
1117}
1118
1119impl futures::Stream for ViewEventStream {
1120    type Item = Result<ViewEvent, fidl::Error>;
1121
1122    fn poll_next(
1123        mut self: std::pin::Pin<&mut Self>,
1124        cx: &mut std::task::Context<'_>,
1125    ) -> std::task::Poll<Option<Self::Item>> {
1126        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1127            &mut self.event_receiver,
1128            cx
1129        )?) {
1130            Some(buf) => std::task::Poll::Ready(Some(ViewEvent::decode(buf))),
1131            None => std::task::Poll::Ready(None),
1132        }
1133    }
1134}
1135
1136#[derive(Debug)]
1137pub enum ViewEvent {}
1138
1139impl ViewEvent {
1140    /// Decodes a message buffer as a [`ViewEvent`].
1141    fn decode(
1142        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1143    ) -> Result<ViewEvent, fidl::Error> {
1144        let (bytes, _handles) = buf.split_mut();
1145        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1146        debug_assert_eq!(tx_header.tx_id, 0);
1147        match tx_header.ordinal {
1148            _ => Err(fidl::Error::UnknownOrdinal {
1149                ordinal: tx_header.ordinal,
1150                protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1151            }),
1152        }
1153    }
1154}
1155
1156/// A Stream of incoming requests for fuchsia.ui.views/View.
1157pub struct ViewRequestStream {
1158    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1159    is_terminated: bool,
1160}
1161
1162impl std::marker::Unpin for ViewRequestStream {}
1163
1164impl futures::stream::FusedStream for ViewRequestStream {
1165    fn is_terminated(&self) -> bool {
1166        self.is_terminated
1167    }
1168}
1169
1170impl fidl::endpoints::RequestStream for ViewRequestStream {
1171    type Protocol = ViewMarker;
1172    type ControlHandle = ViewControlHandle;
1173
1174    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1175        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1176    }
1177
1178    fn control_handle(&self) -> Self::ControlHandle {
1179        ViewControlHandle { inner: self.inner.clone() }
1180    }
1181
1182    fn into_inner(
1183        self,
1184    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1185    {
1186        (self.inner, self.is_terminated)
1187    }
1188
1189    fn from_inner(
1190        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1191        is_terminated: bool,
1192    ) -> Self {
1193        Self { inner, is_terminated }
1194    }
1195}
1196
1197impl futures::Stream for ViewRequestStream {
1198    type Item = Result<ViewRequest, fidl::Error>;
1199
1200    fn poll_next(
1201        mut self: std::pin::Pin<&mut Self>,
1202        cx: &mut std::task::Context<'_>,
1203    ) -> std::task::Poll<Option<Self::Item>> {
1204        let this = &mut *self;
1205        if this.inner.check_shutdown(cx) {
1206            this.is_terminated = true;
1207            return std::task::Poll::Ready(None);
1208        }
1209        if this.is_terminated {
1210            panic!("polled ViewRequestStream after completion");
1211        }
1212        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1213            |bytes, handles| {
1214                match this.inner.channel().read_etc(cx, bytes, handles) {
1215                    std::task::Poll::Ready(Ok(())) => {}
1216                    std::task::Poll::Pending => return std::task::Poll::Pending,
1217                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1218                        this.is_terminated = true;
1219                        return std::task::Poll::Ready(None);
1220                    }
1221                    std::task::Poll::Ready(Err(e)) => {
1222                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1223                            e.into(),
1224                        ))));
1225                    }
1226                }
1227
1228                // A message has been received from the channel
1229                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1230
1231                std::task::Poll::Ready(Some(match header.ordinal {
1232                    0x6e98ebc6c9de6d9e => {
1233                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1234                        let mut req = fidl::new_empty!(
1235                            ViewPresentRequest,
1236                            fidl::encoding::DefaultFuchsiaResourceDialect
1237                        );
1238                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewPresentRequest>(&header, _body_bytes, handles, &mut req)?;
1239                        let control_handle = ViewControlHandle { inner: this.inner.clone() };
1240                        Ok(ViewRequest::Present { view_token: req.view_token, control_handle })
1241                    }
1242                    _ => Err(fidl::Error::UnknownOrdinal {
1243                        ordinal: header.ordinal,
1244                        protocol_name: <ViewMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1245                    }),
1246                }))
1247            },
1248        )
1249    }
1250}
1251
1252/// Deprecated API for view creation. DO NOT USE.
1253#[derive(Debug)]
1254pub enum ViewRequest {
1255    /// Provides the View with an attachment point to Scenic's scene graph.
1256    ///
1257    /// When `Present()` is called the View's implementation should create a
1258    /// View resource within Scenic by providing it with the `view_token` (using
1259    /// a `fuchsia.ui.gfx.CreateResourceCmd` and `fuchsia.ui.gfx.ViewArgs`).
1260    ///
1261    /// Then the implementation should attach its graphical content to the
1262    /// newly-created View resource using a `fuchsia.ui.gfx.AddChildCmd`.
1263    ///
1264    /// If the implementation already owns a View resource (because `Present()`
1265    /// had already been called before), then it should terminate the connection
1266    /// with an error.
1267    ///
1268    /// TODO(https://fxbug.dev/42098670): Allow re-parenting `View`s with a new `Present()` call.
1269    Present { view_token: ViewToken, control_handle: ViewControlHandle },
1270}
1271
1272impl ViewRequest {
1273    #[allow(irrefutable_let_patterns)]
1274    pub fn into_present(self) -> Option<(ViewToken, ViewControlHandle)> {
1275        if let ViewRequest::Present { view_token, control_handle } = self {
1276            Some((view_token, control_handle))
1277        } else {
1278            None
1279        }
1280    }
1281
1282    /// Name of the method defined in FIDL
1283    pub fn method_name(&self) -> &'static str {
1284        match *self {
1285            ViewRequest::Present { .. } => "present",
1286        }
1287    }
1288}
1289
1290#[derive(Debug, Clone)]
1291pub struct ViewControlHandle {
1292    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1293}
1294
1295impl fidl::endpoints::ControlHandle for ViewControlHandle {
1296    fn shutdown(&self) {
1297        self.inner.shutdown()
1298    }
1299
1300    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1301        self.inner.shutdown_with_epitaph(status)
1302    }
1303
1304    fn is_closed(&self) -> bool {
1305        self.inner.channel().is_closed()
1306    }
1307    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1308        self.inner.channel().on_closed()
1309    }
1310
1311    #[cfg(target_os = "fuchsia")]
1312    fn signal_peer(
1313        &self,
1314        clear_mask: zx::Signals,
1315        set_mask: zx::Signals,
1316    ) -> Result<(), zx_status::Status> {
1317        use fidl::Peered;
1318        self.inner.channel().signal_peer(clear_mask, set_mask)
1319    }
1320}
1321
1322impl ViewControlHandle {}
1323
1324#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1325pub struct ViewRefFocusedMarker;
1326
1327impl fidl::endpoints::ProtocolMarker for ViewRefFocusedMarker {
1328    type Proxy = ViewRefFocusedProxy;
1329    type RequestStream = ViewRefFocusedRequestStream;
1330    #[cfg(target_os = "fuchsia")]
1331    type SynchronousProxy = ViewRefFocusedSynchronousProxy;
1332
1333    const DEBUG_NAME: &'static str = "(anonymous) ViewRefFocused";
1334}
1335
1336pub trait ViewRefFocusedProxyInterface: Send + Sync {
1337    type WatchResponseFut: std::future::Future<Output = Result<FocusState, fidl::Error>> + Send;
1338    fn r#watch(&self) -> Self::WatchResponseFut;
1339}
1340#[derive(Debug)]
1341#[cfg(target_os = "fuchsia")]
1342pub struct ViewRefFocusedSynchronousProxy {
1343    client: fidl::client::sync::Client,
1344}
1345
1346#[cfg(target_os = "fuchsia")]
1347impl fidl::endpoints::SynchronousProxy for ViewRefFocusedSynchronousProxy {
1348    type Proxy = ViewRefFocusedProxy;
1349    type Protocol = ViewRefFocusedMarker;
1350
1351    fn from_channel(inner: fidl::Channel) -> Self {
1352        Self::new(inner)
1353    }
1354
1355    fn into_channel(self) -> fidl::Channel {
1356        self.client.into_channel()
1357    }
1358
1359    fn as_channel(&self) -> &fidl::Channel {
1360        self.client.as_channel()
1361    }
1362}
1363
1364#[cfg(target_os = "fuchsia")]
1365impl ViewRefFocusedSynchronousProxy {
1366    pub fn new(channel: fidl::Channel) -> Self {
1367        let protocol_name = <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1368        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1369    }
1370
1371    pub fn into_channel(self) -> fidl::Channel {
1372        self.client.into_channel()
1373    }
1374
1375    /// Waits until an event arrives and returns it. It is safe for other
1376    /// threads to make concurrent requests while waiting for an event.
1377    pub fn wait_for_event(
1378        &self,
1379        deadline: zx::MonotonicInstant,
1380    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1381        ViewRefFocusedEvent::decode(self.client.wait_for_event(deadline)?)
1382    }
1383
1384    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1385    /// focus. Typically, focus changes happen at a slow pace, such that every
1386    /// transition is captured by the callback. However, focus changes can
1387    /// happen rapidly, so the callback may "compress" focus change history into
1388    /// just the latest known focus state.
1389    ///
1390    /// The callback reports the last focus change spanning the duration from
1391    /// its issuance to the previous callback's issuance. The client may observe
1392    /// any of the following four transitions:
1393    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1394    ///   focus by the time of callback issuance.
1395    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1396    ///   focus by the time of callback issuance.
1397    /// - false -> true: The ViewRef has gained focus at least once, and has
1398    ///   gained focus by the time of callback issuance.
1399    /// - false -> false: The ViewRef has gained focus at least once, and has
1400    ///   lost focus by the time of callback issuance.
1401    ///
1402    /// The client avoids "focus flapping" and always sees the latest state.
1403    /// Every callback issuance is meaningful, and the client should renegotiate
1404    /// focus-related services appropriately, such as IME.
1405    ///
1406    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1407    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1408    /// returns. Non-compliance results in channel closure.
1409    pub fn r#watch(&self, ___deadline: zx::MonotonicInstant) -> Result<FocusState, fidl::Error> {
1410        let _response =
1411            self.client.send_query::<fidl::encoding::EmptyPayload, ViewRefFocusedWatchResponse>(
1412                (),
1413                0x3c5e51096d9299b5,
1414                fidl::encoding::DynamicFlags::empty(),
1415                ___deadline,
1416            )?;
1417        Ok(_response.state)
1418    }
1419}
1420
1421#[cfg(target_os = "fuchsia")]
1422impl From<ViewRefFocusedSynchronousProxy> for zx::NullableHandle {
1423    fn from(value: ViewRefFocusedSynchronousProxy) -> Self {
1424        value.into_channel().into()
1425    }
1426}
1427
1428#[cfg(target_os = "fuchsia")]
1429impl From<fidl::Channel> for ViewRefFocusedSynchronousProxy {
1430    fn from(value: fidl::Channel) -> Self {
1431        Self::new(value)
1432    }
1433}
1434
1435#[cfg(target_os = "fuchsia")]
1436impl fidl::endpoints::FromClient for ViewRefFocusedSynchronousProxy {
1437    type Protocol = ViewRefFocusedMarker;
1438
1439    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefFocusedMarker>) -> Self {
1440        Self::new(value.into_channel())
1441    }
1442}
1443
1444#[derive(Debug, Clone)]
1445pub struct ViewRefFocusedProxy {
1446    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1447}
1448
1449impl fidl::endpoints::Proxy for ViewRefFocusedProxy {
1450    type Protocol = ViewRefFocusedMarker;
1451
1452    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1453        Self::new(inner)
1454    }
1455
1456    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1457        self.client.into_channel().map_err(|client| Self { client })
1458    }
1459
1460    fn as_channel(&self) -> &::fidl::AsyncChannel {
1461        self.client.as_channel()
1462    }
1463}
1464
1465impl ViewRefFocusedProxy {
1466    /// Create a new Proxy for fuchsia.ui.views/ViewRefFocused.
1467    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1468        let protocol_name = <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1469        Self { client: fidl::client::Client::new(channel, protocol_name) }
1470    }
1471
1472    /// Get a Stream of events from the remote end of the protocol.
1473    ///
1474    /// # Panics
1475    ///
1476    /// Panics if the event stream was already taken.
1477    pub fn take_event_stream(&self) -> ViewRefFocusedEventStream {
1478        ViewRefFocusedEventStream { event_receiver: self.client.take_event_receiver() }
1479    }
1480
1481    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1482    /// focus. Typically, focus changes happen at a slow pace, such that every
1483    /// transition is captured by the callback. However, focus changes can
1484    /// happen rapidly, so the callback may "compress" focus change history into
1485    /// just the latest known focus state.
1486    ///
1487    /// The callback reports the last focus change spanning the duration from
1488    /// its issuance to the previous callback's issuance. The client may observe
1489    /// any of the following four transitions:
1490    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1491    ///   focus by the time of callback issuance.
1492    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1493    ///   focus by the time of callback issuance.
1494    /// - false -> true: The ViewRef has gained focus at least once, and has
1495    ///   gained focus by the time of callback issuance.
1496    /// - false -> false: The ViewRef has gained focus at least once, and has
1497    ///   lost focus by the time of callback issuance.
1498    ///
1499    /// The client avoids "focus flapping" and always sees the latest state.
1500    /// Every callback issuance is meaningful, and the client should renegotiate
1501    /// focus-related services appropriately, such as IME.
1502    ///
1503    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1504    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1505    /// returns. Non-compliance results in channel closure.
1506    pub fn r#watch(
1507        &self,
1508    ) -> fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>
1509    {
1510        ViewRefFocusedProxyInterface::r#watch(self)
1511    }
1512}
1513
1514impl ViewRefFocusedProxyInterface for ViewRefFocusedProxy {
1515    type WatchResponseFut =
1516        fidl::client::QueryResponseFut<FocusState, fidl::encoding::DefaultFuchsiaResourceDialect>;
1517    fn r#watch(&self) -> Self::WatchResponseFut {
1518        fn _decode(
1519            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1520        ) -> Result<FocusState, fidl::Error> {
1521            let _response = fidl::client::decode_transaction_body::<
1522                ViewRefFocusedWatchResponse,
1523                fidl::encoding::DefaultFuchsiaResourceDialect,
1524                0x3c5e51096d9299b5,
1525            >(_buf?)?;
1526            Ok(_response.state)
1527        }
1528        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, FocusState>(
1529            (),
1530            0x3c5e51096d9299b5,
1531            fidl::encoding::DynamicFlags::empty(),
1532            _decode,
1533        )
1534    }
1535}
1536
1537pub struct ViewRefFocusedEventStream {
1538    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1539}
1540
1541impl std::marker::Unpin for ViewRefFocusedEventStream {}
1542
1543impl futures::stream::FusedStream for ViewRefFocusedEventStream {
1544    fn is_terminated(&self) -> bool {
1545        self.event_receiver.is_terminated()
1546    }
1547}
1548
1549impl futures::Stream for ViewRefFocusedEventStream {
1550    type Item = Result<ViewRefFocusedEvent, fidl::Error>;
1551
1552    fn poll_next(
1553        mut self: std::pin::Pin<&mut Self>,
1554        cx: &mut std::task::Context<'_>,
1555    ) -> std::task::Poll<Option<Self::Item>> {
1556        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1557            &mut self.event_receiver,
1558            cx
1559        )?) {
1560            Some(buf) => std::task::Poll::Ready(Some(ViewRefFocusedEvent::decode(buf))),
1561            None => std::task::Poll::Ready(None),
1562        }
1563    }
1564}
1565
1566#[derive(Debug)]
1567pub enum ViewRefFocusedEvent {}
1568
1569impl ViewRefFocusedEvent {
1570    /// Decodes a message buffer as a [`ViewRefFocusedEvent`].
1571    fn decode(
1572        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1573    ) -> Result<ViewRefFocusedEvent, fidl::Error> {
1574        let (bytes, _handles) = buf.split_mut();
1575        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1576        debug_assert_eq!(tx_header.tx_id, 0);
1577        match tx_header.ordinal {
1578            _ => Err(fidl::Error::UnknownOrdinal {
1579                ordinal: tx_header.ordinal,
1580                protocol_name:
1581                    <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1582            }),
1583        }
1584    }
1585}
1586
1587/// A Stream of incoming requests for fuchsia.ui.views/ViewRefFocused.
1588pub struct ViewRefFocusedRequestStream {
1589    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1590    is_terminated: bool,
1591}
1592
1593impl std::marker::Unpin for ViewRefFocusedRequestStream {}
1594
1595impl futures::stream::FusedStream for ViewRefFocusedRequestStream {
1596    fn is_terminated(&self) -> bool {
1597        self.is_terminated
1598    }
1599}
1600
1601impl fidl::endpoints::RequestStream for ViewRefFocusedRequestStream {
1602    type Protocol = ViewRefFocusedMarker;
1603    type ControlHandle = ViewRefFocusedControlHandle;
1604
1605    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1606        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1607    }
1608
1609    fn control_handle(&self) -> Self::ControlHandle {
1610        ViewRefFocusedControlHandle { inner: self.inner.clone() }
1611    }
1612
1613    fn into_inner(
1614        self,
1615    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1616    {
1617        (self.inner, self.is_terminated)
1618    }
1619
1620    fn from_inner(
1621        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1622        is_terminated: bool,
1623    ) -> Self {
1624        Self { inner, is_terminated }
1625    }
1626}
1627
1628impl futures::Stream for ViewRefFocusedRequestStream {
1629    type Item = Result<ViewRefFocusedRequest, fidl::Error>;
1630
1631    fn poll_next(
1632        mut self: std::pin::Pin<&mut Self>,
1633        cx: &mut std::task::Context<'_>,
1634    ) -> std::task::Poll<Option<Self::Item>> {
1635        let this = &mut *self;
1636        if this.inner.check_shutdown(cx) {
1637            this.is_terminated = true;
1638            return std::task::Poll::Ready(None);
1639        }
1640        if this.is_terminated {
1641            panic!("polled ViewRefFocusedRequestStream after completion");
1642        }
1643        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1644            |bytes, handles| {
1645                match this.inner.channel().read_etc(cx, bytes, handles) {
1646                    std::task::Poll::Ready(Ok(())) => {}
1647                    std::task::Poll::Pending => return std::task::Poll::Pending,
1648                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1649                        this.is_terminated = true;
1650                        return std::task::Poll::Ready(None);
1651                    }
1652                    std::task::Poll::Ready(Err(e)) => {
1653                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1654                            e.into(),
1655                        ))));
1656                    }
1657                }
1658
1659                // A message has been received from the channel
1660                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1661
1662                std::task::Poll::Ready(Some(match header.ordinal {
1663                    0x3c5e51096d9299b5 => {
1664                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1665                        let mut req = fidl::new_empty!(
1666                            fidl::encoding::EmptyPayload,
1667                            fidl::encoding::DefaultFuchsiaResourceDialect
1668                        );
1669                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1670                        let control_handle =
1671                            ViewRefFocusedControlHandle { inner: this.inner.clone() };
1672                        Ok(ViewRefFocusedRequest::Watch {
1673                            responder: ViewRefFocusedWatchResponder {
1674                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1675                                tx_id: header.tx_id,
1676                            },
1677                        })
1678                    }
1679                    _ => Err(fidl::Error::UnknownOrdinal {
1680                        ordinal: header.ordinal,
1681                        protocol_name:
1682                            <ViewRefFocusedMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1683                    }),
1684                }))
1685            },
1686        )
1687    }
1688}
1689
1690/// A method of enabling a ViewRef creator to determine if its ViewRef has
1691/// gained or lost focus in the view tree.
1692///
1693/// The protocol client has implicit access to the ViewRef it created; the
1694/// protocol itself does not accept a ViewRef parameter. Clients, both trusted
1695/// or otherwise, need access to view-focus state, so the protocol is
1696/// deliberately minimal. Possession of a ViewRef (and this protocol) does not
1697/// grant the power to learn about a ViewRef's focus state.
1698#[derive(Debug)]
1699pub enum ViewRefFocusedRequest {
1700    /// Sets up a callback to fire when the implicit ViewRef has gained or lost
1701    /// focus. Typically, focus changes happen at a slow pace, such that every
1702    /// transition is captured by the callback. However, focus changes can
1703    /// happen rapidly, so the callback may "compress" focus change history into
1704    /// just the latest known focus state.
1705    ///
1706    /// The callback reports the last focus change spanning the duration from
1707    /// its issuance to the previous callback's issuance. The client may observe
1708    /// any of the following four transitions:
1709    /// - true -> true: The ViewRef has lost focus at least once, and has gained
1710    ///   focus by the time of callback issuance.
1711    /// - true -> false: The ViewRef has lost focus at least once, and has lost
1712    ///   focus by the time of callback issuance.
1713    /// - false -> true: The ViewRef has gained focus at least once, and has
1714    ///   gained focus by the time of callback issuance.
1715    /// - false -> false: The ViewRef has gained focus at least once, and has
1716    ///   lost focus by the time of callback issuance.
1717    ///
1718    /// The client avoids "focus flapping" and always sees the latest state.
1719    /// Every callback issuance is meaningful, and the client should renegotiate
1720    /// focus-related services appropriately, such as IME.
1721    ///
1722    /// Flow control: The caller is allowed at most one in-flight |Watch| call
1723    /// at at time: subsequent |Watch| calls must wait until the acknowledgment
1724    /// returns. Non-compliance results in channel closure.
1725    Watch { responder: ViewRefFocusedWatchResponder },
1726}
1727
1728impl ViewRefFocusedRequest {
1729    #[allow(irrefutable_let_patterns)]
1730    pub fn into_watch(self) -> Option<(ViewRefFocusedWatchResponder)> {
1731        if let ViewRefFocusedRequest::Watch { responder } = self { Some((responder)) } else { None }
1732    }
1733
1734    /// Name of the method defined in FIDL
1735    pub fn method_name(&self) -> &'static str {
1736        match *self {
1737            ViewRefFocusedRequest::Watch { .. } => "watch",
1738        }
1739    }
1740}
1741
1742#[derive(Debug, Clone)]
1743pub struct ViewRefFocusedControlHandle {
1744    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1745}
1746
1747impl fidl::endpoints::ControlHandle for ViewRefFocusedControlHandle {
1748    fn shutdown(&self) {
1749        self.inner.shutdown()
1750    }
1751
1752    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1753        self.inner.shutdown_with_epitaph(status)
1754    }
1755
1756    fn is_closed(&self) -> bool {
1757        self.inner.channel().is_closed()
1758    }
1759    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1760        self.inner.channel().on_closed()
1761    }
1762
1763    #[cfg(target_os = "fuchsia")]
1764    fn signal_peer(
1765        &self,
1766        clear_mask: zx::Signals,
1767        set_mask: zx::Signals,
1768    ) -> Result<(), zx_status::Status> {
1769        use fidl::Peered;
1770        self.inner.channel().signal_peer(clear_mask, set_mask)
1771    }
1772}
1773
1774impl ViewRefFocusedControlHandle {}
1775
1776#[must_use = "FIDL methods require a response to be sent"]
1777#[derive(Debug)]
1778pub struct ViewRefFocusedWatchResponder {
1779    control_handle: std::mem::ManuallyDrop<ViewRefFocusedControlHandle>,
1780    tx_id: u32,
1781}
1782
1783/// Set the the channel to be shutdown (see [`ViewRefFocusedControlHandle::shutdown`])
1784/// if the responder is dropped without sending a response, so that the client
1785/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1786impl std::ops::Drop for ViewRefFocusedWatchResponder {
1787    fn drop(&mut self) {
1788        self.control_handle.shutdown();
1789        // Safety: drops once, never accessed again
1790        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1791    }
1792}
1793
1794impl fidl::endpoints::Responder for ViewRefFocusedWatchResponder {
1795    type ControlHandle = ViewRefFocusedControlHandle;
1796
1797    fn control_handle(&self) -> &ViewRefFocusedControlHandle {
1798        &self.control_handle
1799    }
1800
1801    fn drop_without_shutdown(mut self) {
1802        // Safety: drops once, never accessed again due to mem::forget
1803        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1804        // Prevent Drop from running (which would shut down the channel)
1805        std::mem::forget(self);
1806    }
1807}
1808
1809impl ViewRefFocusedWatchResponder {
1810    /// Sends a response to the FIDL transaction.
1811    ///
1812    /// Sets the channel to shutdown if an error occurs.
1813    pub fn send(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1814        let _result = self.send_raw(state);
1815        if _result.is_err() {
1816            self.control_handle.shutdown();
1817        }
1818        self.drop_without_shutdown();
1819        _result
1820    }
1821
1822    /// Similar to "send" but does not shutdown the channel if an error occurs.
1823    pub fn send_no_shutdown_on_err(self, mut state: &FocusState) -> Result<(), fidl::Error> {
1824        let _result = self.send_raw(state);
1825        self.drop_without_shutdown();
1826        _result
1827    }
1828
1829    fn send_raw(&self, mut state: &FocusState) -> Result<(), fidl::Error> {
1830        self.control_handle.inner.send::<ViewRefFocusedWatchResponse>(
1831            (state,),
1832            self.tx_id,
1833            0x3c5e51096d9299b5,
1834            fidl::encoding::DynamicFlags::empty(),
1835        )
1836    }
1837}
1838
1839#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1840pub struct ViewRefInstalledMarker;
1841
1842impl fidl::endpoints::ProtocolMarker for ViewRefInstalledMarker {
1843    type Proxy = ViewRefInstalledProxy;
1844    type RequestStream = ViewRefInstalledRequestStream;
1845    #[cfg(target_os = "fuchsia")]
1846    type SynchronousProxy = ViewRefInstalledSynchronousProxy;
1847
1848    const DEBUG_NAME: &'static str = "fuchsia.ui.views.ViewRefInstalled";
1849}
1850impl fidl::endpoints::DiscoverableProtocolMarker for ViewRefInstalledMarker {}
1851pub type ViewRefInstalledWatchResult = Result<(), ViewRefInstalledError>;
1852
1853pub trait ViewRefInstalledProxyInterface: Send + Sync {
1854    type WatchResponseFut: std::future::Future<Output = Result<ViewRefInstalledWatchResult, fidl::Error>>
1855        + Send;
1856    fn r#watch(&self, view_ref: ViewRef) -> Self::WatchResponseFut;
1857}
1858#[derive(Debug)]
1859#[cfg(target_os = "fuchsia")]
1860pub struct ViewRefInstalledSynchronousProxy {
1861    client: fidl::client::sync::Client,
1862}
1863
1864#[cfg(target_os = "fuchsia")]
1865impl fidl::endpoints::SynchronousProxy for ViewRefInstalledSynchronousProxy {
1866    type Proxy = ViewRefInstalledProxy;
1867    type Protocol = ViewRefInstalledMarker;
1868
1869    fn from_channel(inner: fidl::Channel) -> Self {
1870        Self::new(inner)
1871    }
1872
1873    fn into_channel(self) -> fidl::Channel {
1874        self.client.into_channel()
1875    }
1876
1877    fn as_channel(&self) -> &fidl::Channel {
1878        self.client.as_channel()
1879    }
1880}
1881
1882#[cfg(target_os = "fuchsia")]
1883impl ViewRefInstalledSynchronousProxy {
1884    pub fn new(channel: fidl::Channel) -> Self {
1885        let protocol_name = <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1886        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1887    }
1888
1889    pub fn into_channel(self) -> fidl::Channel {
1890        self.client.into_channel()
1891    }
1892
1893    /// Waits until an event arrives and returns it. It is safe for other
1894    /// threads to make concurrent requests while waiting for an event.
1895    pub fn wait_for_event(
1896        &self,
1897        deadline: zx::MonotonicInstant,
1898    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
1899        ViewRefInstalledEvent::decode(self.client.wait_for_event(deadline)?)
1900    }
1901
1902    /// Sets up a callback to fire when the requested |view_ref| is installed.
1903    /// - If |view_ref| has not already been installed, the |Watch| response
1904    ///   will fire when it is.
1905    /// - If |view_ref| has already been installed, the |Watch| response will
1906    ///   fire immediately.
1907    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
1908    ///   was destroyed), the |Watch| call returns with an error.  The error is
1909    ///   not guaranteed to be immediate, but a ViewRef holder can itself
1910    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
1911    ///
1912    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
1913    /// ViewRefs. There is at most one response per call back to the client.
1914    ///
1915    /// Note: Prior to installation, this |Watch| call is kept alive as long as
1916    ///       the ViewRef is valid.
1917    pub fn r#watch(
1918        &self,
1919        mut view_ref: ViewRef,
1920        ___deadline: zx::MonotonicInstant,
1921    ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
1922        let _response =
1923            self.client.send_query::<ViewRefInstalledWatchRequest, fidl::encoding::ResultType<
1924                fidl::encoding::EmptyStruct,
1925                ViewRefInstalledError,
1926            >>(
1927                (&mut view_ref,),
1928                0x7ddec2f4ca687971,
1929                fidl::encoding::DynamicFlags::empty(),
1930                ___deadline,
1931            )?;
1932        Ok(_response.map(|x| x))
1933    }
1934}
1935
1936#[cfg(target_os = "fuchsia")]
1937impl From<ViewRefInstalledSynchronousProxy> for zx::NullableHandle {
1938    fn from(value: ViewRefInstalledSynchronousProxy) -> Self {
1939        value.into_channel().into()
1940    }
1941}
1942
1943#[cfg(target_os = "fuchsia")]
1944impl From<fidl::Channel> for ViewRefInstalledSynchronousProxy {
1945    fn from(value: fidl::Channel) -> Self {
1946        Self::new(value)
1947    }
1948}
1949
1950#[cfg(target_os = "fuchsia")]
1951impl fidl::endpoints::FromClient for ViewRefInstalledSynchronousProxy {
1952    type Protocol = ViewRefInstalledMarker;
1953
1954    fn from_client(value: fidl::endpoints::ClientEnd<ViewRefInstalledMarker>) -> Self {
1955        Self::new(value.into_channel())
1956    }
1957}
1958
1959#[derive(Debug, Clone)]
1960pub struct ViewRefInstalledProxy {
1961    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1962}
1963
1964impl fidl::endpoints::Proxy for ViewRefInstalledProxy {
1965    type Protocol = ViewRefInstalledMarker;
1966
1967    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1968        Self::new(inner)
1969    }
1970
1971    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1972        self.client.into_channel().map_err(|client| Self { client })
1973    }
1974
1975    fn as_channel(&self) -> &::fidl::AsyncChannel {
1976        self.client.as_channel()
1977    }
1978}
1979
1980impl ViewRefInstalledProxy {
1981    /// Create a new Proxy for fuchsia.ui.views/ViewRefInstalled.
1982    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1983        let protocol_name = <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1984        Self { client: fidl::client::Client::new(channel, protocol_name) }
1985    }
1986
1987    /// Get a Stream of events from the remote end of the protocol.
1988    ///
1989    /// # Panics
1990    ///
1991    /// Panics if the event stream was already taken.
1992    pub fn take_event_stream(&self) -> ViewRefInstalledEventStream {
1993        ViewRefInstalledEventStream { event_receiver: self.client.take_event_receiver() }
1994    }
1995
1996    /// Sets up a callback to fire when the requested |view_ref| is installed.
1997    /// - If |view_ref| has not already been installed, the |Watch| response
1998    ///   will fire when it is.
1999    /// - If |view_ref| has already been installed, the |Watch| response will
2000    ///   fire immediately.
2001    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2002    ///   was destroyed), the |Watch| call returns with an error.  The error is
2003    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2004    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2005    ///
2006    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2007    /// ViewRefs. There is at most one response per call back to the client.
2008    ///
2009    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2010    ///       the ViewRef is valid.
2011    pub fn r#watch(
2012        &self,
2013        mut view_ref: ViewRef,
2014    ) -> fidl::client::QueryResponseFut<
2015        ViewRefInstalledWatchResult,
2016        fidl::encoding::DefaultFuchsiaResourceDialect,
2017    > {
2018        ViewRefInstalledProxyInterface::r#watch(self, view_ref)
2019    }
2020}
2021
2022impl ViewRefInstalledProxyInterface for ViewRefInstalledProxy {
2023    type WatchResponseFut = fidl::client::QueryResponseFut<
2024        ViewRefInstalledWatchResult,
2025        fidl::encoding::DefaultFuchsiaResourceDialect,
2026    >;
2027    fn r#watch(&self, mut view_ref: ViewRef) -> Self::WatchResponseFut {
2028        fn _decode(
2029            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2030        ) -> Result<ViewRefInstalledWatchResult, fidl::Error> {
2031            let _response = fidl::client::decode_transaction_body::<
2032                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ViewRefInstalledError>,
2033                fidl::encoding::DefaultFuchsiaResourceDialect,
2034                0x7ddec2f4ca687971,
2035            >(_buf?)?;
2036            Ok(_response.map(|x| x))
2037        }
2038        self.client
2039            .send_query_and_decode::<ViewRefInstalledWatchRequest, ViewRefInstalledWatchResult>(
2040                (&mut view_ref,),
2041                0x7ddec2f4ca687971,
2042                fidl::encoding::DynamicFlags::empty(),
2043                _decode,
2044            )
2045    }
2046}
2047
2048pub struct ViewRefInstalledEventStream {
2049    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2050}
2051
2052impl std::marker::Unpin for ViewRefInstalledEventStream {}
2053
2054impl futures::stream::FusedStream for ViewRefInstalledEventStream {
2055    fn is_terminated(&self) -> bool {
2056        self.event_receiver.is_terminated()
2057    }
2058}
2059
2060impl futures::Stream for ViewRefInstalledEventStream {
2061    type Item = Result<ViewRefInstalledEvent, fidl::Error>;
2062
2063    fn poll_next(
2064        mut self: std::pin::Pin<&mut Self>,
2065        cx: &mut std::task::Context<'_>,
2066    ) -> std::task::Poll<Option<Self::Item>> {
2067        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2068            &mut self.event_receiver,
2069            cx
2070        )?) {
2071            Some(buf) => std::task::Poll::Ready(Some(ViewRefInstalledEvent::decode(buf))),
2072            None => std::task::Poll::Ready(None),
2073        }
2074    }
2075}
2076
2077#[derive(Debug)]
2078pub enum ViewRefInstalledEvent {}
2079
2080impl ViewRefInstalledEvent {
2081    /// Decodes a message buffer as a [`ViewRefInstalledEvent`].
2082    fn decode(
2083        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2084    ) -> Result<ViewRefInstalledEvent, fidl::Error> {
2085        let (bytes, _handles) = buf.split_mut();
2086        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2087        debug_assert_eq!(tx_header.tx_id, 0);
2088        match tx_header.ordinal {
2089            _ => Err(fidl::Error::UnknownOrdinal {
2090                ordinal: tx_header.ordinal,
2091                protocol_name:
2092                    <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2093            }),
2094        }
2095    }
2096}
2097
2098/// A Stream of incoming requests for fuchsia.ui.views/ViewRefInstalled.
2099pub struct ViewRefInstalledRequestStream {
2100    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2101    is_terminated: bool,
2102}
2103
2104impl std::marker::Unpin for ViewRefInstalledRequestStream {}
2105
2106impl futures::stream::FusedStream for ViewRefInstalledRequestStream {
2107    fn is_terminated(&self) -> bool {
2108        self.is_terminated
2109    }
2110}
2111
2112impl fidl::endpoints::RequestStream for ViewRefInstalledRequestStream {
2113    type Protocol = ViewRefInstalledMarker;
2114    type ControlHandle = ViewRefInstalledControlHandle;
2115
2116    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2117        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2118    }
2119
2120    fn control_handle(&self) -> Self::ControlHandle {
2121        ViewRefInstalledControlHandle { inner: self.inner.clone() }
2122    }
2123
2124    fn into_inner(
2125        self,
2126    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2127    {
2128        (self.inner, self.is_terminated)
2129    }
2130
2131    fn from_inner(
2132        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2133        is_terminated: bool,
2134    ) -> Self {
2135        Self { inner, is_terminated }
2136    }
2137}
2138
2139impl futures::Stream for ViewRefInstalledRequestStream {
2140    type Item = Result<ViewRefInstalledRequest, fidl::Error>;
2141
2142    fn poll_next(
2143        mut self: std::pin::Pin<&mut Self>,
2144        cx: &mut std::task::Context<'_>,
2145    ) -> std::task::Poll<Option<Self::Item>> {
2146        let this = &mut *self;
2147        if this.inner.check_shutdown(cx) {
2148            this.is_terminated = true;
2149            return std::task::Poll::Ready(None);
2150        }
2151        if this.is_terminated {
2152            panic!("polled ViewRefInstalledRequestStream after completion");
2153        }
2154        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2155            |bytes, handles| {
2156                match this.inner.channel().read_etc(cx, bytes, handles) {
2157                    std::task::Poll::Ready(Ok(())) => {}
2158                    std::task::Poll::Pending => return std::task::Poll::Pending,
2159                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2160                        this.is_terminated = true;
2161                        return std::task::Poll::Ready(None);
2162                    }
2163                    std::task::Poll::Ready(Err(e)) => {
2164                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2165                            e.into(),
2166                        ))));
2167                    }
2168                }
2169
2170                // A message has been received from the channel
2171                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2172
2173                std::task::Poll::Ready(Some(match header.ordinal {
2174                    0x7ddec2f4ca687971 => {
2175                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2176                        let mut req = fidl::new_empty!(
2177                            ViewRefInstalledWatchRequest,
2178                            fidl::encoding::DefaultFuchsiaResourceDialect
2179                        );
2180                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ViewRefInstalledWatchRequest>(&header, _body_bytes, handles, &mut req)?;
2181                        let control_handle =
2182                            ViewRefInstalledControlHandle { inner: this.inner.clone() };
2183                        Ok(ViewRefInstalledRequest::Watch {
2184                            view_ref: req.view_ref,
2185
2186                            responder: ViewRefInstalledWatchResponder {
2187                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2188                                tx_id: header.tx_id,
2189                            },
2190                        })
2191                    }
2192                    _ => Err(fidl::Error::UnknownOrdinal {
2193                        ordinal: header.ordinal,
2194                        protocol_name:
2195                            <ViewRefInstalledMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2196                    }),
2197                }))
2198            },
2199        )
2200    }
2201}
2202
2203/// A method of enabling ViewRef holders to determine if a ViewRef has been
2204/// "installed" in the view tree: the time it is first connected, transitively,
2205/// to the root view.  Typically, after installation, view focus may be
2206/// transferred to that ViewRef.
2207///
2208/// Note: It's important to distinguish between a ViewRef's installed status and
2209///       current connected-to-view-tree status.  The former undergoes a state
2210///       change once, from "no" to "yes".  The latter may change continuously,
2211///       depending on view tree topology.  As such, "installed" cannot imply
2212///       "currently connected to view tree"; even a hypothetical
2213///       "ViewRefConnected" protocol is fundamentally racy.
2214#[derive(Debug)]
2215pub enum ViewRefInstalledRequest {
2216    /// Sets up a callback to fire when the requested |view_ref| is installed.
2217    /// - If |view_ref| has not already been installed, the |Watch| response
2218    ///   will fire when it is.
2219    /// - If |view_ref| has already been installed, the |Watch| response will
2220    ///   fire immediately.
2221    /// - If |view_ref| is invalid, or becomes invalid (perhaps because the view
2222    ///   was destroyed), the |Watch| call returns with an error.  The error is
2223    ///   not guaranteed to be immediate, but a ViewRef holder can itself
2224    ///   determine ViewRef validity by listening for ZX_EVENTPAIR_PEER_CLOSED.
2225    ///
2226    /// Flow control: The caller is allowed multiple |Watch| calls on multiple
2227    /// ViewRefs. There is at most one response per call back to the client.
2228    ///
2229    /// Note: Prior to installation, this |Watch| call is kept alive as long as
2230    ///       the ViewRef is valid.
2231    Watch { view_ref: ViewRef, responder: ViewRefInstalledWatchResponder },
2232}
2233
2234impl ViewRefInstalledRequest {
2235    #[allow(irrefutable_let_patterns)]
2236    pub fn into_watch(self) -> Option<(ViewRef, ViewRefInstalledWatchResponder)> {
2237        if let ViewRefInstalledRequest::Watch { view_ref, responder } = self {
2238            Some((view_ref, responder))
2239        } else {
2240            None
2241        }
2242    }
2243
2244    /// Name of the method defined in FIDL
2245    pub fn method_name(&self) -> &'static str {
2246        match *self {
2247            ViewRefInstalledRequest::Watch { .. } => "watch",
2248        }
2249    }
2250}
2251
2252#[derive(Debug, Clone)]
2253pub struct ViewRefInstalledControlHandle {
2254    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2255}
2256
2257impl fidl::endpoints::ControlHandle for ViewRefInstalledControlHandle {
2258    fn shutdown(&self) {
2259        self.inner.shutdown()
2260    }
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    > fidl::encoding::Encode<ViewCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2528        for (T0,)
2529    {
2530        #[inline]
2531        unsafe fn encode(
2532            self,
2533            encoder: &mut fidl::encoding::Encoder<
2534                '_,
2535                fidl::encoding::DefaultFuchsiaResourceDialect,
2536            >,
2537            offset: usize,
2538            depth: fidl::encoding::Depth,
2539        ) -> fidl::Result<()> {
2540            encoder.debug_check_bounds::<ViewCreationToken>(offset);
2541            // Zero out padding regions. There's no need to apply masks
2542            // because the unmasked parts will be overwritten by fields.
2543            // Write the fields.
2544            self.0.encode(encoder, offset + 0, depth)?;
2545            Ok(())
2546        }
2547    }
2548
2549    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2550        for ViewCreationToken
2551    {
2552        #[inline(always)]
2553        fn new_empty() -> Self {
2554            Self {
2555                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2556            }
2557        }
2558
2559        #[inline]
2560        unsafe fn decode(
2561            &mut self,
2562            decoder: &mut fidl::encoding::Decoder<
2563                '_,
2564                fidl::encoding::DefaultFuchsiaResourceDialect,
2565            >,
2566            offset: usize,
2567            _depth: fidl::encoding::Depth,
2568        ) -> fidl::Result<()> {
2569            decoder.debug_check_bounds::<Self>(offset);
2570            // Verify that padding bytes are zero.
2571            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2572            Ok(())
2573        }
2574    }
2575
2576    impl fidl::encoding::ResourceTypeMarker for ViewHolderToken {
2577        type Borrowed<'a> = &'a mut Self;
2578        fn take_or_borrow<'a>(
2579            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2580        ) -> Self::Borrowed<'a> {
2581            value
2582        }
2583    }
2584
2585    unsafe impl fidl::encoding::TypeMarker for ViewHolderToken {
2586        type Owned = Self;
2587
2588        #[inline(always)]
2589        fn inline_align(_context: fidl::encoding::Context) -> usize {
2590            4
2591        }
2592
2593        #[inline(always)]
2594        fn inline_size(_context: fidl::encoding::Context) -> usize {
2595            4
2596        }
2597    }
2598
2599    unsafe impl
2600        fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2601        for &mut ViewHolderToken
2602    {
2603        #[inline]
2604        unsafe fn encode(
2605            self,
2606            encoder: &mut fidl::encoding::Encoder<
2607                '_,
2608                fidl::encoding::DefaultFuchsiaResourceDialect,
2609            >,
2610            offset: usize,
2611            _depth: fidl::encoding::Depth,
2612        ) -> fidl::Result<()> {
2613            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2614            // Delegate to tuple encoding.
2615            fidl::encoding::Encode::<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2616                (
2617                    <fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.value),
2618                ),
2619                encoder, offset, _depth
2620            )
2621        }
2622    }
2623    unsafe impl<
2624        T0: fidl::encoding::Encode<
2625                fidl::encoding::HandleType<
2626                    fidl::EventPair,
2627                    { fidl::ObjectType::EVENTPAIR.into_raw() },
2628                    2147483648,
2629                >,
2630                fidl::encoding::DefaultFuchsiaResourceDialect,
2631            >,
2632    > fidl::encoding::Encode<ViewHolderToken, fidl::encoding::DefaultFuchsiaResourceDialect>
2633        for (T0,)
2634    {
2635        #[inline]
2636        unsafe fn encode(
2637            self,
2638            encoder: &mut fidl::encoding::Encoder<
2639                '_,
2640                fidl::encoding::DefaultFuchsiaResourceDialect,
2641            >,
2642            offset: usize,
2643            depth: fidl::encoding::Depth,
2644        ) -> fidl::Result<()> {
2645            encoder.debug_check_bounds::<ViewHolderToken>(offset);
2646            // Zero out padding regions. There's no need to apply masks
2647            // because the unmasked parts will be overwritten by fields.
2648            // Write the fields.
2649            self.0.encode(encoder, offset + 0, depth)?;
2650            Ok(())
2651        }
2652    }
2653
2654    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2655        for ViewHolderToken
2656    {
2657        #[inline(always)]
2658        fn new_empty() -> Self {
2659            Self {
2660                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
2661            }
2662        }
2663
2664        #[inline]
2665        unsafe fn decode(
2666            &mut self,
2667            decoder: &mut fidl::encoding::Decoder<
2668                '_,
2669                fidl::encoding::DefaultFuchsiaResourceDialect,
2670            >,
2671            offset: usize,
2672            _depth: fidl::encoding::Depth,
2673        ) -> fidl::Result<()> {
2674            decoder.debug_check_bounds::<Self>(offset);
2675            // Verify that padding bytes are zero.
2676            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
2677            Ok(())
2678        }
2679    }
2680
2681    impl fidl::encoding::ResourceTypeMarker for ViewIdentityOnCreation {
2682        type Borrowed<'a> = &'a mut Self;
2683        fn take_or_borrow<'a>(
2684            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2685        ) -> Self::Borrowed<'a> {
2686            value
2687        }
2688    }
2689
2690    unsafe impl fidl::encoding::TypeMarker for ViewIdentityOnCreation {
2691        type Owned = Self;
2692
2693        #[inline(always)]
2694        fn inline_align(_context: fidl::encoding::Context) -> usize {
2695            4
2696        }
2697
2698        #[inline(always)]
2699        fn inline_size(_context: fidl::encoding::Context) -> usize {
2700            8
2701        }
2702    }
2703
2704    unsafe impl
2705        fidl::encoding::Encode<
2706            ViewIdentityOnCreation,
2707            fidl::encoding::DefaultFuchsiaResourceDialect,
2708        > for &mut ViewIdentityOnCreation
2709    {
2710        #[inline]
2711        unsafe fn encode(
2712            self,
2713            encoder: &mut fidl::encoding::Encoder<
2714                '_,
2715                fidl::encoding::DefaultFuchsiaResourceDialect,
2716            >,
2717            offset: usize,
2718            _depth: fidl::encoding::Depth,
2719        ) -> fidl::Result<()> {
2720            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2721            // Delegate to tuple encoding.
2722            fidl::encoding::Encode::<
2723                ViewIdentityOnCreation,
2724                fidl::encoding::DefaultFuchsiaResourceDialect,
2725            >::encode(
2726                (
2727                    <ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2728                        &mut self.view_ref,
2729                    ),
2730                    <ViewRefControl as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2731                        &mut self.view_ref_control,
2732                    ),
2733                ),
2734                encoder,
2735                offset,
2736                _depth,
2737            )
2738        }
2739    }
2740    unsafe impl<
2741        T0: fidl::encoding::Encode<ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect>,
2742        T1: fidl::encoding::Encode<ViewRefControl, fidl::encoding::DefaultFuchsiaResourceDialect>,
2743    >
2744        fidl::encoding::Encode<
2745            ViewIdentityOnCreation,
2746            fidl::encoding::DefaultFuchsiaResourceDialect,
2747        > for (T0, T1)
2748    {
2749        #[inline]
2750        unsafe fn encode(
2751            self,
2752            encoder: &mut fidl::encoding::Encoder<
2753                '_,
2754                fidl::encoding::DefaultFuchsiaResourceDialect,
2755            >,
2756            offset: usize,
2757            depth: fidl::encoding::Depth,
2758        ) -> fidl::Result<()> {
2759            encoder.debug_check_bounds::<ViewIdentityOnCreation>(offset);
2760            // Zero out padding regions. There's no need to apply masks
2761            // because the unmasked parts will be overwritten by fields.
2762            // Write the fields.
2763            self.0.encode(encoder, offset + 0, depth)?;
2764            self.1.encode(encoder, offset + 4, depth)?;
2765            Ok(())
2766        }
2767    }
2768
2769    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2770        for ViewIdentityOnCreation
2771    {
2772        #[inline(always)]
2773        fn new_empty() -> Self {
2774            Self {
2775                view_ref: fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect),
2776                view_ref_control: fidl::new_empty!(
2777                    ViewRefControl,
2778                    fidl::encoding::DefaultFuchsiaResourceDialect
2779                ),
2780            }
2781        }
2782
2783        #[inline]
2784        unsafe fn decode(
2785            &mut self,
2786            decoder: &mut fidl::encoding::Decoder<
2787                '_,
2788                fidl::encoding::DefaultFuchsiaResourceDialect,
2789            >,
2790            offset: usize,
2791            _depth: fidl::encoding::Depth,
2792        ) -> fidl::Result<()> {
2793            decoder.debug_check_bounds::<Self>(offset);
2794            // Verify that padding bytes are zero.
2795            fidl::decode!(
2796                ViewRef,
2797                fidl::encoding::DefaultFuchsiaResourceDialect,
2798                &mut self.view_ref,
2799                decoder,
2800                offset + 0,
2801                _depth
2802            )?;
2803            fidl::decode!(
2804                ViewRefControl,
2805                fidl::encoding::DefaultFuchsiaResourceDialect,
2806                &mut self.view_ref_control,
2807                decoder,
2808                offset + 4,
2809                _depth
2810            )?;
2811            Ok(())
2812        }
2813    }
2814
2815    impl fidl::encoding::ResourceTypeMarker for ViewPresentRequest {
2816        type Borrowed<'a> = &'a mut Self;
2817        fn take_or_borrow<'a>(
2818            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2819        ) -> Self::Borrowed<'a> {
2820            value
2821        }
2822    }
2823
2824    unsafe impl fidl::encoding::TypeMarker for ViewPresentRequest {
2825        type Owned = Self;
2826
2827        #[inline(always)]
2828        fn inline_align(_context: fidl::encoding::Context) -> usize {
2829            4
2830        }
2831
2832        #[inline(always)]
2833        fn inline_size(_context: fidl::encoding::Context) -> usize {
2834            4
2835        }
2836    }
2837
2838    unsafe impl
2839        fidl::encoding::Encode<ViewPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
2840        for &mut ViewPresentRequest
2841    {
2842        #[inline]
2843        unsafe fn encode(
2844            self,
2845            encoder: &mut fidl::encoding::Encoder<
2846                '_,
2847                fidl::encoding::DefaultFuchsiaResourceDialect,
2848            >,
2849            offset: usize,
2850            _depth: fidl::encoding::Depth,
2851        ) -> fidl::Result<()> {
2852            encoder.debug_check_bounds::<ViewPresentRequest>(offset);
2853            // Delegate to tuple encoding.
2854            fidl::encoding::Encode::<
2855                ViewPresentRequest,
2856                fidl::encoding::DefaultFuchsiaResourceDialect,
2857            >::encode(
2858                (<ViewToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
2859                    &mut self.view_token,
2860                ),),
2861                encoder,
2862                offset,
2863                _depth,
2864            )
2865        }
2866    }
2867    unsafe impl<
2868        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> for (T0,)
3309    {
3310        #[inline]
3311        unsafe fn encode(
3312            self,
3313            encoder: &mut fidl::encoding::Encoder<
3314                '_,
3315                fidl::encoding::DefaultFuchsiaResourceDialect,
3316            >,
3317            offset: usize,
3318            depth: fidl::encoding::Depth,
3319        ) -> fidl::Result<()> {
3320            encoder.debug_check_bounds::<ViewToken>(offset);
3321            // Zero out padding regions. There's no need to apply masks
3322            // because the unmasked parts will be overwritten by fields.
3323            // Write the fields.
3324            self.0.encode(encoder, offset + 0, depth)?;
3325            Ok(())
3326        }
3327    }
3328
3329    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for ViewToken {
3330        #[inline(always)]
3331        fn new_empty() -> Self {
3332            Self {
3333                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3334            }
3335        }
3336
3337        #[inline]
3338        unsafe fn decode(
3339            &mut self,
3340            decoder: &mut fidl::encoding::Decoder<
3341                '_,
3342                fidl::encoding::DefaultFuchsiaResourceDialect,
3343            >,
3344            offset: usize,
3345            _depth: fidl::encoding::Depth,
3346        ) -> fidl::Result<()> {
3347            decoder.debug_check_bounds::<Self>(offset);
3348            // Verify that padding bytes are zero.
3349            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3350            Ok(())
3351        }
3352    }
3353
3354    impl fidl::encoding::ResourceTypeMarker for ViewportCreationToken {
3355        type Borrowed<'a> = &'a mut Self;
3356        fn take_or_borrow<'a>(
3357            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3358        ) -> Self::Borrowed<'a> {
3359            value
3360        }
3361    }
3362
3363    unsafe impl fidl::encoding::TypeMarker for ViewportCreationToken {
3364        type Owned = Self;
3365
3366        #[inline(always)]
3367        fn inline_align(_context: fidl::encoding::Context) -> usize {
3368            4
3369        }
3370
3371        #[inline(always)]
3372        fn inline_size(_context: fidl::encoding::Context) -> usize {
3373            4
3374        }
3375    }
3376
3377    unsafe impl
3378        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3379        for &mut ViewportCreationToken
3380    {
3381        #[inline]
3382        unsafe fn encode(
3383            self,
3384            encoder: &mut fidl::encoding::Encoder<
3385                '_,
3386                fidl::encoding::DefaultFuchsiaResourceDialect,
3387            >,
3388            offset: usize,
3389            _depth: fidl::encoding::Depth,
3390        ) -> fidl::Result<()> {
3391            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3392            // Delegate to tuple encoding.
3393            fidl::encoding::Encode::<
3394                ViewportCreationToken,
3395                fidl::encoding::DefaultFuchsiaResourceDialect,
3396            >::encode(
3397                (<fidl::encoding::HandleType<
3398                    fidl::Channel,
3399                    { fidl::ObjectType::CHANNEL.into_raw() },
3400                    2147483648,
3401                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3402                    &mut self.value
3403                ),),
3404                encoder,
3405                offset,
3406                _depth,
3407            )
3408        }
3409    }
3410    unsafe impl<
3411        T0: fidl::encoding::Encode<
3412                fidl::encoding::HandleType<
3413                    fidl::Channel,
3414                    { fidl::ObjectType::CHANNEL.into_raw() },
3415                    2147483648,
3416                >,
3417                fidl::encoding::DefaultFuchsiaResourceDialect,
3418            >,
3419    >
3420        fidl::encoding::Encode<ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>
3421        for (T0,)
3422    {
3423        #[inline]
3424        unsafe fn encode(
3425            self,
3426            encoder: &mut fidl::encoding::Encoder<
3427                '_,
3428                fidl::encoding::DefaultFuchsiaResourceDialect,
3429            >,
3430            offset: usize,
3431            depth: fidl::encoding::Depth,
3432        ) -> fidl::Result<()> {
3433            encoder.debug_check_bounds::<ViewportCreationToken>(offset);
3434            // Zero out padding regions. There's no need to apply masks
3435            // because the unmasked parts will be overwritten by fields.
3436            // Write the fields.
3437            self.0.encode(encoder, offset + 0, depth)?;
3438            Ok(())
3439        }
3440    }
3441
3442    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3443        for ViewportCreationToken
3444    {
3445        #[inline(always)]
3446        fn new_empty() -> Self {
3447            Self {
3448                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3449            }
3450        }
3451
3452        #[inline]
3453        unsafe fn decode(
3454            &mut self,
3455            decoder: &mut fidl::encoding::Decoder<
3456                '_,
3457                fidl::encoding::DefaultFuchsiaResourceDialect,
3458            >,
3459            offset: usize,
3460            _depth: fidl::encoding::Depth,
3461        ) -> fidl::Result<()> {
3462            decoder.debug_check_bounds::<Self>(offset);
3463            // Verify that padding bytes are zero.
3464            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
3465            Ok(())
3466        }
3467    }
3468
3469    impl FocuserSetAutoFocusRequest {
3470        #[inline(always)]
3471        fn max_ordinal_present(&self) -> u64 {
3472            if let Some(_) = self.view_ref {
3473                return 1;
3474            }
3475            0
3476        }
3477    }
3478
3479    impl fidl::encoding::ResourceTypeMarker for FocuserSetAutoFocusRequest {
3480        type Borrowed<'a> = &'a mut Self;
3481        fn take_or_borrow<'a>(
3482            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3483        ) -> Self::Borrowed<'a> {
3484            value
3485        }
3486    }
3487
3488    unsafe impl fidl::encoding::TypeMarker for FocuserSetAutoFocusRequest {
3489        type Owned = Self;
3490
3491        #[inline(always)]
3492        fn inline_align(_context: fidl::encoding::Context) -> usize {
3493            8
3494        }
3495
3496        #[inline(always)]
3497        fn inline_size(_context: fidl::encoding::Context) -> usize {
3498            16
3499        }
3500    }
3501
3502    unsafe impl
3503        fidl::encoding::Encode<
3504            FocuserSetAutoFocusRequest,
3505            fidl::encoding::DefaultFuchsiaResourceDialect,
3506        > for &mut FocuserSetAutoFocusRequest
3507    {
3508        unsafe fn encode(
3509            self,
3510            encoder: &mut fidl::encoding::Encoder<
3511                '_,
3512                fidl::encoding::DefaultFuchsiaResourceDialect,
3513            >,
3514            offset: usize,
3515            mut depth: fidl::encoding::Depth,
3516        ) -> fidl::Result<()> {
3517            encoder.debug_check_bounds::<FocuserSetAutoFocusRequest>(offset);
3518            // Vector header
3519            let max_ordinal: u64 = self.max_ordinal_present();
3520            encoder.write_num(max_ordinal, offset);
3521            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
3522            // Calling encoder.out_of_line_offset(0) is not allowed.
3523            if max_ordinal == 0 {
3524                return Ok(());
3525            }
3526            depth.increment()?;
3527            let envelope_size = 8;
3528            let bytes_len = max_ordinal as usize * envelope_size;
3529            #[allow(unused_variables)]
3530            let offset = encoder.out_of_line_offset(bytes_len);
3531            let mut _prev_end_offset: usize = 0;
3532            if 1 > max_ordinal {
3533                return Ok(());
3534            }
3535
3536            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
3537            // are envelope_size bytes.
3538            let cur_offset: usize = (1 - 1) * envelope_size;
3539
3540            // Zero reserved fields.
3541            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
3542
3543            // Safety:
3544            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
3545            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
3546            //   envelope_size bytes, there is always sufficient room.
3547            fidl::encoding::encode_in_envelope_optional::<
3548                ViewRef,
3549                fidl::encoding::DefaultFuchsiaResourceDialect,
3550            >(
3551                self.view_ref
3552                    .as_mut()
3553                    .map(<ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
3554                encoder,
3555                offset + cur_offset,
3556                depth,
3557            )?;
3558
3559            _prev_end_offset = cur_offset + envelope_size;
3560
3561            Ok(())
3562        }
3563    }
3564
3565    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3566        for FocuserSetAutoFocusRequest
3567    {
3568        #[inline(always)]
3569        fn new_empty() -> Self {
3570            Self::default()
3571        }
3572
3573        unsafe fn decode(
3574            &mut self,
3575            decoder: &mut fidl::encoding::Decoder<
3576                '_,
3577                fidl::encoding::DefaultFuchsiaResourceDialect,
3578            >,
3579            offset: usize,
3580            mut depth: fidl::encoding::Depth,
3581        ) -> fidl::Result<()> {
3582            decoder.debug_check_bounds::<Self>(offset);
3583            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
3584                None => return Err(fidl::Error::NotNullable),
3585                Some(len) => len,
3586            };
3587            // Calling decoder.out_of_line_offset(0) is not allowed.
3588            if len == 0 {
3589                return Ok(());
3590            };
3591            depth.increment()?;
3592            let envelope_size = 8;
3593            let bytes_len = len * envelope_size;
3594            let offset = decoder.out_of_line_offset(bytes_len)?;
3595            // Decode the envelope for each type.
3596            let mut _next_ordinal_to_read = 0;
3597            let mut next_offset = offset;
3598            let end_offset = offset + bytes_len;
3599            _next_ordinal_to_read += 1;
3600            if next_offset >= end_offset {
3601                return Ok(());
3602            }
3603
3604            // Decode unknown envelopes for gaps in ordinals.
3605            while _next_ordinal_to_read < 1 {
3606                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3607                _next_ordinal_to_read += 1;
3608                next_offset += envelope_size;
3609            }
3610
3611            let next_out_of_line = decoder.next_out_of_line();
3612            let handles_before = decoder.remaining_handles();
3613            if let Some((inlined, num_bytes, num_handles)) =
3614                fidl::encoding::decode_envelope_header(decoder, next_offset)?
3615            {
3616                let member_inline_size =
3617                    <ViewRef as fidl::encoding::TypeMarker>::inline_size(decoder.context);
3618                if inlined != (member_inline_size <= 4) {
3619                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
3620                }
3621                let inner_offset;
3622                let mut inner_depth = depth.clone();
3623                if inlined {
3624                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
3625                    inner_offset = next_offset;
3626                } else {
3627                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
3628                    inner_depth.increment()?;
3629                }
3630                let val_ref = self.view_ref.get_or_insert_with(|| {
3631                    fidl::new_empty!(ViewRef, fidl::encoding::DefaultFuchsiaResourceDialect)
3632                });
3633                fidl::decode!(
3634                    ViewRef,
3635                    fidl::encoding::DefaultFuchsiaResourceDialect,
3636                    val_ref,
3637                    decoder,
3638                    inner_offset,
3639                    inner_depth
3640                )?;
3641                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
3642                {
3643                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
3644                }
3645                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
3646                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
3647                }
3648            }
3649
3650            next_offset += envelope_size;
3651
3652            // Decode the remaining unknown envelopes.
3653            while next_offset < end_offset {
3654                _next_ordinal_to_read += 1;
3655                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
3656                next_offset += envelope_size;
3657            }
3658
3659            Ok(())
3660        }
3661    }
3662}