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