fidl_fuchsia_ui_scenic/
fidl_fuchsia_ui_scenic.rs

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