fidl_fuchsia_ui_scenic/
fidl_fuchsia_ui_scenic.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_ui_scenic__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct ScenicCreateSession2Request {
16    pub session: fidl::endpoints::ServerEnd<SessionMarker>,
17    pub listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
18    pub view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
19}
20
21impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
22    for ScenicCreateSession2Request
23{
24}
25
26#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
27pub struct ScenicCreateSessionRequest {
28    pub session: fidl::endpoints::ServerEnd<SessionMarker>,
29    pub listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
33    for ScenicCreateSessionRequest
34{
35}
36
37#[derive(Debug, PartialEq)]
38pub struct ScenicCreateSessionTRequest {
39    pub endpoints: SessionEndpoints,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for ScenicCreateSessionTRequest
44{
45}
46
47#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48pub struct ScenicGetDisplayOwnershipEventResponse {
49    pub ownership_event: fidl::Event,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for ScenicGetDisplayOwnershipEventResponse
54{
55}
56
57#[derive(Debug, PartialEq)]
58pub struct ScenicTakeScreenshotResponse {
59    pub img_data: ScreenshotData,
60    pub success: bool,
61}
62
63impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
64    for ScenicTakeScreenshotResponse
65{
66}
67
68/// Scenic.TakeScreenshot() returns a raw BGRA formatted image in
69/// sRGB color space and with a non-linear transfer function in this
70/// struct.
71#[derive(Debug, PartialEq)]
72pub struct ScreenshotData {
73    pub info: fidl_fuchsia_images::ImageInfo,
74    pub data: fidl_fuchsia_mem::Buffer,
75}
76
77impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotData {}
78
79#[derive(Debug, PartialEq)]
80pub struct SessionEnqueueRequest {
81    pub cmds: Vec<Command>,
82}
83
84impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionEnqueueRequest {}
85
86#[derive(Debug, PartialEq)]
87pub struct SessionListenerOnScenicEventRequest {
88    pub events: Vec<Event>,
89}
90
91impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
92    for SessionListenerOnScenicEventRequest
93{
94}
95
96#[derive(Debug, PartialEq)]
97pub struct SessionPresent2Request {
98    pub args: Present2Args,
99}
100
101impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionPresent2Request {}
102
103#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
104pub struct SessionPresentRequest {
105    pub presentation_time: u64,
106    pub acquire_fences: Vec<fidl::Event>,
107    pub release_fences: Vec<fidl::Event>,
108}
109
110impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionPresentRequest {}
111
112#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
113pub struct SessionRegisterBufferCollectionRequest {
114    pub buffer_id: u32,
115    pub token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
116}
117
118impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
119    for SessionRegisterBufferCollectionRequest
120{
121}
122
123/// Arguments passed into Present2(). Note that every argument is mandatory.
124#[derive(Debug, Default, PartialEq)]
125pub struct Present2Args {
126    /// `requested_presentation_time` specifies the time on or after which the
127    /// client would like the enqueued operations to take visible effect
128    /// (light up pixels on the screen), expressed in nanoseconds in the
129    /// `CLOCK_MONOTONIC` timebase.
130    ///
131    /// Using a `requested_presentation_time` in the present or past (such as 0)
132    /// schedules enqueued operations to take visible effect as soon as
133    /// possible, during the next frame to be prepared. Requested presentation
134    /// times must be monotonically increasing.
135    ///
136    /// Using a `requested_presentation_time` in the future schedules the enqueued
137    /// operations to take visible effect as closely as possible to or after
138    /// the stated time, but no earlier.
139    ///
140    /// Each rendered frame has a target presentation time. This is when Scenic
141    /// aims to have the frame presented to the user. Before rendering a frame,
142    /// the scene manager applies all enqueued operations associated with all
143    /// prior calls to Present2 whose `requested_presentation_time` is on or
144    /// before the frame's target presentation time.
145    pub requested_presentation_time: Option<i64>,
146    /// Scenic will wait until all of a session's `acquire_fences` are ready
147    /// before it will execute the presented commands.
148    pub acquire_fences: Option<Vec<fidl::Event>>,
149    /// `release_fences` is the list of events that will be signalled by Scenic when
150    /// the following Present2 call's `acquire_fences` has been signalled, and
151    /// the updated session state has been fully committed: future frames will be
152    /// rendered using this state, and all frames generated using previous session
153    /// states have been fully-rendered and presented to the display.
154    pub release_fences: Option<Vec<fidl::Event>>,
155    /// `requested_prediction_span` is the amount of time into the future Scenic
156    /// will provide predictions for. A span of 0 is guaranteed to provide at
157    /// least one future time.
158    pub requested_prediction_span: Option<i64>,
159    #[doc(hidden)]
160    pub __source_breaking: fidl::marker::SourceBreaking,
161}
162
163impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Present2Args {}
164
165/// The protocol endpoints used in creating a Scenic Session.
166#[derive(Debug, Default, PartialEq)]
167pub struct SessionEndpoints {
168    /// Enqueue commands and present content.
169    /// Required.
170    pub session: Option<fidl::endpoints::ServerEnd<SessionMarker>>,
171    /// Receive session-related events.
172    /// Optional.
173    pub session_listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
174    /// Change view focus, within the session view's subtree.
175    /// Optional.
176    pub view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
177    /// Learn when this session view receives or loses view focus.
178    /// Optional.
179    pub view_ref_focused:
180        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>>,
181    /// Ask for touch events and negotiate for gesture ownership.
182    /// Optional.
183    pub touch_source:
184        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>>,
185    /// Ask for mouse events.
186    /// Optional.
187    pub mouse_source:
188        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
189    #[doc(hidden)]
190    pub __source_breaking: fidl::marker::SourceBreaking,
191}
192
193impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for SessionEndpoints {}
194
195#[derive(Debug, PartialEq)]
196pub enum Command {
197    Gfx(fidl_fuchsia_ui_gfx::Command),
198    Views(fidl_fuchsia_ui_views::Command),
199    Input(fidl_fuchsia_ui_input::Command),
200}
201
202impl Command {
203    #[inline]
204    pub fn ordinal(&self) -> u64 {
205        match *self {
206            Self::Gfx(_) => 1,
207            Self::Views(_) => 3,
208            Self::Input(_) => 4,
209        }
210    }
211}
212
213impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Command {}
214
215#[derive(Debug, PartialEq)]
216pub enum Event {
217    Gfx(fidl_fuchsia_ui_gfx::Event),
218    Input(fidl_fuchsia_ui_input::InputEvent),
219    Unhandled(Command),
220}
221
222impl Event {
223    #[inline]
224    pub fn ordinal(&self) -> u64 {
225        match *self {
226            Self::Gfx(_) => 1,
227            Self::Input(_) => 2,
228            Self::Unhandled(_) => 3,
229        }
230    }
231}
232
233impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Event {}
234
235#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
236pub struct ScenicMarker;
237
238impl fidl::endpoints::ProtocolMarker for ScenicMarker {
239    type Proxy = ScenicProxy;
240    type RequestStream = ScenicRequestStream;
241    #[cfg(target_os = "fuchsia")]
242    type SynchronousProxy = ScenicSynchronousProxy;
243
244    const DEBUG_NAME: &'static str = "fuchsia.ui.scenic.Scenic";
245}
246impl fidl::endpoints::DiscoverableProtocolMarker for ScenicMarker {}
247
248pub trait ScenicProxyInterface: Send + Sync {
249    fn r#create_session(
250        &self,
251        session: fidl::endpoints::ServerEnd<SessionMarker>,
252        listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
253    ) -> Result<(), fidl::Error>;
254    fn r#create_session2(
255        &self,
256        session: fidl::endpoints::ServerEnd<SessionMarker>,
257        listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
258        view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
259    ) -> Result<(), fidl::Error>;
260    type CreateSessionTResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
261    fn r#create_session_t(&self, endpoints: SessionEndpoints) -> Self::CreateSessionTResponseFut;
262    type GetDisplayInfoResponseFut: std::future::Future<Output = Result<fidl_fuchsia_ui_gfx::DisplayInfo, fidl::Error>>
263        + Send;
264    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut;
265    type GetDisplayOwnershipEventResponseFut: std::future::Future<Output = Result<fidl::Event, fidl::Error>>
266        + Send;
267    fn r#get_display_ownership_event(&self) -> Self::GetDisplayOwnershipEventResponseFut;
268    type TakeScreenshotResponseFut: std::future::Future<Output = Result<(ScreenshotData, bool), fidl::Error>>
269        + Send;
270    fn r#take_screenshot(&self) -> Self::TakeScreenshotResponseFut;
271    type UsesFlatlandResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
272    fn r#uses_flatland(&self) -> Self::UsesFlatlandResponseFut;
273}
274#[derive(Debug)]
275#[cfg(target_os = "fuchsia")]
276pub struct ScenicSynchronousProxy {
277    client: fidl::client::sync::Client,
278}
279
280#[cfg(target_os = "fuchsia")]
281impl fidl::endpoints::SynchronousProxy for ScenicSynchronousProxy {
282    type Proxy = ScenicProxy;
283    type Protocol = ScenicMarker;
284
285    fn from_channel(inner: fidl::Channel) -> Self {
286        Self::new(inner)
287    }
288
289    fn into_channel(self) -> fidl::Channel {
290        self.client.into_channel()
291    }
292
293    fn as_channel(&self) -> &fidl::Channel {
294        self.client.as_channel()
295    }
296}
297
298#[cfg(target_os = "fuchsia")]
299impl ScenicSynchronousProxy {
300    pub fn new(channel: fidl::Channel) -> Self {
301        let protocol_name = <ScenicMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
302        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
303    }
304
305    pub fn into_channel(self) -> fidl::Channel {
306        self.client.into_channel()
307    }
308
309    /// Waits until an event arrives and returns it. It is safe for other
310    /// threads to make concurrent requests while waiting for an event.
311    pub fn wait_for_event(
312        &self,
313        deadline: zx::MonotonicInstant,
314    ) -> Result<ScenicEvent, fidl::Error> {
315        ScenicEvent::decode(self.client.wait_for_event(deadline)?)
316    }
317
318    /// Create a new Session, which is the primary way to interact with Scenic.
319    pub fn r#create_session(
320        &self,
321        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
322        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
323    ) -> Result<(), fidl::Error> {
324        self.client.send::<ScenicCreateSessionRequest>(
325            (session, listener),
326            0x2af781f341771a50,
327            fidl::encoding::DynamicFlags::empty(),
328        )
329    }
330
331    /// Create a new Session, which is the primary way to interact with Scenic.
332    ///
333    /// In this variant, the caller may register a request for focus management.
334    /// The `view_focuser`'s client is coupled to the requested `session`, and
335    /// this coupling acts as a security boundary: the ViewRef used as the basis
336    /// for authority by `view_focuser` must come from `session`.
337    pub fn r#create_session2(
338        &self,
339        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
340        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
341        mut view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
342    ) -> Result<(), fidl::Error> {
343        self.client.send::<ScenicCreateSession2Request>(
344            (session, listener, view_focuser),
345            0x11fa60f776121fa5,
346            fidl::encoding::DynamicFlags::empty(),
347        )
348    }
349
350    /// Create a new Session, which is the primary way to interact with Scenic.
351    ///
352    /// In this variant, the caller may submit a combination of protocols
353    /// that make sense for it. The Session protocol is the only required
354    /// protocol. The SessionEndpoints table may be extended with more protocol
355    /// fields, but these extensions should retain ABI and API compatibility
356    /// with existing (pre-compiled) clients.
357    ///
358    /// The response acknowledges the request to create a Session, but actual
359    /// creation may happen later.
360    pub fn r#create_session_t(
361        &self,
362        mut endpoints: SessionEndpoints,
363        ___deadline: zx::MonotonicInstant,
364    ) -> Result<(), fidl::Error> {
365        let _response =
366            self.client.send_query::<ScenicCreateSessionTRequest, fidl::encoding::EmptyPayload>(
367                (&mut endpoints,),
368                0x369061a897552d4f,
369                fidl::encoding::DynamicFlags::empty(),
370                ___deadline,
371            )?;
372        Ok(_response)
373    }
374
375    /// Get information about the Scenic's primary display.
376    pub fn r#get_display_info(
377        &self,
378        ___deadline: zx::MonotonicInstant,
379    ) -> Result<fidl_fuchsia_ui_gfx::DisplayInfo, fidl::Error> {
380        let _response =
381            self.client.send_query::<fidl::encoding::EmptyPayload, ScenicGetDisplayInfoResponse>(
382                (),
383                0x3e4cdecbf7cc1797,
384                fidl::encoding::DynamicFlags::empty(),
385                ___deadline,
386            )?;
387        Ok(_response.info)
388    }
389
390    /// Gets an event signaled with displayOwnedSignal or displayNotOwnedSignal
391    /// when display ownership changes.
392    pub fn r#get_display_ownership_event(
393        &self,
394        ___deadline: zx::MonotonicInstant,
395    ) -> Result<fidl::Event, fidl::Error> {
396        let _response = self
397            .client
398            .send_query::<fidl::encoding::EmptyPayload, ScenicGetDisplayOwnershipEventResponse>(
399                (),
400                0x54c114c7322b24d6,
401                fidl::encoding::DynamicFlags::empty(),
402                ___deadline,
403            )?;
404        Ok(_response.ownership_event)
405    }
406
407    /// Take a screenshot and return the data in `img_data`. `img_data` will
408    /// not contain BGRA data if `success` is false.
409    pub fn r#take_screenshot(
410        &self,
411        ___deadline: zx::MonotonicInstant,
412    ) -> Result<(ScreenshotData, bool), fidl::Error> {
413        let _response =
414            self.client.send_query::<fidl::encoding::EmptyPayload, ScenicTakeScreenshotResponse>(
415                (),
416                0x53f5e06463987df2,
417                fidl::encoding::DynamicFlags::empty(),
418                ___deadline,
419            )?;
420        Ok((_response.img_data, _response.success))
421    }
422
423    /// Returns whether the clients should use [`fuchsia.ui.composition/Flatland`] protocol to
424    /// interact with Scenic instead.
425    pub fn r#uses_flatland(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
426        let _response =
427            self.client.send_query::<fidl::encoding::EmptyPayload, ScenicUsesFlatlandResponse>(
428                (),
429                0x5f2e5e19463ae706,
430                fidl::encoding::DynamicFlags::empty(),
431                ___deadline,
432            )?;
433        Ok(_response.flatland_enabled)
434    }
435}
436
437#[cfg(target_os = "fuchsia")]
438impl From<ScenicSynchronousProxy> for zx::Handle {
439    fn from(value: ScenicSynchronousProxy) -> Self {
440        value.into_channel().into()
441    }
442}
443
444#[cfg(target_os = "fuchsia")]
445impl From<fidl::Channel> for ScenicSynchronousProxy {
446    fn from(value: fidl::Channel) -> Self {
447        Self::new(value)
448    }
449}
450
451#[derive(Debug, Clone)]
452pub struct ScenicProxy {
453    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
454}
455
456impl fidl::endpoints::Proxy for ScenicProxy {
457    type Protocol = ScenicMarker;
458
459    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
460        Self::new(inner)
461    }
462
463    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
464        self.client.into_channel().map_err(|client| Self { client })
465    }
466
467    fn as_channel(&self) -> &::fidl::AsyncChannel {
468        self.client.as_channel()
469    }
470}
471
472impl ScenicProxy {
473    /// Create a new Proxy for fuchsia.ui.scenic/Scenic.
474    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
475        let protocol_name = <ScenicMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
476        Self { client: fidl::client::Client::new(channel, protocol_name) }
477    }
478
479    /// Get a Stream of events from the remote end of the protocol.
480    ///
481    /// # Panics
482    ///
483    /// Panics if the event stream was already taken.
484    pub fn take_event_stream(&self) -> ScenicEventStream {
485        ScenicEventStream { event_receiver: self.client.take_event_receiver() }
486    }
487
488    /// Create a new Session, which is the primary way to interact with Scenic.
489    pub fn r#create_session(
490        &self,
491        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
492        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
493    ) -> Result<(), fidl::Error> {
494        ScenicProxyInterface::r#create_session(self, session, listener)
495    }
496
497    /// Create a new Session, which is the primary way to interact with Scenic.
498    ///
499    /// In this variant, the caller may register a request for focus management.
500    /// The `view_focuser`'s client is coupled to the requested `session`, and
501    /// this coupling acts as a security boundary: the ViewRef used as the basis
502    /// for authority by `view_focuser` must come from `session`.
503    pub fn r#create_session2(
504        &self,
505        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
506        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
507        mut view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
508    ) -> Result<(), fidl::Error> {
509        ScenicProxyInterface::r#create_session2(self, session, listener, view_focuser)
510    }
511
512    /// Create a new Session, which is the primary way to interact with Scenic.
513    ///
514    /// In this variant, the caller may submit a combination of protocols
515    /// that make sense for it. The Session protocol is the only required
516    /// protocol. The SessionEndpoints table may be extended with more protocol
517    /// fields, but these extensions should retain ABI and API compatibility
518    /// with existing (pre-compiled) clients.
519    ///
520    /// The response acknowledges the request to create a Session, but actual
521    /// creation may happen later.
522    pub fn r#create_session_t(
523        &self,
524        mut endpoints: SessionEndpoints,
525    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
526        ScenicProxyInterface::r#create_session_t(self, endpoints)
527    }
528
529    /// Get information about the Scenic's primary display.
530    pub fn r#get_display_info(
531        &self,
532    ) -> fidl::client::QueryResponseFut<
533        fidl_fuchsia_ui_gfx::DisplayInfo,
534        fidl::encoding::DefaultFuchsiaResourceDialect,
535    > {
536        ScenicProxyInterface::r#get_display_info(self)
537    }
538
539    /// Gets an event signaled with displayOwnedSignal or displayNotOwnedSignal
540    /// when display ownership changes.
541    pub fn r#get_display_ownership_event(
542        &self,
543    ) -> fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>
544    {
545        ScenicProxyInterface::r#get_display_ownership_event(self)
546    }
547
548    /// Take a screenshot and return the data in `img_data`. `img_data` will
549    /// not contain BGRA data if `success` is false.
550    pub fn r#take_screenshot(
551        &self,
552    ) -> fidl::client::QueryResponseFut<
553        (ScreenshotData, bool),
554        fidl::encoding::DefaultFuchsiaResourceDialect,
555    > {
556        ScenicProxyInterface::r#take_screenshot(self)
557    }
558
559    /// Returns whether the clients should use [`fuchsia.ui.composition/Flatland`] protocol to
560    /// interact with Scenic instead.
561    pub fn r#uses_flatland(
562        &self,
563    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
564        ScenicProxyInterface::r#uses_flatland(self)
565    }
566}
567
568impl ScenicProxyInterface for ScenicProxy {
569    fn r#create_session(
570        &self,
571        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
572        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
573    ) -> Result<(), fidl::Error> {
574        self.client.send::<ScenicCreateSessionRequest>(
575            (session, listener),
576            0x2af781f341771a50,
577            fidl::encoding::DynamicFlags::empty(),
578        )
579    }
580
581    fn r#create_session2(
582        &self,
583        mut session: fidl::endpoints::ServerEnd<SessionMarker>,
584        mut listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
585        mut view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
586    ) -> Result<(), fidl::Error> {
587        self.client.send::<ScenicCreateSession2Request>(
588            (session, listener, view_focuser),
589            0x11fa60f776121fa5,
590            fidl::encoding::DynamicFlags::empty(),
591        )
592    }
593
594    type CreateSessionTResponseFut =
595        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
596    fn r#create_session_t(
597        &self,
598        mut endpoints: SessionEndpoints,
599    ) -> Self::CreateSessionTResponseFut {
600        fn _decode(
601            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
602        ) -> Result<(), fidl::Error> {
603            let _response = fidl::client::decode_transaction_body::<
604                fidl::encoding::EmptyPayload,
605                fidl::encoding::DefaultFuchsiaResourceDialect,
606                0x369061a897552d4f,
607            >(_buf?)?;
608            Ok(_response)
609        }
610        self.client.send_query_and_decode::<ScenicCreateSessionTRequest, ()>(
611            (&mut endpoints,),
612            0x369061a897552d4f,
613            fidl::encoding::DynamicFlags::empty(),
614            _decode,
615        )
616    }
617
618    type GetDisplayInfoResponseFut = fidl::client::QueryResponseFut<
619        fidl_fuchsia_ui_gfx::DisplayInfo,
620        fidl::encoding::DefaultFuchsiaResourceDialect,
621    >;
622    fn r#get_display_info(&self) -> Self::GetDisplayInfoResponseFut {
623        fn _decode(
624            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
625        ) -> Result<fidl_fuchsia_ui_gfx::DisplayInfo, fidl::Error> {
626            let _response = fidl::client::decode_transaction_body::<
627                ScenicGetDisplayInfoResponse,
628                fidl::encoding::DefaultFuchsiaResourceDialect,
629                0x3e4cdecbf7cc1797,
630            >(_buf?)?;
631            Ok(_response.info)
632        }
633        self.client.send_query_and_decode::<
634            fidl::encoding::EmptyPayload,
635            fidl_fuchsia_ui_gfx::DisplayInfo,
636        >(
637            (),
638            0x3e4cdecbf7cc1797,
639            fidl::encoding::DynamicFlags::empty(),
640            _decode,
641        )
642    }
643
644    type GetDisplayOwnershipEventResponseFut =
645        fidl::client::QueryResponseFut<fidl::Event, fidl::encoding::DefaultFuchsiaResourceDialect>;
646    fn r#get_display_ownership_event(&self) -> Self::GetDisplayOwnershipEventResponseFut {
647        fn _decode(
648            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
649        ) -> Result<fidl::Event, fidl::Error> {
650            let _response = fidl::client::decode_transaction_body::<
651                ScenicGetDisplayOwnershipEventResponse,
652                fidl::encoding::DefaultFuchsiaResourceDialect,
653                0x54c114c7322b24d6,
654            >(_buf?)?;
655            Ok(_response.ownership_event)
656        }
657        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::Event>(
658            (),
659            0x54c114c7322b24d6,
660            fidl::encoding::DynamicFlags::empty(),
661            _decode,
662        )
663    }
664
665    type TakeScreenshotResponseFut = fidl::client::QueryResponseFut<
666        (ScreenshotData, bool),
667        fidl::encoding::DefaultFuchsiaResourceDialect,
668    >;
669    fn r#take_screenshot(&self) -> Self::TakeScreenshotResponseFut {
670        fn _decode(
671            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
672        ) -> Result<(ScreenshotData, bool), fidl::Error> {
673            let _response = fidl::client::decode_transaction_body::<
674                ScenicTakeScreenshotResponse,
675                fidl::encoding::DefaultFuchsiaResourceDialect,
676                0x53f5e06463987df2,
677            >(_buf?)?;
678            Ok((_response.img_data, _response.success))
679        }
680        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, (ScreenshotData, bool)>(
681            (),
682            0x53f5e06463987df2,
683            fidl::encoding::DynamicFlags::empty(),
684            _decode,
685        )
686    }
687
688    type UsesFlatlandResponseFut =
689        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
690    fn r#uses_flatland(&self) -> Self::UsesFlatlandResponseFut {
691        fn _decode(
692            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
693        ) -> Result<bool, fidl::Error> {
694            let _response = fidl::client::decode_transaction_body::<
695                ScenicUsesFlatlandResponse,
696                fidl::encoding::DefaultFuchsiaResourceDialect,
697                0x5f2e5e19463ae706,
698            >(_buf?)?;
699            Ok(_response.flatland_enabled)
700        }
701        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
702            (),
703            0x5f2e5e19463ae706,
704            fidl::encoding::DynamicFlags::empty(),
705            _decode,
706        )
707    }
708}
709
710pub struct ScenicEventStream {
711    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
712}
713
714impl std::marker::Unpin for ScenicEventStream {}
715
716impl futures::stream::FusedStream for ScenicEventStream {
717    fn is_terminated(&self) -> bool {
718        self.event_receiver.is_terminated()
719    }
720}
721
722impl futures::Stream for ScenicEventStream {
723    type Item = Result<ScenicEvent, fidl::Error>;
724
725    fn poll_next(
726        mut self: std::pin::Pin<&mut Self>,
727        cx: &mut std::task::Context<'_>,
728    ) -> std::task::Poll<Option<Self::Item>> {
729        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
730            &mut self.event_receiver,
731            cx
732        )?) {
733            Some(buf) => std::task::Poll::Ready(Some(ScenicEvent::decode(buf))),
734            None => std::task::Poll::Ready(None),
735        }
736    }
737}
738
739#[derive(Debug)]
740pub enum ScenicEvent {}
741
742impl ScenicEvent {
743    /// Decodes a message buffer as a [`ScenicEvent`].
744    fn decode(
745        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
746    ) -> Result<ScenicEvent, fidl::Error> {
747        let (bytes, _handles) = buf.split_mut();
748        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
749        debug_assert_eq!(tx_header.tx_id, 0);
750        match tx_header.ordinal {
751            _ => Err(fidl::Error::UnknownOrdinal {
752                ordinal: tx_header.ordinal,
753                protocol_name: <ScenicMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
754            }),
755        }
756    }
757}
758
759/// A Stream of incoming requests for fuchsia.ui.scenic/Scenic.
760pub struct ScenicRequestStream {
761    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
762    is_terminated: bool,
763}
764
765impl std::marker::Unpin for ScenicRequestStream {}
766
767impl futures::stream::FusedStream for ScenicRequestStream {
768    fn is_terminated(&self) -> bool {
769        self.is_terminated
770    }
771}
772
773impl fidl::endpoints::RequestStream for ScenicRequestStream {
774    type Protocol = ScenicMarker;
775    type ControlHandle = ScenicControlHandle;
776
777    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
778        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
779    }
780
781    fn control_handle(&self) -> Self::ControlHandle {
782        ScenicControlHandle { inner: self.inner.clone() }
783    }
784
785    fn into_inner(
786        self,
787    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
788    {
789        (self.inner, self.is_terminated)
790    }
791
792    fn from_inner(
793        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
794        is_terminated: bool,
795    ) -> Self {
796        Self { inner, is_terminated }
797    }
798}
799
800impl futures::Stream for ScenicRequestStream {
801    type Item = Result<ScenicRequest, fidl::Error>;
802
803    fn poll_next(
804        mut self: std::pin::Pin<&mut Self>,
805        cx: &mut std::task::Context<'_>,
806    ) -> std::task::Poll<Option<Self::Item>> {
807        let this = &mut *self;
808        if this.inner.check_shutdown(cx) {
809            this.is_terminated = true;
810            return std::task::Poll::Ready(None);
811        }
812        if this.is_terminated {
813            panic!("polled ScenicRequestStream after completion");
814        }
815        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
816            |bytes, handles| {
817                match this.inner.channel().read_etc(cx, bytes, handles) {
818                    std::task::Poll::Ready(Ok(())) => {}
819                    std::task::Poll::Pending => return std::task::Poll::Pending,
820                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
821                        this.is_terminated = true;
822                        return std::task::Poll::Ready(None);
823                    }
824                    std::task::Poll::Ready(Err(e)) => {
825                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
826                            e.into(),
827                        ))))
828                    }
829                }
830
831                // A message has been received from the channel
832                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
833
834                std::task::Poll::Ready(Some(match header.ordinal {
835                    0x2af781f341771a50 => {
836                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
837                        let mut req = fidl::new_empty!(
838                            ScenicCreateSessionRequest,
839                            fidl::encoding::DefaultFuchsiaResourceDialect
840                        );
841                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScenicCreateSessionRequest>(&header, _body_bytes, handles, &mut req)?;
842                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
843                        Ok(ScenicRequest::CreateSession {
844                            session: req.session,
845                            listener: req.listener,
846
847                            control_handle,
848                        })
849                    }
850                    0x11fa60f776121fa5 => {
851                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
852                        let mut req = fidl::new_empty!(
853                            ScenicCreateSession2Request,
854                            fidl::encoding::DefaultFuchsiaResourceDialect
855                        );
856                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScenicCreateSession2Request>(&header, _body_bytes, handles, &mut req)?;
857                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
858                        Ok(ScenicRequest::CreateSession2 {
859                            session: req.session,
860                            listener: req.listener,
861                            view_focuser: req.view_focuser,
862
863                            control_handle,
864                        })
865                    }
866                    0x369061a897552d4f => {
867                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
868                        let mut req = fidl::new_empty!(
869                            ScenicCreateSessionTRequest,
870                            fidl::encoding::DefaultFuchsiaResourceDialect
871                        );
872                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScenicCreateSessionTRequest>(&header, _body_bytes, handles, &mut req)?;
873                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
874                        Ok(ScenicRequest::CreateSessionT {
875                            endpoints: req.endpoints,
876
877                            responder: ScenicCreateSessionTResponder {
878                                control_handle: std::mem::ManuallyDrop::new(control_handle),
879                                tx_id: header.tx_id,
880                            },
881                        })
882                    }
883                    0x3e4cdecbf7cc1797 => {
884                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
885                        let mut req = fidl::new_empty!(
886                            fidl::encoding::EmptyPayload,
887                            fidl::encoding::DefaultFuchsiaResourceDialect
888                        );
889                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
890                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
891                        Ok(ScenicRequest::GetDisplayInfo {
892                            responder: ScenicGetDisplayInfoResponder {
893                                control_handle: std::mem::ManuallyDrop::new(control_handle),
894                                tx_id: header.tx_id,
895                            },
896                        })
897                    }
898                    0x54c114c7322b24d6 => {
899                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
900                        let mut req = fidl::new_empty!(
901                            fidl::encoding::EmptyPayload,
902                            fidl::encoding::DefaultFuchsiaResourceDialect
903                        );
904                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
905                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
906                        Ok(ScenicRequest::GetDisplayOwnershipEvent {
907                            responder: ScenicGetDisplayOwnershipEventResponder {
908                                control_handle: std::mem::ManuallyDrop::new(control_handle),
909                                tx_id: header.tx_id,
910                            },
911                        })
912                    }
913                    0x53f5e06463987df2 => {
914                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
915                        let mut req = fidl::new_empty!(
916                            fidl::encoding::EmptyPayload,
917                            fidl::encoding::DefaultFuchsiaResourceDialect
918                        );
919                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
920                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
921                        Ok(ScenicRequest::TakeScreenshot {
922                            responder: ScenicTakeScreenshotResponder {
923                                control_handle: std::mem::ManuallyDrop::new(control_handle),
924                                tx_id: header.tx_id,
925                            },
926                        })
927                    }
928                    0x5f2e5e19463ae706 => {
929                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
930                        let mut req = fidl::new_empty!(
931                            fidl::encoding::EmptyPayload,
932                            fidl::encoding::DefaultFuchsiaResourceDialect
933                        );
934                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
935                        let control_handle = ScenicControlHandle { inner: this.inner.clone() };
936                        Ok(ScenicRequest::UsesFlatland {
937                            responder: ScenicUsesFlatlandResponder {
938                                control_handle: std::mem::ManuallyDrop::new(control_handle),
939                                tx_id: header.tx_id,
940                            },
941                        })
942                    }
943                    _ => Err(fidl::Error::UnknownOrdinal {
944                        ordinal: header.ordinal,
945                        protocol_name:
946                            <ScenicMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
947                    }),
948                }))
949            },
950        )
951    }
952}
953
954#[derive(Debug)]
955pub enum ScenicRequest {
956    /// Create a new Session, which is the primary way to interact with Scenic.
957    CreateSession {
958        session: fidl::endpoints::ServerEnd<SessionMarker>,
959        listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
960        control_handle: ScenicControlHandle,
961    },
962    /// Create a new Session, which is the primary way to interact with Scenic.
963    ///
964    /// In this variant, the caller may register a request for focus management.
965    /// The `view_focuser`'s client is coupled to the requested `session`, and
966    /// this coupling acts as a security boundary: the ViewRef used as the basis
967    /// for authority by `view_focuser` must come from `session`.
968    CreateSession2 {
969        session: fidl::endpoints::ServerEnd<SessionMarker>,
970        listener: Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
971        view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
972        control_handle: ScenicControlHandle,
973    },
974    /// Create a new Session, which is the primary way to interact with Scenic.
975    ///
976    /// In this variant, the caller may submit a combination of protocols
977    /// that make sense for it. The Session protocol is the only required
978    /// protocol. The SessionEndpoints table may be extended with more protocol
979    /// fields, but these extensions should retain ABI and API compatibility
980    /// with existing (pre-compiled) clients.
981    ///
982    /// The response acknowledges the request to create a Session, but actual
983    /// creation may happen later.
984    CreateSessionT { endpoints: SessionEndpoints, responder: ScenicCreateSessionTResponder },
985    /// Get information about the Scenic's primary display.
986    GetDisplayInfo { responder: ScenicGetDisplayInfoResponder },
987    /// Gets an event signaled with displayOwnedSignal or displayNotOwnedSignal
988    /// when display ownership changes.
989    GetDisplayOwnershipEvent { responder: ScenicGetDisplayOwnershipEventResponder },
990    /// Take a screenshot and return the data in `img_data`. `img_data` will
991    /// not contain BGRA data if `success` is false.
992    TakeScreenshot { responder: ScenicTakeScreenshotResponder },
993    /// Returns whether the clients should use [`fuchsia.ui.composition/Flatland`] protocol to
994    /// interact with Scenic instead.
995    UsesFlatland { responder: ScenicUsesFlatlandResponder },
996}
997
998impl ScenicRequest {
999    #[allow(irrefutable_let_patterns)]
1000    pub fn into_create_session(
1001        self,
1002    ) -> Option<(
1003        fidl::endpoints::ServerEnd<SessionMarker>,
1004        Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
1005        ScenicControlHandle,
1006    )> {
1007        if let ScenicRequest::CreateSession { session, listener, control_handle } = self {
1008            Some((session, listener, control_handle))
1009        } else {
1010            None
1011        }
1012    }
1013
1014    #[allow(irrefutable_let_patterns)]
1015    pub fn into_create_session2(
1016        self,
1017    ) -> Option<(
1018        fidl::endpoints::ServerEnd<SessionMarker>,
1019        Option<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
1020        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
1021        ScenicControlHandle,
1022    )> {
1023        if let ScenicRequest::CreateSession2 { session, listener, view_focuser, control_handle } =
1024            self
1025        {
1026            Some((session, listener, view_focuser, control_handle))
1027        } else {
1028            None
1029        }
1030    }
1031
1032    #[allow(irrefutable_let_patterns)]
1033    pub fn into_create_session_t(
1034        self,
1035    ) -> Option<(SessionEndpoints, ScenicCreateSessionTResponder)> {
1036        if let ScenicRequest::CreateSessionT { endpoints, responder } = self {
1037            Some((endpoints, responder))
1038        } else {
1039            None
1040        }
1041    }
1042
1043    #[allow(irrefutable_let_patterns)]
1044    pub fn into_get_display_info(self) -> Option<(ScenicGetDisplayInfoResponder)> {
1045        if let ScenicRequest::GetDisplayInfo { responder } = self {
1046            Some((responder))
1047        } else {
1048            None
1049        }
1050    }
1051
1052    #[allow(irrefutable_let_patterns)]
1053    pub fn into_get_display_ownership_event(
1054        self,
1055    ) -> Option<(ScenicGetDisplayOwnershipEventResponder)> {
1056        if let ScenicRequest::GetDisplayOwnershipEvent { responder } = self {
1057            Some((responder))
1058        } else {
1059            None
1060        }
1061    }
1062
1063    #[allow(irrefutable_let_patterns)]
1064    pub fn into_take_screenshot(self) -> Option<(ScenicTakeScreenshotResponder)> {
1065        if let ScenicRequest::TakeScreenshot { responder } = self {
1066            Some((responder))
1067        } else {
1068            None
1069        }
1070    }
1071
1072    #[allow(irrefutable_let_patterns)]
1073    pub fn into_uses_flatland(self) -> Option<(ScenicUsesFlatlandResponder)> {
1074        if let ScenicRequest::UsesFlatland { responder } = self {
1075            Some((responder))
1076        } else {
1077            None
1078        }
1079    }
1080
1081    /// Name of the method defined in FIDL
1082    pub fn method_name(&self) -> &'static str {
1083        match *self {
1084            ScenicRequest::CreateSession { .. } => "create_session",
1085            ScenicRequest::CreateSession2 { .. } => "create_session2",
1086            ScenicRequest::CreateSessionT { .. } => "create_session_t",
1087            ScenicRequest::GetDisplayInfo { .. } => "get_display_info",
1088            ScenicRequest::GetDisplayOwnershipEvent { .. } => "get_display_ownership_event",
1089            ScenicRequest::TakeScreenshot { .. } => "take_screenshot",
1090            ScenicRequest::UsesFlatland { .. } => "uses_flatland",
1091        }
1092    }
1093}
1094
1095#[derive(Debug, Clone)]
1096pub struct ScenicControlHandle {
1097    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1098}
1099
1100impl fidl::endpoints::ControlHandle for ScenicControlHandle {
1101    fn shutdown(&self) {
1102        self.inner.shutdown()
1103    }
1104    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1105        self.inner.shutdown_with_epitaph(status)
1106    }
1107
1108    fn is_closed(&self) -> bool {
1109        self.inner.channel().is_closed()
1110    }
1111    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1112        self.inner.channel().on_closed()
1113    }
1114
1115    #[cfg(target_os = "fuchsia")]
1116    fn signal_peer(
1117        &self,
1118        clear_mask: zx::Signals,
1119        set_mask: zx::Signals,
1120    ) -> Result<(), zx_status::Status> {
1121        use fidl::Peered;
1122        self.inner.channel().signal_peer(clear_mask, set_mask)
1123    }
1124}
1125
1126impl ScenicControlHandle {}
1127
1128#[must_use = "FIDL methods require a response to be sent"]
1129#[derive(Debug)]
1130pub struct ScenicCreateSessionTResponder {
1131    control_handle: std::mem::ManuallyDrop<ScenicControlHandle>,
1132    tx_id: u32,
1133}
1134
1135/// Set the the channel to be shutdown (see [`ScenicControlHandle::shutdown`])
1136/// if the responder is dropped without sending a response, so that the client
1137/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1138impl std::ops::Drop for ScenicCreateSessionTResponder {
1139    fn drop(&mut self) {
1140        self.control_handle.shutdown();
1141        // Safety: drops once, never accessed again
1142        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1143    }
1144}
1145
1146impl fidl::endpoints::Responder for ScenicCreateSessionTResponder {
1147    type ControlHandle = ScenicControlHandle;
1148
1149    fn control_handle(&self) -> &ScenicControlHandle {
1150        &self.control_handle
1151    }
1152
1153    fn drop_without_shutdown(mut self) {
1154        // Safety: drops once, never accessed again due to mem::forget
1155        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1156        // Prevent Drop from running (which would shut down the channel)
1157        std::mem::forget(self);
1158    }
1159}
1160
1161impl ScenicCreateSessionTResponder {
1162    /// Sends a response to the FIDL transaction.
1163    ///
1164    /// Sets the channel to shutdown if an error occurs.
1165    pub fn send(self) -> Result<(), fidl::Error> {
1166        let _result = self.send_raw();
1167        if _result.is_err() {
1168            self.control_handle.shutdown();
1169        }
1170        self.drop_without_shutdown();
1171        _result
1172    }
1173
1174    /// Similar to "send" but does not shutdown the channel if an error occurs.
1175    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1176        let _result = self.send_raw();
1177        self.drop_without_shutdown();
1178        _result
1179    }
1180
1181    fn send_raw(&self) -> Result<(), fidl::Error> {
1182        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1183            (),
1184            self.tx_id,
1185            0x369061a897552d4f,
1186            fidl::encoding::DynamicFlags::empty(),
1187        )
1188    }
1189}
1190
1191#[must_use = "FIDL methods require a response to be sent"]
1192#[derive(Debug)]
1193pub struct ScenicGetDisplayInfoResponder {
1194    control_handle: std::mem::ManuallyDrop<ScenicControlHandle>,
1195    tx_id: u32,
1196}
1197
1198/// Set the the channel to be shutdown (see [`ScenicControlHandle::shutdown`])
1199/// if the responder is dropped without sending a response, so that the client
1200/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1201impl std::ops::Drop for ScenicGetDisplayInfoResponder {
1202    fn drop(&mut self) {
1203        self.control_handle.shutdown();
1204        // Safety: drops once, never accessed again
1205        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1206    }
1207}
1208
1209impl fidl::endpoints::Responder for ScenicGetDisplayInfoResponder {
1210    type ControlHandle = ScenicControlHandle;
1211
1212    fn control_handle(&self) -> &ScenicControlHandle {
1213        &self.control_handle
1214    }
1215
1216    fn drop_without_shutdown(mut self) {
1217        // Safety: drops once, never accessed again due to mem::forget
1218        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1219        // Prevent Drop from running (which would shut down the channel)
1220        std::mem::forget(self);
1221    }
1222}
1223
1224impl ScenicGetDisplayInfoResponder {
1225    /// Sends a response to the FIDL transaction.
1226    ///
1227    /// Sets the channel to shutdown if an error occurs.
1228    pub fn send(self, mut info: &fidl_fuchsia_ui_gfx::DisplayInfo) -> Result<(), fidl::Error> {
1229        let _result = self.send_raw(info);
1230        if _result.is_err() {
1231            self.control_handle.shutdown();
1232        }
1233        self.drop_without_shutdown();
1234        _result
1235    }
1236
1237    /// Similar to "send" but does not shutdown the channel if an error occurs.
1238    pub fn send_no_shutdown_on_err(
1239        self,
1240        mut info: &fidl_fuchsia_ui_gfx::DisplayInfo,
1241    ) -> Result<(), fidl::Error> {
1242        let _result = self.send_raw(info);
1243        self.drop_without_shutdown();
1244        _result
1245    }
1246
1247    fn send_raw(&self, mut info: &fidl_fuchsia_ui_gfx::DisplayInfo) -> Result<(), fidl::Error> {
1248        self.control_handle.inner.send::<ScenicGetDisplayInfoResponse>(
1249            (info,),
1250            self.tx_id,
1251            0x3e4cdecbf7cc1797,
1252            fidl::encoding::DynamicFlags::empty(),
1253        )
1254    }
1255}
1256
1257#[must_use = "FIDL methods require a response to be sent"]
1258#[derive(Debug)]
1259pub struct ScenicGetDisplayOwnershipEventResponder {
1260    control_handle: std::mem::ManuallyDrop<ScenicControlHandle>,
1261    tx_id: u32,
1262}
1263
1264/// Set the the channel to be shutdown (see [`ScenicControlHandle::shutdown`])
1265/// if the responder is dropped without sending a response, so that the client
1266/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1267impl std::ops::Drop for ScenicGetDisplayOwnershipEventResponder {
1268    fn drop(&mut self) {
1269        self.control_handle.shutdown();
1270        // Safety: drops once, never accessed again
1271        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1272    }
1273}
1274
1275impl fidl::endpoints::Responder for ScenicGetDisplayOwnershipEventResponder {
1276    type ControlHandle = ScenicControlHandle;
1277
1278    fn control_handle(&self) -> &ScenicControlHandle {
1279        &self.control_handle
1280    }
1281
1282    fn drop_without_shutdown(mut self) {
1283        // Safety: drops once, never accessed again due to mem::forget
1284        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1285        // Prevent Drop from running (which would shut down the channel)
1286        std::mem::forget(self);
1287    }
1288}
1289
1290impl ScenicGetDisplayOwnershipEventResponder {
1291    /// Sends a response to the FIDL transaction.
1292    ///
1293    /// Sets the channel to shutdown if an error occurs.
1294    pub fn send(self, mut ownership_event: fidl::Event) -> Result<(), fidl::Error> {
1295        let _result = self.send_raw(ownership_event);
1296        if _result.is_err() {
1297            self.control_handle.shutdown();
1298        }
1299        self.drop_without_shutdown();
1300        _result
1301    }
1302
1303    /// Similar to "send" but does not shutdown the channel if an error occurs.
1304    pub fn send_no_shutdown_on_err(
1305        self,
1306        mut ownership_event: fidl::Event,
1307    ) -> Result<(), fidl::Error> {
1308        let _result = self.send_raw(ownership_event);
1309        self.drop_without_shutdown();
1310        _result
1311    }
1312
1313    fn send_raw(&self, mut ownership_event: fidl::Event) -> Result<(), fidl::Error> {
1314        self.control_handle.inner.send::<ScenicGetDisplayOwnershipEventResponse>(
1315            (ownership_event,),
1316            self.tx_id,
1317            0x54c114c7322b24d6,
1318            fidl::encoding::DynamicFlags::empty(),
1319        )
1320    }
1321}
1322
1323#[must_use = "FIDL methods require a response to be sent"]
1324#[derive(Debug)]
1325pub struct ScenicTakeScreenshotResponder {
1326    control_handle: std::mem::ManuallyDrop<ScenicControlHandle>,
1327    tx_id: u32,
1328}
1329
1330/// Set the the channel to be shutdown (see [`ScenicControlHandle::shutdown`])
1331/// if the responder is dropped without sending a response, so that the client
1332/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1333impl std::ops::Drop for ScenicTakeScreenshotResponder {
1334    fn drop(&mut self) {
1335        self.control_handle.shutdown();
1336        // Safety: drops once, never accessed again
1337        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1338    }
1339}
1340
1341impl fidl::endpoints::Responder for ScenicTakeScreenshotResponder {
1342    type ControlHandle = ScenicControlHandle;
1343
1344    fn control_handle(&self) -> &ScenicControlHandle {
1345        &self.control_handle
1346    }
1347
1348    fn drop_without_shutdown(mut self) {
1349        // Safety: drops once, never accessed again due to mem::forget
1350        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1351        // Prevent Drop from running (which would shut down the channel)
1352        std::mem::forget(self);
1353    }
1354}
1355
1356impl ScenicTakeScreenshotResponder {
1357    /// Sends a response to the FIDL transaction.
1358    ///
1359    /// Sets the channel to shutdown if an error occurs.
1360    pub fn send(self, mut img_data: ScreenshotData, mut success: bool) -> Result<(), fidl::Error> {
1361        let _result = self.send_raw(img_data, success);
1362        if _result.is_err() {
1363            self.control_handle.shutdown();
1364        }
1365        self.drop_without_shutdown();
1366        _result
1367    }
1368
1369    /// Similar to "send" but does not shutdown the channel if an error occurs.
1370    pub fn send_no_shutdown_on_err(
1371        self,
1372        mut img_data: ScreenshotData,
1373        mut success: bool,
1374    ) -> Result<(), fidl::Error> {
1375        let _result = self.send_raw(img_data, success);
1376        self.drop_without_shutdown();
1377        _result
1378    }
1379
1380    fn send_raw(&self, mut img_data: ScreenshotData, mut success: bool) -> Result<(), fidl::Error> {
1381        self.control_handle.inner.send::<ScenicTakeScreenshotResponse>(
1382            (&mut img_data, success),
1383            self.tx_id,
1384            0x53f5e06463987df2,
1385            fidl::encoding::DynamicFlags::empty(),
1386        )
1387    }
1388}
1389
1390#[must_use = "FIDL methods require a response to be sent"]
1391#[derive(Debug)]
1392pub struct ScenicUsesFlatlandResponder {
1393    control_handle: std::mem::ManuallyDrop<ScenicControlHandle>,
1394    tx_id: u32,
1395}
1396
1397/// Set the the channel to be shutdown (see [`ScenicControlHandle::shutdown`])
1398/// if the responder is dropped without sending a response, so that the client
1399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1400impl std::ops::Drop for ScenicUsesFlatlandResponder {
1401    fn drop(&mut self) {
1402        self.control_handle.shutdown();
1403        // Safety: drops once, never accessed again
1404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405    }
1406}
1407
1408impl fidl::endpoints::Responder for ScenicUsesFlatlandResponder {
1409    type ControlHandle = ScenicControlHandle;
1410
1411    fn control_handle(&self) -> &ScenicControlHandle {
1412        &self.control_handle
1413    }
1414
1415    fn drop_without_shutdown(mut self) {
1416        // Safety: drops once, never accessed again due to mem::forget
1417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1418        // Prevent Drop from running (which would shut down the channel)
1419        std::mem::forget(self);
1420    }
1421}
1422
1423impl ScenicUsesFlatlandResponder {
1424    /// Sends a response to the FIDL transaction.
1425    ///
1426    /// Sets the channel to shutdown if an error occurs.
1427    pub fn send(self, mut flatland_enabled: bool) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw(flatland_enabled);
1429        if _result.is_err() {
1430            self.control_handle.shutdown();
1431        }
1432        self.drop_without_shutdown();
1433        _result
1434    }
1435
1436    /// Similar to "send" but does not shutdown the channel if an error occurs.
1437    pub fn send_no_shutdown_on_err(self, mut flatland_enabled: bool) -> Result<(), fidl::Error> {
1438        let _result = self.send_raw(flatland_enabled);
1439        self.drop_without_shutdown();
1440        _result
1441    }
1442
1443    fn send_raw(&self, mut flatland_enabled: bool) -> Result<(), fidl::Error> {
1444        self.control_handle.inner.send::<ScenicUsesFlatlandResponse>(
1445            (flatland_enabled,),
1446            self.tx_id,
1447            0x5f2e5e19463ae706,
1448            fidl::encoding::DynamicFlags::empty(),
1449        )
1450    }
1451}
1452
1453#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1454pub struct SessionMarker;
1455
1456impl fidl::endpoints::ProtocolMarker for SessionMarker {
1457    type Proxy = SessionProxy;
1458    type RequestStream = SessionRequestStream;
1459    #[cfg(target_os = "fuchsia")]
1460    type SynchronousProxy = SessionSynchronousProxy;
1461
1462    const DEBUG_NAME: &'static str = "(anonymous) Session";
1463}
1464
1465pub trait SessionProxyInterface: Send + Sync {
1466    fn r#enqueue(&self, cmds: Vec<Command>) -> Result<(), fidl::Error>;
1467    type PresentResponseFut: std::future::Future<Output = Result<fidl_fuchsia_images::PresentationInfo, fidl::Error>>
1468        + Send;
1469    fn r#present(
1470        &self,
1471        presentation_time: u64,
1472        acquire_fences: Vec<fidl::Event>,
1473        release_fences: Vec<fidl::Event>,
1474    ) -> Self::PresentResponseFut;
1475    type Present2ResponseFut: std::future::Future<
1476            Output = Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error>,
1477        > + Send;
1478    fn r#present2(&self, args: Present2Args) -> Self::Present2ResponseFut;
1479    type RequestPresentationTimesResponseFut: std::future::Future<
1480            Output = Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error>,
1481        > + Send;
1482    fn r#request_presentation_times(
1483        &self,
1484        requested_prediction_span: i64,
1485    ) -> Self::RequestPresentationTimesResponseFut;
1486    fn r#register_buffer_collection(
1487        &self,
1488        buffer_id: u32,
1489        token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
1490    ) -> Result<(), fidl::Error>;
1491    fn r#deregister_buffer_collection(&self, buffer_id: u32) -> Result<(), fidl::Error>;
1492    fn r#set_debug_name(&self, debug_name: &str) -> Result<(), fidl::Error>;
1493}
1494#[derive(Debug)]
1495#[cfg(target_os = "fuchsia")]
1496pub struct SessionSynchronousProxy {
1497    client: fidl::client::sync::Client,
1498}
1499
1500#[cfg(target_os = "fuchsia")]
1501impl fidl::endpoints::SynchronousProxy for SessionSynchronousProxy {
1502    type Proxy = SessionProxy;
1503    type Protocol = SessionMarker;
1504
1505    fn from_channel(inner: fidl::Channel) -> Self {
1506        Self::new(inner)
1507    }
1508
1509    fn into_channel(self) -> fidl::Channel {
1510        self.client.into_channel()
1511    }
1512
1513    fn as_channel(&self) -> &fidl::Channel {
1514        self.client.as_channel()
1515    }
1516}
1517
1518#[cfg(target_os = "fuchsia")]
1519impl SessionSynchronousProxy {
1520    pub fn new(channel: fidl::Channel) -> Self {
1521        let protocol_name = <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1522        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1523    }
1524
1525    pub fn into_channel(self) -> fidl::Channel {
1526        self.client.into_channel()
1527    }
1528
1529    /// Waits until an event arrives and returns it. It is safe for other
1530    /// threads to make concurrent requests while waiting for an event.
1531    pub fn wait_for_event(
1532        &self,
1533        deadline: zx::MonotonicInstant,
1534    ) -> Result<SessionEvent, fidl::Error> {
1535        SessionEvent::decode(self.client.wait_for_event(deadline)?)
1536    }
1537
1538    pub fn r#enqueue(&self, mut cmds: Vec<Command>) -> Result<(), fidl::Error> {
1539        self.client.send::<SessionEnqueueRequest>(
1540            (cmds.as_mut(),),
1541            0x61e1e8b2cb6b0852,
1542            fidl::encoding::DynamicFlags::empty(),
1543        )
1544    }
1545
1546    /// Present all previously enqueued operations.  In order to pipeline the
1547    /// preparation of the resources required to render the scene, two lists of
1548    /// fences (implemented as events) are passed.
1549    ///
1550    /// SCHEDULING PRESENTATION
1551    ///
1552    /// `presentation_time` specifies the time on or after which the
1553    /// client would like the enqueued operations should take visible effect
1554    /// (light up pixels on the screen), expressed in nanoseconds in the
1555    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
1556    /// monotonically non-decreasing.
1557    ///
1558    /// Using a desired presentation time in the present or past (such as 0)
1559    /// schedules enqueued operations to take visible effect as soon as possible
1560    /// (during the next frame to be prepared).
1561    ///
1562    /// Using a desired presentation time in the future schedules the enqueued
1563    /// operations to take visible effect as closely as possible to or after
1564    /// the stated time (but no earlier).
1565    ///
1566    /// Each rendered frame has a target presentation time.  Before rendering
1567    /// a frame, the scene manager applies all enqueued operations associated
1568    /// with all prior calls to `Present()` whose desired presentation time
1569    /// is on or before the frame's target presentation time.
1570    ///
1571    /// The `Present()` method does not return until the scene manager begins
1572    /// preparing the first frame which includes its presented content.
1573    /// Upon return, the `PresentationInfo` provides timing information for the
1574    /// frame which includes the presented content.
1575    ///
1576    /// To present new content on each successive frame, wait for `Present()`
1577    /// to return before calling `Present()` again with content for the next
1578    /// frame.
1579    ///
1580    /// It is also possible to enqueue and present successive frames of content
1581    /// all at once with increasing desired presentation times, incrementing by
1582    /// `PresentationInfo.presentation_interval` for each one.
1583    ///
1584    /// Animation updates are also coordinated in terms of presentation time.
1585    ///
1586    /// SYNCHRONIZATION
1587    ///
1588    /// `acquire_fences` are used by Scenic to wait until all of the session's
1589    /// resources are ready to render (or to allow downstream components, such as
1590    /// the Vulkan driver, to wait for these resources).
1591    ///
1592    /// For example, Fuchsia's Vulkan driver allows an zx::event to be obtained
1593    /// from a VkSemaphore.  This allows a Scenic client to submit a Vulkan command
1594    /// buffer to generate images/meshes/etc., and instructing Vulkan to signal a
1595    /// VkSemaphore when it is done.  By inserting the zx::event corresponding to
1596    /// this semaphore into `acquire_fences`, the client allows Scenic to submit work
1597    /// to the Vulkan driver without waiting on the CPU for the event to be
1598    /// signalled.
1599    ///
1600    /// `release_fences` is a list of events that will be signalled by Scenic when
1601    /// the updated session state has been fully committed: future frames will be
1602    /// rendered using this state, and all frames generated using previous session
1603    /// states have been fully-rendered and presented to the display.
1604    ///
1605    /// Together, `acquire_fences` and `release_fences` are intended to allow clients
1606    /// to implement strategies such as double-buffering.  For example, a client
1607    /// might do the following in the Scenic subsystem:
1608    ///   1) create two Image with resource IDs #1 and #2.
1609    ///   2) create two Materials with resource IDs #3 and #4, which respectively
1610    ///      use Images #1 and #2 as their texture.
1611    ///   3) create a tree of Nodes and attach them to the scene.
1612    ///   4) set one of the nodes above, say #5, to use Material #3.
1613    ///   5) submit a Vulkan command-buffer which renders into Image #1, and
1614    ///      will signal a VkSemaphore.
1615    ///   6) call Present() with one acquire-fence (obtained from the VkSemaphore
1616    ///      above) and one newly-created release-fence.
1617    ///
1618    /// After the steps above, Scenic will use the committed session state to render
1619    /// frames whenever necessary.  When the client wants to display something
1620    /// different than Image #1, it would do something similar to steps 4) to 6):
1621    ///   7) set Node #5 to use Material #4.
1622    ///   8) submit a Vulkan command-buffer which renders into Image #1, and
1623    ///      will signal a VkSemaphore.
1624    ///   9) call Present() with one acquire-fence (obtained from the VkSemaphore
1625    ///      above) and one newly-created release-fence.
1626    ///
1627    /// Finally, to continually draw new content, the client could repeat steps
1628    /// 4) to 9), with one important difference: step 5) must wait on the event
1629    /// signalled by step 9).  Otherwise, it might render into Image #1 while that
1630    /// image is still being used by Scenic to render a frame.  Similarly, step 8)
1631    /// must wait on the event signalled by step 6).
1632    ///
1633    /// The scenario described above uses one acquire-fence and one release-fence,
1634    /// but it is easy to imagine cases that require more.  For example, in addition
1635    /// to using Vulkan to render into Images #1 and #2, the client might also
1636    /// upload other resources to Vulkan on a different VkQueue, which would
1637    /// would signal a separate semaphore, and therefore require an additional
1638    /// acquire-fence.
1639    ///
1640    /// Note: `acquire_fences` and `release_fences` are only necessary to synchronize
1641    /// access to memory (and other external resources).  Any modification to
1642    /// resources made via the Session API are automatically synchronized.
1643    pub fn r#present(
1644        &self,
1645        mut presentation_time: u64,
1646        mut acquire_fences: Vec<fidl::Event>,
1647        mut release_fences: Vec<fidl::Event>,
1648        ___deadline: zx::MonotonicInstant,
1649    ) -> Result<fidl_fuchsia_images::PresentationInfo, fidl::Error> {
1650        let _response = self.client.send_query::<SessionPresentRequest, SessionPresentResponse>(
1651            (presentation_time, acquire_fences.as_mut(), release_fences.as_mut()),
1652            0x36967062cdd2c37e,
1653            fidl::encoding::DynamicFlags::empty(),
1654            ___deadline,
1655        )?;
1656        Ok(_response.presentation_info)
1657    }
1658
1659    /// Present all previously enqueued operations. In order to pipeline the
1660    /// preparation of the resources required to render the scene, two lists of
1661    /// fences, implemented as events, are passed.
1662    ///
1663    /// When a client calls Present2, they receive an immediate callback
1664    /// consisting of the same information they would get as if they had called
1665    /// `RequestPresentationTimes` with the equivalent
1666    /// `requested_prediction_span`. See its documentation below for more
1667    /// information, as Present2's functionality is a superset of it.
1668    ///
1669    /// Then, when the commands flushed by Present2 make it to display, an
1670    /// `OnFramePresented` event is fired. This event includes information
1671    /// pertaining to all Present2s that had content that were part of that
1672    /// frame.
1673    ///
1674    /// Clients may only use one of Present/Present2 per Session.
1675    /// Switching between both is an error that will result in the Session being
1676    /// closed.
1677    ///
1678    /// See `Present2Args` documentation above for more detailed information on
1679    /// what arguments are passed in and their role.
1680    pub fn r#present2(
1681        &self,
1682        mut args: Present2Args,
1683        ___deadline: zx::MonotonicInstant,
1684    ) -> Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error> {
1685        let _response = self.client.send_query::<SessionPresent2Request, SessionPresent2Response>(
1686            (&mut args,),
1687            0x5d307d6198d76a65,
1688            fidl::encoding::DynamicFlags::empty(),
1689            ___deadline,
1690        )?;
1691        Ok(_response.request_presentation_times_info)
1692    }
1693
1694    /// Returns information about future presentation times, and their
1695    /// respective latch points. Clients can use the returned information to
1696    /// make informed scheduling decisions: if a client wants their frame to be
1697    /// displayed at a given `presentation_time`, they should aim to have all
1698    /// `acquire_fences` fired before the associated `latch_point`.
1699    ///
1700    /// Scenic will attempt to return predictions that span a duration equal to
1701    /// `requested_prediction_span`, up to a limit.
1702    ///
1703    /// A value of 0 is guaranteed to give at least one future presentation info.
1704    pub fn r#request_presentation_times(
1705        &self,
1706        mut requested_prediction_span: i64,
1707        ___deadline: zx::MonotonicInstant,
1708    ) -> Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error> {
1709        let _response = self.client.send_query::<
1710            SessionRequestPresentationTimesRequest,
1711            SessionRequestPresentationTimesResponse,
1712        >(
1713            (requested_prediction_span,),
1714            0x14a087997bf83904,
1715            fidl::encoding::DynamicFlags::empty(),
1716            ___deadline,
1717        )?;
1718        Ok(_response.request_presentation_times_info)
1719    }
1720
1721    /// Registers BufferCollection referenced by the `token` and sets contraints on it.
1722    /// It does not block on the buffers being allocated until content backed by one of the
1723    /// collection's VMOs is created, e.g. an Image2.
1724    ///
1725    /// A value of 0 for the `buffer_id` is invalid. All other values are valid as long as they
1726    /// are not currently in use.
1727    pub fn r#register_buffer_collection(
1728        &self,
1729        mut buffer_id: u32,
1730        mut token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
1731    ) -> Result<(), fidl::Error> {
1732        self.client.send::<SessionRegisterBufferCollectionRequest>(
1733            (buffer_id, token),
1734            0x141b0d5768c5ecf8,
1735            fidl::encoding::DynamicFlags::empty(),
1736        )
1737    }
1738
1739    /// Deregisters the BufferCollection previously registered with the `buffer_id` and sets it
1740    /// to be garbage collected as soon as it is no longer referenced by any resources.
1741    ///
1742    /// Only `buffer_id` that have been previously registered and not yet deregistered are valid.
1743    pub fn r#deregister_buffer_collection(&self, mut buffer_id: u32) -> Result<(), fidl::Error> {
1744        self.client.send::<SessionDeregisterBufferCollectionRequest>(
1745            (buffer_id,),
1746            0x34e6c5c26b6cdb1e,
1747            fidl::encoding::DynamicFlags::empty(),
1748        )
1749    }
1750
1751    /// Set an optional debug name for the session. The debug name will be
1752    /// output in things such as logging and trace events.
1753    pub fn r#set_debug_name(&self, mut debug_name: &str) -> Result<(), fidl::Error> {
1754        self.client.send::<SessionSetDebugNameRequest>(
1755            (debug_name,),
1756            0xdb157bf88f57b91,
1757            fidl::encoding::DynamicFlags::empty(),
1758        )
1759    }
1760}
1761
1762#[cfg(target_os = "fuchsia")]
1763impl From<SessionSynchronousProxy> for zx::Handle {
1764    fn from(value: SessionSynchronousProxy) -> Self {
1765        value.into_channel().into()
1766    }
1767}
1768
1769#[cfg(target_os = "fuchsia")]
1770impl From<fidl::Channel> for SessionSynchronousProxy {
1771    fn from(value: fidl::Channel) -> Self {
1772        Self::new(value)
1773    }
1774}
1775
1776#[derive(Debug, Clone)]
1777pub struct SessionProxy {
1778    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1779}
1780
1781impl fidl::endpoints::Proxy for SessionProxy {
1782    type Protocol = SessionMarker;
1783
1784    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1785        Self::new(inner)
1786    }
1787
1788    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1789        self.client.into_channel().map_err(|client| Self { client })
1790    }
1791
1792    fn as_channel(&self) -> &::fidl::AsyncChannel {
1793        self.client.as_channel()
1794    }
1795}
1796
1797impl SessionProxy {
1798    /// Create a new Proxy for fuchsia.ui.scenic/Session.
1799    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1800        let protocol_name = <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1801        Self { client: fidl::client::Client::new(channel, protocol_name) }
1802    }
1803
1804    /// Get a Stream of events from the remote end of the protocol.
1805    ///
1806    /// # Panics
1807    ///
1808    /// Panics if the event stream was already taken.
1809    pub fn take_event_stream(&self) -> SessionEventStream {
1810        SessionEventStream { event_receiver: self.client.take_event_receiver() }
1811    }
1812
1813    pub fn r#enqueue(&self, mut cmds: Vec<Command>) -> Result<(), fidl::Error> {
1814        SessionProxyInterface::r#enqueue(self, cmds)
1815    }
1816
1817    /// Present all previously enqueued operations.  In order to pipeline the
1818    /// preparation of the resources required to render the scene, two lists of
1819    /// fences (implemented as events) are passed.
1820    ///
1821    /// SCHEDULING PRESENTATION
1822    ///
1823    /// `presentation_time` specifies the time on or after which the
1824    /// client would like the enqueued operations should take visible effect
1825    /// (light up pixels on the screen), expressed in nanoseconds in the
1826    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
1827    /// monotonically non-decreasing.
1828    ///
1829    /// Using a desired presentation time in the present or past (such as 0)
1830    /// schedules enqueued operations to take visible effect as soon as possible
1831    /// (during the next frame to be prepared).
1832    ///
1833    /// Using a desired presentation time in the future schedules the enqueued
1834    /// operations to take visible effect as closely as possible to or after
1835    /// the stated time (but no earlier).
1836    ///
1837    /// Each rendered frame has a target presentation time.  Before rendering
1838    /// a frame, the scene manager applies all enqueued operations associated
1839    /// with all prior calls to `Present()` whose desired presentation time
1840    /// is on or before the frame's target presentation time.
1841    ///
1842    /// The `Present()` method does not return until the scene manager begins
1843    /// preparing the first frame which includes its presented content.
1844    /// Upon return, the `PresentationInfo` provides timing information for the
1845    /// frame which includes the presented content.
1846    ///
1847    /// To present new content on each successive frame, wait for `Present()`
1848    /// to return before calling `Present()` again with content for the next
1849    /// frame.
1850    ///
1851    /// It is also possible to enqueue and present successive frames of content
1852    /// all at once with increasing desired presentation times, incrementing by
1853    /// `PresentationInfo.presentation_interval` for each one.
1854    ///
1855    /// Animation updates are also coordinated in terms of presentation time.
1856    ///
1857    /// SYNCHRONIZATION
1858    ///
1859    /// `acquire_fences` are used by Scenic to wait until all of the session's
1860    /// resources are ready to render (or to allow downstream components, such as
1861    /// the Vulkan driver, to wait for these resources).
1862    ///
1863    /// For example, Fuchsia's Vulkan driver allows an zx::event to be obtained
1864    /// from a VkSemaphore.  This allows a Scenic client to submit a Vulkan command
1865    /// buffer to generate images/meshes/etc., and instructing Vulkan to signal a
1866    /// VkSemaphore when it is done.  By inserting the zx::event corresponding to
1867    /// this semaphore into `acquire_fences`, the client allows Scenic to submit work
1868    /// to the Vulkan driver without waiting on the CPU for the event to be
1869    /// signalled.
1870    ///
1871    /// `release_fences` is a list of events that will be signalled by Scenic when
1872    /// the updated session state has been fully committed: future frames will be
1873    /// rendered using this state, and all frames generated using previous session
1874    /// states have been fully-rendered and presented to the display.
1875    ///
1876    /// Together, `acquire_fences` and `release_fences` are intended to allow clients
1877    /// to implement strategies such as double-buffering.  For example, a client
1878    /// might do the following in the Scenic subsystem:
1879    ///   1) create two Image with resource IDs #1 and #2.
1880    ///   2) create two Materials with resource IDs #3 and #4, which respectively
1881    ///      use Images #1 and #2 as their texture.
1882    ///   3) create a tree of Nodes and attach them to the scene.
1883    ///   4) set one of the nodes above, say #5, to use Material #3.
1884    ///   5) submit a Vulkan command-buffer which renders into Image #1, and
1885    ///      will signal a VkSemaphore.
1886    ///   6) call Present() with one acquire-fence (obtained from the VkSemaphore
1887    ///      above) and one newly-created release-fence.
1888    ///
1889    /// After the steps above, Scenic will use the committed session state to render
1890    /// frames whenever necessary.  When the client wants to display something
1891    /// different than Image #1, it would do something similar to steps 4) to 6):
1892    ///   7) set Node #5 to use Material #4.
1893    ///   8) submit a Vulkan command-buffer which renders into Image #1, and
1894    ///      will signal a VkSemaphore.
1895    ///   9) call Present() with one acquire-fence (obtained from the VkSemaphore
1896    ///      above) and one newly-created release-fence.
1897    ///
1898    /// Finally, to continually draw new content, the client could repeat steps
1899    /// 4) to 9), with one important difference: step 5) must wait on the event
1900    /// signalled by step 9).  Otherwise, it might render into Image #1 while that
1901    /// image is still being used by Scenic to render a frame.  Similarly, step 8)
1902    /// must wait on the event signalled by step 6).
1903    ///
1904    /// The scenario described above uses one acquire-fence and one release-fence,
1905    /// but it is easy to imagine cases that require more.  For example, in addition
1906    /// to using Vulkan to render into Images #1 and #2, the client might also
1907    /// upload other resources to Vulkan on a different VkQueue, which would
1908    /// would signal a separate semaphore, and therefore require an additional
1909    /// acquire-fence.
1910    ///
1911    /// Note: `acquire_fences` and `release_fences` are only necessary to synchronize
1912    /// access to memory (and other external resources).  Any modification to
1913    /// resources made via the Session API are automatically synchronized.
1914    pub fn r#present(
1915        &self,
1916        mut presentation_time: u64,
1917        mut acquire_fences: Vec<fidl::Event>,
1918        mut release_fences: Vec<fidl::Event>,
1919    ) -> fidl::client::QueryResponseFut<
1920        fidl_fuchsia_images::PresentationInfo,
1921        fidl::encoding::DefaultFuchsiaResourceDialect,
1922    > {
1923        SessionProxyInterface::r#present(self, presentation_time, acquire_fences, release_fences)
1924    }
1925
1926    /// Present all previously enqueued operations. In order to pipeline the
1927    /// preparation of the resources required to render the scene, two lists of
1928    /// fences, implemented as events, are passed.
1929    ///
1930    /// When a client calls Present2, they receive an immediate callback
1931    /// consisting of the same information they would get as if they had called
1932    /// `RequestPresentationTimes` with the equivalent
1933    /// `requested_prediction_span`. See its documentation below for more
1934    /// information, as Present2's functionality is a superset of it.
1935    ///
1936    /// Then, when the commands flushed by Present2 make it to display, an
1937    /// `OnFramePresented` event is fired. This event includes information
1938    /// pertaining to all Present2s that had content that were part of that
1939    /// frame.
1940    ///
1941    /// Clients may only use one of Present/Present2 per Session.
1942    /// Switching between both is an error that will result in the Session being
1943    /// closed.
1944    ///
1945    /// See `Present2Args` documentation above for more detailed information on
1946    /// what arguments are passed in and their role.
1947    pub fn r#present2(
1948        &self,
1949        mut args: Present2Args,
1950    ) -> fidl::client::QueryResponseFut<
1951        fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
1952        fidl::encoding::DefaultFuchsiaResourceDialect,
1953    > {
1954        SessionProxyInterface::r#present2(self, args)
1955    }
1956
1957    /// Returns information about future presentation times, and their
1958    /// respective latch points. Clients can use the returned information to
1959    /// make informed scheduling decisions: if a client wants their frame to be
1960    /// displayed at a given `presentation_time`, they should aim to have all
1961    /// `acquire_fences` fired before the associated `latch_point`.
1962    ///
1963    /// Scenic will attempt to return predictions that span a duration equal to
1964    /// `requested_prediction_span`, up to a limit.
1965    ///
1966    /// A value of 0 is guaranteed to give at least one future presentation info.
1967    pub fn r#request_presentation_times(
1968        &self,
1969        mut requested_prediction_span: i64,
1970    ) -> fidl::client::QueryResponseFut<
1971        fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
1972        fidl::encoding::DefaultFuchsiaResourceDialect,
1973    > {
1974        SessionProxyInterface::r#request_presentation_times(self, requested_prediction_span)
1975    }
1976
1977    /// Registers BufferCollection referenced by the `token` and sets contraints on it.
1978    /// It does not block on the buffers being allocated until content backed by one of the
1979    /// collection's VMOs is created, e.g. an Image2.
1980    ///
1981    /// A value of 0 for the `buffer_id` is invalid. All other values are valid as long as they
1982    /// are not currently in use.
1983    pub fn r#register_buffer_collection(
1984        &self,
1985        mut buffer_id: u32,
1986        mut token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
1987    ) -> Result<(), fidl::Error> {
1988        SessionProxyInterface::r#register_buffer_collection(self, buffer_id, token)
1989    }
1990
1991    /// Deregisters the BufferCollection previously registered with the `buffer_id` and sets it
1992    /// to be garbage collected as soon as it is no longer referenced by any resources.
1993    ///
1994    /// Only `buffer_id` that have been previously registered and not yet deregistered are valid.
1995    pub fn r#deregister_buffer_collection(&self, mut buffer_id: u32) -> Result<(), fidl::Error> {
1996        SessionProxyInterface::r#deregister_buffer_collection(self, buffer_id)
1997    }
1998
1999    /// Set an optional debug name for the session. The debug name will be
2000    /// output in things such as logging and trace events.
2001    pub fn r#set_debug_name(&self, mut debug_name: &str) -> Result<(), fidl::Error> {
2002        SessionProxyInterface::r#set_debug_name(self, debug_name)
2003    }
2004}
2005
2006impl SessionProxyInterface for SessionProxy {
2007    fn r#enqueue(&self, mut cmds: Vec<Command>) -> Result<(), fidl::Error> {
2008        self.client.send::<SessionEnqueueRequest>(
2009            (cmds.as_mut(),),
2010            0x61e1e8b2cb6b0852,
2011            fidl::encoding::DynamicFlags::empty(),
2012        )
2013    }
2014
2015    type PresentResponseFut = fidl::client::QueryResponseFut<
2016        fidl_fuchsia_images::PresentationInfo,
2017        fidl::encoding::DefaultFuchsiaResourceDialect,
2018    >;
2019    fn r#present(
2020        &self,
2021        mut presentation_time: u64,
2022        mut acquire_fences: Vec<fidl::Event>,
2023        mut release_fences: Vec<fidl::Event>,
2024    ) -> Self::PresentResponseFut {
2025        fn _decode(
2026            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2027        ) -> Result<fidl_fuchsia_images::PresentationInfo, fidl::Error> {
2028            let _response = fidl::client::decode_transaction_body::<
2029                SessionPresentResponse,
2030                fidl::encoding::DefaultFuchsiaResourceDialect,
2031                0x36967062cdd2c37e,
2032            >(_buf?)?;
2033            Ok(_response.presentation_info)
2034        }
2035        self.client
2036            .send_query_and_decode::<SessionPresentRequest, fidl_fuchsia_images::PresentationInfo>(
2037                (presentation_time, acquire_fences.as_mut(), release_fences.as_mut()),
2038                0x36967062cdd2c37e,
2039                fidl::encoding::DynamicFlags::empty(),
2040                _decode,
2041            )
2042    }
2043
2044    type Present2ResponseFut = fidl::client::QueryResponseFut<
2045        fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2046        fidl::encoding::DefaultFuchsiaResourceDialect,
2047    >;
2048    fn r#present2(&self, mut args: Present2Args) -> Self::Present2ResponseFut {
2049        fn _decode(
2050            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2051        ) -> Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error> {
2052            let _response = fidl::client::decode_transaction_body::<
2053                SessionPresent2Response,
2054                fidl::encoding::DefaultFuchsiaResourceDialect,
2055                0x5d307d6198d76a65,
2056            >(_buf?)?;
2057            Ok(_response.request_presentation_times_info)
2058        }
2059        self.client.send_query_and_decode::<
2060            SessionPresent2Request,
2061            fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2062        >(
2063            (&mut args,),
2064            0x5d307d6198d76a65,
2065            fidl::encoding::DynamicFlags::empty(),
2066            _decode,
2067        )
2068    }
2069
2070    type RequestPresentationTimesResponseFut = fidl::client::QueryResponseFut<
2071        fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2072        fidl::encoding::DefaultFuchsiaResourceDialect,
2073    >;
2074    fn r#request_presentation_times(
2075        &self,
2076        mut requested_prediction_span: i64,
2077    ) -> Self::RequestPresentationTimesResponseFut {
2078        fn _decode(
2079            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2080        ) -> Result<fidl_fuchsia_scenic_scheduling::FuturePresentationTimes, fidl::Error> {
2081            let _response = fidl::client::decode_transaction_body::<
2082                SessionRequestPresentationTimesResponse,
2083                fidl::encoding::DefaultFuchsiaResourceDialect,
2084                0x14a087997bf83904,
2085            >(_buf?)?;
2086            Ok(_response.request_presentation_times_info)
2087        }
2088        self.client.send_query_and_decode::<
2089            SessionRequestPresentationTimesRequest,
2090            fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2091        >(
2092            (requested_prediction_span,),
2093            0x14a087997bf83904,
2094            fidl::encoding::DynamicFlags::empty(),
2095            _decode,
2096        )
2097    }
2098
2099    fn r#register_buffer_collection(
2100        &self,
2101        mut buffer_id: u32,
2102        mut token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
2103    ) -> Result<(), fidl::Error> {
2104        self.client.send::<SessionRegisterBufferCollectionRequest>(
2105            (buffer_id, token),
2106            0x141b0d5768c5ecf8,
2107            fidl::encoding::DynamicFlags::empty(),
2108        )
2109    }
2110
2111    fn r#deregister_buffer_collection(&self, mut buffer_id: u32) -> Result<(), fidl::Error> {
2112        self.client.send::<SessionDeregisterBufferCollectionRequest>(
2113            (buffer_id,),
2114            0x34e6c5c26b6cdb1e,
2115            fidl::encoding::DynamicFlags::empty(),
2116        )
2117    }
2118
2119    fn r#set_debug_name(&self, mut debug_name: &str) -> Result<(), fidl::Error> {
2120        self.client.send::<SessionSetDebugNameRequest>(
2121            (debug_name,),
2122            0xdb157bf88f57b91,
2123            fidl::encoding::DynamicFlags::empty(),
2124        )
2125    }
2126}
2127
2128pub struct SessionEventStream {
2129    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2130}
2131
2132impl std::marker::Unpin for SessionEventStream {}
2133
2134impl futures::stream::FusedStream for SessionEventStream {
2135    fn is_terminated(&self) -> bool {
2136        self.event_receiver.is_terminated()
2137    }
2138}
2139
2140impl futures::Stream for SessionEventStream {
2141    type Item = Result<SessionEvent, fidl::Error>;
2142
2143    fn poll_next(
2144        mut self: std::pin::Pin<&mut Self>,
2145        cx: &mut std::task::Context<'_>,
2146    ) -> std::task::Poll<Option<Self::Item>> {
2147        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2148            &mut self.event_receiver,
2149            cx
2150        )?) {
2151            Some(buf) => std::task::Poll::Ready(Some(SessionEvent::decode(buf))),
2152            None => std::task::Poll::Ready(None),
2153        }
2154    }
2155}
2156
2157#[derive(Debug)]
2158pub enum SessionEvent {
2159    OnFramePresented { frame_presented_info: fidl_fuchsia_scenic_scheduling::FramePresentedInfo },
2160}
2161
2162impl SessionEvent {
2163    #[allow(irrefutable_let_patterns)]
2164    pub fn into_on_frame_presented(
2165        self,
2166    ) -> Option<fidl_fuchsia_scenic_scheduling::FramePresentedInfo> {
2167        if let SessionEvent::OnFramePresented { frame_presented_info } = self {
2168            Some((frame_presented_info))
2169        } else {
2170            None
2171        }
2172    }
2173
2174    /// Decodes a message buffer as a [`SessionEvent`].
2175    fn decode(
2176        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2177    ) -> Result<SessionEvent, fidl::Error> {
2178        let (bytes, _handles) = buf.split_mut();
2179        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2180        debug_assert_eq!(tx_header.tx_id, 0);
2181        match tx_header.ordinal {
2182            0x26e3bdd1559be16b => {
2183                let mut out = fidl::new_empty!(
2184                    SessionOnFramePresentedRequest,
2185                    fidl::encoding::DefaultFuchsiaResourceDialect
2186                );
2187                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionOnFramePresentedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
2188                Ok((SessionEvent::OnFramePresented {
2189                    frame_presented_info: out.frame_presented_info,
2190                }))
2191            }
2192            _ => Err(fidl::Error::UnknownOrdinal {
2193                ordinal: tx_header.ordinal,
2194                protocol_name: <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2195            }),
2196        }
2197    }
2198}
2199
2200/// A Stream of incoming requests for fuchsia.ui.scenic/Session.
2201pub struct SessionRequestStream {
2202    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2203    is_terminated: bool,
2204}
2205
2206impl std::marker::Unpin for SessionRequestStream {}
2207
2208impl futures::stream::FusedStream for SessionRequestStream {
2209    fn is_terminated(&self) -> bool {
2210        self.is_terminated
2211    }
2212}
2213
2214impl fidl::endpoints::RequestStream for SessionRequestStream {
2215    type Protocol = SessionMarker;
2216    type ControlHandle = SessionControlHandle;
2217
2218    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2219        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2220    }
2221
2222    fn control_handle(&self) -> Self::ControlHandle {
2223        SessionControlHandle { inner: self.inner.clone() }
2224    }
2225
2226    fn into_inner(
2227        self,
2228    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2229    {
2230        (self.inner, self.is_terminated)
2231    }
2232
2233    fn from_inner(
2234        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2235        is_terminated: bool,
2236    ) -> Self {
2237        Self { inner, is_terminated }
2238    }
2239}
2240
2241impl futures::Stream for SessionRequestStream {
2242    type Item = Result<SessionRequest, fidl::Error>;
2243
2244    fn poll_next(
2245        mut self: std::pin::Pin<&mut Self>,
2246        cx: &mut std::task::Context<'_>,
2247    ) -> std::task::Poll<Option<Self::Item>> {
2248        let this = &mut *self;
2249        if this.inner.check_shutdown(cx) {
2250            this.is_terminated = true;
2251            return std::task::Poll::Ready(None);
2252        }
2253        if this.is_terminated {
2254            panic!("polled SessionRequestStream after completion");
2255        }
2256        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2257            |bytes, handles| {
2258                match this.inner.channel().read_etc(cx, bytes, handles) {
2259                    std::task::Poll::Ready(Ok(())) => {}
2260                    std::task::Poll::Pending => return std::task::Poll::Pending,
2261                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2262                        this.is_terminated = true;
2263                        return std::task::Poll::Ready(None);
2264                    }
2265                    std::task::Poll::Ready(Err(e)) => {
2266                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2267                            e.into(),
2268                        ))))
2269                    }
2270                }
2271
2272                // A message has been received from the channel
2273                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2274
2275                std::task::Poll::Ready(Some(match header.ordinal {
2276                    0x61e1e8b2cb6b0852 => {
2277                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2278                        let mut req = fidl::new_empty!(
2279                            SessionEnqueueRequest,
2280                            fidl::encoding::DefaultFuchsiaResourceDialect
2281                        );
2282                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionEnqueueRequest>(&header, _body_bytes, handles, &mut req)?;
2283                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2284                        Ok(SessionRequest::Enqueue { cmds: req.cmds, control_handle })
2285                    }
2286                    0x36967062cdd2c37e => {
2287                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2288                        let mut req = fidl::new_empty!(
2289                            SessionPresentRequest,
2290                            fidl::encoding::DefaultFuchsiaResourceDialect
2291                        );
2292                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionPresentRequest>(&header, _body_bytes, handles, &mut req)?;
2293                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2294                        Ok(SessionRequest::Present {
2295                            presentation_time: req.presentation_time,
2296                            acquire_fences: req.acquire_fences,
2297                            release_fences: req.release_fences,
2298
2299                            responder: SessionPresentResponder {
2300                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2301                                tx_id: header.tx_id,
2302                            },
2303                        })
2304                    }
2305                    0x5d307d6198d76a65 => {
2306                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2307                        let mut req = fidl::new_empty!(
2308                            SessionPresent2Request,
2309                            fidl::encoding::DefaultFuchsiaResourceDialect
2310                        );
2311                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionPresent2Request>(&header, _body_bytes, handles, &mut req)?;
2312                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2313                        Ok(SessionRequest::Present2 {
2314                            args: req.args,
2315
2316                            responder: SessionPresent2Responder {
2317                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2318                                tx_id: header.tx_id,
2319                            },
2320                        })
2321                    }
2322                    0x14a087997bf83904 => {
2323                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2324                        let mut req = fidl::new_empty!(
2325                            SessionRequestPresentationTimesRequest,
2326                            fidl::encoding::DefaultFuchsiaResourceDialect
2327                        );
2328                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionRequestPresentationTimesRequest>(&header, _body_bytes, handles, &mut req)?;
2329                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2330                        Ok(SessionRequest::RequestPresentationTimes {
2331                            requested_prediction_span: req.requested_prediction_span,
2332
2333                            responder: SessionRequestPresentationTimesResponder {
2334                                control_handle: std::mem::ManuallyDrop::new(control_handle),
2335                                tx_id: header.tx_id,
2336                            },
2337                        })
2338                    }
2339                    0x141b0d5768c5ecf8 => {
2340                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2341                        let mut req = fidl::new_empty!(
2342                            SessionRegisterBufferCollectionRequest,
2343                            fidl::encoding::DefaultFuchsiaResourceDialect
2344                        );
2345                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionRegisterBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
2346                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2347                        Ok(SessionRequest::RegisterBufferCollection {
2348                            buffer_id: req.buffer_id,
2349                            token: req.token,
2350
2351                            control_handle,
2352                        })
2353                    }
2354                    0x34e6c5c26b6cdb1e => {
2355                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2356                        let mut req = fidl::new_empty!(
2357                            SessionDeregisterBufferCollectionRequest,
2358                            fidl::encoding::DefaultFuchsiaResourceDialect
2359                        );
2360                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionDeregisterBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
2361                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2362                        Ok(SessionRequest::DeregisterBufferCollection {
2363                            buffer_id: req.buffer_id,
2364
2365                            control_handle,
2366                        })
2367                    }
2368                    0xdb157bf88f57b91 => {
2369                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
2370                        let mut req = fidl::new_empty!(
2371                            SessionSetDebugNameRequest,
2372                            fidl::encoding::DefaultFuchsiaResourceDialect
2373                        );
2374                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionSetDebugNameRequest>(&header, _body_bytes, handles, &mut req)?;
2375                        let control_handle = SessionControlHandle { inner: this.inner.clone() };
2376                        Ok(SessionRequest::SetDebugName {
2377                            debug_name: req.debug_name,
2378
2379                            control_handle,
2380                        })
2381                    }
2382                    _ => Err(fidl::Error::UnknownOrdinal {
2383                        ordinal: header.ordinal,
2384                        protocol_name:
2385                            <SessionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2386                    }),
2387                }))
2388            },
2389        )
2390    }
2391}
2392
2393/// Client use Sessions to interact with a Scenic instance by enqueuing commands
2394/// that create or modify resources.
2395#[derive(Debug)]
2396pub enum SessionRequest {
2397    Enqueue {
2398        cmds: Vec<Command>,
2399        control_handle: SessionControlHandle,
2400    },
2401    /// Present all previously enqueued operations.  In order to pipeline the
2402    /// preparation of the resources required to render the scene, two lists of
2403    /// fences (implemented as events) are passed.
2404    ///
2405    /// SCHEDULING PRESENTATION
2406    ///
2407    /// `presentation_time` specifies the time on or after which the
2408    /// client would like the enqueued operations should take visible effect
2409    /// (light up pixels on the screen), expressed in nanoseconds in the
2410    /// `CLOCK_MONOTONIC` timebase.  Desired presentation times must be
2411    /// monotonically non-decreasing.
2412    ///
2413    /// Using a desired presentation time in the present or past (such as 0)
2414    /// schedules enqueued operations to take visible effect as soon as possible
2415    /// (during the next frame to be prepared).
2416    ///
2417    /// Using a desired presentation time in the future schedules the enqueued
2418    /// operations to take visible effect as closely as possible to or after
2419    /// the stated time (but no earlier).
2420    ///
2421    /// Each rendered frame has a target presentation time.  Before rendering
2422    /// a frame, the scene manager applies all enqueued operations associated
2423    /// with all prior calls to `Present()` whose desired presentation time
2424    /// is on or before the frame's target presentation time.
2425    ///
2426    /// The `Present()` method does not return until the scene manager begins
2427    /// preparing the first frame which includes its presented content.
2428    /// Upon return, the `PresentationInfo` provides timing information for the
2429    /// frame which includes the presented content.
2430    ///
2431    /// To present new content on each successive frame, wait for `Present()`
2432    /// to return before calling `Present()` again with content for the next
2433    /// frame.
2434    ///
2435    /// It is also possible to enqueue and present successive frames of content
2436    /// all at once with increasing desired presentation times, incrementing by
2437    /// `PresentationInfo.presentation_interval` for each one.
2438    ///
2439    /// Animation updates are also coordinated in terms of presentation time.
2440    ///
2441    /// SYNCHRONIZATION
2442    ///
2443    /// `acquire_fences` are used by Scenic to wait until all of the session's
2444    /// resources are ready to render (or to allow downstream components, such as
2445    /// the Vulkan driver, to wait for these resources).
2446    ///
2447    /// For example, Fuchsia's Vulkan driver allows an zx::event to be obtained
2448    /// from a VkSemaphore.  This allows a Scenic client to submit a Vulkan command
2449    /// buffer to generate images/meshes/etc., and instructing Vulkan to signal a
2450    /// VkSemaphore when it is done.  By inserting the zx::event corresponding to
2451    /// this semaphore into `acquire_fences`, the client allows Scenic to submit work
2452    /// to the Vulkan driver without waiting on the CPU for the event to be
2453    /// signalled.
2454    ///
2455    /// `release_fences` is a list of events that will be signalled by Scenic when
2456    /// the updated session state has been fully committed: future frames will be
2457    /// rendered using this state, and all frames generated using previous session
2458    /// states have been fully-rendered and presented to the display.
2459    ///
2460    /// Together, `acquire_fences` and `release_fences` are intended to allow clients
2461    /// to implement strategies such as double-buffering.  For example, a client
2462    /// might do the following in the Scenic subsystem:
2463    ///   1) create two Image with resource IDs #1 and #2.
2464    ///   2) create two Materials with resource IDs #3 and #4, which respectively
2465    ///      use Images #1 and #2 as their texture.
2466    ///   3) create a tree of Nodes and attach them to the scene.
2467    ///   4) set one of the nodes above, say #5, to use Material #3.
2468    ///   5) submit a Vulkan command-buffer which renders into Image #1, and
2469    ///      will signal a VkSemaphore.
2470    ///   6) call Present() with one acquire-fence (obtained from the VkSemaphore
2471    ///      above) and one newly-created release-fence.
2472    ///
2473    /// After the steps above, Scenic will use the committed session state to render
2474    /// frames whenever necessary.  When the client wants to display something
2475    /// different than Image #1, it would do something similar to steps 4) to 6):
2476    ///   7) set Node #5 to use Material #4.
2477    ///   8) submit a Vulkan command-buffer which renders into Image #1, and
2478    ///      will signal a VkSemaphore.
2479    ///   9) call Present() with one acquire-fence (obtained from the VkSemaphore
2480    ///      above) and one newly-created release-fence.
2481    ///
2482    /// Finally, to continually draw new content, the client could repeat steps
2483    /// 4) to 9), with one important difference: step 5) must wait on the event
2484    /// signalled by step 9).  Otherwise, it might render into Image #1 while that
2485    /// image is still being used by Scenic to render a frame.  Similarly, step 8)
2486    /// must wait on the event signalled by step 6).
2487    ///
2488    /// The scenario described above uses one acquire-fence and one release-fence,
2489    /// but it is easy to imagine cases that require more.  For example, in addition
2490    /// to using Vulkan to render into Images #1 and #2, the client might also
2491    /// upload other resources to Vulkan on a different VkQueue, which would
2492    /// would signal a separate semaphore, and therefore require an additional
2493    /// acquire-fence.
2494    ///
2495    /// Note: `acquire_fences` and `release_fences` are only necessary to synchronize
2496    /// access to memory (and other external resources).  Any modification to
2497    /// resources made via the Session API are automatically synchronized.
2498    Present {
2499        presentation_time: u64,
2500        acquire_fences: Vec<fidl::Event>,
2501        release_fences: Vec<fidl::Event>,
2502        responder: SessionPresentResponder,
2503    },
2504    /// Present all previously enqueued operations. In order to pipeline the
2505    /// preparation of the resources required to render the scene, two lists of
2506    /// fences, implemented as events, are passed.
2507    ///
2508    /// When a client calls Present2, they receive an immediate callback
2509    /// consisting of the same information they would get as if they had called
2510    /// `RequestPresentationTimes` with the equivalent
2511    /// `requested_prediction_span`. See its documentation below for more
2512    /// information, as Present2's functionality is a superset of it.
2513    ///
2514    /// Then, when the commands flushed by Present2 make it to display, an
2515    /// `OnFramePresented` event is fired. This event includes information
2516    /// pertaining to all Present2s that had content that were part of that
2517    /// frame.
2518    ///
2519    /// Clients may only use one of Present/Present2 per Session.
2520    /// Switching between both is an error that will result in the Session being
2521    /// closed.
2522    ///
2523    /// See `Present2Args` documentation above for more detailed information on
2524    /// what arguments are passed in and their role.
2525    Present2 {
2526        args: Present2Args,
2527        responder: SessionPresent2Responder,
2528    },
2529    /// Returns information about future presentation times, and their
2530    /// respective latch points. Clients can use the returned information to
2531    /// make informed scheduling decisions: if a client wants their frame to be
2532    /// displayed at a given `presentation_time`, they should aim to have all
2533    /// `acquire_fences` fired before the associated `latch_point`.
2534    ///
2535    /// Scenic will attempt to return predictions that span a duration equal to
2536    /// `requested_prediction_span`, up to a limit.
2537    ///
2538    /// A value of 0 is guaranteed to give at least one future presentation info.
2539    RequestPresentationTimes {
2540        requested_prediction_span: i64,
2541        responder: SessionRequestPresentationTimesResponder,
2542    },
2543    /// Registers BufferCollection referenced by the `token` and sets contraints on it.
2544    /// It does not block on the buffers being allocated until content backed by one of the
2545    /// collection's VMOs is created, e.g. an Image2.
2546    ///
2547    /// A value of 0 for the `buffer_id` is invalid. All other values are valid as long as they
2548    /// are not currently in use.
2549    RegisterBufferCollection {
2550        buffer_id: u32,
2551        token: fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
2552        control_handle: SessionControlHandle,
2553    },
2554    /// Deregisters the BufferCollection previously registered with the `buffer_id` and sets it
2555    /// to be garbage collected as soon as it is no longer referenced by any resources.
2556    ///
2557    /// Only `buffer_id` that have been previously registered and not yet deregistered are valid.
2558    DeregisterBufferCollection {
2559        buffer_id: u32,
2560        control_handle: SessionControlHandle,
2561    },
2562    /// Set an optional debug name for the session. The debug name will be
2563    /// output in things such as logging and trace events.
2564    SetDebugName {
2565        debug_name: String,
2566        control_handle: SessionControlHandle,
2567    },
2568}
2569
2570impl SessionRequest {
2571    #[allow(irrefutable_let_patterns)]
2572    pub fn into_enqueue(self) -> Option<(Vec<Command>, SessionControlHandle)> {
2573        if let SessionRequest::Enqueue { cmds, control_handle } = self {
2574            Some((cmds, control_handle))
2575        } else {
2576            None
2577        }
2578    }
2579
2580    #[allow(irrefutable_let_patterns)]
2581    pub fn into_present(
2582        self,
2583    ) -> Option<(u64, Vec<fidl::Event>, Vec<fidl::Event>, SessionPresentResponder)> {
2584        if let SessionRequest::Present {
2585            presentation_time,
2586            acquire_fences,
2587            release_fences,
2588            responder,
2589        } = self
2590        {
2591            Some((presentation_time, acquire_fences, release_fences, responder))
2592        } else {
2593            None
2594        }
2595    }
2596
2597    #[allow(irrefutable_let_patterns)]
2598    pub fn into_present2(self) -> Option<(Present2Args, SessionPresent2Responder)> {
2599        if let SessionRequest::Present2 { args, responder } = self {
2600            Some((args, responder))
2601        } else {
2602            None
2603        }
2604    }
2605
2606    #[allow(irrefutable_let_patterns)]
2607    pub fn into_request_presentation_times(
2608        self,
2609    ) -> Option<(i64, SessionRequestPresentationTimesResponder)> {
2610        if let SessionRequest::RequestPresentationTimes { requested_prediction_span, responder } =
2611            self
2612        {
2613            Some((requested_prediction_span, responder))
2614        } else {
2615            None
2616        }
2617    }
2618
2619    #[allow(irrefutable_let_patterns)]
2620    pub fn into_register_buffer_collection(
2621        self,
2622    ) -> Option<(
2623        u32,
2624        fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
2625        SessionControlHandle,
2626    )> {
2627        if let SessionRequest::RegisterBufferCollection { buffer_id, token, control_handle } = self
2628        {
2629            Some((buffer_id, token, control_handle))
2630        } else {
2631            None
2632        }
2633    }
2634
2635    #[allow(irrefutable_let_patterns)]
2636    pub fn into_deregister_buffer_collection(self) -> Option<(u32, SessionControlHandle)> {
2637        if let SessionRequest::DeregisterBufferCollection { buffer_id, control_handle } = self {
2638            Some((buffer_id, control_handle))
2639        } else {
2640            None
2641        }
2642    }
2643
2644    #[allow(irrefutable_let_patterns)]
2645    pub fn into_set_debug_name(self) -> Option<(String, SessionControlHandle)> {
2646        if let SessionRequest::SetDebugName { debug_name, control_handle } = self {
2647            Some((debug_name, control_handle))
2648        } else {
2649            None
2650        }
2651    }
2652
2653    /// Name of the method defined in FIDL
2654    pub fn method_name(&self) -> &'static str {
2655        match *self {
2656            SessionRequest::Enqueue { .. } => "enqueue",
2657            SessionRequest::Present { .. } => "present",
2658            SessionRequest::Present2 { .. } => "present2",
2659            SessionRequest::RequestPresentationTimes { .. } => "request_presentation_times",
2660            SessionRequest::RegisterBufferCollection { .. } => "register_buffer_collection",
2661            SessionRequest::DeregisterBufferCollection { .. } => "deregister_buffer_collection",
2662            SessionRequest::SetDebugName { .. } => "set_debug_name",
2663        }
2664    }
2665}
2666
2667#[derive(Debug, Clone)]
2668pub struct SessionControlHandle {
2669    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2670}
2671
2672impl fidl::endpoints::ControlHandle for SessionControlHandle {
2673    fn shutdown(&self) {
2674        self.inner.shutdown()
2675    }
2676    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2677        self.inner.shutdown_with_epitaph(status)
2678    }
2679
2680    fn is_closed(&self) -> bool {
2681        self.inner.channel().is_closed()
2682    }
2683    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2684        self.inner.channel().on_closed()
2685    }
2686
2687    #[cfg(target_os = "fuchsia")]
2688    fn signal_peer(
2689        &self,
2690        clear_mask: zx::Signals,
2691        set_mask: zx::Signals,
2692    ) -> Result<(), zx_status::Status> {
2693        use fidl::Peered;
2694        self.inner.channel().signal_peer(clear_mask, set_mask)
2695    }
2696}
2697
2698impl SessionControlHandle {
2699    pub fn send_on_frame_presented(
2700        &self,
2701        mut frame_presented_info: &fidl_fuchsia_scenic_scheduling::FramePresentedInfo,
2702    ) -> Result<(), fidl::Error> {
2703        self.inner.send::<SessionOnFramePresentedRequest>(
2704            (frame_presented_info,),
2705            0,
2706            0x26e3bdd1559be16b,
2707            fidl::encoding::DynamicFlags::empty(),
2708        )
2709    }
2710}
2711
2712#[must_use = "FIDL methods require a response to be sent"]
2713#[derive(Debug)]
2714pub struct SessionPresentResponder {
2715    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
2716    tx_id: u32,
2717}
2718
2719/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
2720/// if the responder is dropped without sending a response, so that the client
2721/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2722impl std::ops::Drop for SessionPresentResponder {
2723    fn drop(&mut self) {
2724        self.control_handle.shutdown();
2725        // Safety: drops once, never accessed again
2726        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2727    }
2728}
2729
2730impl fidl::endpoints::Responder for SessionPresentResponder {
2731    type ControlHandle = SessionControlHandle;
2732
2733    fn control_handle(&self) -> &SessionControlHandle {
2734        &self.control_handle
2735    }
2736
2737    fn drop_without_shutdown(mut self) {
2738        // Safety: drops once, never accessed again due to mem::forget
2739        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2740        // Prevent Drop from running (which would shut down the channel)
2741        std::mem::forget(self);
2742    }
2743}
2744
2745impl SessionPresentResponder {
2746    /// Sends a response to the FIDL transaction.
2747    ///
2748    /// Sets the channel to shutdown if an error occurs.
2749    pub fn send(
2750        self,
2751        mut presentation_info: &fidl_fuchsia_images::PresentationInfo,
2752    ) -> Result<(), fidl::Error> {
2753        let _result = self.send_raw(presentation_info);
2754        if _result.is_err() {
2755            self.control_handle.shutdown();
2756        }
2757        self.drop_without_shutdown();
2758        _result
2759    }
2760
2761    /// Similar to "send" but does not shutdown the channel if an error occurs.
2762    pub fn send_no_shutdown_on_err(
2763        self,
2764        mut presentation_info: &fidl_fuchsia_images::PresentationInfo,
2765    ) -> Result<(), fidl::Error> {
2766        let _result = self.send_raw(presentation_info);
2767        self.drop_without_shutdown();
2768        _result
2769    }
2770
2771    fn send_raw(
2772        &self,
2773        mut presentation_info: &fidl_fuchsia_images::PresentationInfo,
2774    ) -> Result<(), fidl::Error> {
2775        self.control_handle.inner.send::<SessionPresentResponse>(
2776            (presentation_info,),
2777            self.tx_id,
2778            0x36967062cdd2c37e,
2779            fidl::encoding::DynamicFlags::empty(),
2780        )
2781    }
2782}
2783
2784#[must_use = "FIDL methods require a response to be sent"]
2785#[derive(Debug)]
2786pub struct SessionPresent2Responder {
2787    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
2788    tx_id: u32,
2789}
2790
2791/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
2792/// if the responder is dropped without sending a response, so that the client
2793/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2794impl std::ops::Drop for SessionPresent2Responder {
2795    fn drop(&mut self) {
2796        self.control_handle.shutdown();
2797        // Safety: drops once, never accessed again
2798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2799    }
2800}
2801
2802impl fidl::endpoints::Responder for SessionPresent2Responder {
2803    type ControlHandle = SessionControlHandle;
2804
2805    fn control_handle(&self) -> &SessionControlHandle {
2806        &self.control_handle
2807    }
2808
2809    fn drop_without_shutdown(mut self) {
2810        // Safety: drops once, never accessed again due to mem::forget
2811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2812        // Prevent Drop from running (which would shut down the channel)
2813        std::mem::forget(self);
2814    }
2815}
2816
2817impl SessionPresent2Responder {
2818    /// Sends a response to the FIDL transaction.
2819    ///
2820    /// Sets the channel to shutdown if an error occurs.
2821    pub fn send(
2822        self,
2823        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2824    ) -> Result<(), fidl::Error> {
2825        let _result = self.send_raw(request_presentation_times_info);
2826        if _result.is_err() {
2827            self.control_handle.shutdown();
2828        }
2829        self.drop_without_shutdown();
2830        _result
2831    }
2832
2833    /// Similar to "send" but does not shutdown the channel if an error occurs.
2834    pub fn send_no_shutdown_on_err(
2835        self,
2836        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2837    ) -> Result<(), fidl::Error> {
2838        let _result = self.send_raw(request_presentation_times_info);
2839        self.drop_without_shutdown();
2840        _result
2841    }
2842
2843    fn send_raw(
2844        &self,
2845        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2846    ) -> Result<(), fidl::Error> {
2847        self.control_handle.inner.send::<SessionPresent2Response>(
2848            (request_presentation_times_info,),
2849            self.tx_id,
2850            0x5d307d6198d76a65,
2851            fidl::encoding::DynamicFlags::empty(),
2852        )
2853    }
2854}
2855
2856#[must_use = "FIDL methods require a response to be sent"]
2857#[derive(Debug)]
2858pub struct SessionRequestPresentationTimesResponder {
2859    control_handle: std::mem::ManuallyDrop<SessionControlHandle>,
2860    tx_id: u32,
2861}
2862
2863/// Set the the channel to be shutdown (see [`SessionControlHandle::shutdown`])
2864/// if the responder is dropped without sending a response, so that the client
2865/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2866impl std::ops::Drop for SessionRequestPresentationTimesResponder {
2867    fn drop(&mut self) {
2868        self.control_handle.shutdown();
2869        // Safety: drops once, never accessed again
2870        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2871    }
2872}
2873
2874impl fidl::endpoints::Responder for SessionRequestPresentationTimesResponder {
2875    type ControlHandle = SessionControlHandle;
2876
2877    fn control_handle(&self) -> &SessionControlHandle {
2878        &self.control_handle
2879    }
2880
2881    fn drop_without_shutdown(mut self) {
2882        // Safety: drops once, never accessed again due to mem::forget
2883        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2884        // Prevent Drop from running (which would shut down the channel)
2885        std::mem::forget(self);
2886    }
2887}
2888
2889impl SessionRequestPresentationTimesResponder {
2890    /// Sends a response to the FIDL transaction.
2891    ///
2892    /// Sets the channel to shutdown if an error occurs.
2893    pub fn send(
2894        self,
2895        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2896    ) -> Result<(), fidl::Error> {
2897        let _result = self.send_raw(request_presentation_times_info);
2898        if _result.is_err() {
2899            self.control_handle.shutdown();
2900        }
2901        self.drop_without_shutdown();
2902        _result
2903    }
2904
2905    /// Similar to "send" but does not shutdown the channel if an error occurs.
2906    pub fn send_no_shutdown_on_err(
2907        self,
2908        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2909    ) -> Result<(), fidl::Error> {
2910        let _result = self.send_raw(request_presentation_times_info);
2911        self.drop_without_shutdown();
2912        _result
2913    }
2914
2915    fn send_raw(
2916        &self,
2917        mut request_presentation_times_info: &fidl_fuchsia_scenic_scheduling::FuturePresentationTimes,
2918    ) -> Result<(), fidl::Error> {
2919        self.control_handle.inner.send::<SessionRequestPresentationTimesResponse>(
2920            (request_presentation_times_info,),
2921            self.tx_id,
2922            0x14a087997bf83904,
2923            fidl::encoding::DynamicFlags::empty(),
2924        )
2925    }
2926}
2927
2928#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2929pub struct SessionListenerMarker;
2930
2931impl fidl::endpoints::ProtocolMarker for SessionListenerMarker {
2932    type Proxy = SessionListenerProxy;
2933    type RequestStream = SessionListenerRequestStream;
2934    #[cfg(target_os = "fuchsia")]
2935    type SynchronousProxy = SessionListenerSynchronousProxy;
2936
2937    const DEBUG_NAME: &'static str = "(anonymous) SessionListener";
2938}
2939
2940pub trait SessionListenerProxyInterface: Send + Sync {
2941    fn r#on_scenic_error(&self, error: &str) -> Result<(), fidl::Error>;
2942    fn r#on_scenic_event(&self, events: Vec<Event>) -> Result<(), fidl::Error>;
2943}
2944#[derive(Debug)]
2945#[cfg(target_os = "fuchsia")]
2946pub struct SessionListenerSynchronousProxy {
2947    client: fidl::client::sync::Client,
2948}
2949
2950#[cfg(target_os = "fuchsia")]
2951impl fidl::endpoints::SynchronousProxy for SessionListenerSynchronousProxy {
2952    type Proxy = SessionListenerProxy;
2953    type Protocol = SessionListenerMarker;
2954
2955    fn from_channel(inner: fidl::Channel) -> Self {
2956        Self::new(inner)
2957    }
2958
2959    fn into_channel(self) -> fidl::Channel {
2960        self.client.into_channel()
2961    }
2962
2963    fn as_channel(&self) -> &fidl::Channel {
2964        self.client.as_channel()
2965    }
2966}
2967
2968#[cfg(target_os = "fuchsia")]
2969impl SessionListenerSynchronousProxy {
2970    pub fn new(channel: fidl::Channel) -> Self {
2971        let protocol_name = <SessionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2972        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
2973    }
2974
2975    pub fn into_channel(self) -> fidl::Channel {
2976        self.client.into_channel()
2977    }
2978
2979    /// Waits until an event arrives and returns it. It is safe for other
2980    /// threads to make concurrent requests while waiting for an event.
2981    pub fn wait_for_event(
2982        &self,
2983        deadline: zx::MonotonicInstant,
2984    ) -> Result<SessionListenerEvent, fidl::Error> {
2985        SessionListenerEvent::decode(self.client.wait_for_event(deadline)?)
2986    }
2987
2988    /// Called when an error has occurred and the session will be torn down.
2989    pub fn r#on_scenic_error(&self, mut error: &str) -> Result<(), fidl::Error> {
2990        self.client.send::<SessionListenerOnScenicErrorRequest>(
2991            (error,),
2992            0x68095b89cb6c45f7,
2993            fidl::encoding::DynamicFlags::empty(),
2994        )
2995    }
2996
2997    /// Called to deliver a batch of one or more events to the listener.
2998    /// Use `SetEventMaskCmd` to enable event delivery for a resource.
2999    pub fn r#on_scenic_event(&self, mut events: Vec<Event>) -> Result<(), fidl::Error> {
3000        self.client.send::<SessionListenerOnScenicEventRequest>(
3001            (events.as_mut(),),
3002            0x5f66bec36e87b3ea,
3003            fidl::encoding::DynamicFlags::empty(),
3004        )
3005    }
3006}
3007
3008#[cfg(target_os = "fuchsia")]
3009impl From<SessionListenerSynchronousProxy> for zx::Handle {
3010    fn from(value: SessionListenerSynchronousProxy) -> Self {
3011        value.into_channel().into()
3012    }
3013}
3014
3015#[cfg(target_os = "fuchsia")]
3016impl From<fidl::Channel> for SessionListenerSynchronousProxy {
3017    fn from(value: fidl::Channel) -> Self {
3018        Self::new(value)
3019    }
3020}
3021
3022#[derive(Debug, Clone)]
3023pub struct SessionListenerProxy {
3024    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
3025}
3026
3027impl fidl::endpoints::Proxy for SessionListenerProxy {
3028    type Protocol = SessionListenerMarker;
3029
3030    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
3031        Self::new(inner)
3032    }
3033
3034    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
3035        self.client.into_channel().map_err(|client| Self { client })
3036    }
3037
3038    fn as_channel(&self) -> &::fidl::AsyncChannel {
3039        self.client.as_channel()
3040    }
3041}
3042
3043impl SessionListenerProxy {
3044    /// Create a new Proxy for fuchsia.ui.scenic/SessionListener.
3045    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
3046        let protocol_name = <SessionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
3047        Self { client: fidl::client::Client::new(channel, protocol_name) }
3048    }
3049
3050    /// Get a Stream of events from the remote end of the protocol.
3051    ///
3052    /// # Panics
3053    ///
3054    /// Panics if the event stream was already taken.
3055    pub fn take_event_stream(&self) -> SessionListenerEventStream {
3056        SessionListenerEventStream { event_receiver: self.client.take_event_receiver() }
3057    }
3058
3059    /// Called when an error has occurred and the session will be torn down.
3060    pub fn r#on_scenic_error(&self, mut error: &str) -> Result<(), fidl::Error> {
3061        SessionListenerProxyInterface::r#on_scenic_error(self, error)
3062    }
3063
3064    /// Called to deliver a batch of one or more events to the listener.
3065    /// Use `SetEventMaskCmd` to enable event delivery for a resource.
3066    pub fn r#on_scenic_event(&self, mut events: Vec<Event>) -> Result<(), fidl::Error> {
3067        SessionListenerProxyInterface::r#on_scenic_event(self, events)
3068    }
3069}
3070
3071impl SessionListenerProxyInterface for SessionListenerProxy {
3072    fn r#on_scenic_error(&self, mut error: &str) -> Result<(), fidl::Error> {
3073        self.client.send::<SessionListenerOnScenicErrorRequest>(
3074            (error,),
3075            0x68095b89cb6c45f7,
3076            fidl::encoding::DynamicFlags::empty(),
3077        )
3078    }
3079
3080    fn r#on_scenic_event(&self, mut events: Vec<Event>) -> Result<(), fidl::Error> {
3081        self.client.send::<SessionListenerOnScenicEventRequest>(
3082            (events.as_mut(),),
3083            0x5f66bec36e87b3ea,
3084            fidl::encoding::DynamicFlags::empty(),
3085        )
3086    }
3087}
3088
3089pub struct SessionListenerEventStream {
3090    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3091}
3092
3093impl std::marker::Unpin for SessionListenerEventStream {}
3094
3095impl futures::stream::FusedStream for SessionListenerEventStream {
3096    fn is_terminated(&self) -> bool {
3097        self.event_receiver.is_terminated()
3098    }
3099}
3100
3101impl futures::Stream for SessionListenerEventStream {
3102    type Item = Result<SessionListenerEvent, fidl::Error>;
3103
3104    fn poll_next(
3105        mut self: std::pin::Pin<&mut Self>,
3106        cx: &mut std::task::Context<'_>,
3107    ) -> std::task::Poll<Option<Self::Item>> {
3108        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3109            &mut self.event_receiver,
3110            cx
3111        )?) {
3112            Some(buf) => std::task::Poll::Ready(Some(SessionListenerEvent::decode(buf))),
3113            None => std::task::Poll::Ready(None),
3114        }
3115    }
3116}
3117
3118#[derive(Debug)]
3119pub enum SessionListenerEvent {}
3120
3121impl SessionListenerEvent {
3122    /// Decodes a message buffer as a [`SessionListenerEvent`].
3123    fn decode(
3124        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3125    ) -> Result<SessionListenerEvent, fidl::Error> {
3126        let (bytes, _handles) = buf.split_mut();
3127        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3128        debug_assert_eq!(tx_header.tx_id, 0);
3129        match tx_header.ordinal {
3130            _ => Err(fidl::Error::UnknownOrdinal {
3131                ordinal: tx_header.ordinal,
3132                protocol_name:
3133                    <SessionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3134            }),
3135        }
3136    }
3137}
3138
3139/// A Stream of incoming requests for fuchsia.ui.scenic/SessionListener.
3140pub struct SessionListenerRequestStream {
3141    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3142    is_terminated: bool,
3143}
3144
3145impl std::marker::Unpin for SessionListenerRequestStream {}
3146
3147impl futures::stream::FusedStream for SessionListenerRequestStream {
3148    fn is_terminated(&self) -> bool {
3149        self.is_terminated
3150    }
3151}
3152
3153impl fidl::endpoints::RequestStream for SessionListenerRequestStream {
3154    type Protocol = SessionListenerMarker;
3155    type ControlHandle = SessionListenerControlHandle;
3156
3157    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3158        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3159    }
3160
3161    fn control_handle(&self) -> Self::ControlHandle {
3162        SessionListenerControlHandle { inner: self.inner.clone() }
3163    }
3164
3165    fn into_inner(
3166        self,
3167    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3168    {
3169        (self.inner, self.is_terminated)
3170    }
3171
3172    fn from_inner(
3173        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3174        is_terminated: bool,
3175    ) -> Self {
3176        Self { inner, is_terminated }
3177    }
3178}
3179
3180impl futures::Stream for SessionListenerRequestStream {
3181    type Item = Result<SessionListenerRequest, fidl::Error>;
3182
3183    fn poll_next(
3184        mut self: std::pin::Pin<&mut Self>,
3185        cx: &mut std::task::Context<'_>,
3186    ) -> std::task::Poll<Option<Self::Item>> {
3187        let this = &mut *self;
3188        if this.inner.check_shutdown(cx) {
3189            this.is_terminated = true;
3190            return std::task::Poll::Ready(None);
3191        }
3192        if this.is_terminated {
3193            panic!("polled SessionListenerRequestStream after completion");
3194        }
3195        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3196            |bytes, handles| {
3197                match this.inner.channel().read_etc(cx, bytes, handles) {
3198                    std::task::Poll::Ready(Ok(())) => {}
3199                    std::task::Poll::Pending => return std::task::Poll::Pending,
3200                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3201                        this.is_terminated = true;
3202                        return std::task::Poll::Ready(None);
3203                    }
3204                    std::task::Poll::Ready(Err(e)) => {
3205                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3206                            e.into(),
3207                        ))))
3208                    }
3209                }
3210
3211                // A message has been received from the channel
3212                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3213
3214                std::task::Poll::Ready(Some(match header.ordinal {
3215                    0x68095b89cb6c45f7 => {
3216                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3217                        let mut req = fidl::new_empty!(
3218                            SessionListenerOnScenicErrorRequest,
3219                            fidl::encoding::DefaultFuchsiaResourceDialect
3220                        );
3221                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionListenerOnScenicErrorRequest>(&header, _body_bytes, handles, &mut req)?;
3222                        let control_handle =
3223                            SessionListenerControlHandle { inner: this.inner.clone() };
3224                        Ok(SessionListenerRequest::OnScenicError {
3225                            error: req.error,
3226
3227                            control_handle,
3228                        })
3229                    }
3230                    0x5f66bec36e87b3ea => {
3231                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3232                        let mut req = fidl::new_empty!(
3233                            SessionListenerOnScenicEventRequest,
3234                            fidl::encoding::DefaultFuchsiaResourceDialect
3235                        );
3236                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<SessionListenerOnScenicEventRequest>(&header, _body_bytes, handles, &mut req)?;
3237                        let control_handle =
3238                            SessionListenerControlHandle { inner: this.inner.clone() };
3239                        Ok(SessionListenerRequest::OnScenicEvent {
3240                            events: req.events,
3241
3242                            control_handle,
3243                        })
3244                    }
3245                    _ => Err(fidl::Error::UnknownOrdinal {
3246                        ordinal: header.ordinal,
3247                        protocol_name:
3248                            <SessionListenerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3249                    }),
3250                }))
3251            },
3252        )
3253    }
3254}
3255
3256/// Listens for events which occur within the session.
3257#[derive(Debug)]
3258pub enum SessionListenerRequest {
3259    /// Called when an error has occurred and the session will be torn down.
3260    OnScenicError { error: String, control_handle: SessionListenerControlHandle },
3261    /// Called to deliver a batch of one or more events to the listener.
3262    /// Use `SetEventMaskCmd` to enable event delivery for a resource.
3263    OnScenicEvent { events: Vec<Event>, control_handle: SessionListenerControlHandle },
3264}
3265
3266impl SessionListenerRequest {
3267    #[allow(irrefutable_let_patterns)]
3268    pub fn into_on_scenic_error(self) -> Option<(String, SessionListenerControlHandle)> {
3269        if let SessionListenerRequest::OnScenicError { error, control_handle } = self {
3270            Some((error, control_handle))
3271        } else {
3272            None
3273        }
3274    }
3275
3276    #[allow(irrefutable_let_patterns)]
3277    pub fn into_on_scenic_event(self) -> Option<(Vec<Event>, SessionListenerControlHandle)> {
3278        if let SessionListenerRequest::OnScenicEvent { events, control_handle } = self {
3279            Some((events, control_handle))
3280        } else {
3281            None
3282        }
3283    }
3284
3285    /// Name of the method defined in FIDL
3286    pub fn method_name(&self) -> &'static str {
3287        match *self {
3288            SessionListenerRequest::OnScenicError { .. } => "on_scenic_error",
3289            SessionListenerRequest::OnScenicEvent { .. } => "on_scenic_event",
3290        }
3291    }
3292}
3293
3294#[derive(Debug, Clone)]
3295pub struct SessionListenerControlHandle {
3296    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3297}
3298
3299impl fidl::endpoints::ControlHandle for SessionListenerControlHandle {
3300    fn shutdown(&self) {
3301        self.inner.shutdown()
3302    }
3303    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
3304        self.inner.shutdown_with_epitaph(status)
3305    }
3306
3307    fn is_closed(&self) -> bool {
3308        self.inner.channel().is_closed()
3309    }
3310    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
3311        self.inner.channel().on_closed()
3312    }
3313
3314    #[cfg(target_os = "fuchsia")]
3315    fn signal_peer(
3316        &self,
3317        clear_mask: zx::Signals,
3318        set_mask: zx::Signals,
3319    ) -> Result<(), zx_status::Status> {
3320        use fidl::Peered;
3321        self.inner.channel().signal_peer(clear_mask, set_mask)
3322    }
3323}
3324
3325impl SessionListenerControlHandle {}
3326
3327mod internal {
3328    use super::*;
3329
3330    impl fidl::encoding::ResourceTypeMarker for ScenicCreateSession2Request {
3331        type Borrowed<'a> = &'a mut Self;
3332        fn take_or_borrow<'a>(
3333            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3334        ) -> Self::Borrowed<'a> {
3335            value
3336        }
3337    }
3338
3339    unsafe impl fidl::encoding::TypeMarker for ScenicCreateSession2Request {
3340        type Owned = Self;
3341
3342        #[inline(always)]
3343        fn inline_align(_context: fidl::encoding::Context) -> usize {
3344            4
3345        }
3346
3347        #[inline(always)]
3348        fn inline_size(_context: fidl::encoding::Context) -> usize {
3349            12
3350        }
3351    }
3352
3353    unsafe impl
3354        fidl::encoding::Encode<
3355            ScenicCreateSession2Request,
3356            fidl::encoding::DefaultFuchsiaResourceDialect,
3357        > for &mut ScenicCreateSession2Request
3358    {
3359        #[inline]
3360        unsafe fn encode(
3361            self,
3362            encoder: &mut fidl::encoding::Encoder<
3363                '_,
3364                fidl::encoding::DefaultFuchsiaResourceDialect,
3365            >,
3366            offset: usize,
3367            _depth: fidl::encoding::Depth,
3368        ) -> fidl::Result<()> {
3369            encoder.debug_check_bounds::<ScenicCreateSession2Request>(offset);
3370            // Delegate to tuple encoding.
3371            fidl::encoding::Encode::<ScenicCreateSession2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3372                (
3373                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
3374                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
3375                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_focuser),
3376                ),
3377                encoder, offset, _depth
3378            )
3379        }
3380    }
3381    unsafe impl<
3382            T0: fidl::encoding::Encode<
3383                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3384                fidl::encoding::DefaultFuchsiaResourceDialect,
3385            >,
3386            T1: fidl::encoding::Encode<
3387                fidl::encoding::Optional<
3388                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3389                >,
3390                fidl::encoding::DefaultFuchsiaResourceDialect,
3391            >,
3392            T2: fidl::encoding::Encode<
3393                fidl::encoding::Optional<
3394                    fidl::encoding::Endpoint<
3395                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
3396                    >,
3397                >,
3398                fidl::encoding::DefaultFuchsiaResourceDialect,
3399            >,
3400        >
3401        fidl::encoding::Encode<
3402            ScenicCreateSession2Request,
3403            fidl::encoding::DefaultFuchsiaResourceDialect,
3404        > for (T0, T1, T2)
3405    {
3406        #[inline]
3407        unsafe fn encode(
3408            self,
3409            encoder: &mut fidl::encoding::Encoder<
3410                '_,
3411                fidl::encoding::DefaultFuchsiaResourceDialect,
3412            >,
3413            offset: usize,
3414            depth: fidl::encoding::Depth,
3415        ) -> fidl::Result<()> {
3416            encoder.debug_check_bounds::<ScenicCreateSession2Request>(offset);
3417            // Zero out padding regions. There's no need to apply masks
3418            // because the unmasked parts will be overwritten by fields.
3419            // Write the fields.
3420            self.0.encode(encoder, offset + 0, depth)?;
3421            self.1.encode(encoder, offset + 4, depth)?;
3422            self.2.encode(encoder, offset + 8, depth)?;
3423            Ok(())
3424        }
3425    }
3426
3427    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3428        for ScenicCreateSession2Request
3429    {
3430        #[inline(always)]
3431        fn new_empty() -> Self {
3432            Self {
3433                session: fidl::new_empty!(
3434                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3435                    fidl::encoding::DefaultFuchsiaResourceDialect
3436                ),
3437                listener: fidl::new_empty!(
3438                    fidl::encoding::Optional<
3439                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3440                    >,
3441                    fidl::encoding::DefaultFuchsiaResourceDialect
3442                ),
3443                view_focuser: fidl::new_empty!(
3444                    fidl::encoding::Optional<
3445                        fidl::encoding::Endpoint<
3446                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
3447                        >,
3448                    >,
3449                    fidl::encoding::DefaultFuchsiaResourceDialect
3450                ),
3451            }
3452        }
3453
3454        #[inline]
3455        unsafe fn decode(
3456            &mut self,
3457            decoder: &mut fidl::encoding::Decoder<
3458                '_,
3459                fidl::encoding::DefaultFuchsiaResourceDialect,
3460            >,
3461            offset: usize,
3462            _depth: fidl::encoding::Depth,
3463        ) -> fidl::Result<()> {
3464            decoder.debug_check_bounds::<Self>(offset);
3465            // Verify that padding bytes are zero.
3466            fidl::decode!(
3467                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3468                fidl::encoding::DefaultFuchsiaResourceDialect,
3469                &mut self.session,
3470                decoder,
3471                offset + 0,
3472                _depth
3473            )?;
3474            fidl::decode!(
3475                fidl::encoding::Optional<
3476                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3477                >,
3478                fidl::encoding::DefaultFuchsiaResourceDialect,
3479                &mut self.listener,
3480                decoder,
3481                offset + 4,
3482                _depth
3483            )?;
3484            fidl::decode!(
3485                fidl::encoding::Optional<
3486                    fidl::encoding::Endpoint<
3487                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
3488                    >,
3489                >,
3490                fidl::encoding::DefaultFuchsiaResourceDialect,
3491                &mut self.view_focuser,
3492                decoder,
3493                offset + 8,
3494                _depth
3495            )?;
3496            Ok(())
3497        }
3498    }
3499
3500    impl fidl::encoding::ResourceTypeMarker for ScenicCreateSessionRequest {
3501        type Borrowed<'a> = &'a mut Self;
3502        fn take_or_borrow<'a>(
3503            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3504        ) -> Self::Borrowed<'a> {
3505            value
3506        }
3507    }
3508
3509    unsafe impl fidl::encoding::TypeMarker for ScenicCreateSessionRequest {
3510        type Owned = Self;
3511
3512        #[inline(always)]
3513        fn inline_align(_context: fidl::encoding::Context) -> usize {
3514            4
3515        }
3516
3517        #[inline(always)]
3518        fn inline_size(_context: fidl::encoding::Context) -> usize {
3519            8
3520        }
3521    }
3522
3523    unsafe impl
3524        fidl::encoding::Encode<
3525            ScenicCreateSessionRequest,
3526            fidl::encoding::DefaultFuchsiaResourceDialect,
3527        > for &mut ScenicCreateSessionRequest
3528    {
3529        #[inline]
3530        unsafe fn encode(
3531            self,
3532            encoder: &mut fidl::encoding::Encoder<
3533                '_,
3534                fidl::encoding::DefaultFuchsiaResourceDialect,
3535            >,
3536            offset: usize,
3537            _depth: fidl::encoding::Depth,
3538        ) -> fidl::Result<()> {
3539            encoder.debug_check_bounds::<ScenicCreateSessionRequest>(offset);
3540            // Delegate to tuple encoding.
3541            fidl::encoding::Encode::<ScenicCreateSessionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3542                (
3543                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.session),
3544                    <fidl::encoding::Optional<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.listener),
3545                ),
3546                encoder, offset, _depth
3547            )
3548        }
3549    }
3550    unsafe impl<
3551            T0: fidl::encoding::Encode<
3552                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3553                fidl::encoding::DefaultFuchsiaResourceDialect,
3554            >,
3555            T1: fidl::encoding::Encode<
3556                fidl::encoding::Optional<
3557                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3558                >,
3559                fidl::encoding::DefaultFuchsiaResourceDialect,
3560            >,
3561        >
3562        fidl::encoding::Encode<
3563            ScenicCreateSessionRequest,
3564            fidl::encoding::DefaultFuchsiaResourceDialect,
3565        > for (T0, T1)
3566    {
3567        #[inline]
3568        unsafe fn encode(
3569            self,
3570            encoder: &mut fidl::encoding::Encoder<
3571                '_,
3572                fidl::encoding::DefaultFuchsiaResourceDialect,
3573            >,
3574            offset: usize,
3575            depth: fidl::encoding::Depth,
3576        ) -> fidl::Result<()> {
3577            encoder.debug_check_bounds::<ScenicCreateSessionRequest>(offset);
3578            // Zero out padding regions. There's no need to apply masks
3579            // because the unmasked parts will be overwritten by fields.
3580            // Write the fields.
3581            self.0.encode(encoder, offset + 0, depth)?;
3582            self.1.encode(encoder, offset + 4, depth)?;
3583            Ok(())
3584        }
3585    }
3586
3587    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3588        for ScenicCreateSessionRequest
3589    {
3590        #[inline(always)]
3591        fn new_empty() -> Self {
3592            Self {
3593                session: fidl::new_empty!(
3594                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3595                    fidl::encoding::DefaultFuchsiaResourceDialect
3596                ),
3597                listener: fidl::new_empty!(
3598                    fidl::encoding::Optional<
3599                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3600                    >,
3601                    fidl::encoding::DefaultFuchsiaResourceDialect
3602                ),
3603            }
3604        }
3605
3606        #[inline]
3607        unsafe fn decode(
3608            &mut self,
3609            decoder: &mut fidl::encoding::Decoder<
3610                '_,
3611                fidl::encoding::DefaultFuchsiaResourceDialect,
3612            >,
3613            offset: usize,
3614            _depth: fidl::encoding::Depth,
3615        ) -> fidl::Result<()> {
3616            decoder.debug_check_bounds::<Self>(offset);
3617            // Verify that padding bytes are zero.
3618            fidl::decode!(
3619                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
3620                fidl::encoding::DefaultFuchsiaResourceDialect,
3621                &mut self.session,
3622                decoder,
3623                offset + 0,
3624                _depth
3625            )?;
3626            fidl::decode!(
3627                fidl::encoding::Optional<
3628                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
3629                >,
3630                fidl::encoding::DefaultFuchsiaResourceDialect,
3631                &mut self.listener,
3632                decoder,
3633                offset + 4,
3634                _depth
3635            )?;
3636            Ok(())
3637        }
3638    }
3639
3640    impl fidl::encoding::ResourceTypeMarker for ScenicCreateSessionTRequest {
3641        type Borrowed<'a> = &'a mut Self;
3642        fn take_or_borrow<'a>(
3643            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3644        ) -> Self::Borrowed<'a> {
3645            value
3646        }
3647    }
3648
3649    unsafe impl fidl::encoding::TypeMarker for ScenicCreateSessionTRequest {
3650        type Owned = Self;
3651
3652        #[inline(always)]
3653        fn inline_align(_context: fidl::encoding::Context) -> usize {
3654            8
3655        }
3656
3657        #[inline(always)]
3658        fn inline_size(_context: fidl::encoding::Context) -> usize {
3659            16
3660        }
3661    }
3662
3663    unsafe impl
3664        fidl::encoding::Encode<
3665            ScenicCreateSessionTRequest,
3666            fidl::encoding::DefaultFuchsiaResourceDialect,
3667        > for &mut ScenicCreateSessionTRequest
3668    {
3669        #[inline]
3670        unsafe fn encode(
3671            self,
3672            encoder: &mut fidl::encoding::Encoder<
3673                '_,
3674                fidl::encoding::DefaultFuchsiaResourceDialect,
3675            >,
3676            offset: usize,
3677            _depth: fidl::encoding::Depth,
3678        ) -> fidl::Result<()> {
3679            encoder.debug_check_bounds::<ScenicCreateSessionTRequest>(offset);
3680            // Delegate to tuple encoding.
3681            fidl::encoding::Encode::<
3682                ScenicCreateSessionTRequest,
3683                fidl::encoding::DefaultFuchsiaResourceDialect,
3684            >::encode(
3685                (<SessionEndpoints as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3686                    &mut self.endpoints,
3687                ),),
3688                encoder,
3689                offset,
3690                _depth,
3691            )
3692        }
3693    }
3694    unsafe impl<
3695            T0: fidl::encoding::Encode<SessionEndpoints, fidl::encoding::DefaultFuchsiaResourceDialect>,
3696        >
3697        fidl::encoding::Encode<
3698            ScenicCreateSessionTRequest,
3699            fidl::encoding::DefaultFuchsiaResourceDialect,
3700        > for (T0,)
3701    {
3702        #[inline]
3703        unsafe fn encode(
3704            self,
3705            encoder: &mut fidl::encoding::Encoder<
3706                '_,
3707                fidl::encoding::DefaultFuchsiaResourceDialect,
3708            >,
3709            offset: usize,
3710            depth: fidl::encoding::Depth,
3711        ) -> fidl::Result<()> {
3712            encoder.debug_check_bounds::<ScenicCreateSessionTRequest>(offset);
3713            // Zero out padding regions. There's no need to apply masks
3714            // because the unmasked parts will be overwritten by fields.
3715            // Write the fields.
3716            self.0.encode(encoder, offset + 0, depth)?;
3717            Ok(())
3718        }
3719    }
3720
3721    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3722        for ScenicCreateSessionTRequest
3723    {
3724        #[inline(always)]
3725        fn new_empty() -> Self {
3726            Self {
3727                endpoints: fidl::new_empty!(
3728                    SessionEndpoints,
3729                    fidl::encoding::DefaultFuchsiaResourceDialect
3730                ),
3731            }
3732        }
3733
3734        #[inline]
3735        unsafe fn decode(
3736            &mut self,
3737            decoder: &mut fidl::encoding::Decoder<
3738                '_,
3739                fidl::encoding::DefaultFuchsiaResourceDialect,
3740            >,
3741            offset: usize,
3742            _depth: fidl::encoding::Depth,
3743        ) -> fidl::Result<()> {
3744            decoder.debug_check_bounds::<Self>(offset);
3745            // Verify that padding bytes are zero.
3746            fidl::decode!(
3747                SessionEndpoints,
3748                fidl::encoding::DefaultFuchsiaResourceDialect,
3749                &mut self.endpoints,
3750                decoder,
3751                offset + 0,
3752                _depth
3753            )?;
3754            Ok(())
3755        }
3756    }
3757
3758    impl fidl::encoding::ResourceTypeMarker for ScenicGetDisplayOwnershipEventResponse {
3759        type Borrowed<'a> = &'a mut Self;
3760        fn take_or_borrow<'a>(
3761            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3762        ) -> Self::Borrowed<'a> {
3763            value
3764        }
3765    }
3766
3767    unsafe impl fidl::encoding::TypeMarker for ScenicGetDisplayOwnershipEventResponse {
3768        type Owned = Self;
3769
3770        #[inline(always)]
3771        fn inline_align(_context: fidl::encoding::Context) -> usize {
3772            4
3773        }
3774
3775        #[inline(always)]
3776        fn inline_size(_context: fidl::encoding::Context) -> usize {
3777            4
3778        }
3779    }
3780
3781    unsafe impl
3782        fidl::encoding::Encode<
3783            ScenicGetDisplayOwnershipEventResponse,
3784            fidl::encoding::DefaultFuchsiaResourceDialect,
3785        > for &mut ScenicGetDisplayOwnershipEventResponse
3786    {
3787        #[inline]
3788        unsafe fn encode(
3789            self,
3790            encoder: &mut fidl::encoding::Encoder<
3791                '_,
3792                fidl::encoding::DefaultFuchsiaResourceDialect,
3793            >,
3794            offset: usize,
3795            _depth: fidl::encoding::Depth,
3796        ) -> fidl::Result<()> {
3797            encoder.debug_check_bounds::<ScenicGetDisplayOwnershipEventResponse>(offset);
3798            // Delegate to tuple encoding.
3799            fidl::encoding::Encode::<
3800                ScenicGetDisplayOwnershipEventResponse,
3801                fidl::encoding::DefaultFuchsiaResourceDialect,
3802            >::encode(
3803                (<fidl::encoding::HandleType<
3804                    fidl::Event,
3805                    { fidl::ObjectType::EVENT.into_raw() },
3806                    2147483648,
3807                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3808                    &mut self.ownership_event,
3809                ),),
3810                encoder,
3811                offset,
3812                _depth,
3813            )
3814        }
3815    }
3816    unsafe impl<
3817            T0: fidl::encoding::Encode<
3818                fidl::encoding::HandleType<
3819                    fidl::Event,
3820                    { fidl::ObjectType::EVENT.into_raw() },
3821                    2147483648,
3822                >,
3823                fidl::encoding::DefaultFuchsiaResourceDialect,
3824            >,
3825        >
3826        fidl::encoding::Encode<
3827            ScenicGetDisplayOwnershipEventResponse,
3828            fidl::encoding::DefaultFuchsiaResourceDialect,
3829        > for (T0,)
3830    {
3831        #[inline]
3832        unsafe fn encode(
3833            self,
3834            encoder: &mut fidl::encoding::Encoder<
3835                '_,
3836                fidl::encoding::DefaultFuchsiaResourceDialect,
3837            >,
3838            offset: usize,
3839            depth: fidl::encoding::Depth,
3840        ) -> fidl::Result<()> {
3841            encoder.debug_check_bounds::<ScenicGetDisplayOwnershipEventResponse>(offset);
3842            // Zero out padding regions. There's no need to apply masks
3843            // because the unmasked parts will be overwritten by fields.
3844            // Write the fields.
3845            self.0.encode(encoder, offset + 0, depth)?;
3846            Ok(())
3847        }
3848    }
3849
3850    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3851        for ScenicGetDisplayOwnershipEventResponse
3852    {
3853        #[inline(always)]
3854        fn new_empty() -> Self {
3855            Self {
3856                ownership_event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
3857            }
3858        }
3859
3860        #[inline]
3861        unsafe fn decode(
3862            &mut self,
3863            decoder: &mut fidl::encoding::Decoder<
3864                '_,
3865                fidl::encoding::DefaultFuchsiaResourceDialect,
3866            >,
3867            offset: usize,
3868            _depth: fidl::encoding::Depth,
3869        ) -> fidl::Result<()> {
3870            decoder.debug_check_bounds::<Self>(offset);
3871            // Verify that padding bytes are zero.
3872            fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.ownership_event, decoder, offset + 0, _depth)?;
3873            Ok(())
3874        }
3875    }
3876
3877    impl fidl::encoding::ResourceTypeMarker for ScenicTakeScreenshotResponse {
3878        type Borrowed<'a> = &'a mut Self;
3879        fn take_or_borrow<'a>(
3880            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3881        ) -> Self::Borrowed<'a> {
3882            value
3883        }
3884    }
3885
3886    unsafe impl fidl::encoding::TypeMarker for ScenicTakeScreenshotResponse {
3887        type Owned = Self;
3888
3889        #[inline(always)]
3890        fn inline_align(_context: fidl::encoding::Context) -> usize {
3891            8
3892        }
3893
3894        #[inline(always)]
3895        fn inline_size(_context: fidl::encoding::Context) -> usize {
3896            56
3897        }
3898    }
3899
3900    unsafe impl
3901        fidl::encoding::Encode<
3902            ScenicTakeScreenshotResponse,
3903            fidl::encoding::DefaultFuchsiaResourceDialect,
3904        > for &mut ScenicTakeScreenshotResponse
3905    {
3906        #[inline]
3907        unsafe fn encode(
3908            self,
3909            encoder: &mut fidl::encoding::Encoder<
3910                '_,
3911                fidl::encoding::DefaultFuchsiaResourceDialect,
3912            >,
3913            offset: usize,
3914            _depth: fidl::encoding::Depth,
3915        ) -> fidl::Result<()> {
3916            encoder.debug_check_bounds::<ScenicTakeScreenshotResponse>(offset);
3917            // Delegate to tuple encoding.
3918            fidl::encoding::Encode::<
3919                ScenicTakeScreenshotResponse,
3920                fidl::encoding::DefaultFuchsiaResourceDialect,
3921            >::encode(
3922                (
3923                    <ScreenshotData as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3924                        &mut self.img_data,
3925                    ),
3926                    <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.success),
3927                ),
3928                encoder,
3929                offset,
3930                _depth,
3931            )
3932        }
3933    }
3934    unsafe impl<
3935            T0: fidl::encoding::Encode<ScreenshotData, fidl::encoding::DefaultFuchsiaResourceDialect>,
3936            T1: fidl::encoding::Encode<bool, fidl::encoding::DefaultFuchsiaResourceDialect>,
3937        >
3938        fidl::encoding::Encode<
3939            ScenicTakeScreenshotResponse,
3940            fidl::encoding::DefaultFuchsiaResourceDialect,
3941        > for (T0, T1)
3942    {
3943        #[inline]
3944        unsafe fn encode(
3945            self,
3946            encoder: &mut fidl::encoding::Encoder<
3947                '_,
3948                fidl::encoding::DefaultFuchsiaResourceDialect,
3949            >,
3950            offset: usize,
3951            depth: fidl::encoding::Depth,
3952        ) -> fidl::Result<()> {
3953            encoder.debug_check_bounds::<ScenicTakeScreenshotResponse>(offset);
3954            // Zero out padding regions. There's no need to apply masks
3955            // because the unmasked parts will be overwritten by fields.
3956            unsafe {
3957                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(48);
3958                (ptr as *mut u64).write_unaligned(0);
3959            }
3960            // Write the fields.
3961            self.0.encode(encoder, offset + 0, depth)?;
3962            self.1.encode(encoder, offset + 48, depth)?;
3963            Ok(())
3964        }
3965    }
3966
3967    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3968        for ScenicTakeScreenshotResponse
3969    {
3970        #[inline(always)]
3971        fn new_empty() -> Self {
3972            Self {
3973                img_data: fidl::new_empty!(
3974                    ScreenshotData,
3975                    fidl::encoding::DefaultFuchsiaResourceDialect
3976                ),
3977                success: fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect),
3978            }
3979        }
3980
3981        #[inline]
3982        unsafe fn decode(
3983            &mut self,
3984            decoder: &mut fidl::encoding::Decoder<
3985                '_,
3986                fidl::encoding::DefaultFuchsiaResourceDialect,
3987            >,
3988            offset: usize,
3989            _depth: fidl::encoding::Depth,
3990        ) -> fidl::Result<()> {
3991            decoder.debug_check_bounds::<Self>(offset);
3992            // Verify that padding bytes are zero.
3993            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(48) };
3994            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3995            let mask = 0xffffffffffffff00u64;
3996            let maskedval = padval & mask;
3997            if maskedval != 0 {
3998                return Err(fidl::Error::NonZeroPadding {
3999                    padding_start: offset + 48 + ((mask as u64).trailing_zeros() / 8) as usize,
4000                });
4001            }
4002            fidl::decode!(
4003                ScreenshotData,
4004                fidl::encoding::DefaultFuchsiaResourceDialect,
4005                &mut self.img_data,
4006                decoder,
4007                offset + 0,
4008                _depth
4009            )?;
4010            fidl::decode!(
4011                bool,
4012                fidl::encoding::DefaultFuchsiaResourceDialect,
4013                &mut self.success,
4014                decoder,
4015                offset + 48,
4016                _depth
4017            )?;
4018            Ok(())
4019        }
4020    }
4021
4022    impl fidl::encoding::ResourceTypeMarker for ScreenshotData {
4023        type Borrowed<'a> = &'a mut Self;
4024        fn take_or_borrow<'a>(
4025            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4026        ) -> Self::Borrowed<'a> {
4027            value
4028        }
4029    }
4030
4031    unsafe impl fidl::encoding::TypeMarker for ScreenshotData {
4032        type Owned = Self;
4033
4034        #[inline(always)]
4035        fn inline_align(_context: fidl::encoding::Context) -> usize {
4036            8
4037        }
4038
4039        #[inline(always)]
4040        fn inline_size(_context: fidl::encoding::Context) -> usize {
4041            48
4042        }
4043    }
4044
4045    unsafe impl
4046        fidl::encoding::Encode<ScreenshotData, fidl::encoding::DefaultFuchsiaResourceDialect>
4047        for &mut ScreenshotData
4048    {
4049        #[inline]
4050        unsafe fn encode(
4051            self,
4052            encoder: &mut fidl::encoding::Encoder<
4053                '_,
4054                fidl::encoding::DefaultFuchsiaResourceDialect,
4055            >,
4056            offset: usize,
4057            _depth: fidl::encoding::Depth,
4058        ) -> fidl::Result<()> {
4059            encoder.debug_check_bounds::<ScreenshotData>(offset);
4060            // Delegate to tuple encoding.
4061            fidl::encoding::Encode::<ScreenshotData, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4062                (
4063                    <fidl_fuchsia_images::ImageInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
4064                    <fidl_fuchsia_mem::Buffer as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.data),
4065                ),
4066                encoder, offset, _depth
4067            )
4068        }
4069    }
4070    unsafe impl<
4071            T0: fidl::encoding::Encode<
4072                fidl_fuchsia_images::ImageInfo,
4073                fidl::encoding::DefaultFuchsiaResourceDialect,
4074            >,
4075            T1: fidl::encoding::Encode<
4076                fidl_fuchsia_mem::Buffer,
4077                fidl::encoding::DefaultFuchsiaResourceDialect,
4078            >,
4079        > fidl::encoding::Encode<ScreenshotData, fidl::encoding::DefaultFuchsiaResourceDialect>
4080        for (T0, T1)
4081    {
4082        #[inline]
4083        unsafe fn encode(
4084            self,
4085            encoder: &mut fidl::encoding::Encoder<
4086                '_,
4087                fidl::encoding::DefaultFuchsiaResourceDialect,
4088            >,
4089            offset: usize,
4090            depth: fidl::encoding::Depth,
4091        ) -> fidl::Result<()> {
4092            encoder.debug_check_bounds::<ScreenshotData>(offset);
4093            // Zero out padding regions. There's no need to apply masks
4094            // because the unmasked parts will be overwritten by fields.
4095            // Write the fields.
4096            self.0.encode(encoder, offset + 0, depth)?;
4097            self.1.encode(encoder, offset + 32, depth)?;
4098            Ok(())
4099        }
4100    }
4101
4102    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4103        for ScreenshotData
4104    {
4105        #[inline(always)]
4106        fn new_empty() -> Self {
4107            Self {
4108                info: fidl::new_empty!(
4109                    fidl_fuchsia_images::ImageInfo,
4110                    fidl::encoding::DefaultFuchsiaResourceDialect
4111                ),
4112                data: fidl::new_empty!(
4113                    fidl_fuchsia_mem::Buffer,
4114                    fidl::encoding::DefaultFuchsiaResourceDialect
4115                ),
4116            }
4117        }
4118
4119        #[inline]
4120        unsafe fn decode(
4121            &mut self,
4122            decoder: &mut fidl::encoding::Decoder<
4123                '_,
4124                fidl::encoding::DefaultFuchsiaResourceDialect,
4125            >,
4126            offset: usize,
4127            _depth: fidl::encoding::Depth,
4128        ) -> fidl::Result<()> {
4129            decoder.debug_check_bounds::<Self>(offset);
4130            // Verify that padding bytes are zero.
4131            fidl::decode!(
4132                fidl_fuchsia_images::ImageInfo,
4133                fidl::encoding::DefaultFuchsiaResourceDialect,
4134                &mut self.info,
4135                decoder,
4136                offset + 0,
4137                _depth
4138            )?;
4139            fidl::decode!(
4140                fidl_fuchsia_mem::Buffer,
4141                fidl::encoding::DefaultFuchsiaResourceDialect,
4142                &mut self.data,
4143                decoder,
4144                offset + 32,
4145                _depth
4146            )?;
4147            Ok(())
4148        }
4149    }
4150
4151    impl fidl::encoding::ResourceTypeMarker for SessionEnqueueRequest {
4152        type Borrowed<'a> = &'a mut Self;
4153        fn take_or_borrow<'a>(
4154            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4155        ) -> Self::Borrowed<'a> {
4156            value
4157        }
4158    }
4159
4160    unsafe impl fidl::encoding::TypeMarker for SessionEnqueueRequest {
4161        type Owned = Self;
4162
4163        #[inline(always)]
4164        fn inline_align(_context: fidl::encoding::Context) -> usize {
4165            8
4166        }
4167
4168        #[inline(always)]
4169        fn inline_size(_context: fidl::encoding::Context) -> usize {
4170            16
4171        }
4172    }
4173
4174    unsafe impl
4175        fidl::encoding::Encode<SessionEnqueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4176        for &mut SessionEnqueueRequest
4177    {
4178        #[inline]
4179        unsafe fn encode(
4180            self,
4181            encoder: &mut fidl::encoding::Encoder<
4182                '_,
4183                fidl::encoding::DefaultFuchsiaResourceDialect,
4184            >,
4185            offset: usize,
4186            _depth: fidl::encoding::Depth,
4187        ) -> fidl::Result<()> {
4188            encoder.debug_check_bounds::<SessionEnqueueRequest>(offset);
4189            // Delegate to tuple encoding.
4190            fidl::encoding::Encode::<SessionEnqueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4191                (
4192                    <fidl::encoding::UnboundedVector<Command> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.cmds),
4193                ),
4194                encoder, offset, _depth
4195            )
4196        }
4197    }
4198    unsafe impl<
4199            T0: fidl::encoding::Encode<
4200                fidl::encoding::UnboundedVector<Command>,
4201                fidl::encoding::DefaultFuchsiaResourceDialect,
4202            >,
4203        >
4204        fidl::encoding::Encode<SessionEnqueueRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4205        for (T0,)
4206    {
4207        #[inline]
4208        unsafe fn encode(
4209            self,
4210            encoder: &mut fidl::encoding::Encoder<
4211                '_,
4212                fidl::encoding::DefaultFuchsiaResourceDialect,
4213            >,
4214            offset: usize,
4215            depth: fidl::encoding::Depth,
4216        ) -> fidl::Result<()> {
4217            encoder.debug_check_bounds::<SessionEnqueueRequest>(offset);
4218            // Zero out padding regions. There's no need to apply masks
4219            // because the unmasked parts will be overwritten by fields.
4220            // Write the fields.
4221            self.0.encode(encoder, offset + 0, depth)?;
4222            Ok(())
4223        }
4224    }
4225
4226    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4227        for SessionEnqueueRequest
4228    {
4229        #[inline(always)]
4230        fn new_empty() -> Self {
4231            Self {
4232                cmds: fidl::new_empty!(
4233                    fidl::encoding::UnboundedVector<Command>,
4234                    fidl::encoding::DefaultFuchsiaResourceDialect
4235                ),
4236            }
4237        }
4238
4239        #[inline]
4240        unsafe fn decode(
4241            &mut self,
4242            decoder: &mut fidl::encoding::Decoder<
4243                '_,
4244                fidl::encoding::DefaultFuchsiaResourceDialect,
4245            >,
4246            offset: usize,
4247            _depth: fidl::encoding::Depth,
4248        ) -> fidl::Result<()> {
4249            decoder.debug_check_bounds::<Self>(offset);
4250            // Verify that padding bytes are zero.
4251            fidl::decode!(
4252                fidl::encoding::UnboundedVector<Command>,
4253                fidl::encoding::DefaultFuchsiaResourceDialect,
4254                &mut self.cmds,
4255                decoder,
4256                offset + 0,
4257                _depth
4258            )?;
4259            Ok(())
4260        }
4261    }
4262
4263    impl fidl::encoding::ResourceTypeMarker for SessionListenerOnScenicEventRequest {
4264        type Borrowed<'a> = &'a mut Self;
4265        fn take_or_borrow<'a>(
4266            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4267        ) -> Self::Borrowed<'a> {
4268            value
4269        }
4270    }
4271
4272    unsafe impl fidl::encoding::TypeMarker for SessionListenerOnScenicEventRequest {
4273        type Owned = Self;
4274
4275        #[inline(always)]
4276        fn inline_align(_context: fidl::encoding::Context) -> usize {
4277            8
4278        }
4279
4280        #[inline(always)]
4281        fn inline_size(_context: fidl::encoding::Context) -> usize {
4282            16
4283        }
4284    }
4285
4286    unsafe impl
4287        fidl::encoding::Encode<
4288            SessionListenerOnScenicEventRequest,
4289            fidl::encoding::DefaultFuchsiaResourceDialect,
4290        > for &mut SessionListenerOnScenicEventRequest
4291    {
4292        #[inline]
4293        unsafe fn encode(
4294            self,
4295            encoder: &mut fidl::encoding::Encoder<
4296                '_,
4297                fidl::encoding::DefaultFuchsiaResourceDialect,
4298            >,
4299            offset: usize,
4300            _depth: fidl::encoding::Depth,
4301        ) -> fidl::Result<()> {
4302            encoder.debug_check_bounds::<SessionListenerOnScenicEventRequest>(offset);
4303            // Delegate to tuple encoding.
4304            fidl::encoding::Encode::<SessionListenerOnScenicEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
4305                (
4306                    <fidl::encoding::UnboundedVector<Event> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.events),
4307                ),
4308                encoder, offset, _depth
4309            )
4310        }
4311    }
4312    unsafe impl<
4313            T0: fidl::encoding::Encode<
4314                fidl::encoding::UnboundedVector<Event>,
4315                fidl::encoding::DefaultFuchsiaResourceDialect,
4316            >,
4317        >
4318        fidl::encoding::Encode<
4319            SessionListenerOnScenicEventRequest,
4320            fidl::encoding::DefaultFuchsiaResourceDialect,
4321        > for (T0,)
4322    {
4323        #[inline]
4324        unsafe fn encode(
4325            self,
4326            encoder: &mut fidl::encoding::Encoder<
4327                '_,
4328                fidl::encoding::DefaultFuchsiaResourceDialect,
4329            >,
4330            offset: usize,
4331            depth: fidl::encoding::Depth,
4332        ) -> fidl::Result<()> {
4333            encoder.debug_check_bounds::<SessionListenerOnScenicEventRequest>(offset);
4334            // Zero out padding regions. There's no need to apply masks
4335            // because the unmasked parts will be overwritten by fields.
4336            // Write the fields.
4337            self.0.encode(encoder, offset + 0, depth)?;
4338            Ok(())
4339        }
4340    }
4341
4342    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4343        for SessionListenerOnScenicEventRequest
4344    {
4345        #[inline(always)]
4346        fn new_empty() -> Self {
4347            Self {
4348                events: fidl::new_empty!(
4349                    fidl::encoding::UnboundedVector<Event>,
4350                    fidl::encoding::DefaultFuchsiaResourceDialect
4351                ),
4352            }
4353        }
4354
4355        #[inline]
4356        unsafe fn decode(
4357            &mut self,
4358            decoder: &mut fidl::encoding::Decoder<
4359                '_,
4360                fidl::encoding::DefaultFuchsiaResourceDialect,
4361            >,
4362            offset: usize,
4363            _depth: fidl::encoding::Depth,
4364        ) -> fidl::Result<()> {
4365            decoder.debug_check_bounds::<Self>(offset);
4366            // Verify that padding bytes are zero.
4367            fidl::decode!(
4368                fidl::encoding::UnboundedVector<Event>,
4369                fidl::encoding::DefaultFuchsiaResourceDialect,
4370                &mut self.events,
4371                decoder,
4372                offset + 0,
4373                _depth
4374            )?;
4375            Ok(())
4376        }
4377    }
4378
4379    impl fidl::encoding::ResourceTypeMarker for SessionPresent2Request {
4380        type Borrowed<'a> = &'a mut Self;
4381        fn take_or_borrow<'a>(
4382            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4383        ) -> Self::Borrowed<'a> {
4384            value
4385        }
4386    }
4387
4388    unsafe impl fidl::encoding::TypeMarker for SessionPresent2Request {
4389        type Owned = Self;
4390
4391        #[inline(always)]
4392        fn inline_align(_context: fidl::encoding::Context) -> usize {
4393            8
4394        }
4395
4396        #[inline(always)]
4397        fn inline_size(_context: fidl::encoding::Context) -> usize {
4398            16
4399        }
4400    }
4401
4402    unsafe impl
4403        fidl::encoding::Encode<
4404            SessionPresent2Request,
4405            fidl::encoding::DefaultFuchsiaResourceDialect,
4406        > for &mut SessionPresent2Request
4407    {
4408        #[inline]
4409        unsafe fn encode(
4410            self,
4411            encoder: &mut fidl::encoding::Encoder<
4412                '_,
4413                fidl::encoding::DefaultFuchsiaResourceDialect,
4414            >,
4415            offset: usize,
4416            _depth: fidl::encoding::Depth,
4417        ) -> fidl::Result<()> {
4418            encoder.debug_check_bounds::<SessionPresent2Request>(offset);
4419            // Delegate to tuple encoding.
4420            fidl::encoding::Encode::<
4421                SessionPresent2Request,
4422                fidl::encoding::DefaultFuchsiaResourceDialect,
4423            >::encode(
4424                (<Present2Args as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4425                    &mut self.args,
4426                ),),
4427                encoder,
4428                offset,
4429                _depth,
4430            )
4431        }
4432    }
4433    unsafe impl<
4434            T0: fidl::encoding::Encode<Present2Args, fidl::encoding::DefaultFuchsiaResourceDialect>,
4435        >
4436        fidl::encoding::Encode<
4437            SessionPresent2Request,
4438            fidl::encoding::DefaultFuchsiaResourceDialect,
4439        > for (T0,)
4440    {
4441        #[inline]
4442        unsafe fn encode(
4443            self,
4444            encoder: &mut fidl::encoding::Encoder<
4445                '_,
4446                fidl::encoding::DefaultFuchsiaResourceDialect,
4447            >,
4448            offset: usize,
4449            depth: fidl::encoding::Depth,
4450        ) -> fidl::Result<()> {
4451            encoder.debug_check_bounds::<SessionPresent2Request>(offset);
4452            // Zero out padding regions. There's no need to apply masks
4453            // because the unmasked parts will be overwritten by fields.
4454            // Write the fields.
4455            self.0.encode(encoder, offset + 0, depth)?;
4456            Ok(())
4457        }
4458    }
4459
4460    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4461        for SessionPresent2Request
4462    {
4463        #[inline(always)]
4464        fn new_empty() -> Self {
4465            Self {
4466                args: fidl::new_empty!(Present2Args, fidl::encoding::DefaultFuchsiaResourceDialect),
4467            }
4468        }
4469
4470        #[inline]
4471        unsafe fn decode(
4472            &mut self,
4473            decoder: &mut fidl::encoding::Decoder<
4474                '_,
4475                fidl::encoding::DefaultFuchsiaResourceDialect,
4476            >,
4477            offset: usize,
4478            _depth: fidl::encoding::Depth,
4479        ) -> fidl::Result<()> {
4480            decoder.debug_check_bounds::<Self>(offset);
4481            // Verify that padding bytes are zero.
4482            fidl::decode!(
4483                Present2Args,
4484                fidl::encoding::DefaultFuchsiaResourceDialect,
4485                &mut self.args,
4486                decoder,
4487                offset + 0,
4488                _depth
4489            )?;
4490            Ok(())
4491        }
4492    }
4493
4494    impl fidl::encoding::ResourceTypeMarker for SessionPresentRequest {
4495        type Borrowed<'a> = &'a mut Self;
4496        fn take_or_borrow<'a>(
4497            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4498        ) -> Self::Borrowed<'a> {
4499            value
4500        }
4501    }
4502
4503    unsafe impl fidl::encoding::TypeMarker for SessionPresentRequest {
4504        type Owned = Self;
4505
4506        #[inline(always)]
4507        fn inline_align(_context: fidl::encoding::Context) -> usize {
4508            8
4509        }
4510
4511        #[inline(always)]
4512        fn inline_size(_context: fidl::encoding::Context) -> usize {
4513            40
4514        }
4515    }
4516
4517    unsafe impl
4518        fidl::encoding::Encode<SessionPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4519        for &mut SessionPresentRequest
4520    {
4521        #[inline]
4522        unsafe fn encode(
4523            self,
4524            encoder: &mut fidl::encoding::Encoder<
4525                '_,
4526                fidl::encoding::DefaultFuchsiaResourceDialect,
4527            >,
4528            offset: usize,
4529            _depth: fidl::encoding::Depth,
4530        ) -> fidl::Result<()> {
4531            encoder.debug_check_bounds::<SessionPresentRequest>(offset);
4532            // Delegate to tuple encoding.
4533            fidl::encoding::Encode::<
4534                SessionPresentRequest,
4535                fidl::encoding::DefaultFuchsiaResourceDialect,
4536            >::encode(
4537                (
4538                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.presentation_time),
4539                    <fidl::encoding::UnboundedVector<
4540                        fidl::encoding::HandleType<
4541                            fidl::Event,
4542                            { fidl::ObjectType::EVENT.into_raw() },
4543                            2147483648,
4544                        >,
4545                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4546                        &mut self.acquire_fences,
4547                    ),
4548                    <fidl::encoding::UnboundedVector<
4549                        fidl::encoding::HandleType<
4550                            fidl::Event,
4551                            { fidl::ObjectType::EVENT.into_raw() },
4552                            2147483648,
4553                        >,
4554                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4555                        &mut self.release_fences,
4556                    ),
4557                ),
4558                encoder,
4559                offset,
4560                _depth,
4561            )
4562        }
4563    }
4564    unsafe impl<
4565            T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
4566            T1: fidl::encoding::Encode<
4567                fidl::encoding::UnboundedVector<
4568                    fidl::encoding::HandleType<
4569                        fidl::Event,
4570                        { fidl::ObjectType::EVENT.into_raw() },
4571                        2147483648,
4572                    >,
4573                >,
4574                fidl::encoding::DefaultFuchsiaResourceDialect,
4575            >,
4576            T2: fidl::encoding::Encode<
4577                fidl::encoding::UnboundedVector<
4578                    fidl::encoding::HandleType<
4579                        fidl::Event,
4580                        { fidl::ObjectType::EVENT.into_raw() },
4581                        2147483648,
4582                    >,
4583                >,
4584                fidl::encoding::DefaultFuchsiaResourceDialect,
4585            >,
4586        >
4587        fidl::encoding::Encode<SessionPresentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
4588        for (T0, T1, T2)
4589    {
4590        #[inline]
4591        unsafe fn encode(
4592            self,
4593            encoder: &mut fidl::encoding::Encoder<
4594                '_,
4595                fidl::encoding::DefaultFuchsiaResourceDialect,
4596            >,
4597            offset: usize,
4598            depth: fidl::encoding::Depth,
4599        ) -> fidl::Result<()> {
4600            encoder.debug_check_bounds::<SessionPresentRequest>(offset);
4601            // Zero out padding regions. There's no need to apply masks
4602            // because the unmasked parts will be overwritten by fields.
4603            // Write the fields.
4604            self.0.encode(encoder, offset + 0, depth)?;
4605            self.1.encode(encoder, offset + 8, depth)?;
4606            self.2.encode(encoder, offset + 24, depth)?;
4607            Ok(())
4608        }
4609    }
4610
4611    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4612        for SessionPresentRequest
4613    {
4614        #[inline(always)]
4615        fn new_empty() -> Self {
4616            Self {
4617                presentation_time: fidl::new_empty!(
4618                    u64,
4619                    fidl::encoding::DefaultFuchsiaResourceDialect
4620                ),
4621                acquire_fences: fidl::new_empty!(
4622                    fidl::encoding::UnboundedVector<
4623                        fidl::encoding::HandleType<
4624                            fidl::Event,
4625                            { fidl::ObjectType::EVENT.into_raw() },
4626                            2147483648,
4627                        >,
4628                    >,
4629                    fidl::encoding::DefaultFuchsiaResourceDialect
4630                ),
4631                release_fences: fidl::new_empty!(
4632                    fidl::encoding::UnboundedVector<
4633                        fidl::encoding::HandleType<
4634                            fidl::Event,
4635                            { fidl::ObjectType::EVENT.into_raw() },
4636                            2147483648,
4637                        >,
4638                    >,
4639                    fidl::encoding::DefaultFuchsiaResourceDialect
4640                ),
4641            }
4642        }
4643
4644        #[inline]
4645        unsafe fn decode(
4646            &mut self,
4647            decoder: &mut fidl::encoding::Decoder<
4648                '_,
4649                fidl::encoding::DefaultFuchsiaResourceDialect,
4650            >,
4651            offset: usize,
4652            _depth: fidl::encoding::Depth,
4653        ) -> fidl::Result<()> {
4654            decoder.debug_check_bounds::<Self>(offset);
4655            // Verify that padding bytes are zero.
4656            fidl::decode!(
4657                u64,
4658                fidl::encoding::DefaultFuchsiaResourceDialect,
4659                &mut self.presentation_time,
4660                decoder,
4661                offset + 0,
4662                _depth
4663            )?;
4664            fidl::decode!(
4665                fidl::encoding::UnboundedVector<
4666                    fidl::encoding::HandleType<
4667                        fidl::Event,
4668                        { fidl::ObjectType::EVENT.into_raw() },
4669                        2147483648,
4670                    >,
4671                >,
4672                fidl::encoding::DefaultFuchsiaResourceDialect,
4673                &mut self.acquire_fences,
4674                decoder,
4675                offset + 8,
4676                _depth
4677            )?;
4678            fidl::decode!(
4679                fidl::encoding::UnboundedVector<
4680                    fidl::encoding::HandleType<
4681                        fidl::Event,
4682                        { fidl::ObjectType::EVENT.into_raw() },
4683                        2147483648,
4684                    >,
4685                >,
4686                fidl::encoding::DefaultFuchsiaResourceDialect,
4687                &mut self.release_fences,
4688                decoder,
4689                offset + 24,
4690                _depth
4691            )?;
4692            Ok(())
4693        }
4694    }
4695
4696    impl fidl::encoding::ResourceTypeMarker for SessionRegisterBufferCollectionRequest {
4697        type Borrowed<'a> = &'a mut Self;
4698        fn take_or_borrow<'a>(
4699            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4700        ) -> Self::Borrowed<'a> {
4701            value
4702        }
4703    }
4704
4705    unsafe impl fidl::encoding::TypeMarker for SessionRegisterBufferCollectionRequest {
4706        type Owned = Self;
4707
4708        #[inline(always)]
4709        fn inline_align(_context: fidl::encoding::Context) -> usize {
4710            4
4711        }
4712
4713        #[inline(always)]
4714        fn inline_size(_context: fidl::encoding::Context) -> usize {
4715            8
4716        }
4717    }
4718
4719    unsafe impl
4720        fidl::encoding::Encode<
4721            SessionRegisterBufferCollectionRequest,
4722            fidl::encoding::DefaultFuchsiaResourceDialect,
4723        > for &mut SessionRegisterBufferCollectionRequest
4724    {
4725        #[inline]
4726        unsafe fn encode(
4727            self,
4728            encoder: &mut fidl::encoding::Encoder<
4729                '_,
4730                fidl::encoding::DefaultFuchsiaResourceDialect,
4731            >,
4732            offset: usize,
4733            _depth: fidl::encoding::Depth,
4734        ) -> fidl::Result<()> {
4735            encoder.debug_check_bounds::<SessionRegisterBufferCollectionRequest>(offset);
4736            // Delegate to tuple encoding.
4737            fidl::encoding::Encode::<
4738                SessionRegisterBufferCollectionRequest,
4739                fidl::encoding::DefaultFuchsiaResourceDialect,
4740            >::encode(
4741                (
4742                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.buffer_id),
4743                    <fidl::encoding::Endpoint<
4744                        fidl::endpoints::ClientEnd<
4745                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
4746                        >,
4747                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
4748                        &mut self.token
4749                    ),
4750                ),
4751                encoder,
4752                offset,
4753                _depth,
4754            )
4755        }
4756    }
4757    unsafe impl<
4758            T0: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
4759            T1: fidl::encoding::Encode<
4760                fidl::encoding::Endpoint<
4761                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
4762                >,
4763                fidl::encoding::DefaultFuchsiaResourceDialect,
4764            >,
4765        >
4766        fidl::encoding::Encode<
4767            SessionRegisterBufferCollectionRequest,
4768            fidl::encoding::DefaultFuchsiaResourceDialect,
4769        > for (T0, T1)
4770    {
4771        #[inline]
4772        unsafe fn encode(
4773            self,
4774            encoder: &mut fidl::encoding::Encoder<
4775                '_,
4776                fidl::encoding::DefaultFuchsiaResourceDialect,
4777            >,
4778            offset: usize,
4779            depth: fidl::encoding::Depth,
4780        ) -> fidl::Result<()> {
4781            encoder.debug_check_bounds::<SessionRegisterBufferCollectionRequest>(offset);
4782            // Zero out padding regions. There's no need to apply masks
4783            // because the unmasked parts will be overwritten by fields.
4784            // Write the fields.
4785            self.0.encode(encoder, offset + 0, depth)?;
4786            self.1.encode(encoder, offset + 4, depth)?;
4787            Ok(())
4788        }
4789    }
4790
4791    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
4792        for SessionRegisterBufferCollectionRequest
4793    {
4794        #[inline(always)]
4795        fn new_empty() -> Self {
4796            Self {
4797                buffer_id: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
4798                token: fidl::new_empty!(
4799                    fidl::encoding::Endpoint<
4800                        fidl::endpoints::ClientEnd<
4801                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
4802                        >,
4803                    >,
4804                    fidl::encoding::DefaultFuchsiaResourceDialect
4805                ),
4806            }
4807        }
4808
4809        #[inline]
4810        unsafe fn decode(
4811            &mut self,
4812            decoder: &mut fidl::encoding::Decoder<
4813                '_,
4814                fidl::encoding::DefaultFuchsiaResourceDialect,
4815            >,
4816            offset: usize,
4817            _depth: fidl::encoding::Depth,
4818        ) -> fidl::Result<()> {
4819            decoder.debug_check_bounds::<Self>(offset);
4820            // Verify that padding bytes are zero.
4821            fidl::decode!(
4822                u32,
4823                fidl::encoding::DefaultFuchsiaResourceDialect,
4824                &mut self.buffer_id,
4825                decoder,
4826                offset + 0,
4827                _depth
4828            )?;
4829            fidl::decode!(
4830                fidl::encoding::Endpoint<
4831                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
4832                >,
4833                fidl::encoding::DefaultFuchsiaResourceDialect,
4834                &mut self.token,
4835                decoder,
4836                offset + 4,
4837                _depth
4838            )?;
4839            Ok(())
4840        }
4841    }
4842
4843    impl Present2Args {
4844        #[inline(always)]
4845        fn max_ordinal_present(&self) -> u64 {
4846            if let Some(_) = self.requested_prediction_span {
4847                return 4;
4848            }
4849            if let Some(_) = self.release_fences {
4850                return 3;
4851            }
4852            if let Some(_) = self.acquire_fences {
4853                return 2;
4854            }
4855            if let Some(_) = self.requested_presentation_time {
4856                return 1;
4857            }
4858            0
4859        }
4860    }
4861
4862    impl fidl::encoding::ResourceTypeMarker for Present2Args {
4863        type Borrowed<'a> = &'a mut Self;
4864        fn take_or_borrow<'a>(
4865            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
4866        ) -> Self::Borrowed<'a> {
4867            value
4868        }
4869    }
4870
4871    unsafe impl fidl::encoding::TypeMarker for Present2Args {
4872        type Owned = Self;
4873
4874        #[inline(always)]
4875        fn inline_align(_context: fidl::encoding::Context) -> usize {
4876            8
4877        }
4878
4879        #[inline(always)]
4880        fn inline_size(_context: fidl::encoding::Context) -> usize {
4881            16
4882        }
4883    }
4884
4885    unsafe impl fidl::encoding::Encode<Present2Args, fidl::encoding::DefaultFuchsiaResourceDialect>
4886        for &mut Present2Args
4887    {
4888        unsafe fn encode(
4889            self,
4890            encoder: &mut fidl::encoding::Encoder<
4891                '_,
4892                fidl::encoding::DefaultFuchsiaResourceDialect,
4893            >,
4894            offset: usize,
4895            mut depth: fidl::encoding::Depth,
4896        ) -> fidl::Result<()> {
4897            encoder.debug_check_bounds::<Present2Args>(offset);
4898            // Vector header
4899            let max_ordinal: u64 = self.max_ordinal_present();
4900            encoder.write_num(max_ordinal, offset);
4901            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
4902            // Calling encoder.out_of_line_offset(0) is not allowed.
4903            if max_ordinal == 0 {
4904                return Ok(());
4905            }
4906            depth.increment()?;
4907            let envelope_size = 8;
4908            let bytes_len = max_ordinal as usize * envelope_size;
4909            #[allow(unused_variables)]
4910            let offset = encoder.out_of_line_offset(bytes_len);
4911            let mut _prev_end_offset: usize = 0;
4912            if 1 > max_ordinal {
4913                return Ok(());
4914            }
4915
4916            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4917            // are envelope_size bytes.
4918            let cur_offset: usize = (1 - 1) * envelope_size;
4919
4920            // Zero reserved fields.
4921            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4922
4923            // Safety:
4924            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4925            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4926            //   envelope_size bytes, there is always sufficient room.
4927            fidl::encoding::encode_in_envelope_optional::<
4928                i64,
4929                fidl::encoding::DefaultFuchsiaResourceDialect,
4930            >(
4931                self.requested_presentation_time
4932                    .as_ref()
4933                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
4934                encoder,
4935                offset + cur_offset,
4936                depth,
4937            )?;
4938
4939            _prev_end_offset = cur_offset + envelope_size;
4940            if 2 > max_ordinal {
4941                return Ok(());
4942            }
4943
4944            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4945            // are envelope_size bytes.
4946            let cur_offset: usize = (2 - 1) * envelope_size;
4947
4948            // Zero reserved fields.
4949            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4950
4951            // Safety:
4952            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4953            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4954            //   envelope_size bytes, there is always sufficient room.
4955            fidl::encoding::encode_in_envelope_optional::<
4956                fidl::encoding::UnboundedVector<
4957                    fidl::encoding::HandleType<
4958                        fidl::Event,
4959                        { fidl::ObjectType::EVENT.into_raw() },
4960                        2147483648,
4961                    >,
4962                >,
4963                fidl::encoding::DefaultFuchsiaResourceDialect,
4964            >(
4965                self.acquire_fences.as_mut().map(
4966                    <fidl::encoding::UnboundedVector<
4967                        fidl::encoding::HandleType<
4968                            fidl::Event,
4969                            { fidl::ObjectType::EVENT.into_raw() },
4970                            2147483648,
4971                        >,
4972                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
4973                ),
4974                encoder,
4975                offset + cur_offset,
4976                depth,
4977            )?;
4978
4979            _prev_end_offset = cur_offset + envelope_size;
4980            if 3 > max_ordinal {
4981                return Ok(());
4982            }
4983
4984            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
4985            // are envelope_size bytes.
4986            let cur_offset: usize = (3 - 1) * envelope_size;
4987
4988            // Zero reserved fields.
4989            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
4990
4991            // Safety:
4992            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
4993            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
4994            //   envelope_size bytes, there is always sufficient room.
4995            fidl::encoding::encode_in_envelope_optional::<
4996                fidl::encoding::UnboundedVector<
4997                    fidl::encoding::HandleType<
4998                        fidl::Event,
4999                        { fidl::ObjectType::EVENT.into_raw() },
5000                        2147483648,
5001                    >,
5002                >,
5003                fidl::encoding::DefaultFuchsiaResourceDialect,
5004            >(
5005                self.release_fences.as_mut().map(
5006                    <fidl::encoding::UnboundedVector<
5007                        fidl::encoding::HandleType<
5008                            fidl::Event,
5009                            { fidl::ObjectType::EVENT.into_raw() },
5010                            2147483648,
5011                        >,
5012                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5013                ),
5014                encoder,
5015                offset + cur_offset,
5016                depth,
5017            )?;
5018
5019            _prev_end_offset = cur_offset + envelope_size;
5020            if 4 > max_ordinal {
5021                return Ok(());
5022            }
5023
5024            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5025            // are envelope_size bytes.
5026            let cur_offset: usize = (4 - 1) * envelope_size;
5027
5028            // Zero reserved fields.
5029            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5030
5031            // Safety:
5032            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5033            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5034            //   envelope_size bytes, there is always sufficient room.
5035            fidl::encoding::encode_in_envelope_optional::<
5036                i64,
5037                fidl::encoding::DefaultFuchsiaResourceDialect,
5038            >(
5039                self.requested_prediction_span
5040                    .as_ref()
5041                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
5042                encoder,
5043                offset + cur_offset,
5044                depth,
5045            )?;
5046
5047            _prev_end_offset = cur_offset + envelope_size;
5048
5049            Ok(())
5050        }
5051    }
5052
5053    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Present2Args {
5054        #[inline(always)]
5055        fn new_empty() -> Self {
5056            Self::default()
5057        }
5058
5059        unsafe fn decode(
5060            &mut self,
5061            decoder: &mut fidl::encoding::Decoder<
5062                '_,
5063                fidl::encoding::DefaultFuchsiaResourceDialect,
5064            >,
5065            offset: usize,
5066            mut depth: fidl::encoding::Depth,
5067        ) -> fidl::Result<()> {
5068            decoder.debug_check_bounds::<Self>(offset);
5069            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5070                None => return Err(fidl::Error::NotNullable),
5071                Some(len) => len,
5072            };
5073            // Calling decoder.out_of_line_offset(0) is not allowed.
5074            if len == 0 {
5075                return Ok(());
5076            };
5077            depth.increment()?;
5078            let envelope_size = 8;
5079            let bytes_len = len * envelope_size;
5080            let offset = decoder.out_of_line_offset(bytes_len)?;
5081            // Decode the envelope for each type.
5082            let mut _next_ordinal_to_read = 0;
5083            let mut next_offset = offset;
5084            let end_offset = offset + bytes_len;
5085            _next_ordinal_to_read += 1;
5086            if next_offset >= end_offset {
5087                return Ok(());
5088            }
5089
5090            // Decode unknown envelopes for gaps in ordinals.
5091            while _next_ordinal_to_read < 1 {
5092                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5093                _next_ordinal_to_read += 1;
5094                next_offset += envelope_size;
5095            }
5096
5097            let next_out_of_line = decoder.next_out_of_line();
5098            let handles_before = decoder.remaining_handles();
5099            if let Some((inlined, num_bytes, num_handles)) =
5100                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5101            {
5102                let member_inline_size =
5103                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5104                if inlined != (member_inline_size <= 4) {
5105                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5106                }
5107                let inner_offset;
5108                let mut inner_depth = depth.clone();
5109                if inlined {
5110                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5111                    inner_offset = next_offset;
5112                } else {
5113                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5114                    inner_depth.increment()?;
5115                }
5116                let val_ref = self.requested_presentation_time.get_or_insert_with(|| {
5117                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
5118                });
5119                fidl::decode!(
5120                    i64,
5121                    fidl::encoding::DefaultFuchsiaResourceDialect,
5122                    val_ref,
5123                    decoder,
5124                    inner_offset,
5125                    inner_depth
5126                )?;
5127                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5128                {
5129                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5130                }
5131                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5132                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5133                }
5134            }
5135
5136            next_offset += envelope_size;
5137            _next_ordinal_to_read += 1;
5138            if next_offset >= end_offset {
5139                return Ok(());
5140            }
5141
5142            // Decode unknown envelopes for gaps in ordinals.
5143            while _next_ordinal_to_read < 2 {
5144                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5145                _next_ordinal_to_read += 1;
5146                next_offset += envelope_size;
5147            }
5148
5149            let next_out_of_line = decoder.next_out_of_line();
5150            let handles_before = decoder.remaining_handles();
5151            if let Some((inlined, num_bytes, num_handles)) =
5152                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5153            {
5154                let member_inline_size = <fidl::encoding::UnboundedVector<
5155                    fidl::encoding::HandleType<
5156                        fidl::Event,
5157                        { fidl::ObjectType::EVENT.into_raw() },
5158                        2147483648,
5159                    >,
5160                > as fidl::encoding::TypeMarker>::inline_size(
5161                    decoder.context
5162                );
5163                if inlined != (member_inline_size <= 4) {
5164                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5165                }
5166                let inner_offset;
5167                let mut inner_depth = depth.clone();
5168                if inlined {
5169                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5170                    inner_offset = next_offset;
5171                } else {
5172                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5173                    inner_depth.increment()?;
5174                }
5175                let val_ref = self.acquire_fences.get_or_insert_with(|| {
5176                    fidl::new_empty!(
5177                        fidl::encoding::UnboundedVector<
5178                            fidl::encoding::HandleType<
5179                                fidl::Event,
5180                                { fidl::ObjectType::EVENT.into_raw() },
5181                                2147483648,
5182                            >,
5183                        >,
5184                        fidl::encoding::DefaultFuchsiaResourceDialect
5185                    )
5186                });
5187                fidl::decode!(
5188                    fidl::encoding::UnboundedVector<
5189                        fidl::encoding::HandleType<
5190                            fidl::Event,
5191                            { fidl::ObjectType::EVENT.into_raw() },
5192                            2147483648,
5193                        >,
5194                    >,
5195                    fidl::encoding::DefaultFuchsiaResourceDialect,
5196                    val_ref,
5197                    decoder,
5198                    inner_offset,
5199                    inner_depth
5200                )?;
5201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5202                {
5203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5204                }
5205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5207                }
5208            }
5209
5210            next_offset += envelope_size;
5211            _next_ordinal_to_read += 1;
5212            if next_offset >= end_offset {
5213                return Ok(());
5214            }
5215
5216            // Decode unknown envelopes for gaps in ordinals.
5217            while _next_ordinal_to_read < 3 {
5218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5219                _next_ordinal_to_read += 1;
5220                next_offset += envelope_size;
5221            }
5222
5223            let next_out_of_line = decoder.next_out_of_line();
5224            let handles_before = decoder.remaining_handles();
5225            if let Some((inlined, num_bytes, num_handles)) =
5226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5227            {
5228                let member_inline_size = <fidl::encoding::UnboundedVector<
5229                    fidl::encoding::HandleType<
5230                        fidl::Event,
5231                        { fidl::ObjectType::EVENT.into_raw() },
5232                        2147483648,
5233                    >,
5234                > as fidl::encoding::TypeMarker>::inline_size(
5235                    decoder.context
5236                );
5237                if inlined != (member_inline_size <= 4) {
5238                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5239                }
5240                let inner_offset;
5241                let mut inner_depth = depth.clone();
5242                if inlined {
5243                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5244                    inner_offset = next_offset;
5245                } else {
5246                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5247                    inner_depth.increment()?;
5248                }
5249                let val_ref = self.release_fences.get_or_insert_with(|| {
5250                    fidl::new_empty!(
5251                        fidl::encoding::UnboundedVector<
5252                            fidl::encoding::HandleType<
5253                                fidl::Event,
5254                                { fidl::ObjectType::EVENT.into_raw() },
5255                                2147483648,
5256                            >,
5257                        >,
5258                        fidl::encoding::DefaultFuchsiaResourceDialect
5259                    )
5260                });
5261                fidl::decode!(
5262                    fidl::encoding::UnboundedVector<
5263                        fidl::encoding::HandleType<
5264                            fidl::Event,
5265                            { fidl::ObjectType::EVENT.into_raw() },
5266                            2147483648,
5267                        >,
5268                    >,
5269                    fidl::encoding::DefaultFuchsiaResourceDialect,
5270                    val_ref,
5271                    decoder,
5272                    inner_offset,
5273                    inner_depth
5274                )?;
5275                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5276                {
5277                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5278                }
5279                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5280                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5281                }
5282            }
5283
5284            next_offset += envelope_size;
5285            _next_ordinal_to_read += 1;
5286            if next_offset >= end_offset {
5287                return Ok(());
5288            }
5289
5290            // Decode unknown envelopes for gaps in ordinals.
5291            while _next_ordinal_to_read < 4 {
5292                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5293                _next_ordinal_to_read += 1;
5294                next_offset += envelope_size;
5295            }
5296
5297            let next_out_of_line = decoder.next_out_of_line();
5298            let handles_before = decoder.remaining_handles();
5299            if let Some((inlined, num_bytes, num_handles)) =
5300                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5301            {
5302                let member_inline_size =
5303                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
5304                if inlined != (member_inline_size <= 4) {
5305                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5306                }
5307                let inner_offset;
5308                let mut inner_depth = depth.clone();
5309                if inlined {
5310                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5311                    inner_offset = next_offset;
5312                } else {
5313                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5314                    inner_depth.increment()?;
5315                }
5316                let val_ref = self.requested_prediction_span.get_or_insert_with(|| {
5317                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
5318                });
5319                fidl::decode!(
5320                    i64,
5321                    fidl::encoding::DefaultFuchsiaResourceDialect,
5322                    val_ref,
5323                    decoder,
5324                    inner_offset,
5325                    inner_depth
5326                )?;
5327                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5328                {
5329                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5330                }
5331                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5332                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5333                }
5334            }
5335
5336            next_offset += envelope_size;
5337
5338            // Decode the remaining unknown envelopes.
5339            while next_offset < end_offset {
5340                _next_ordinal_to_read += 1;
5341                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5342                next_offset += envelope_size;
5343            }
5344
5345            Ok(())
5346        }
5347    }
5348
5349    impl SessionEndpoints {
5350        #[inline(always)]
5351        fn max_ordinal_present(&self) -> u64 {
5352            if let Some(_) = self.mouse_source {
5353                return 6;
5354            }
5355            if let Some(_) = self.touch_source {
5356                return 5;
5357            }
5358            if let Some(_) = self.view_ref_focused {
5359                return 4;
5360            }
5361            if let Some(_) = self.view_focuser {
5362                return 3;
5363            }
5364            if let Some(_) = self.session_listener {
5365                return 2;
5366            }
5367            if let Some(_) = self.session {
5368                return 1;
5369            }
5370            0
5371        }
5372    }
5373
5374    impl fidl::encoding::ResourceTypeMarker for SessionEndpoints {
5375        type Borrowed<'a> = &'a mut Self;
5376        fn take_or_borrow<'a>(
5377            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
5378        ) -> Self::Borrowed<'a> {
5379            value
5380        }
5381    }
5382
5383    unsafe impl fidl::encoding::TypeMarker for SessionEndpoints {
5384        type Owned = Self;
5385
5386        #[inline(always)]
5387        fn inline_align(_context: fidl::encoding::Context) -> usize {
5388            8
5389        }
5390
5391        #[inline(always)]
5392        fn inline_size(_context: fidl::encoding::Context) -> usize {
5393            16
5394        }
5395    }
5396
5397    unsafe impl
5398        fidl::encoding::Encode<SessionEndpoints, fidl::encoding::DefaultFuchsiaResourceDialect>
5399        for &mut SessionEndpoints
5400    {
5401        unsafe fn encode(
5402            self,
5403            encoder: &mut fidl::encoding::Encoder<
5404                '_,
5405                fidl::encoding::DefaultFuchsiaResourceDialect,
5406            >,
5407            offset: usize,
5408            mut depth: fidl::encoding::Depth,
5409        ) -> fidl::Result<()> {
5410            encoder.debug_check_bounds::<SessionEndpoints>(offset);
5411            // Vector header
5412            let max_ordinal: u64 = self.max_ordinal_present();
5413            encoder.write_num(max_ordinal, offset);
5414            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
5415            // Calling encoder.out_of_line_offset(0) is not allowed.
5416            if max_ordinal == 0 {
5417                return Ok(());
5418            }
5419            depth.increment()?;
5420            let envelope_size = 8;
5421            let bytes_len = max_ordinal as usize * envelope_size;
5422            #[allow(unused_variables)]
5423            let offset = encoder.out_of_line_offset(bytes_len);
5424            let mut _prev_end_offset: usize = 0;
5425            if 1 > max_ordinal {
5426                return Ok(());
5427            }
5428
5429            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5430            // are envelope_size bytes.
5431            let cur_offset: usize = (1 - 1) * envelope_size;
5432
5433            // Zero reserved fields.
5434            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5435
5436            // Safety:
5437            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5438            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5439            //   envelope_size bytes, there is always sufficient room.
5440            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5441            self.session.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5442            encoder, offset + cur_offset, depth
5443        )?;
5444
5445            _prev_end_offset = cur_offset + envelope_size;
5446            if 2 > max_ordinal {
5447                return Ok(());
5448            }
5449
5450            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5451            // are envelope_size bytes.
5452            let cur_offset: usize = (2 - 1) * envelope_size;
5453
5454            // Zero reserved fields.
5455            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5456
5457            // Safety:
5458            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5459            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5460            //   envelope_size bytes, there is always sufficient room.
5461            fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>, fidl::encoding::DefaultFuchsiaResourceDialect>(
5462            self.session_listener.as_mut().map(<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
5463            encoder, offset + cur_offset, depth
5464        )?;
5465
5466            _prev_end_offset = cur_offset + envelope_size;
5467            if 3 > max_ordinal {
5468                return Ok(());
5469            }
5470
5471            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5472            // are envelope_size bytes.
5473            let cur_offset: usize = (3 - 1) * envelope_size;
5474
5475            // Zero reserved fields.
5476            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5477
5478            // Safety:
5479            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5480            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5481            //   envelope_size bytes, there is always sufficient room.
5482            fidl::encoding::encode_in_envelope_optional::<
5483                fidl::encoding::Endpoint<
5484                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
5485                >,
5486                fidl::encoding::DefaultFuchsiaResourceDialect,
5487            >(
5488                self.view_focuser.as_mut().map(
5489                    <fidl::encoding::Endpoint<
5490                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
5491                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5492                ),
5493                encoder,
5494                offset + cur_offset,
5495                depth,
5496            )?;
5497
5498            _prev_end_offset = cur_offset + envelope_size;
5499            if 4 > max_ordinal {
5500                return Ok(());
5501            }
5502
5503            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5504            // are envelope_size bytes.
5505            let cur_offset: usize = (4 - 1) * envelope_size;
5506
5507            // Zero reserved fields.
5508            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5509
5510            // Safety:
5511            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5512            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5513            //   envelope_size bytes, there is always sufficient room.
5514            fidl::encoding::encode_in_envelope_optional::<
5515                fidl::encoding::Endpoint<
5516                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
5517                >,
5518                fidl::encoding::DefaultFuchsiaResourceDialect,
5519            >(
5520                self.view_ref_focused.as_mut().map(
5521                    <fidl::encoding::Endpoint<
5522                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
5523                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5524                ),
5525                encoder,
5526                offset + cur_offset,
5527                depth,
5528            )?;
5529
5530            _prev_end_offset = cur_offset + envelope_size;
5531            if 5 > max_ordinal {
5532                return Ok(());
5533            }
5534
5535            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5536            // are envelope_size bytes.
5537            let cur_offset: usize = (5 - 1) * envelope_size;
5538
5539            // Zero reserved fields.
5540            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5541
5542            // Safety:
5543            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5544            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5545            //   envelope_size bytes, there is always sufficient room.
5546            fidl::encoding::encode_in_envelope_optional::<
5547                fidl::encoding::Endpoint<
5548                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
5549                >,
5550                fidl::encoding::DefaultFuchsiaResourceDialect,
5551            >(
5552                self.touch_source.as_mut().map(
5553                    <fidl::encoding::Endpoint<
5554                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
5555                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5556                ),
5557                encoder,
5558                offset + cur_offset,
5559                depth,
5560            )?;
5561
5562            _prev_end_offset = cur_offset + envelope_size;
5563            if 6 > max_ordinal {
5564                return Ok(());
5565            }
5566
5567            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
5568            // are envelope_size bytes.
5569            let cur_offset: usize = (6 - 1) * envelope_size;
5570
5571            // Zero reserved fields.
5572            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
5573
5574            // Safety:
5575            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
5576            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
5577            //   envelope_size bytes, there is always sufficient room.
5578            fidl::encoding::encode_in_envelope_optional::<
5579                fidl::encoding::Endpoint<
5580                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
5581                >,
5582                fidl::encoding::DefaultFuchsiaResourceDialect,
5583            >(
5584                self.mouse_source.as_mut().map(
5585                    <fidl::encoding::Endpoint<
5586                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
5587                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
5588                ),
5589                encoder,
5590                offset + cur_offset,
5591                depth,
5592            )?;
5593
5594            _prev_end_offset = cur_offset + envelope_size;
5595
5596            Ok(())
5597        }
5598    }
5599
5600    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
5601        for SessionEndpoints
5602    {
5603        #[inline(always)]
5604        fn new_empty() -> Self {
5605            Self::default()
5606        }
5607
5608        unsafe fn decode(
5609            &mut self,
5610            decoder: &mut fidl::encoding::Decoder<
5611                '_,
5612                fidl::encoding::DefaultFuchsiaResourceDialect,
5613            >,
5614            offset: usize,
5615            mut depth: fidl::encoding::Depth,
5616        ) -> fidl::Result<()> {
5617            decoder.debug_check_bounds::<Self>(offset);
5618            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
5619                None => return Err(fidl::Error::NotNullable),
5620                Some(len) => len,
5621            };
5622            // Calling decoder.out_of_line_offset(0) is not allowed.
5623            if len == 0 {
5624                return Ok(());
5625            };
5626            depth.increment()?;
5627            let envelope_size = 8;
5628            let bytes_len = len * envelope_size;
5629            let offset = decoder.out_of_line_offset(bytes_len)?;
5630            // Decode the envelope for each type.
5631            let mut _next_ordinal_to_read = 0;
5632            let mut next_offset = offset;
5633            let end_offset = offset + bytes_len;
5634            _next_ordinal_to_read += 1;
5635            if next_offset >= end_offset {
5636                return Ok(());
5637            }
5638
5639            // Decode unknown envelopes for gaps in ordinals.
5640            while _next_ordinal_to_read < 1 {
5641                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5642                _next_ordinal_to_read += 1;
5643                next_offset += envelope_size;
5644            }
5645
5646            let next_out_of_line = decoder.next_out_of_line();
5647            let handles_before = decoder.remaining_handles();
5648            if let Some((inlined, num_bytes, num_handles)) =
5649                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5650            {
5651                let member_inline_size = <fidl::encoding::Endpoint<
5652                    fidl::endpoints::ServerEnd<SessionMarker>,
5653                > as fidl::encoding::TypeMarker>::inline_size(
5654                    decoder.context
5655                );
5656                if inlined != (member_inline_size <= 4) {
5657                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5658                }
5659                let inner_offset;
5660                let mut inner_depth = depth.clone();
5661                if inlined {
5662                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5663                    inner_offset = next_offset;
5664                } else {
5665                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5666                    inner_depth.increment()?;
5667                }
5668                let val_ref = self.session.get_or_insert_with(|| {
5669                    fidl::new_empty!(
5670                        fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
5671                        fidl::encoding::DefaultFuchsiaResourceDialect
5672                    )
5673                });
5674                fidl::decode!(
5675                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<SessionMarker>>,
5676                    fidl::encoding::DefaultFuchsiaResourceDialect,
5677                    val_ref,
5678                    decoder,
5679                    inner_offset,
5680                    inner_depth
5681                )?;
5682                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5683                {
5684                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5685                }
5686                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5687                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5688                }
5689            }
5690
5691            next_offset += envelope_size;
5692            _next_ordinal_to_read += 1;
5693            if next_offset >= end_offset {
5694                return Ok(());
5695            }
5696
5697            // Decode unknown envelopes for gaps in ordinals.
5698            while _next_ordinal_to_read < 2 {
5699                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5700                _next_ordinal_to_read += 1;
5701                next_offset += envelope_size;
5702            }
5703
5704            let next_out_of_line = decoder.next_out_of_line();
5705            let handles_before = decoder.remaining_handles();
5706            if let Some((inlined, num_bytes, num_handles)) =
5707                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5708            {
5709                let member_inline_size = <fidl::encoding::Endpoint<
5710                    fidl::endpoints::ClientEnd<SessionListenerMarker>,
5711                > as fidl::encoding::TypeMarker>::inline_size(
5712                    decoder.context
5713                );
5714                if inlined != (member_inline_size <= 4) {
5715                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5716                }
5717                let inner_offset;
5718                let mut inner_depth = depth.clone();
5719                if inlined {
5720                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5721                    inner_offset = next_offset;
5722                } else {
5723                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5724                    inner_depth.increment()?;
5725                }
5726                let val_ref = self.session_listener.get_or_insert_with(|| {
5727                    fidl::new_empty!(
5728                        fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
5729                        fidl::encoding::DefaultFuchsiaResourceDialect
5730                    )
5731                });
5732                fidl::decode!(
5733                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<SessionListenerMarker>>,
5734                    fidl::encoding::DefaultFuchsiaResourceDialect,
5735                    val_ref,
5736                    decoder,
5737                    inner_offset,
5738                    inner_depth
5739                )?;
5740                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5741                {
5742                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5743                }
5744                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5745                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5746                }
5747            }
5748
5749            next_offset += envelope_size;
5750            _next_ordinal_to_read += 1;
5751            if next_offset >= end_offset {
5752                return Ok(());
5753            }
5754
5755            // Decode unknown envelopes for gaps in ordinals.
5756            while _next_ordinal_to_read < 3 {
5757                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5758                _next_ordinal_to_read += 1;
5759                next_offset += envelope_size;
5760            }
5761
5762            let next_out_of_line = decoder.next_out_of_line();
5763            let handles_before = decoder.remaining_handles();
5764            if let Some((inlined, num_bytes, num_handles)) =
5765                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5766            {
5767                let member_inline_size = <fidl::encoding::Endpoint<
5768                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
5769                > as fidl::encoding::TypeMarker>::inline_size(
5770                    decoder.context
5771                );
5772                if inlined != (member_inline_size <= 4) {
5773                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5774                }
5775                let inner_offset;
5776                let mut inner_depth = depth.clone();
5777                if inlined {
5778                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5779                    inner_offset = next_offset;
5780                } else {
5781                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5782                    inner_depth.increment()?;
5783                }
5784                let val_ref = self.view_focuser.get_or_insert_with(|| {
5785                    fidl::new_empty!(
5786                        fidl::encoding::Endpoint<
5787                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
5788                        >,
5789                        fidl::encoding::DefaultFuchsiaResourceDialect
5790                    )
5791                });
5792                fidl::decode!(
5793                    fidl::encoding::Endpoint<
5794                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
5795                    >,
5796                    fidl::encoding::DefaultFuchsiaResourceDialect,
5797                    val_ref,
5798                    decoder,
5799                    inner_offset,
5800                    inner_depth
5801                )?;
5802                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5803                {
5804                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5805                }
5806                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5807                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5808                }
5809            }
5810
5811            next_offset += envelope_size;
5812            _next_ordinal_to_read += 1;
5813            if next_offset >= end_offset {
5814                return Ok(());
5815            }
5816
5817            // Decode unknown envelopes for gaps in ordinals.
5818            while _next_ordinal_to_read < 4 {
5819                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5820                _next_ordinal_to_read += 1;
5821                next_offset += envelope_size;
5822            }
5823
5824            let next_out_of_line = decoder.next_out_of_line();
5825            let handles_before = decoder.remaining_handles();
5826            if let Some((inlined, num_bytes, num_handles)) =
5827                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5828            {
5829                let member_inline_size = <fidl::encoding::Endpoint<
5830                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
5831                > as fidl::encoding::TypeMarker>::inline_size(
5832                    decoder.context
5833                );
5834                if inlined != (member_inline_size <= 4) {
5835                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5836                }
5837                let inner_offset;
5838                let mut inner_depth = depth.clone();
5839                if inlined {
5840                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5841                    inner_offset = next_offset;
5842                } else {
5843                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5844                    inner_depth.increment()?;
5845                }
5846                let val_ref = self.view_ref_focused.get_or_insert_with(|| {
5847                    fidl::new_empty!(
5848                        fidl::encoding::Endpoint<
5849                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
5850                        >,
5851                        fidl::encoding::DefaultFuchsiaResourceDialect
5852                    )
5853                });
5854                fidl::decode!(
5855                    fidl::encoding::Endpoint<
5856                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
5857                    >,
5858                    fidl::encoding::DefaultFuchsiaResourceDialect,
5859                    val_ref,
5860                    decoder,
5861                    inner_offset,
5862                    inner_depth
5863                )?;
5864                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5865                {
5866                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5867                }
5868                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5869                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5870                }
5871            }
5872
5873            next_offset += envelope_size;
5874            _next_ordinal_to_read += 1;
5875            if next_offset >= end_offset {
5876                return Ok(());
5877            }
5878
5879            // Decode unknown envelopes for gaps in ordinals.
5880            while _next_ordinal_to_read < 5 {
5881                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5882                _next_ordinal_to_read += 1;
5883                next_offset += envelope_size;
5884            }
5885
5886            let next_out_of_line = decoder.next_out_of_line();
5887            let handles_before = decoder.remaining_handles();
5888            if let Some((inlined, num_bytes, num_handles)) =
5889                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5890            {
5891                let member_inline_size = <fidl::encoding::Endpoint<
5892                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
5893                > as fidl::encoding::TypeMarker>::inline_size(
5894                    decoder.context
5895                );
5896                if inlined != (member_inline_size <= 4) {
5897                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5898                }
5899                let inner_offset;
5900                let mut inner_depth = depth.clone();
5901                if inlined {
5902                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5903                    inner_offset = next_offset;
5904                } else {
5905                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5906                    inner_depth.increment()?;
5907                }
5908                let val_ref = self.touch_source.get_or_insert_with(|| {
5909                    fidl::new_empty!(
5910                        fidl::encoding::Endpoint<
5911                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
5912                        >,
5913                        fidl::encoding::DefaultFuchsiaResourceDialect
5914                    )
5915                });
5916                fidl::decode!(
5917                    fidl::encoding::Endpoint<
5918                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
5919                    >,
5920                    fidl::encoding::DefaultFuchsiaResourceDialect,
5921                    val_ref,
5922                    decoder,
5923                    inner_offset,
5924                    inner_depth
5925                )?;
5926                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5927                {
5928                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5929                }
5930                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5931                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5932                }
5933            }
5934
5935            next_offset += envelope_size;
5936            _next_ordinal_to_read += 1;
5937            if next_offset >= end_offset {
5938                return Ok(());
5939            }
5940
5941            // Decode unknown envelopes for gaps in ordinals.
5942            while _next_ordinal_to_read < 6 {
5943                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
5944                _next_ordinal_to_read += 1;
5945                next_offset += envelope_size;
5946            }
5947
5948            let next_out_of_line = decoder.next_out_of_line();
5949            let handles_before = decoder.remaining_handles();
5950            if let Some((inlined, num_bytes, num_handles)) =
5951                fidl::encoding::decode_envelope_header(decoder, next_offset)?
5952            {
5953                let member_inline_size = <fidl::encoding::Endpoint<
5954                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
5955                > as fidl::encoding::TypeMarker>::inline_size(
5956                    decoder.context
5957                );
5958                if inlined != (member_inline_size <= 4) {
5959                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
5960                }
5961                let inner_offset;
5962                let mut inner_depth = depth.clone();
5963                if inlined {
5964                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
5965                    inner_offset = next_offset;
5966                } else {
5967                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
5968                    inner_depth.increment()?;
5969                }
5970                let val_ref = self.mouse_source.get_or_insert_with(|| {
5971                    fidl::new_empty!(
5972                        fidl::encoding::Endpoint<
5973                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
5974                        >,
5975                        fidl::encoding::DefaultFuchsiaResourceDialect
5976                    )
5977                });
5978                fidl::decode!(
5979                    fidl::encoding::Endpoint<
5980                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
5981                    >,
5982                    fidl::encoding::DefaultFuchsiaResourceDialect,
5983                    val_ref,
5984                    decoder,
5985                    inner_offset,
5986                    inner_depth
5987                )?;
5988                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
5989                {
5990                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
5991                }
5992                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
5993                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
5994                }
5995            }
5996
5997            next_offset += envelope_size;
5998
5999            // Decode the remaining unknown envelopes.
6000            while next_offset < end_offset {
6001                _next_ordinal_to_read += 1;
6002                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
6003                next_offset += envelope_size;
6004            }
6005
6006            Ok(())
6007        }
6008    }
6009
6010    impl fidl::encoding::ResourceTypeMarker for Command {
6011        type Borrowed<'a> = &'a mut Self;
6012        fn take_or_borrow<'a>(
6013            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6014        ) -> Self::Borrowed<'a> {
6015            value
6016        }
6017    }
6018
6019    unsafe impl fidl::encoding::TypeMarker for Command {
6020        type Owned = Self;
6021
6022        #[inline(always)]
6023        fn inline_align(_context: fidl::encoding::Context) -> usize {
6024            8
6025        }
6026
6027        #[inline(always)]
6028        fn inline_size(_context: fidl::encoding::Context) -> usize {
6029            16
6030        }
6031    }
6032
6033    unsafe impl fidl::encoding::Encode<Command, fidl::encoding::DefaultFuchsiaResourceDialect>
6034        for &mut Command
6035    {
6036        #[inline]
6037        unsafe fn encode(
6038            self,
6039            encoder: &mut fidl::encoding::Encoder<
6040                '_,
6041                fidl::encoding::DefaultFuchsiaResourceDialect,
6042            >,
6043            offset: usize,
6044            _depth: fidl::encoding::Depth,
6045        ) -> fidl::Result<()> {
6046            encoder.debug_check_bounds::<Command>(offset);
6047            encoder.write_num::<u64>(self.ordinal(), offset);
6048            match self {
6049            Command::Gfx(ref mut val) => {
6050                fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_gfx::Command, fidl::encoding::DefaultFuchsiaResourceDialect>(
6051                    <fidl_fuchsia_ui_gfx::Command as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
6052                    encoder, offset + 8, _depth
6053                )
6054            }
6055            Command::Views(ref val) => {
6056                fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_views::Command, fidl::encoding::DefaultFuchsiaResourceDialect>(
6057                    <fidl_fuchsia_ui_views::Command as fidl::encoding::ValueTypeMarker>::borrow(val),
6058                    encoder, offset + 8, _depth
6059                )
6060            }
6061            Command::Input(ref val) => {
6062                fidl::encoding::encode_in_envelope::<fidl_fuchsia_ui_input::Command, fidl::encoding::DefaultFuchsiaResourceDialect>(
6063                    <fidl_fuchsia_ui_input::Command as fidl::encoding::ValueTypeMarker>::borrow(val),
6064                    encoder, offset + 8, _depth
6065                )
6066            }
6067        }
6068        }
6069    }
6070
6071    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Command {
6072        #[inline(always)]
6073        fn new_empty() -> Self {
6074            Self::Gfx(fidl::new_empty!(
6075                fidl_fuchsia_ui_gfx::Command,
6076                fidl::encoding::DefaultFuchsiaResourceDialect
6077            ))
6078        }
6079
6080        #[inline]
6081        unsafe fn decode(
6082            &mut self,
6083            decoder: &mut fidl::encoding::Decoder<
6084                '_,
6085                fidl::encoding::DefaultFuchsiaResourceDialect,
6086            >,
6087            offset: usize,
6088            mut depth: fidl::encoding::Depth,
6089        ) -> fidl::Result<()> {
6090            decoder.debug_check_bounds::<Self>(offset);
6091            #[allow(unused_variables)]
6092            let next_out_of_line = decoder.next_out_of_line();
6093            let handles_before = decoder.remaining_handles();
6094            let (ordinal, inlined, num_bytes, num_handles) =
6095                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
6096
6097            let member_inline_size = match ordinal {
6098                1 => <fidl_fuchsia_ui_gfx::Command as fidl::encoding::TypeMarker>::inline_size(
6099                    decoder.context,
6100                ),
6101                3 => <fidl_fuchsia_ui_views::Command as fidl::encoding::TypeMarker>::inline_size(
6102                    decoder.context,
6103                ),
6104                4 => <fidl_fuchsia_ui_input::Command as fidl::encoding::TypeMarker>::inline_size(
6105                    decoder.context,
6106                ),
6107                _ => return Err(fidl::Error::UnknownUnionTag),
6108            };
6109
6110            if inlined != (member_inline_size <= 4) {
6111                return Err(fidl::Error::InvalidInlineBitInEnvelope);
6112            }
6113            let _inner_offset;
6114            if inlined {
6115                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
6116                _inner_offset = offset + 8;
6117            } else {
6118                depth.increment()?;
6119                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6120            }
6121            match ordinal {
6122                1 => {
6123                    #[allow(irrefutable_let_patterns)]
6124                    if let Command::Gfx(_) = self {
6125                        // Do nothing, read the value into the object
6126                    } else {
6127                        // Initialize `self` to the right variant
6128                        *self = Command::Gfx(fidl::new_empty!(
6129                            fidl_fuchsia_ui_gfx::Command,
6130                            fidl::encoding::DefaultFuchsiaResourceDialect
6131                        ));
6132                    }
6133                    #[allow(irrefutable_let_patterns)]
6134                    if let Command::Gfx(ref mut val) = self {
6135                        fidl::decode!(
6136                            fidl_fuchsia_ui_gfx::Command,
6137                            fidl::encoding::DefaultFuchsiaResourceDialect,
6138                            val,
6139                            decoder,
6140                            _inner_offset,
6141                            depth
6142                        )?;
6143                    } else {
6144                        unreachable!()
6145                    }
6146                }
6147                3 => {
6148                    #[allow(irrefutable_let_patterns)]
6149                    if let Command::Views(_) = self {
6150                        // Do nothing, read the value into the object
6151                    } else {
6152                        // Initialize `self` to the right variant
6153                        *self = Command::Views(fidl::new_empty!(
6154                            fidl_fuchsia_ui_views::Command,
6155                            fidl::encoding::DefaultFuchsiaResourceDialect
6156                        ));
6157                    }
6158                    #[allow(irrefutable_let_patterns)]
6159                    if let Command::Views(ref mut val) = self {
6160                        fidl::decode!(
6161                            fidl_fuchsia_ui_views::Command,
6162                            fidl::encoding::DefaultFuchsiaResourceDialect,
6163                            val,
6164                            decoder,
6165                            _inner_offset,
6166                            depth
6167                        )?;
6168                    } else {
6169                        unreachable!()
6170                    }
6171                }
6172                4 => {
6173                    #[allow(irrefutable_let_patterns)]
6174                    if let Command::Input(_) = self {
6175                        // Do nothing, read the value into the object
6176                    } else {
6177                        // Initialize `self` to the right variant
6178                        *self = Command::Input(fidl::new_empty!(
6179                            fidl_fuchsia_ui_input::Command,
6180                            fidl::encoding::DefaultFuchsiaResourceDialect
6181                        ));
6182                    }
6183                    #[allow(irrefutable_let_patterns)]
6184                    if let Command::Input(ref mut val) = self {
6185                        fidl::decode!(
6186                            fidl_fuchsia_ui_input::Command,
6187                            fidl::encoding::DefaultFuchsiaResourceDialect,
6188                            val,
6189                            decoder,
6190                            _inner_offset,
6191                            depth
6192                        )?;
6193                    } else {
6194                        unreachable!()
6195                    }
6196                }
6197                ordinal => panic!("unexpected ordinal {:?}", ordinal),
6198            }
6199            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
6200                return Err(fidl::Error::InvalidNumBytesInEnvelope);
6201            }
6202            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6203                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6204            }
6205            Ok(())
6206        }
6207    }
6208
6209    impl fidl::encoding::ResourceTypeMarker for Event {
6210        type Borrowed<'a> = &'a mut Self;
6211        fn take_or_borrow<'a>(
6212            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
6213        ) -> Self::Borrowed<'a> {
6214            value
6215        }
6216    }
6217
6218    unsafe impl fidl::encoding::TypeMarker for Event {
6219        type Owned = Self;
6220
6221        #[inline(always)]
6222        fn inline_align(_context: fidl::encoding::Context) -> usize {
6223            8
6224        }
6225
6226        #[inline(always)]
6227        fn inline_size(_context: fidl::encoding::Context) -> usize {
6228            16
6229        }
6230    }
6231
6232    unsafe impl fidl::encoding::Encode<Event, fidl::encoding::DefaultFuchsiaResourceDialect>
6233        for &mut Event
6234    {
6235        #[inline]
6236        unsafe fn encode(
6237            self,
6238            encoder: &mut fidl::encoding::Encoder<
6239                '_,
6240                fidl::encoding::DefaultFuchsiaResourceDialect,
6241            >,
6242            offset: usize,
6243            _depth: fidl::encoding::Depth,
6244        ) -> fidl::Result<()> {
6245            encoder.debug_check_bounds::<Event>(offset);
6246            encoder.write_num::<u64>(self.ordinal(), offset);
6247            match self {
6248                Event::Gfx(ref val) => fidl::encoding::encode_in_envelope::<
6249                    fidl_fuchsia_ui_gfx::Event,
6250                    fidl::encoding::DefaultFuchsiaResourceDialect,
6251                >(
6252                    <fidl_fuchsia_ui_gfx::Event as fidl::encoding::ValueTypeMarker>::borrow(val),
6253                    encoder,
6254                    offset + 8,
6255                    _depth,
6256                ),
6257                Event::Input(ref val) => fidl::encoding::encode_in_envelope::<
6258                    fidl_fuchsia_ui_input::InputEvent,
6259                    fidl::encoding::DefaultFuchsiaResourceDialect,
6260                >(
6261                    <fidl_fuchsia_ui_input::InputEvent as fidl::encoding::ValueTypeMarker>::borrow(
6262                        val,
6263                    ),
6264                    encoder,
6265                    offset + 8,
6266                    _depth,
6267                ),
6268                Event::Unhandled(ref mut val) => fidl::encoding::encode_in_envelope::<
6269                    Command,
6270                    fidl::encoding::DefaultFuchsiaResourceDialect,
6271                >(
6272                    <Command as fidl::encoding::ResourceTypeMarker>::take_or_borrow(val),
6273                    encoder,
6274                    offset + 8,
6275                    _depth,
6276                ),
6277            }
6278        }
6279    }
6280
6281    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Event {
6282        #[inline(always)]
6283        fn new_empty() -> Self {
6284            Self::Gfx(fidl::new_empty!(
6285                fidl_fuchsia_ui_gfx::Event,
6286                fidl::encoding::DefaultFuchsiaResourceDialect
6287            ))
6288        }
6289
6290        #[inline]
6291        unsafe fn decode(
6292            &mut self,
6293            decoder: &mut fidl::encoding::Decoder<
6294                '_,
6295                fidl::encoding::DefaultFuchsiaResourceDialect,
6296            >,
6297            offset: usize,
6298            mut depth: fidl::encoding::Depth,
6299        ) -> fidl::Result<()> {
6300            decoder.debug_check_bounds::<Self>(offset);
6301            #[allow(unused_variables)]
6302            let next_out_of_line = decoder.next_out_of_line();
6303            let handles_before = decoder.remaining_handles();
6304            let (ordinal, inlined, num_bytes, num_handles) =
6305                fidl::encoding::decode_union_inline_portion(decoder, offset)?;
6306
6307            let member_inline_size = match ordinal {
6308                1 => <fidl_fuchsia_ui_gfx::Event as fidl::encoding::TypeMarker>::inline_size(
6309                    decoder.context,
6310                ),
6311                2 => {
6312                    <fidl_fuchsia_ui_input::InputEvent as fidl::encoding::TypeMarker>::inline_size(
6313                        decoder.context,
6314                    )
6315                }
6316                3 => <Command as fidl::encoding::TypeMarker>::inline_size(decoder.context),
6317                _ => return Err(fidl::Error::UnknownUnionTag),
6318            };
6319
6320            if inlined != (member_inline_size <= 4) {
6321                return Err(fidl::Error::InvalidInlineBitInEnvelope);
6322            }
6323            let _inner_offset;
6324            if inlined {
6325                decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
6326                _inner_offset = offset + 8;
6327            } else {
6328                depth.increment()?;
6329                _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
6330            }
6331            match ordinal {
6332                1 => {
6333                    #[allow(irrefutable_let_patterns)]
6334                    if let Event::Gfx(_) = self {
6335                        // Do nothing, read the value into the object
6336                    } else {
6337                        // Initialize `self` to the right variant
6338                        *self = Event::Gfx(fidl::new_empty!(
6339                            fidl_fuchsia_ui_gfx::Event,
6340                            fidl::encoding::DefaultFuchsiaResourceDialect
6341                        ));
6342                    }
6343                    #[allow(irrefutable_let_patterns)]
6344                    if let Event::Gfx(ref mut val) = self {
6345                        fidl::decode!(
6346                            fidl_fuchsia_ui_gfx::Event,
6347                            fidl::encoding::DefaultFuchsiaResourceDialect,
6348                            val,
6349                            decoder,
6350                            _inner_offset,
6351                            depth
6352                        )?;
6353                    } else {
6354                        unreachable!()
6355                    }
6356                }
6357                2 => {
6358                    #[allow(irrefutable_let_patterns)]
6359                    if let Event::Input(_) = self {
6360                        // Do nothing, read the value into the object
6361                    } else {
6362                        // Initialize `self` to the right variant
6363                        *self = Event::Input(fidl::new_empty!(
6364                            fidl_fuchsia_ui_input::InputEvent,
6365                            fidl::encoding::DefaultFuchsiaResourceDialect
6366                        ));
6367                    }
6368                    #[allow(irrefutable_let_patterns)]
6369                    if let Event::Input(ref mut val) = self {
6370                        fidl::decode!(
6371                            fidl_fuchsia_ui_input::InputEvent,
6372                            fidl::encoding::DefaultFuchsiaResourceDialect,
6373                            val,
6374                            decoder,
6375                            _inner_offset,
6376                            depth
6377                        )?;
6378                    } else {
6379                        unreachable!()
6380                    }
6381                }
6382                3 => {
6383                    #[allow(irrefutable_let_patterns)]
6384                    if let Event::Unhandled(_) = self {
6385                        // Do nothing, read the value into the object
6386                    } else {
6387                        // Initialize `self` to the right variant
6388                        *self = Event::Unhandled(fidl::new_empty!(
6389                            Command,
6390                            fidl::encoding::DefaultFuchsiaResourceDialect
6391                        ));
6392                    }
6393                    #[allow(irrefutable_let_patterns)]
6394                    if let Event::Unhandled(ref mut val) = self {
6395                        fidl::decode!(
6396                            Command,
6397                            fidl::encoding::DefaultFuchsiaResourceDialect,
6398                            val,
6399                            decoder,
6400                            _inner_offset,
6401                            depth
6402                        )?;
6403                    } else {
6404                        unreachable!()
6405                    }
6406                }
6407                ordinal => panic!("unexpected ordinal {:?}", ordinal),
6408            }
6409            if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
6410                return Err(fidl::Error::InvalidNumBytesInEnvelope);
6411            }
6412            if handles_before != decoder.remaining_handles() + (num_handles as usize) {
6413                return Err(fidl::Error::InvalidNumHandlesInEnvelope);
6414            }
6415            Ok(())
6416        }
6417    }
6418}