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