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