fidl_fuchsia_ui_test_scene/
fidl_fuchsia_ui_test_scene.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_test_scene_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ControllerRegisterViewTreeWatcherRequest {
16    pub watcher:
17        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
18}
19
20impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
21    for ControllerRegisterViewTreeWatcherRequest
22{
23}
24
25#[derive(Debug, Default, PartialEq)]
26pub struct ControllerAttachClientViewRequest {
27    pub view_provider: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>>,
28    #[doc(hidden)]
29    pub __source_breaking: fidl::marker::SourceBreaking,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for ControllerAttachClientViewRequest
34{
35}
36
37#[derive(Debug, Default, PartialEq)]
38pub struct ControllerPresentClientViewRequest {
39    pub viewport_creation_token: Option<fidl_fuchsia_ui_views::ViewportCreationToken>,
40    #[doc(hidden)]
41    pub __source_breaking: fidl::marker::SourceBreaking,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for ControllerPresentClientViewRequest
46{
47}
48
49#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
50pub struct ControllerMarker;
51
52impl fidl::endpoints::ProtocolMarker for ControllerMarker {
53    type Proxy = ControllerProxy;
54    type RequestStream = ControllerRequestStream;
55    #[cfg(target_os = "fuchsia")]
56    type SynchronousProxy = ControllerSynchronousProxy;
57
58    const DEBUG_NAME: &'static str = "fuchsia.ui.test.scene.Controller";
59}
60impl fidl::endpoints::DiscoverableProtocolMarker for ControllerMarker {}
61
62pub trait ControllerProxyInterface: Send + Sync {
63    type AttachClientViewResponseFut: std::future::Future<Output = Result<u64, fidl::Error>> + Send;
64    fn r#attach_client_view(
65        &self,
66        payload: ControllerAttachClientViewRequest,
67    ) -> Self::AttachClientViewResponseFut;
68    fn r#present_client_view(
69        &self,
70        payload: ControllerPresentClientViewRequest,
71    ) -> Result<(), fidl::Error>;
72    type RegisterViewTreeWatcherResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
73        + Send;
74    fn r#register_view_tree_watcher(
75        &self,
76        watcher: fidl::endpoints::ServerEnd<
77            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
78        >,
79    ) -> Self::RegisterViewTreeWatcherResponseFut;
80    type WatchViewPresentationResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
81        + Send;
82    fn r#watch_view_presentation(&self) -> Self::WatchViewPresentationResponseFut;
83}
84#[derive(Debug)]
85#[cfg(target_os = "fuchsia")]
86pub struct ControllerSynchronousProxy {
87    client: fidl::client::sync::Client,
88}
89
90#[cfg(target_os = "fuchsia")]
91impl fidl::endpoints::SynchronousProxy for ControllerSynchronousProxy {
92    type Proxy = ControllerProxy;
93    type Protocol = ControllerMarker;
94
95    fn from_channel(inner: fidl::Channel) -> Self {
96        Self::new(inner)
97    }
98
99    fn into_channel(self) -> fidl::Channel {
100        self.client.into_channel()
101    }
102
103    fn as_channel(&self) -> &fidl::Channel {
104        self.client.as_channel()
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl ControllerSynchronousProxy {
110    pub fn new(channel: fidl::Channel) -> Self {
111        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
112        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
113    }
114
115    pub fn into_channel(self) -> fidl::Channel {
116        self.client.into_channel()
117    }
118
119    /// Waits until an event arrives and returns it. It is safe for other
120    /// threads to make concurrent requests while waiting for an event.
121    pub fn wait_for_event(
122        &self,
123        deadline: zx::MonotonicInstant,
124    ) -> Result<ControllerEvent, fidl::Error> {
125        ControllerEvent::decode(self.client.wait_for_event(deadline)?)
126    }
127
128    /// *** NOTE: `ViewProvider` is no longer the preferred way for a parent
129    /// and child view to agree on a ViewportCreationToken / ViewCreationToken
130    /// pair. Flatland-based clients are encouraged to use `PresentView` (below)
131    /// instead of `AttachClientView`.
132    ///
133    /// Elicits the server to request a view using the
134    /// `fuchsia.ui.app.ViewProvider` handle provided, and attach it to the
135    /// scene.
136    ///
137    /// RETURN VALUE
138    ///
139    /// This method returns the KOID for the client view's `ViewRef`.
140    ///
141    /// SYNCHRONIZATION
142    ///
143    /// This call returns as soon as the client `ViewRef` is available. Note
144    /// that this signal does NOT necessarily indicate that the view has been
145    /// attached to the scene.
146    ///
147    /// LIFE CYCLE
148    ///
149    /// Clients may drop the `Controller` connection once `AttachClientView` has
150    /// returned.
151    pub fn r#attach_client_view(
152        &self,
153        mut payload: ControllerAttachClientViewRequest,
154        ___deadline: zx::MonotonicInstant,
155    ) -> Result<u64, fidl::Error> {
156        let _response = self
157            .client
158            .send_query::<ControllerAttachClientViewRequest, ControllerAttachClientViewResponse>(
159                &mut payload,
160                0x271d621cc0687761,
161                fidl::encoding::DynamicFlags::empty(),
162                ___deadline,
163            )?;
164        Ok(_response.view_ref_koid)
165    }
166
167    /// Elicits the server to create a viewport using `viewport_creation_token`.
168    ///
169    /// LIFE CYCLE
170    ///
171    /// Clients may drop the `Controller` connection once `PresentClientView` has
172    /// returned.
173    pub fn r#present_client_view(
174        &self,
175        mut payload: ControllerPresentClientViewRequest,
176    ) -> Result<(), fidl::Error> {
177        self.client.send::<ControllerPresentClientViewRequest>(
178            &mut payload,
179            0x50b3378ecc810ca9,
180            fidl::encoding::DynamicFlags::empty(),
181        )
182    }
183
184    /// Registers a `ViewTreeWatcher` on the client's behalf.
185    ///
186    /// The `ViewTreeWatcher` registered on behalf of the client will currently
187    /// be scoped globally; we intend to restrict the scope to the client view's
188    /// subtree as soon as it's feasible to do so.
189    ///
190    /// For more information on geometry observation, see the documentation
191    /// in //sdk/fidl/fuchsia.ui.observation.geometry/watcher.fidl.
192    pub fn r#register_view_tree_watcher(
193        &self,
194        mut watcher: fidl::endpoints::ServerEnd<
195            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
196        >,
197        ___deadline: zx::MonotonicInstant,
198    ) -> Result<(), fidl::Error> {
199        let _response = self
200            .client
201            .send_query::<ControllerRegisterViewTreeWatcherRequest, fidl::encoding::EmptyPayload>(
202                (watcher,),
203                0x1370345f4914064,
204                fidl::encoding::DynamicFlags::empty(),
205                ___deadline,
206            )?;
207        Ok(_response)
208    }
209
210    /// A hanging get to watch for updates to view presentation.
211    ///
212    /// Callers can use this method to wait until a `ClientView` has
213    /// `Present()`-ed through any of the following view presentation methods:
214    ///   * `fuchsia.ui.test.scene.Controller/AttachClientView()`
215    ///   * `fuchsia.ui.test.scene.Controller/PresentClientView()`
216    ///   * `fuchsia.element.GraphicalPresenter/PresentView()`
217    ///
218    /// Callers should expect to call this method once for each view they
219    /// expect to wait for.
220    ///
221    /// Note that callers must take care when interleaving calls, since
222    /// this method has no way to
223    ///   a) associate a `Present()` with a specific `ClientView`, or
224    ///   b) associate a `Present()` with an `AttachClientView()` call, rather
225    ///    than a `PresentClientView()` or `PresentView` call.
226    ///
227    /// It is invalid to call `WatchViewPresentation` while a previous call is
228    /// still pending; subsequent requests will be ignored.
229    pub fn r#watch_view_presentation(
230        &self,
231        ___deadline: zx::MonotonicInstant,
232    ) -> Result<(), fidl::Error> {
233        let _response =
234            self.client.send_query::<fidl::encoding::EmptyPayload, fidl::encoding::EmptyPayload>(
235                (),
236                0x15439375bfe6d21d,
237                fidl::encoding::DynamicFlags::empty(),
238                ___deadline,
239            )?;
240        Ok(_response)
241    }
242}
243
244#[derive(Debug, Clone)]
245pub struct ControllerProxy {
246    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
247}
248
249impl fidl::endpoints::Proxy for ControllerProxy {
250    type Protocol = ControllerMarker;
251
252    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
253        Self::new(inner)
254    }
255
256    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
257        self.client.into_channel().map_err(|client| Self { client })
258    }
259
260    fn as_channel(&self) -> &::fidl::AsyncChannel {
261        self.client.as_channel()
262    }
263}
264
265impl ControllerProxy {
266    /// Create a new Proxy for fuchsia.ui.test.scene/Controller.
267    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
268        let protocol_name = <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
269        Self { client: fidl::client::Client::new(channel, protocol_name) }
270    }
271
272    /// Get a Stream of events from the remote end of the protocol.
273    ///
274    /// # Panics
275    ///
276    /// Panics if the event stream was already taken.
277    pub fn take_event_stream(&self) -> ControllerEventStream {
278        ControllerEventStream { event_receiver: self.client.take_event_receiver() }
279    }
280
281    /// *** NOTE: `ViewProvider` is no longer the preferred way for a parent
282    /// and child view to agree on a ViewportCreationToken / ViewCreationToken
283    /// pair. Flatland-based clients are encouraged to use `PresentView` (below)
284    /// instead of `AttachClientView`.
285    ///
286    /// Elicits the server to request a view using the
287    /// `fuchsia.ui.app.ViewProvider` handle provided, and attach it to the
288    /// scene.
289    ///
290    /// RETURN VALUE
291    ///
292    /// This method returns the KOID for the client view's `ViewRef`.
293    ///
294    /// SYNCHRONIZATION
295    ///
296    /// This call returns as soon as the client `ViewRef` is available. Note
297    /// that this signal does NOT necessarily indicate that the view has been
298    /// attached to the scene.
299    ///
300    /// LIFE CYCLE
301    ///
302    /// Clients may drop the `Controller` connection once `AttachClientView` has
303    /// returned.
304    pub fn r#attach_client_view(
305        &self,
306        mut payload: ControllerAttachClientViewRequest,
307    ) -> fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect> {
308        ControllerProxyInterface::r#attach_client_view(self, payload)
309    }
310
311    /// Elicits the server to create a viewport using `viewport_creation_token`.
312    ///
313    /// LIFE CYCLE
314    ///
315    /// Clients may drop the `Controller` connection once `PresentClientView` has
316    /// returned.
317    pub fn r#present_client_view(
318        &self,
319        mut payload: ControllerPresentClientViewRequest,
320    ) -> Result<(), fidl::Error> {
321        ControllerProxyInterface::r#present_client_view(self, payload)
322    }
323
324    /// Registers a `ViewTreeWatcher` on the client's behalf.
325    ///
326    /// The `ViewTreeWatcher` registered on behalf of the client will currently
327    /// be scoped globally; we intend to restrict the scope to the client view's
328    /// subtree as soon as it's feasible to do so.
329    ///
330    /// For more information on geometry observation, see the documentation
331    /// in //sdk/fidl/fuchsia.ui.observation.geometry/watcher.fidl.
332    pub fn r#register_view_tree_watcher(
333        &self,
334        mut watcher: fidl::endpoints::ServerEnd<
335            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
336        >,
337    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
338        ControllerProxyInterface::r#register_view_tree_watcher(self, watcher)
339    }
340
341    /// A hanging get to watch for updates to view presentation.
342    ///
343    /// Callers can use this method to wait until a `ClientView` has
344    /// `Present()`-ed through any of the following view presentation methods:
345    ///   * `fuchsia.ui.test.scene.Controller/AttachClientView()`
346    ///   * `fuchsia.ui.test.scene.Controller/PresentClientView()`
347    ///   * `fuchsia.element.GraphicalPresenter/PresentView()`
348    ///
349    /// Callers should expect to call this method once for each view they
350    /// expect to wait for.
351    ///
352    /// Note that callers must take care when interleaving calls, since
353    /// this method has no way to
354    ///   a) associate a `Present()` with a specific `ClientView`, or
355    ///   b) associate a `Present()` with an `AttachClientView()` call, rather
356    ///    than a `PresentClientView()` or `PresentView` call.
357    ///
358    /// It is invalid to call `WatchViewPresentation` while a previous call is
359    /// still pending; subsequent requests will be ignored.
360    pub fn r#watch_view_presentation(
361        &self,
362    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
363        ControllerProxyInterface::r#watch_view_presentation(self)
364    }
365}
366
367impl ControllerProxyInterface for ControllerProxy {
368    type AttachClientViewResponseFut =
369        fidl::client::QueryResponseFut<u64, fidl::encoding::DefaultFuchsiaResourceDialect>;
370    fn r#attach_client_view(
371        &self,
372        mut payload: ControllerAttachClientViewRequest,
373    ) -> Self::AttachClientViewResponseFut {
374        fn _decode(
375            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
376        ) -> Result<u64, fidl::Error> {
377            let _response = fidl::client::decode_transaction_body::<
378                ControllerAttachClientViewResponse,
379                fidl::encoding::DefaultFuchsiaResourceDialect,
380                0x271d621cc0687761,
381            >(_buf?)?;
382            Ok(_response.view_ref_koid)
383        }
384        self.client.send_query_and_decode::<ControllerAttachClientViewRequest, u64>(
385            &mut payload,
386            0x271d621cc0687761,
387            fidl::encoding::DynamicFlags::empty(),
388            _decode,
389        )
390    }
391
392    fn r#present_client_view(
393        &self,
394        mut payload: ControllerPresentClientViewRequest,
395    ) -> Result<(), fidl::Error> {
396        self.client.send::<ControllerPresentClientViewRequest>(
397            &mut payload,
398            0x50b3378ecc810ca9,
399            fidl::encoding::DynamicFlags::empty(),
400        )
401    }
402
403    type RegisterViewTreeWatcherResponseFut =
404        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
405    fn r#register_view_tree_watcher(
406        &self,
407        mut watcher: fidl::endpoints::ServerEnd<
408            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
409        >,
410    ) -> Self::RegisterViewTreeWatcherResponseFut {
411        fn _decode(
412            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
413        ) -> Result<(), fidl::Error> {
414            let _response = fidl::client::decode_transaction_body::<
415                fidl::encoding::EmptyPayload,
416                fidl::encoding::DefaultFuchsiaResourceDialect,
417                0x1370345f4914064,
418            >(_buf?)?;
419            Ok(_response)
420        }
421        self.client.send_query_and_decode::<ControllerRegisterViewTreeWatcherRequest, ()>(
422            (watcher,),
423            0x1370345f4914064,
424            fidl::encoding::DynamicFlags::empty(),
425            _decode,
426        )
427    }
428
429    type WatchViewPresentationResponseFut =
430        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
431    fn r#watch_view_presentation(&self) -> Self::WatchViewPresentationResponseFut {
432        fn _decode(
433            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
434        ) -> Result<(), fidl::Error> {
435            let _response = fidl::client::decode_transaction_body::<
436                fidl::encoding::EmptyPayload,
437                fidl::encoding::DefaultFuchsiaResourceDialect,
438                0x15439375bfe6d21d,
439            >(_buf?)?;
440            Ok(_response)
441        }
442        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ()>(
443            (),
444            0x15439375bfe6d21d,
445            fidl::encoding::DynamicFlags::empty(),
446            _decode,
447        )
448    }
449}
450
451pub struct ControllerEventStream {
452    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
453}
454
455impl std::marker::Unpin for ControllerEventStream {}
456
457impl futures::stream::FusedStream for ControllerEventStream {
458    fn is_terminated(&self) -> bool {
459        self.event_receiver.is_terminated()
460    }
461}
462
463impl futures::Stream for ControllerEventStream {
464    type Item = Result<ControllerEvent, fidl::Error>;
465
466    fn poll_next(
467        mut self: std::pin::Pin<&mut Self>,
468        cx: &mut std::task::Context<'_>,
469    ) -> std::task::Poll<Option<Self::Item>> {
470        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
471            &mut self.event_receiver,
472            cx
473        )?) {
474            Some(buf) => std::task::Poll::Ready(Some(ControllerEvent::decode(buf))),
475            None => std::task::Poll::Ready(None),
476        }
477    }
478}
479
480#[derive(Debug)]
481pub enum ControllerEvent {}
482
483impl ControllerEvent {
484    /// Decodes a message buffer as a [`ControllerEvent`].
485    fn decode(
486        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
487    ) -> Result<ControllerEvent, fidl::Error> {
488        let (bytes, _handles) = buf.split_mut();
489        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
490        debug_assert_eq!(tx_header.tx_id, 0);
491        match tx_header.ordinal {
492            _ => Err(fidl::Error::UnknownOrdinal {
493                ordinal: tx_header.ordinal,
494                protocol_name: <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
495            }),
496        }
497    }
498}
499
500/// A Stream of incoming requests for fuchsia.ui.test.scene/Controller.
501pub struct ControllerRequestStream {
502    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
503    is_terminated: bool,
504}
505
506impl std::marker::Unpin for ControllerRequestStream {}
507
508impl futures::stream::FusedStream for ControllerRequestStream {
509    fn is_terminated(&self) -> bool {
510        self.is_terminated
511    }
512}
513
514impl fidl::endpoints::RequestStream for ControllerRequestStream {
515    type Protocol = ControllerMarker;
516    type ControlHandle = ControllerControlHandle;
517
518    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
519        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
520    }
521
522    fn control_handle(&self) -> Self::ControlHandle {
523        ControllerControlHandle { inner: self.inner.clone() }
524    }
525
526    fn into_inner(
527        self,
528    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
529    {
530        (self.inner, self.is_terminated)
531    }
532
533    fn from_inner(
534        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
535        is_terminated: bool,
536    ) -> Self {
537        Self { inner, is_terminated }
538    }
539}
540
541impl futures::Stream for ControllerRequestStream {
542    type Item = Result<ControllerRequest, fidl::Error>;
543
544    fn poll_next(
545        mut self: std::pin::Pin<&mut Self>,
546        cx: &mut std::task::Context<'_>,
547    ) -> std::task::Poll<Option<Self::Item>> {
548        let this = &mut *self;
549        if this.inner.check_shutdown(cx) {
550            this.is_terminated = true;
551            return std::task::Poll::Ready(None);
552        }
553        if this.is_terminated {
554            panic!("polled ControllerRequestStream after completion");
555        }
556        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
557            |bytes, handles| {
558                match this.inner.channel().read_etc(cx, bytes, handles) {
559                    std::task::Poll::Ready(Ok(())) => {}
560                    std::task::Poll::Pending => return std::task::Poll::Pending,
561                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
562                        this.is_terminated = true;
563                        return std::task::Poll::Ready(None);
564                    }
565                    std::task::Poll::Ready(Err(e)) => {
566                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
567                            e.into(),
568                        ))))
569                    }
570                }
571
572                // A message has been received from the channel
573                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
574
575                std::task::Poll::Ready(Some(match header.ordinal {
576                    0x271d621cc0687761 => {
577                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
578                        let mut req = fidl::new_empty!(
579                            ControllerAttachClientViewRequest,
580                            fidl::encoding::DefaultFuchsiaResourceDialect
581                        );
582                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerAttachClientViewRequest>(&header, _body_bytes, handles, &mut req)?;
583                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
584                        Ok(ControllerRequest::AttachClientView {
585                            payload: req,
586                            responder: ControllerAttachClientViewResponder {
587                                control_handle: std::mem::ManuallyDrop::new(control_handle),
588                                tx_id: header.tx_id,
589                            },
590                        })
591                    }
592                    0x50b3378ecc810ca9 => {
593                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
594                        let mut req = fidl::new_empty!(
595                            ControllerPresentClientViewRequest,
596                            fidl::encoding::DefaultFuchsiaResourceDialect
597                        );
598                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerPresentClientViewRequest>(&header, _body_bytes, handles, &mut req)?;
599                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
600                        Ok(ControllerRequest::PresentClientView { payload: req, control_handle })
601                    }
602                    0x1370345f4914064 => {
603                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
604                        let mut req = fidl::new_empty!(
605                            ControllerRegisterViewTreeWatcherRequest,
606                            fidl::encoding::DefaultFuchsiaResourceDialect
607                        );
608                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ControllerRegisterViewTreeWatcherRequest>(&header, _body_bytes, handles, &mut req)?;
609                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
610                        Ok(ControllerRequest::RegisterViewTreeWatcher {
611                            watcher: req.watcher,
612
613                            responder: ControllerRegisterViewTreeWatcherResponder {
614                                control_handle: std::mem::ManuallyDrop::new(control_handle),
615                                tx_id: header.tx_id,
616                            },
617                        })
618                    }
619                    0x15439375bfe6d21d => {
620                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
621                        let mut req = fidl::new_empty!(
622                            fidl::encoding::EmptyPayload,
623                            fidl::encoding::DefaultFuchsiaResourceDialect
624                        );
625                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
626                        let control_handle = ControllerControlHandle { inner: this.inner.clone() };
627                        Ok(ControllerRequest::WatchViewPresentation {
628                            responder: ControllerWatchViewPresentationResponder {
629                                control_handle: std::mem::ManuallyDrop::new(control_handle),
630                                tx_id: header.tx_id,
631                            },
632                        })
633                    }
634                    _ => Err(fidl::Error::UnknownOrdinal {
635                        ordinal: header.ordinal,
636                        protocol_name:
637                            <ControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
638                    }),
639                }))
640            },
641        )
642    }
643}
644
645/// Controls a UI test scene. Allows a test to attach test Views to the scene
646/// and add View-related instrumentation.
647#[derive(Debug)]
648pub enum ControllerRequest {
649    /// *** NOTE: `ViewProvider` is no longer the preferred way for a parent
650    /// and child view to agree on a ViewportCreationToken / ViewCreationToken
651    /// pair. Flatland-based clients are encouraged to use `PresentView` (below)
652    /// instead of `AttachClientView`.
653    ///
654    /// Elicits the server to request a view using the
655    /// `fuchsia.ui.app.ViewProvider` handle provided, and attach it to the
656    /// scene.
657    ///
658    /// RETURN VALUE
659    ///
660    /// This method returns the KOID for the client view's `ViewRef`.
661    ///
662    /// SYNCHRONIZATION
663    ///
664    /// This call returns as soon as the client `ViewRef` is available. Note
665    /// that this signal does NOT necessarily indicate that the view has been
666    /// attached to the scene.
667    ///
668    /// LIFE CYCLE
669    ///
670    /// Clients may drop the `Controller` connection once `AttachClientView` has
671    /// returned.
672    AttachClientView {
673        payload: ControllerAttachClientViewRequest,
674        responder: ControllerAttachClientViewResponder,
675    },
676    /// Elicits the server to create a viewport using `viewport_creation_token`.
677    ///
678    /// LIFE CYCLE
679    ///
680    /// Clients may drop the `Controller` connection once `PresentClientView` has
681    /// returned.
682    PresentClientView {
683        payload: ControllerPresentClientViewRequest,
684        control_handle: ControllerControlHandle,
685    },
686    /// Registers a `ViewTreeWatcher` on the client's behalf.
687    ///
688    /// The `ViewTreeWatcher` registered on behalf of the client will currently
689    /// be scoped globally; we intend to restrict the scope to the client view's
690    /// subtree as soon as it's feasible to do so.
691    ///
692    /// For more information on geometry observation, see the documentation
693    /// in //sdk/fidl/fuchsia.ui.observation.geometry/watcher.fidl.
694    RegisterViewTreeWatcher {
695        watcher:
696            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
697        responder: ControllerRegisterViewTreeWatcherResponder,
698    },
699    /// A hanging get to watch for updates to view presentation.
700    ///
701    /// Callers can use this method to wait until a `ClientView` has
702    /// `Present()`-ed through any of the following view presentation methods:
703    ///   * `fuchsia.ui.test.scene.Controller/AttachClientView()`
704    ///   * `fuchsia.ui.test.scene.Controller/PresentClientView()`
705    ///   * `fuchsia.element.GraphicalPresenter/PresentView()`
706    ///
707    /// Callers should expect to call this method once for each view they
708    /// expect to wait for.
709    ///
710    /// Note that callers must take care when interleaving calls, since
711    /// this method has no way to
712    ///   a) associate a `Present()` with a specific `ClientView`, or
713    ///   b) associate a `Present()` with an `AttachClientView()` call, rather
714    ///    than a `PresentClientView()` or `PresentView` call.
715    ///
716    /// It is invalid to call `WatchViewPresentation` while a previous call is
717    /// still pending; subsequent requests will be ignored.
718    WatchViewPresentation { responder: ControllerWatchViewPresentationResponder },
719}
720
721impl ControllerRequest {
722    #[allow(irrefutable_let_patterns)]
723    pub fn into_attach_client_view(
724        self,
725    ) -> Option<(ControllerAttachClientViewRequest, ControllerAttachClientViewResponder)> {
726        if let ControllerRequest::AttachClientView { payload, responder } = self {
727            Some((payload, responder))
728        } else {
729            None
730        }
731    }
732
733    #[allow(irrefutable_let_patterns)]
734    pub fn into_present_client_view(
735        self,
736    ) -> Option<(ControllerPresentClientViewRequest, ControllerControlHandle)> {
737        if let ControllerRequest::PresentClientView { payload, control_handle } = self {
738            Some((payload, control_handle))
739        } else {
740            None
741        }
742    }
743
744    #[allow(irrefutable_let_patterns)]
745    pub fn into_register_view_tree_watcher(
746        self,
747    ) -> Option<(
748        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker>,
749        ControllerRegisterViewTreeWatcherResponder,
750    )> {
751        if let ControllerRequest::RegisterViewTreeWatcher { watcher, responder } = self {
752            Some((watcher, responder))
753        } else {
754            None
755        }
756    }
757
758    #[allow(irrefutable_let_patterns)]
759    pub fn into_watch_view_presentation(
760        self,
761    ) -> Option<(ControllerWatchViewPresentationResponder)> {
762        if let ControllerRequest::WatchViewPresentation { responder } = self {
763            Some((responder))
764        } else {
765            None
766        }
767    }
768
769    /// Name of the method defined in FIDL
770    pub fn method_name(&self) -> &'static str {
771        match *self {
772            ControllerRequest::AttachClientView { .. } => "attach_client_view",
773            ControllerRequest::PresentClientView { .. } => "present_client_view",
774            ControllerRequest::RegisterViewTreeWatcher { .. } => "register_view_tree_watcher",
775            ControllerRequest::WatchViewPresentation { .. } => "watch_view_presentation",
776        }
777    }
778}
779
780#[derive(Debug, Clone)]
781pub struct ControllerControlHandle {
782    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
783}
784
785impl fidl::endpoints::ControlHandle for ControllerControlHandle {
786    fn shutdown(&self) {
787        self.inner.shutdown()
788    }
789    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
790        self.inner.shutdown_with_epitaph(status)
791    }
792
793    fn is_closed(&self) -> bool {
794        self.inner.channel().is_closed()
795    }
796    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
797        self.inner.channel().on_closed()
798    }
799
800    #[cfg(target_os = "fuchsia")]
801    fn signal_peer(
802        &self,
803        clear_mask: zx::Signals,
804        set_mask: zx::Signals,
805    ) -> Result<(), zx_status::Status> {
806        use fidl::Peered;
807        self.inner.channel().signal_peer(clear_mask, set_mask)
808    }
809}
810
811impl ControllerControlHandle {}
812
813#[must_use = "FIDL methods require a response to be sent"]
814#[derive(Debug)]
815pub struct ControllerAttachClientViewResponder {
816    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
817    tx_id: u32,
818}
819
820/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
821/// if the responder is dropped without sending a response, so that the client
822/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
823impl std::ops::Drop for ControllerAttachClientViewResponder {
824    fn drop(&mut self) {
825        self.control_handle.shutdown();
826        // Safety: drops once, never accessed again
827        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
828    }
829}
830
831impl fidl::endpoints::Responder for ControllerAttachClientViewResponder {
832    type ControlHandle = ControllerControlHandle;
833
834    fn control_handle(&self) -> &ControllerControlHandle {
835        &self.control_handle
836    }
837
838    fn drop_without_shutdown(mut self) {
839        // Safety: drops once, never accessed again due to mem::forget
840        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
841        // Prevent Drop from running (which would shut down the channel)
842        std::mem::forget(self);
843    }
844}
845
846impl ControllerAttachClientViewResponder {
847    /// Sends a response to the FIDL transaction.
848    ///
849    /// Sets the channel to shutdown if an error occurs.
850    pub fn send(self, mut view_ref_koid: u64) -> Result<(), fidl::Error> {
851        let _result = self.send_raw(view_ref_koid);
852        if _result.is_err() {
853            self.control_handle.shutdown();
854        }
855        self.drop_without_shutdown();
856        _result
857    }
858
859    /// Similar to "send" but does not shutdown the channel if an error occurs.
860    pub fn send_no_shutdown_on_err(self, mut view_ref_koid: u64) -> Result<(), fidl::Error> {
861        let _result = self.send_raw(view_ref_koid);
862        self.drop_without_shutdown();
863        _result
864    }
865
866    fn send_raw(&self, mut view_ref_koid: u64) -> Result<(), fidl::Error> {
867        self.control_handle.inner.send::<ControllerAttachClientViewResponse>(
868            (view_ref_koid,),
869            self.tx_id,
870            0x271d621cc0687761,
871            fidl::encoding::DynamicFlags::empty(),
872        )
873    }
874}
875
876#[must_use = "FIDL methods require a response to be sent"]
877#[derive(Debug)]
878pub struct ControllerRegisterViewTreeWatcherResponder {
879    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
880    tx_id: u32,
881}
882
883/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
884/// if the responder is dropped without sending a response, so that the client
885/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
886impl std::ops::Drop for ControllerRegisterViewTreeWatcherResponder {
887    fn drop(&mut self) {
888        self.control_handle.shutdown();
889        // Safety: drops once, never accessed again
890        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
891    }
892}
893
894impl fidl::endpoints::Responder for ControllerRegisterViewTreeWatcherResponder {
895    type ControlHandle = ControllerControlHandle;
896
897    fn control_handle(&self) -> &ControllerControlHandle {
898        &self.control_handle
899    }
900
901    fn drop_without_shutdown(mut self) {
902        // Safety: drops once, never accessed again due to mem::forget
903        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
904        // Prevent Drop from running (which would shut down the channel)
905        std::mem::forget(self);
906    }
907}
908
909impl ControllerRegisterViewTreeWatcherResponder {
910    /// Sends a response to the FIDL transaction.
911    ///
912    /// Sets the channel to shutdown if an error occurs.
913    pub fn send(self) -> Result<(), fidl::Error> {
914        let _result = self.send_raw();
915        if _result.is_err() {
916            self.control_handle.shutdown();
917        }
918        self.drop_without_shutdown();
919        _result
920    }
921
922    /// Similar to "send" but does not shutdown the channel if an error occurs.
923    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
924        let _result = self.send_raw();
925        self.drop_without_shutdown();
926        _result
927    }
928
929    fn send_raw(&self) -> Result<(), fidl::Error> {
930        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
931            (),
932            self.tx_id,
933            0x1370345f4914064,
934            fidl::encoding::DynamicFlags::empty(),
935        )
936    }
937}
938
939#[must_use = "FIDL methods require a response to be sent"]
940#[derive(Debug)]
941pub struct ControllerWatchViewPresentationResponder {
942    control_handle: std::mem::ManuallyDrop<ControllerControlHandle>,
943    tx_id: u32,
944}
945
946/// Set the the channel to be shutdown (see [`ControllerControlHandle::shutdown`])
947/// if the responder is dropped without sending a response, so that the client
948/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
949impl std::ops::Drop for ControllerWatchViewPresentationResponder {
950    fn drop(&mut self) {
951        self.control_handle.shutdown();
952        // Safety: drops once, never accessed again
953        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
954    }
955}
956
957impl fidl::endpoints::Responder for ControllerWatchViewPresentationResponder {
958    type ControlHandle = ControllerControlHandle;
959
960    fn control_handle(&self) -> &ControllerControlHandle {
961        &self.control_handle
962    }
963
964    fn drop_without_shutdown(mut self) {
965        // Safety: drops once, never accessed again due to mem::forget
966        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
967        // Prevent Drop from running (which would shut down the channel)
968        std::mem::forget(self);
969    }
970}
971
972impl ControllerWatchViewPresentationResponder {
973    /// Sends a response to the FIDL transaction.
974    ///
975    /// Sets the channel to shutdown if an error occurs.
976    pub fn send(self) -> Result<(), fidl::Error> {
977        let _result = self.send_raw();
978        if _result.is_err() {
979            self.control_handle.shutdown();
980        }
981        self.drop_without_shutdown();
982        _result
983    }
984
985    /// Similar to "send" but does not shutdown the channel if an error occurs.
986    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
987        let _result = self.send_raw();
988        self.drop_without_shutdown();
989        _result
990    }
991
992    fn send_raw(&self) -> Result<(), fidl::Error> {
993        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
994            (),
995            self.tx_id,
996            0x15439375bfe6d21d,
997            fidl::encoding::DynamicFlags::empty(),
998        )
999    }
1000}
1001
1002mod internal {
1003    use super::*;
1004
1005    impl fidl::encoding::ResourceTypeMarker for ControllerRegisterViewTreeWatcherRequest {
1006        type Borrowed<'a> = &'a mut Self;
1007        fn take_or_borrow<'a>(
1008            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1009        ) -> Self::Borrowed<'a> {
1010            value
1011        }
1012    }
1013
1014    unsafe impl fidl::encoding::TypeMarker for ControllerRegisterViewTreeWatcherRequest {
1015        type Owned = Self;
1016
1017        #[inline(always)]
1018        fn inline_align(_context: fidl::encoding::Context) -> usize {
1019            4
1020        }
1021
1022        #[inline(always)]
1023        fn inline_size(_context: fidl::encoding::Context) -> usize {
1024            4
1025        }
1026    }
1027
1028    unsafe impl
1029        fidl::encoding::Encode<
1030            ControllerRegisterViewTreeWatcherRequest,
1031            fidl::encoding::DefaultFuchsiaResourceDialect,
1032        > for &mut ControllerRegisterViewTreeWatcherRequest
1033    {
1034        #[inline]
1035        unsafe fn encode(
1036            self,
1037            encoder: &mut fidl::encoding::Encoder<
1038                '_,
1039                fidl::encoding::DefaultFuchsiaResourceDialect,
1040            >,
1041            offset: usize,
1042            _depth: fidl::encoding::Depth,
1043        ) -> fidl::Result<()> {
1044            encoder.debug_check_bounds::<ControllerRegisterViewTreeWatcherRequest>(offset);
1045            // Delegate to tuple encoding.
1046            fidl::encoding::Encode::<
1047                ControllerRegisterViewTreeWatcherRequest,
1048                fidl::encoding::DefaultFuchsiaResourceDialect,
1049            >::encode(
1050                (<fidl::encoding::Endpoint<
1051                    fidl::endpoints::ServerEnd<
1052                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
1053                    >,
1054                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1055                    &mut self.watcher
1056                ),),
1057                encoder,
1058                offset,
1059                _depth,
1060            )
1061        }
1062    }
1063    unsafe impl<
1064            T0: fidl::encoding::Encode<
1065                fidl::encoding::Endpoint<
1066                    fidl::endpoints::ServerEnd<
1067                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
1068                    >,
1069                >,
1070                fidl::encoding::DefaultFuchsiaResourceDialect,
1071            >,
1072        >
1073        fidl::encoding::Encode<
1074            ControllerRegisterViewTreeWatcherRequest,
1075            fidl::encoding::DefaultFuchsiaResourceDialect,
1076        > for (T0,)
1077    {
1078        #[inline]
1079        unsafe fn encode(
1080            self,
1081            encoder: &mut fidl::encoding::Encoder<
1082                '_,
1083                fidl::encoding::DefaultFuchsiaResourceDialect,
1084            >,
1085            offset: usize,
1086            depth: fidl::encoding::Depth,
1087        ) -> fidl::Result<()> {
1088            encoder.debug_check_bounds::<ControllerRegisterViewTreeWatcherRequest>(offset);
1089            // Zero out padding regions. There's no need to apply masks
1090            // because the unmasked parts will be overwritten by fields.
1091            // Write the fields.
1092            self.0.encode(encoder, offset + 0, depth)?;
1093            Ok(())
1094        }
1095    }
1096
1097    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1098        for ControllerRegisterViewTreeWatcherRequest
1099    {
1100        #[inline(always)]
1101        fn new_empty() -> Self {
1102            Self {
1103                watcher: fidl::new_empty!(
1104                    fidl::encoding::Endpoint<
1105                        fidl::endpoints::ServerEnd<
1106                            fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
1107                        >,
1108                    >,
1109                    fidl::encoding::DefaultFuchsiaResourceDialect
1110                ),
1111            }
1112        }
1113
1114        #[inline]
1115        unsafe fn decode(
1116            &mut self,
1117            decoder: &mut fidl::encoding::Decoder<
1118                '_,
1119                fidl::encoding::DefaultFuchsiaResourceDialect,
1120            >,
1121            offset: usize,
1122            _depth: fidl::encoding::Depth,
1123        ) -> fidl::Result<()> {
1124            decoder.debug_check_bounds::<Self>(offset);
1125            // Verify that padding bytes are zero.
1126            fidl::decode!(
1127                fidl::encoding::Endpoint<
1128                    fidl::endpoints::ServerEnd<
1129                        fidl_fuchsia_ui_observation_geometry::ViewTreeWatcherMarker,
1130                    >,
1131                >,
1132                fidl::encoding::DefaultFuchsiaResourceDialect,
1133                &mut self.watcher,
1134                decoder,
1135                offset + 0,
1136                _depth
1137            )?;
1138            Ok(())
1139        }
1140    }
1141
1142    impl ControllerAttachClientViewRequest {
1143        #[inline(always)]
1144        fn max_ordinal_present(&self) -> u64 {
1145            if let Some(_) = self.view_provider {
1146                return 1;
1147            }
1148            0
1149        }
1150    }
1151
1152    impl fidl::encoding::ResourceTypeMarker for ControllerAttachClientViewRequest {
1153        type Borrowed<'a> = &'a mut Self;
1154        fn take_or_borrow<'a>(
1155            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1156        ) -> Self::Borrowed<'a> {
1157            value
1158        }
1159    }
1160
1161    unsafe impl fidl::encoding::TypeMarker for ControllerAttachClientViewRequest {
1162        type Owned = Self;
1163
1164        #[inline(always)]
1165        fn inline_align(_context: fidl::encoding::Context) -> usize {
1166            8
1167        }
1168
1169        #[inline(always)]
1170        fn inline_size(_context: fidl::encoding::Context) -> usize {
1171            16
1172        }
1173    }
1174
1175    unsafe impl
1176        fidl::encoding::Encode<
1177            ControllerAttachClientViewRequest,
1178            fidl::encoding::DefaultFuchsiaResourceDialect,
1179        > for &mut ControllerAttachClientViewRequest
1180    {
1181        unsafe fn encode(
1182            self,
1183            encoder: &mut fidl::encoding::Encoder<
1184                '_,
1185                fidl::encoding::DefaultFuchsiaResourceDialect,
1186            >,
1187            offset: usize,
1188            mut depth: fidl::encoding::Depth,
1189        ) -> fidl::Result<()> {
1190            encoder.debug_check_bounds::<ControllerAttachClientViewRequest>(offset);
1191            // Vector header
1192            let max_ordinal: u64 = self.max_ordinal_present();
1193            encoder.write_num(max_ordinal, offset);
1194            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1195            // Calling encoder.out_of_line_offset(0) is not allowed.
1196            if max_ordinal == 0 {
1197                return Ok(());
1198            }
1199            depth.increment()?;
1200            let envelope_size = 8;
1201            let bytes_len = max_ordinal as usize * envelope_size;
1202            #[allow(unused_variables)]
1203            let offset = encoder.out_of_line_offset(bytes_len);
1204            let mut _prev_end_offset: usize = 0;
1205            if 1 > max_ordinal {
1206                return Ok(());
1207            }
1208
1209            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1210            // are envelope_size bytes.
1211            let cur_offset: usize = (1 - 1) * envelope_size;
1212
1213            // Zero reserved fields.
1214            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1215
1216            // Safety:
1217            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1218            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1219            //   envelope_size bytes, there is always sufficient room.
1220            fidl::encoding::encode_in_envelope_optional::<
1221                fidl::encoding::Endpoint<
1222                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>,
1223                >,
1224                fidl::encoding::DefaultFuchsiaResourceDialect,
1225            >(
1226                self.view_provider.as_mut().map(
1227                    <fidl::encoding::Endpoint<
1228                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>,
1229                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1230                ),
1231                encoder,
1232                offset + cur_offset,
1233                depth,
1234            )?;
1235
1236            _prev_end_offset = cur_offset + envelope_size;
1237
1238            Ok(())
1239        }
1240    }
1241
1242    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1243        for ControllerAttachClientViewRequest
1244    {
1245        #[inline(always)]
1246        fn new_empty() -> Self {
1247            Self::default()
1248        }
1249
1250        unsafe fn decode(
1251            &mut self,
1252            decoder: &mut fidl::encoding::Decoder<
1253                '_,
1254                fidl::encoding::DefaultFuchsiaResourceDialect,
1255            >,
1256            offset: usize,
1257            mut depth: fidl::encoding::Depth,
1258        ) -> fidl::Result<()> {
1259            decoder.debug_check_bounds::<Self>(offset);
1260            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1261                None => return Err(fidl::Error::NotNullable),
1262                Some(len) => len,
1263            };
1264            // Calling decoder.out_of_line_offset(0) is not allowed.
1265            if len == 0 {
1266                return Ok(());
1267            };
1268            depth.increment()?;
1269            let envelope_size = 8;
1270            let bytes_len = len * envelope_size;
1271            let offset = decoder.out_of_line_offset(bytes_len)?;
1272            // Decode the envelope for each type.
1273            let mut _next_ordinal_to_read = 0;
1274            let mut next_offset = offset;
1275            let end_offset = offset + bytes_len;
1276            _next_ordinal_to_read += 1;
1277            if next_offset >= end_offset {
1278                return Ok(());
1279            }
1280
1281            // Decode unknown envelopes for gaps in ordinals.
1282            while _next_ordinal_to_read < 1 {
1283                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1284                _next_ordinal_to_read += 1;
1285                next_offset += envelope_size;
1286            }
1287
1288            let next_out_of_line = decoder.next_out_of_line();
1289            let handles_before = decoder.remaining_handles();
1290            if let Some((inlined, num_bytes, num_handles)) =
1291                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1292            {
1293                let member_inline_size = <fidl::encoding::Endpoint<
1294                    fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>,
1295                > as fidl::encoding::TypeMarker>::inline_size(
1296                    decoder.context
1297                );
1298                if inlined != (member_inline_size <= 4) {
1299                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1300                }
1301                let inner_offset;
1302                let mut inner_depth = depth.clone();
1303                if inlined {
1304                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1305                    inner_offset = next_offset;
1306                } else {
1307                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1308                    inner_depth.increment()?;
1309                }
1310                let val_ref = self.view_provider.get_or_insert_with(|| {
1311                    fidl::new_empty!(
1312                        fidl::encoding::Endpoint<
1313                            fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>,
1314                        >,
1315                        fidl::encoding::DefaultFuchsiaResourceDialect
1316                    )
1317                });
1318                fidl::decode!(
1319                    fidl::encoding::Endpoint<
1320                        fidl::endpoints::ClientEnd<fidl_fuchsia_ui_app::ViewProviderMarker>,
1321                    >,
1322                    fidl::encoding::DefaultFuchsiaResourceDialect,
1323                    val_ref,
1324                    decoder,
1325                    inner_offset,
1326                    inner_depth
1327                )?;
1328                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1329                {
1330                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1331                }
1332                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1333                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1334                }
1335            }
1336
1337            next_offset += envelope_size;
1338
1339            // Decode the remaining unknown envelopes.
1340            while next_offset < end_offset {
1341                _next_ordinal_to_read += 1;
1342                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1343                next_offset += envelope_size;
1344            }
1345
1346            Ok(())
1347        }
1348    }
1349
1350    impl ControllerPresentClientViewRequest {
1351        #[inline(always)]
1352        fn max_ordinal_present(&self) -> u64 {
1353            if let Some(_) = self.viewport_creation_token {
1354                return 1;
1355            }
1356            0
1357        }
1358    }
1359
1360    impl fidl::encoding::ResourceTypeMarker for ControllerPresentClientViewRequest {
1361        type Borrowed<'a> = &'a mut Self;
1362        fn take_or_borrow<'a>(
1363            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1364        ) -> Self::Borrowed<'a> {
1365            value
1366        }
1367    }
1368
1369    unsafe impl fidl::encoding::TypeMarker for ControllerPresentClientViewRequest {
1370        type Owned = Self;
1371
1372        #[inline(always)]
1373        fn inline_align(_context: fidl::encoding::Context) -> usize {
1374            8
1375        }
1376
1377        #[inline(always)]
1378        fn inline_size(_context: fidl::encoding::Context) -> usize {
1379            16
1380        }
1381    }
1382
1383    unsafe impl
1384        fidl::encoding::Encode<
1385            ControllerPresentClientViewRequest,
1386            fidl::encoding::DefaultFuchsiaResourceDialect,
1387        > for &mut ControllerPresentClientViewRequest
1388    {
1389        unsafe fn encode(
1390            self,
1391            encoder: &mut fidl::encoding::Encoder<
1392                '_,
1393                fidl::encoding::DefaultFuchsiaResourceDialect,
1394            >,
1395            offset: usize,
1396            mut depth: fidl::encoding::Depth,
1397        ) -> fidl::Result<()> {
1398            encoder.debug_check_bounds::<ControllerPresentClientViewRequest>(offset);
1399            // Vector header
1400            let max_ordinal: u64 = self.max_ordinal_present();
1401            encoder.write_num(max_ordinal, offset);
1402            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1403            // Calling encoder.out_of_line_offset(0) is not allowed.
1404            if max_ordinal == 0 {
1405                return Ok(());
1406            }
1407            depth.increment()?;
1408            let envelope_size = 8;
1409            let bytes_len = max_ordinal as usize * envelope_size;
1410            #[allow(unused_variables)]
1411            let offset = encoder.out_of_line_offset(bytes_len);
1412            let mut _prev_end_offset: usize = 0;
1413            if 1 > max_ordinal {
1414                return Ok(());
1415            }
1416
1417            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
1418            // are envelope_size bytes.
1419            let cur_offset: usize = (1 - 1) * envelope_size;
1420
1421            // Zero reserved fields.
1422            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1423
1424            // Safety:
1425            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
1426            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
1427            //   envelope_size bytes, there is always sufficient room.
1428            fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
1429            self.viewport_creation_token.as_mut().map(<fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1430            encoder, offset + cur_offset, depth
1431        )?;
1432
1433            _prev_end_offset = cur_offset + envelope_size;
1434
1435            Ok(())
1436        }
1437    }
1438
1439    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1440        for ControllerPresentClientViewRequest
1441    {
1442        #[inline(always)]
1443        fn new_empty() -> Self {
1444            Self::default()
1445        }
1446
1447        unsafe fn decode(
1448            &mut self,
1449            decoder: &mut fidl::encoding::Decoder<
1450                '_,
1451                fidl::encoding::DefaultFuchsiaResourceDialect,
1452            >,
1453            offset: usize,
1454            mut depth: fidl::encoding::Depth,
1455        ) -> fidl::Result<()> {
1456            decoder.debug_check_bounds::<Self>(offset);
1457            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1458                None => return Err(fidl::Error::NotNullable),
1459                Some(len) => len,
1460            };
1461            // Calling decoder.out_of_line_offset(0) is not allowed.
1462            if len == 0 {
1463                return Ok(());
1464            };
1465            depth.increment()?;
1466            let envelope_size = 8;
1467            let bytes_len = len * envelope_size;
1468            let offset = decoder.out_of_line_offset(bytes_len)?;
1469            // Decode the envelope for each type.
1470            let mut _next_ordinal_to_read = 0;
1471            let mut next_offset = offset;
1472            let end_offset = offset + bytes_len;
1473            _next_ordinal_to_read += 1;
1474            if next_offset >= end_offset {
1475                return Ok(());
1476            }
1477
1478            // Decode unknown envelopes for gaps in ordinals.
1479            while _next_ordinal_to_read < 1 {
1480                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1481                _next_ordinal_to_read += 1;
1482                next_offset += envelope_size;
1483            }
1484
1485            let next_out_of_line = decoder.next_out_of_line();
1486            let handles_before = decoder.remaining_handles();
1487            if let Some((inlined, num_bytes, num_handles)) =
1488                fidl::encoding::decode_envelope_header(decoder, next_offset)?
1489            {
1490                let member_inline_size = <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::TypeMarker>::inline_size(decoder.context);
1491                if inlined != (member_inline_size <= 4) {
1492                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
1493                }
1494                let inner_offset;
1495                let mut inner_depth = depth.clone();
1496                if inlined {
1497                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
1498                    inner_offset = next_offset;
1499                } else {
1500                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
1501                    inner_depth.increment()?;
1502                }
1503                let val_ref = self.viewport_creation_token.get_or_insert_with(|| {
1504                    fidl::new_empty!(
1505                        fidl_fuchsia_ui_views::ViewportCreationToken,
1506                        fidl::encoding::DefaultFuchsiaResourceDialect
1507                    )
1508                });
1509                fidl::decode!(
1510                    fidl_fuchsia_ui_views::ViewportCreationToken,
1511                    fidl::encoding::DefaultFuchsiaResourceDialect,
1512                    val_ref,
1513                    decoder,
1514                    inner_offset,
1515                    inner_depth
1516                )?;
1517                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
1518                {
1519                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
1520                }
1521                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
1522                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
1523                }
1524            }
1525
1526            next_offset += envelope_size;
1527
1528            // Decode the remaining unknown envelopes.
1529            while next_offset < end_offset {
1530                _next_ordinal_to_read += 1;
1531                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1532                next_offset += envelope_size;
1533            }
1534
1535            Ok(())
1536        }
1537    }
1538}