Skip to main content

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