Skip to main content

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