fidl_fuchsia_ui_views/
fidl_fuchsia_ui_views.rs

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