fidl_fuchsia_ui_composition/
fidl_fuchsia_ui_composition.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_composition__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct AllocatorRegisterBufferCollectionRequest {
16    pub args: RegisterBufferCollectionArgs,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for AllocatorRegisterBufferCollectionRequest
21{
22}
23
24/// A typed wrapper for an eventpair, representing the registry endpoint of a buffer collection.
25#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
26pub struct BufferCollectionExportToken {
27    pub value: fidl::EventPair,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
31    for BufferCollectionExportToken
32{
33}
34
35/// A typed wrapper for an eventpair, representing the Image import endpoint of a buffer
36/// collection.
37#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
38pub struct BufferCollectionImportToken {
39    pub value: fidl::EventPair,
40}
41
42impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
43    for BufferCollectionImportToken
44{
45}
46
47#[derive(Debug, PartialEq)]
48pub struct ChildViewWatcherGetViewRefResponse {
49    pub view_ref: fidl_fuchsia_ui_views::ViewRef,
50}
51
52impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
53    for ChildViewWatcherGetViewRefResponse
54{
55}
56
57#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
58#[repr(C)]
59pub struct FlatlandCreateFilledRectRequest {
60    pub rect_id: ContentId,
61}
62
63impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
64    for FlatlandCreateFilledRectRequest
65{
66}
67
68#[derive(Debug, PartialEq)]
69pub struct FlatlandCreateImageRequest {
70    pub image_id: ContentId,
71    pub import_token: BufferCollectionImportToken,
72    pub vmo_index: u32,
73    pub properties: ImageProperties,
74}
75
76impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
77    for FlatlandCreateImageRequest
78{
79}
80
81#[derive(Debug, PartialEq)]
82pub struct FlatlandCreateView2Request {
83    /// A typed wrapper for a channel, representing the child endpoint of the connection
84    /// between two Flatland instances.
85    pub token: fidl_fuchsia_ui_views::ViewCreationToken,
86    /// The ViewRef to strongly associate with [`token`].
87    pub view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
88    /// The protocol endpoints that are strongly bound to the ViewRef in [`view_identity`].
89    /// The protocols are bound when the view is created and installed in the view tree.
90    pub protocols: ViewBoundProtocols,
91    pub parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
92}
93
94impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
95    for FlatlandCreateView2Request
96{
97}
98
99#[derive(Debug, PartialEq)]
100pub struct FlatlandCreateViewRequest {
101    pub token: fidl_fuchsia_ui_views::ViewCreationToken,
102    pub parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
103}
104
105impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FlatlandCreateViewRequest {}
106
107#[derive(Debug, PartialEq)]
108pub struct FlatlandCreateViewportRequest {
109    pub viewport_id: ContentId,
110    /// A typed wrapper for a channel, representing the parent endpoint of the connection
111    /// between two Flatland instances.
112    pub token: fidl_fuchsia_ui_views::ViewportCreationToken,
113    pub properties: ViewportProperties,
114    pub child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
115}
116
117impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
118    for FlatlandCreateViewportRequest
119{
120}
121
122#[derive(Debug, PartialEq)]
123pub struct FlatlandDisplaySetContentRequest {
124    pub token: fidl_fuchsia_ui_views::ViewportCreationToken,
125    pub child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
126}
127
128impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
129    for FlatlandDisplaySetContentRequest
130{
131}
132
133#[derive(Debug, PartialEq)]
134pub struct FlatlandPresentRequest {
135    pub args: PresentArgs,
136}
137
138impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FlatlandPresentRequest {}
139
140#[derive(Debug, PartialEq)]
141pub struct FlatlandReleaseViewportResponse {
142    pub token: fidl_fuchsia_ui_views::ViewportCreationToken,
143}
144
145impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
146    for FlatlandReleaseViewportResponse
147{
148}
149
150#[derive(Debug, PartialEq)]
151pub struct FlatlandSetSolidFillRequest {
152    pub rect_id: ContentId,
153    pub color: ColorRgba,
154    pub size: fidl_fuchsia_math::SizeU,
155}
156
157impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
158    for FlatlandSetSolidFillRequest
159{
160}
161
162/// Metadata about the frame rendered by [`GetNextFrame`].
163#[derive(Debug, Default, PartialEq)]
164pub struct FrameInfo {
165    /// The index of the VMO where the requested frame has been rendered. Required.
166    pub buffer_id: Option<u32>,
167    #[doc(hidden)]
168    pub __source_breaking: fidl::marker::SourceBreaking,
169}
170
171impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {}
172
173/// The arguments passed into the [`GetNextFrame`] call. All fields are necessary.
174#[derive(Debug, Default, PartialEq)]
175pub struct GetNextFrameArgs {
176    /// The event that will signal when the requested frame has been rendered. Required.
177    pub event: Option<fidl::Event>,
178    #[doc(hidden)]
179    pub __source_breaking: fidl::marker::SourceBreaking,
180}
181
182impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for GetNextFrameArgs {}
183
184/// Arguments passed into [`Present`]. All arguments are optional, and if an
185/// argument is omitted Flatland will use a reasonable default, specified below.
186#[derive(Debug, Default, PartialEq)]
187pub struct PresentArgs {
188    /// `requested_presentation_time` specifies the time on or after which the client would like the
189    /// enqueued operations to take visible effect (light up pixels on the screen), expressed in
190    /// nanoseconds in the `CLOCK_MONOTONIC` timebase.
191    ///
192    /// The default `requested_presentation_time` is 0.
193    ///
194    /// Using a `requested_presentation_time` in the present or past (such as 0) schedules enqueued
195    /// operations to take visible effect as soon as possible, during the next frame to be prepared.
196    ///
197    /// Using a `requested_presentation_time` in the future schedules the enqueued operations to
198    /// take visible effect on or as closely as possible after the stated time, but no earlier.
199    ///
200    /// Each rendered frame has a target presentation time. This is when Flatland aims to have the
201    /// frame presented to the user. Before rendering a frame, Flatland applies all
202    /// enqueued operations associated with all squashable calls to [`Present`] whose
203    /// `requested_presentation_time` is on or before the frame's target presentation time.
204    pub requested_presentation_time: Option<i64>,
205    /// Flatland will wait until all of a Flatland instance's `acquire_fences` are ready before it
206    /// will execute the presented commands. Not signaling `acquire_fences` will block the current
207    /// [`Present`] as well as the following ones even if their `acquire_fences` are signaled.
208    ///
209    /// The default `acquire_fences` value is the empty vector.
210    pub acquire_fences: Option<Vec<fidl::Event>>,
211    /// Flatland will signal all `release_fences` when it is safe to reuse resources which no longer
212    /// appear in the local scene graph at the time of the current [`Present`].  At the latest, this
213    /// will happen when the local scene graph (checkpointed at this [`Present`]) has been
214    /// integrated into the global scene graph, and the global scene has been displayed on screen.
215    ///
216    /// (Under some circumstances, the fences may be signaled earlier, but clients do not need to
217    /// worry about this: the fences will only be signaled when it is safe to reuse the associated
218    /// resources).
219    ///
220    /// These fences are intended to manage the reuse of shared memory resources such as sysmem
221    /// buffers.  For example, it is undesirable for the client to render into an image which is
222    /// currently displayed on screen, because this may result in graphical artifacts such as
223    /// tearing.
224    ///
225    /// It is up to the client to maintain the mapping between each fence and the resources which
226    /// will become reusable when the fence is signaled.  A common strategy is to keep track of
227    /// resources which were used by the previous [`Present`] but are no longer used by the current
228    /// [`Present`].  For example, if an image is removed from the scene by the current [`Present`],
229    /// the client would insert a fence here.  When the fence is later signaled, the client knows
230    /// that it is safe to render into the image and insert it into the local scene graph in a
231    /// subsequent [`Present`].
232    ///
233    /// If an error occurs, Flatland may close the channel without signaling these fences.  Clients
234    /// may immediately release shared buffers, but they should not immediately modify such buffers,
235    /// because they may still be displayed on screen.  There is currently no good signal available
236    /// to the client about when it is safe to reuse shared buffers.
237    ///
238    /// The default `release_fences` value is the empty vector.
239    pub release_fences: Option<Vec<fidl::Event>>,
240    /// If `unsquashable` is true, then the update is guaranteed to be uniquely shown for at
241    /// least one vsync interval.
242    ///
243    /// If `unsquashable` is false, then the update can be combined with those that come after
244    /// it.
245    ///
246    /// If absent, `unsquashable` is false.
247    pub unsquashable: Option<bool>,
248    /// Unused.  Originally intended to be a renaming of `acquire_fences`, but was never hooked up.
249    pub server_wait_fences: Option<Vec<fidl::Event>>,
250    /// Unused.  Originally intended to be a renaming of `release_fences`, but was never hooked up.
251    pub server_signal_fences: Option<Vec<fidl::Event>>,
252    #[doc(hidden)]
253    pub __source_breaking: fidl::marker::SourceBreaking,
254}
255
256impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for PresentArgs {}
257
258/// The table of arguments for [`RegisterBufferCollection`]. Note that some
259/// fields below are REQUIRED.
260#[derive(Debug, Default, PartialEq)]
261pub struct RegisterBufferCollectionArgs {
262    /// Clients can send [`export_token`] to register buffer collections with Allocator to be used
263    /// later in [`fuchsia.ui.composition/Flatland`] instances or other Scenic APIs, such as
264    /// Screenshot.
265    ///
266    /// For example, by passing a [`BufferCollectionImportToken`] containing the matching peer of
267    /// [`BufferCollectionExportToken`], they can create image resources via
268    /// [`fuchsia.ui.composition/Flatland.CreateImage`].
269    ///
270    /// Clients should wait for the response before using `import_token`.
271    ///
272    /// This field is REQUIRED.
273    pub export_token: Option<BufferCollectionExportToken>,
274    pub buffer_collection_token:
275        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>>,
276    /// The client can register a buffer collection for various uses, each
277    /// coming with their own unique constraints.
278    ///
279    /// This field is OPTIONAL. If `usage` is omitted it will be treated as if
280    /// it has the DEFAULT option.
281    ///
282    /// # Deprecation
283    ///
284    /// This arg is deprecated at API version 9 with addition of |usages|.
285    ///
286    /// If both the `usages` and `usage` fields are set, `usages` takes precedence and `usage` is
287    /// ignored.
288    pub usage: Option<RegisterBufferCollectionUsage>,
289    /// The client can register a buffer collection for various uses and has the ability to
290    /// combine usages if multiple are needed.
291    ///
292    /// This field is OPTIONAL. If `usages` is omitted it will be treated as if
293    /// it has only the DEFAULT option.
294    pub usages: Option<RegisterBufferCollectionUsages>,
295    /// Flatland participates in the allocation of buffers by setting constraints on the
296    /// BufferCollection referenced by `buffer_collection_token`. It will not block on buffers
297    /// being allocated until the client creates content using the BufferCollection.
298    ///
299    /// The buffer collection registered with `export_token` is available and kept alive as long
300    /// as the client holds a valid [`BufferCollectionImportToken`]. They will be garbage collected
301    /// when all [`BufferCollectionImportToken`]s are closed and all the associated Image resources
302    /// are released.
303    ///
304    /// Exactly one of `buffer_collection_token2` / `buffer_collection_token` must be set.
305    pub buffer_collection_token2:
306        Option<fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>>,
307    #[doc(hidden)]
308    pub __source_breaking: fidl::marker::SourceBreaking,
309}
310
311impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
312    for RegisterBufferCollectionArgs
313{
314}
315
316/// The arguments passed into the [`Configure`] call. Note that not all fields are necessary.
317#[derive(Debug, Default, PartialEq)]
318pub struct ScreenCaptureConfig {
319    /// The import token referencing a BufferCollection registered with
320    /// Allocator. Required.
321    pub import_token: Option<BufferCollectionImportToken>,
322    /// The size of the image in pixels. Required.
323    pub size: Option<fidl_fuchsia_math::SizeU>,
324    /// The number of buffers in the BufferCollection. Required.
325    pub buffer_count: Option<u32>,
326    /// The rotation to be applied to the stream of images. Optional; if absent no rotation is
327    /// applied.
328    pub rotation: Option<Rotation>,
329    #[doc(hidden)]
330    pub __source_breaking: fidl::marker::SourceBreaking,
331}
332
333impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenCaptureConfig {}
334
335#[derive(Debug, Default, PartialEq)]
336pub struct ScreenshotTakeFileRequest {
337    /// Format of the requested screenshot.
338    pub format: Option<ScreenshotFormat>,
339    #[doc(hidden)]
340    pub __source_breaking: fidl::marker::SourceBreaking,
341}
342
343impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeFileRequest {}
344
345#[derive(Debug, Default, PartialEq)]
346pub struct ScreenshotTakeFileResponse {
347    /// |fuchsia.io.File| channel used to read the generated screenshot file data.
348    /// The server side of the channel is stored on the device until ZX_CHANNEL_PEER_CLOSED
349    /// is detected.
350    ///
351    /// Basic usage: After the client recieves the client end of the file channel,
352    /// to avoid memory pile-ups, it should finish reading the data
353    /// before calling [`TakeFile`] again. When finished reading,
354    /// the client should call [`Close`] on the |fuchsia.io.File| channel, this will release
355    /// the memory allocated on the server side.
356    pub file: Option<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
357    /// Size of the screenshot in pixels.
358    pub size: Option<fidl_fuchsia_math::SizeU>,
359    #[doc(hidden)]
360    pub __source_breaking: fidl::marker::SourceBreaking,
361}
362
363impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
364    for ScreenshotTakeFileResponse
365{
366}
367
368#[derive(Debug, Default, PartialEq)]
369pub struct ScreenshotTakeRequest {
370    /// Format of the requested screenshot.
371    pub format: Option<ScreenshotFormat>,
372    #[doc(hidden)]
373    pub __source_breaking: fidl::marker::SourceBreaking,
374}
375
376impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeRequest {}
377
378#[derive(Debug, Default, PartialEq)]
379pub struct ScreenshotTakeResponse {
380    /// CPU mappable read-only VMO that contains screenshot data. The server owns the VMO and
381    /// may reuse for the next [`Take`]. The VMO is guaranteed to be accessible after mapping.
382    /// In some allocations, VMO::read() might not be available, i.e. on emulator.
383    ///
384    /// Basic usage: After the client receives a VMO handle, to ensure data stability, it should
385    /// finish reading the VMO before calling [`Take`] again. When finished reading, the client
386    /// should drop the VMO handle.
387    ///
388    /// Advanced usage: To edit the data, or to persist it beyond the next [`Take`] call, the
389    /// client should copy the data to a private VMO.
390    pub vmo: Option<fidl::Vmo>,
391    /// Size of the screenshot in pixels.
392    pub size: Option<fidl_fuchsia_math::SizeU>,
393    #[doc(hidden)]
394    pub __source_breaking: fidl::marker::SourceBreaking,
395}
396
397impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ScreenshotTakeResponse {}
398
399/// The protocol endpoints bound to a Flatland ViewCreationToken. These protocols operate on the
400/// View that ViewCreationToken created in the Flatland session.
401#[derive(Debug, Default, PartialEq)]
402pub struct ViewBoundProtocols {
403    /// Learn when a View gains focus.
404    ///
405    /// Server-bound ViewRef. The [`view_ref_focused`] client does not specify the ViewRef
406    /// explicitly; instead, the server implementation uses the ViewRef used in View creation for
407    /// reporting focus movement on/off this View.
408    pub view_ref_focused:
409        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>>,
410    /// Enable a View to request focus transfer to a child (target) View.
411    ///
412    /// Server-bound ViewRef. The [`view_focuser`] client does not specify the "requestor" ViewRef
413    /// explicitly, only the "target" ViewRef. Instead, the server implementation uses the ViewRef
414    /// used in View creation as the "requestor" ViewRef.
415    pub view_focuser: Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>>,
416    /// Receive touch events that are associated with a View.
417    pub touch_source:
418        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>>,
419    /// Receive mouse events that are associated with a View.
420    pub mouse_source:
421        Option<fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>>,
422    #[doc(hidden)]
423    pub __source_breaking: fidl::marker::SourceBreaking,
424}
425
426impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ViewBoundProtocols {}
427
428#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
429pub struct AllocatorMarker;
430
431impl fidl::endpoints::ProtocolMarker for AllocatorMarker {
432    type Proxy = AllocatorProxy;
433    type RequestStream = AllocatorRequestStream;
434    #[cfg(target_os = "fuchsia")]
435    type SynchronousProxy = AllocatorSynchronousProxy;
436
437    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Allocator";
438}
439impl fidl::endpoints::DiscoverableProtocolMarker for AllocatorMarker {}
440pub type AllocatorRegisterBufferCollectionResult = Result<(), RegisterBufferCollectionError>;
441
442pub trait AllocatorProxyInterface: Send + Sync {
443    type RegisterBufferCollectionResponseFut: std::future::Future<Output = Result<AllocatorRegisterBufferCollectionResult, fidl::Error>>
444        + Send;
445    fn r#register_buffer_collection(
446        &self,
447        args: RegisterBufferCollectionArgs,
448    ) -> Self::RegisterBufferCollectionResponseFut;
449}
450#[derive(Debug)]
451#[cfg(target_os = "fuchsia")]
452pub struct AllocatorSynchronousProxy {
453    client: fidl::client::sync::Client,
454}
455
456#[cfg(target_os = "fuchsia")]
457impl fidl::endpoints::SynchronousProxy for AllocatorSynchronousProxy {
458    type Proxy = AllocatorProxy;
459    type Protocol = AllocatorMarker;
460
461    fn from_channel(inner: fidl::Channel) -> Self {
462        Self::new(inner)
463    }
464
465    fn into_channel(self) -> fidl::Channel {
466        self.client.into_channel()
467    }
468
469    fn as_channel(&self) -> &fidl::Channel {
470        self.client.as_channel()
471    }
472}
473
474#[cfg(target_os = "fuchsia")]
475impl AllocatorSynchronousProxy {
476    pub fn new(channel: fidl::Channel) -> Self {
477        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
478        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
479    }
480
481    pub fn into_channel(self) -> fidl::Channel {
482        self.client.into_channel()
483    }
484
485    /// Waits until an event arrives and returns it. It is safe for other
486    /// threads to make concurrent requests while waiting for an event.
487    pub fn wait_for_event(
488        &self,
489        deadline: zx::MonotonicInstant,
490    ) -> Result<AllocatorEvent, fidl::Error> {
491        AllocatorEvent::decode(self.client.wait_for_event(deadline)?)
492    }
493
494    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
495    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
496    /// BufferCollection as their backing memory.
497    ///
498    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
499    pub fn r#register_buffer_collection(
500        &self,
501        mut args: RegisterBufferCollectionArgs,
502        ___deadline: zx::MonotonicInstant,
503    ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
504        let _response = self
505            .client
506            .send_query::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::ResultType<
507                fidl::encoding::EmptyStruct,
508                RegisterBufferCollectionError,
509            >>(
510                (&mut args,),
511                0x494b7ea578d1061e,
512                fidl::encoding::DynamicFlags::empty(),
513                ___deadline,
514            )?;
515        Ok(_response.map(|x| x))
516    }
517}
518
519#[cfg(target_os = "fuchsia")]
520impl From<AllocatorSynchronousProxy> for zx::Handle {
521    fn from(value: AllocatorSynchronousProxy) -> Self {
522        value.into_channel().into()
523    }
524}
525
526#[cfg(target_os = "fuchsia")]
527impl From<fidl::Channel> for AllocatorSynchronousProxy {
528    fn from(value: fidl::Channel) -> Self {
529        Self::new(value)
530    }
531}
532
533#[cfg(target_os = "fuchsia")]
534impl fidl::endpoints::FromClient for AllocatorSynchronousProxy {
535    type Protocol = AllocatorMarker;
536
537    fn from_client(value: fidl::endpoints::ClientEnd<AllocatorMarker>) -> Self {
538        Self::new(value.into_channel())
539    }
540}
541
542#[derive(Debug, Clone)]
543pub struct AllocatorProxy {
544    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
545}
546
547impl fidl::endpoints::Proxy for AllocatorProxy {
548    type Protocol = AllocatorMarker;
549
550    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
551        Self::new(inner)
552    }
553
554    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
555        self.client.into_channel().map_err(|client| Self { client })
556    }
557
558    fn as_channel(&self) -> &::fidl::AsyncChannel {
559        self.client.as_channel()
560    }
561}
562
563impl AllocatorProxy {
564    /// Create a new Proxy for fuchsia.ui.composition/Allocator.
565    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
566        let protocol_name = <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
567        Self { client: fidl::client::Client::new(channel, protocol_name) }
568    }
569
570    /// Get a Stream of events from the remote end of the protocol.
571    ///
572    /// # Panics
573    ///
574    /// Panics if the event stream was already taken.
575    pub fn take_event_stream(&self) -> AllocatorEventStream {
576        AllocatorEventStream { event_receiver: self.client.take_event_receiver() }
577    }
578
579    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
580    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
581    /// BufferCollection as their backing memory.
582    ///
583    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
584    pub fn r#register_buffer_collection(
585        &self,
586        mut args: RegisterBufferCollectionArgs,
587    ) -> fidl::client::QueryResponseFut<
588        AllocatorRegisterBufferCollectionResult,
589        fidl::encoding::DefaultFuchsiaResourceDialect,
590    > {
591        AllocatorProxyInterface::r#register_buffer_collection(self, args)
592    }
593}
594
595impl AllocatorProxyInterface for AllocatorProxy {
596    type RegisterBufferCollectionResponseFut = fidl::client::QueryResponseFut<
597        AllocatorRegisterBufferCollectionResult,
598        fidl::encoding::DefaultFuchsiaResourceDialect,
599    >;
600    fn r#register_buffer_collection(
601        &self,
602        mut args: RegisterBufferCollectionArgs,
603    ) -> Self::RegisterBufferCollectionResponseFut {
604        fn _decode(
605            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
606        ) -> Result<AllocatorRegisterBufferCollectionResult, fidl::Error> {
607            let _response = fidl::client::decode_transaction_body::<
608                fidl::encoding::ResultType<
609                    fidl::encoding::EmptyStruct,
610                    RegisterBufferCollectionError,
611                >,
612                fidl::encoding::DefaultFuchsiaResourceDialect,
613                0x494b7ea578d1061e,
614            >(_buf?)?;
615            Ok(_response.map(|x| x))
616        }
617        self.client.send_query_and_decode::<
618            AllocatorRegisterBufferCollectionRequest,
619            AllocatorRegisterBufferCollectionResult,
620        >(
621            (&mut args,),
622            0x494b7ea578d1061e,
623            fidl::encoding::DynamicFlags::empty(),
624            _decode,
625        )
626    }
627}
628
629pub struct AllocatorEventStream {
630    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
631}
632
633impl std::marker::Unpin for AllocatorEventStream {}
634
635impl futures::stream::FusedStream for AllocatorEventStream {
636    fn is_terminated(&self) -> bool {
637        self.event_receiver.is_terminated()
638    }
639}
640
641impl futures::Stream for AllocatorEventStream {
642    type Item = Result<AllocatorEvent, fidl::Error>;
643
644    fn poll_next(
645        mut self: std::pin::Pin<&mut Self>,
646        cx: &mut std::task::Context<'_>,
647    ) -> std::task::Poll<Option<Self::Item>> {
648        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
649            &mut self.event_receiver,
650            cx
651        )?) {
652            Some(buf) => std::task::Poll::Ready(Some(AllocatorEvent::decode(buf))),
653            None => std::task::Poll::Ready(None),
654        }
655    }
656}
657
658#[derive(Debug)]
659pub enum AllocatorEvent {}
660
661impl AllocatorEvent {
662    /// Decodes a message buffer as a [`AllocatorEvent`].
663    fn decode(
664        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
665    ) -> Result<AllocatorEvent, fidl::Error> {
666        let (bytes, _handles) = buf.split_mut();
667        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
668        debug_assert_eq!(tx_header.tx_id, 0);
669        match tx_header.ordinal {
670            _ => Err(fidl::Error::UnknownOrdinal {
671                ordinal: tx_header.ordinal,
672                protocol_name: <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
673            }),
674        }
675    }
676}
677
678/// A Stream of incoming requests for fuchsia.ui.composition/Allocator.
679pub struct AllocatorRequestStream {
680    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
681    is_terminated: bool,
682}
683
684impl std::marker::Unpin for AllocatorRequestStream {}
685
686impl futures::stream::FusedStream for AllocatorRequestStream {
687    fn is_terminated(&self) -> bool {
688        self.is_terminated
689    }
690}
691
692impl fidl::endpoints::RequestStream for AllocatorRequestStream {
693    type Protocol = AllocatorMarker;
694    type ControlHandle = AllocatorControlHandle;
695
696    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
697        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
698    }
699
700    fn control_handle(&self) -> Self::ControlHandle {
701        AllocatorControlHandle { inner: self.inner.clone() }
702    }
703
704    fn into_inner(
705        self,
706    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
707    {
708        (self.inner, self.is_terminated)
709    }
710
711    fn from_inner(
712        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
713        is_terminated: bool,
714    ) -> Self {
715        Self { inner, is_terminated }
716    }
717}
718
719impl futures::Stream for AllocatorRequestStream {
720    type Item = Result<AllocatorRequest, fidl::Error>;
721
722    fn poll_next(
723        mut self: std::pin::Pin<&mut Self>,
724        cx: &mut std::task::Context<'_>,
725    ) -> std::task::Poll<Option<Self::Item>> {
726        let this = &mut *self;
727        if this.inner.check_shutdown(cx) {
728            this.is_terminated = true;
729            return std::task::Poll::Ready(None);
730        }
731        if this.is_terminated {
732            panic!("polled AllocatorRequestStream after completion");
733        }
734        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
735            |bytes, handles| {
736                match this.inner.channel().read_etc(cx, bytes, handles) {
737                    std::task::Poll::Ready(Ok(())) => {}
738                    std::task::Poll::Pending => return std::task::Poll::Pending,
739                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
740                        this.is_terminated = true;
741                        return std::task::Poll::Ready(None);
742                    }
743                    std::task::Poll::Ready(Err(e)) => {
744                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
745                            e.into(),
746                        ))))
747                    }
748                }
749
750                // A message has been received from the channel
751                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
752
753                std::task::Poll::Ready(Some(match header.ordinal {
754                    0x494b7ea578d1061e => {
755                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
756                        let mut req = fidl::new_empty!(
757                            AllocatorRegisterBufferCollectionRequest,
758                            fidl::encoding::DefaultFuchsiaResourceDialect
759                        );
760                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<AllocatorRegisterBufferCollectionRequest>(&header, _body_bytes, handles, &mut req)?;
761                        let control_handle = AllocatorControlHandle { inner: this.inner.clone() };
762                        Ok(AllocatorRequest::RegisterBufferCollection {
763                            args: req.args,
764
765                            responder: AllocatorRegisterBufferCollectionResponder {
766                                control_handle: std::mem::ManuallyDrop::new(control_handle),
767                                tx_id: header.tx_id,
768                            },
769                        })
770                    }
771                    _ => Err(fidl::Error::UnknownOrdinal {
772                        ordinal: header.ordinal,
773                        protocol_name:
774                            <AllocatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
775                    }),
776                }))
777            },
778        )
779    }
780}
781
782#[derive(Debug)]
783pub enum AllocatorRequest {
784    /// A BufferCollection is a set of VMOs created by Sysmem and shared by a number of
785    /// participants, one of which is the Flatland Renderer. Some content, such as Images, use a
786    /// BufferCollection as their backing memory.
787    ///
788    /// See [`RegisterBufferCollectionArgs`] for information on each argument.
789    RegisterBufferCollection {
790        args: RegisterBufferCollectionArgs,
791        responder: AllocatorRegisterBufferCollectionResponder,
792    },
793}
794
795impl AllocatorRequest {
796    #[allow(irrefutable_let_patterns)]
797    pub fn into_register_buffer_collection(
798        self,
799    ) -> Option<(RegisterBufferCollectionArgs, AllocatorRegisterBufferCollectionResponder)> {
800        if let AllocatorRequest::RegisterBufferCollection { args, responder } = self {
801            Some((args, responder))
802        } else {
803            None
804        }
805    }
806
807    /// Name of the method defined in FIDL
808    pub fn method_name(&self) -> &'static str {
809        match *self {
810            AllocatorRequest::RegisterBufferCollection { .. } => "register_buffer_collection",
811        }
812    }
813}
814
815#[derive(Debug, Clone)]
816pub struct AllocatorControlHandle {
817    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
818}
819
820impl fidl::endpoints::ControlHandle for AllocatorControlHandle {
821    fn shutdown(&self) {
822        self.inner.shutdown()
823    }
824    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
825        self.inner.shutdown_with_epitaph(status)
826    }
827
828    fn is_closed(&self) -> bool {
829        self.inner.channel().is_closed()
830    }
831    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
832        self.inner.channel().on_closed()
833    }
834
835    #[cfg(target_os = "fuchsia")]
836    fn signal_peer(
837        &self,
838        clear_mask: zx::Signals,
839        set_mask: zx::Signals,
840    ) -> Result<(), zx_status::Status> {
841        use fidl::Peered;
842        self.inner.channel().signal_peer(clear_mask, set_mask)
843    }
844}
845
846impl AllocatorControlHandle {}
847
848#[must_use = "FIDL methods require a response to be sent"]
849#[derive(Debug)]
850pub struct AllocatorRegisterBufferCollectionResponder {
851    control_handle: std::mem::ManuallyDrop<AllocatorControlHandle>,
852    tx_id: u32,
853}
854
855/// Set the the channel to be shutdown (see [`AllocatorControlHandle::shutdown`])
856/// if the responder is dropped without sending a response, so that the client
857/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
858impl std::ops::Drop for AllocatorRegisterBufferCollectionResponder {
859    fn drop(&mut self) {
860        self.control_handle.shutdown();
861        // Safety: drops once, never accessed again
862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
863    }
864}
865
866impl fidl::endpoints::Responder for AllocatorRegisterBufferCollectionResponder {
867    type ControlHandle = AllocatorControlHandle;
868
869    fn control_handle(&self) -> &AllocatorControlHandle {
870        &self.control_handle
871    }
872
873    fn drop_without_shutdown(mut self) {
874        // Safety: drops once, never accessed again due to mem::forget
875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
876        // Prevent Drop from running (which would shut down the channel)
877        std::mem::forget(self);
878    }
879}
880
881impl AllocatorRegisterBufferCollectionResponder {
882    /// Sends a response to the FIDL transaction.
883    ///
884    /// Sets the channel to shutdown if an error occurs.
885    pub fn send(
886        self,
887        mut result: Result<(), RegisterBufferCollectionError>,
888    ) -> Result<(), fidl::Error> {
889        let _result = self.send_raw(result);
890        if _result.is_err() {
891            self.control_handle.shutdown();
892        }
893        self.drop_without_shutdown();
894        _result
895    }
896
897    /// Similar to "send" but does not shutdown the channel if an error occurs.
898    pub fn send_no_shutdown_on_err(
899        self,
900        mut result: Result<(), RegisterBufferCollectionError>,
901    ) -> Result<(), fidl::Error> {
902        let _result = self.send_raw(result);
903        self.drop_without_shutdown();
904        _result
905    }
906
907    fn send_raw(
908        &self,
909        mut result: Result<(), RegisterBufferCollectionError>,
910    ) -> Result<(), fidl::Error> {
911        self.control_handle.inner.send::<fidl::encoding::ResultType<
912            fidl::encoding::EmptyStruct,
913            RegisterBufferCollectionError,
914        >>(
915            result,
916            self.tx_id,
917            0x494b7ea578d1061e,
918            fidl::encoding::DynamicFlags::empty(),
919        )
920    }
921}
922
923#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
924pub struct ChildViewWatcherMarker;
925
926impl fidl::endpoints::ProtocolMarker for ChildViewWatcherMarker {
927    type Proxy = ChildViewWatcherProxy;
928    type RequestStream = ChildViewWatcherRequestStream;
929    #[cfg(target_os = "fuchsia")]
930    type SynchronousProxy = ChildViewWatcherSynchronousProxy;
931
932    const DEBUG_NAME: &'static str = "(anonymous) ChildViewWatcher";
933}
934
935pub trait ChildViewWatcherProxyInterface: Send + Sync {
936    type GetStatusResponseFut: std::future::Future<Output = Result<ChildViewStatus, fidl::Error>>
937        + Send;
938    fn r#get_status(&self) -> Self::GetStatusResponseFut;
939    type GetViewRefResponseFut: std::future::Future<Output = Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error>>
940        + Send;
941    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut;
942}
943#[derive(Debug)]
944#[cfg(target_os = "fuchsia")]
945pub struct ChildViewWatcherSynchronousProxy {
946    client: fidl::client::sync::Client,
947}
948
949#[cfg(target_os = "fuchsia")]
950impl fidl::endpoints::SynchronousProxy for ChildViewWatcherSynchronousProxy {
951    type Proxy = ChildViewWatcherProxy;
952    type Protocol = ChildViewWatcherMarker;
953
954    fn from_channel(inner: fidl::Channel) -> Self {
955        Self::new(inner)
956    }
957
958    fn into_channel(self) -> fidl::Channel {
959        self.client.into_channel()
960    }
961
962    fn as_channel(&self) -> &fidl::Channel {
963        self.client.as_channel()
964    }
965}
966
967#[cfg(target_os = "fuchsia")]
968impl ChildViewWatcherSynchronousProxy {
969    pub fn new(channel: fidl::Channel) -> Self {
970        let protocol_name = <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
971        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
972    }
973
974    pub fn into_channel(self) -> fidl::Channel {
975        self.client.into_channel()
976    }
977
978    /// Waits until an event arrives and returns it. It is safe for other
979    /// threads to make concurrent requests while waiting for an event.
980    pub fn wait_for_event(
981        &self,
982        deadline: zx::MonotonicInstant,
983    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
984        ChildViewWatcherEvent::decode(self.client.wait_for_event(deadline)?)
985    }
986
987    /// A hanging get for receiving the status of a View. This provides information to the parent,
988    /// such as whether or not the child has successfully presented content through this View.
989    ///
990    /// This hanging get will only fire when the ChildViewStatus is different than the previously
991    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
992    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
993    /// to know that the child has content ready to display before the parent modifies their own
994    /// local scene graph to incorporate the child content.
995    ///
996    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
997    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
998    /// closed.
999    pub fn r#get_status(
1000        &self,
1001        ___deadline: zx::MonotonicInstant,
1002    ) -> Result<ChildViewStatus, fidl::Error> {
1003        let _response = self
1004            .client
1005            .send_query::<fidl::encoding::EmptyPayload, ChildViewWatcherGetStatusResponse>(
1006                (),
1007                0x1d622075f4fc8243,
1008                fidl::encoding::DynamicFlags::empty(),
1009                ___deadline,
1010            )?;
1011        Ok(_response.status)
1012    }
1013
1014    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1015    /// is different from the previously-returned View ref. Note: currently the View ref will not
1016    /// change after it is first received, but this will change if/when the API changes to allow
1017    /// relinking of views.
1018    ///
1019    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1020    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1021    /// i.e. the display.
1022    ///
1023    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1024    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1025    /// closed.
1026    ///
1027    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1028    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1029    /// a ViewRef for that View.
1030    pub fn r#get_view_ref(
1031        &self,
1032        ___deadline: zx::MonotonicInstant,
1033    ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1034        let _response = self
1035            .client
1036            .send_query::<fidl::encoding::EmptyPayload, ChildViewWatcherGetViewRefResponse>(
1037                (),
1038                0x3b2f3ca31e8908b4,
1039                fidl::encoding::DynamicFlags::empty(),
1040                ___deadline,
1041            )?;
1042        Ok(_response.view_ref)
1043    }
1044}
1045
1046#[cfg(target_os = "fuchsia")]
1047impl From<ChildViewWatcherSynchronousProxy> for zx::Handle {
1048    fn from(value: ChildViewWatcherSynchronousProxy) -> Self {
1049        value.into_channel().into()
1050    }
1051}
1052
1053#[cfg(target_os = "fuchsia")]
1054impl From<fidl::Channel> for ChildViewWatcherSynchronousProxy {
1055    fn from(value: fidl::Channel) -> Self {
1056        Self::new(value)
1057    }
1058}
1059
1060#[cfg(target_os = "fuchsia")]
1061impl fidl::endpoints::FromClient for ChildViewWatcherSynchronousProxy {
1062    type Protocol = ChildViewWatcherMarker;
1063
1064    fn from_client(value: fidl::endpoints::ClientEnd<ChildViewWatcherMarker>) -> Self {
1065        Self::new(value.into_channel())
1066    }
1067}
1068
1069#[derive(Debug, Clone)]
1070pub struct ChildViewWatcherProxy {
1071    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1072}
1073
1074impl fidl::endpoints::Proxy for ChildViewWatcherProxy {
1075    type Protocol = ChildViewWatcherMarker;
1076
1077    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1078        Self::new(inner)
1079    }
1080
1081    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1082        self.client.into_channel().map_err(|client| Self { client })
1083    }
1084
1085    fn as_channel(&self) -> &::fidl::AsyncChannel {
1086        self.client.as_channel()
1087    }
1088}
1089
1090impl ChildViewWatcherProxy {
1091    /// Create a new Proxy for fuchsia.ui.composition/ChildViewWatcher.
1092    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1093        let protocol_name = <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1094        Self { client: fidl::client::Client::new(channel, protocol_name) }
1095    }
1096
1097    /// Get a Stream of events from the remote end of the protocol.
1098    ///
1099    /// # Panics
1100    ///
1101    /// Panics if the event stream was already taken.
1102    pub fn take_event_stream(&self) -> ChildViewWatcherEventStream {
1103        ChildViewWatcherEventStream { event_receiver: self.client.take_event_receiver() }
1104    }
1105
1106    /// A hanging get for receiving the status of a View. This provides information to the parent,
1107    /// such as whether or not the child has successfully presented content through this View.
1108    ///
1109    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1110    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1111    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1112    /// to know that the child has content ready to display before the parent modifies their own
1113    /// local scene graph to incorporate the child content.
1114    ///
1115    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1116    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1117    /// closed.
1118    pub fn r#get_status(
1119        &self,
1120    ) -> fidl::client::QueryResponseFut<
1121        ChildViewStatus,
1122        fidl::encoding::DefaultFuchsiaResourceDialect,
1123    > {
1124        ChildViewWatcherProxyInterface::r#get_status(self)
1125    }
1126
1127    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1128    /// is different from the previously-returned View ref. Note: currently the View ref will not
1129    /// change after it is first received, but this will change if/when the API changes to allow
1130    /// relinking of views.
1131    ///
1132    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1133    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1134    /// i.e. the display.
1135    ///
1136    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1137    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1138    /// closed.
1139    ///
1140    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1141    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1142    /// a ViewRef for that View.
1143    pub fn r#get_view_ref(
1144        &self,
1145    ) -> fidl::client::QueryResponseFut<
1146        fidl_fuchsia_ui_views::ViewRef,
1147        fidl::encoding::DefaultFuchsiaResourceDialect,
1148    > {
1149        ChildViewWatcherProxyInterface::r#get_view_ref(self)
1150    }
1151}
1152
1153impl ChildViewWatcherProxyInterface for ChildViewWatcherProxy {
1154    type GetStatusResponseFut = fidl::client::QueryResponseFut<
1155        ChildViewStatus,
1156        fidl::encoding::DefaultFuchsiaResourceDialect,
1157    >;
1158    fn r#get_status(&self) -> Self::GetStatusResponseFut {
1159        fn _decode(
1160            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1161        ) -> Result<ChildViewStatus, fidl::Error> {
1162            let _response = fidl::client::decode_transaction_body::<
1163                ChildViewWatcherGetStatusResponse,
1164                fidl::encoding::DefaultFuchsiaResourceDialect,
1165                0x1d622075f4fc8243,
1166            >(_buf?)?;
1167            Ok(_response.status)
1168        }
1169        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ChildViewStatus>(
1170            (),
1171            0x1d622075f4fc8243,
1172            fidl::encoding::DynamicFlags::empty(),
1173            _decode,
1174        )
1175    }
1176
1177    type GetViewRefResponseFut = fidl::client::QueryResponseFut<
1178        fidl_fuchsia_ui_views::ViewRef,
1179        fidl::encoding::DefaultFuchsiaResourceDialect,
1180    >;
1181    fn r#get_view_ref(&self) -> Self::GetViewRefResponseFut {
1182        fn _decode(
1183            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1184        ) -> Result<fidl_fuchsia_ui_views::ViewRef, fidl::Error> {
1185            let _response = fidl::client::decode_transaction_body::<
1186                ChildViewWatcherGetViewRefResponse,
1187                fidl::encoding::DefaultFuchsiaResourceDialect,
1188                0x3b2f3ca31e8908b4,
1189            >(_buf?)?;
1190            Ok(_response.view_ref)
1191        }
1192        self.client
1193            .send_query_and_decode::<fidl::encoding::EmptyPayload, fidl_fuchsia_ui_views::ViewRef>(
1194                (),
1195                0x3b2f3ca31e8908b4,
1196                fidl::encoding::DynamicFlags::empty(),
1197                _decode,
1198            )
1199    }
1200}
1201
1202pub struct ChildViewWatcherEventStream {
1203    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1204}
1205
1206impl std::marker::Unpin for ChildViewWatcherEventStream {}
1207
1208impl futures::stream::FusedStream for ChildViewWatcherEventStream {
1209    fn is_terminated(&self) -> bool {
1210        self.event_receiver.is_terminated()
1211    }
1212}
1213
1214impl futures::Stream for ChildViewWatcherEventStream {
1215    type Item = Result<ChildViewWatcherEvent, fidl::Error>;
1216
1217    fn poll_next(
1218        mut self: std::pin::Pin<&mut Self>,
1219        cx: &mut std::task::Context<'_>,
1220    ) -> std::task::Poll<Option<Self::Item>> {
1221        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1222            &mut self.event_receiver,
1223            cx
1224        )?) {
1225            Some(buf) => std::task::Poll::Ready(Some(ChildViewWatcherEvent::decode(buf))),
1226            None => std::task::Poll::Ready(None),
1227        }
1228    }
1229}
1230
1231#[derive(Debug)]
1232pub enum ChildViewWatcherEvent {}
1233
1234impl ChildViewWatcherEvent {
1235    /// Decodes a message buffer as a [`ChildViewWatcherEvent`].
1236    fn decode(
1237        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1238    ) -> Result<ChildViewWatcherEvent, fidl::Error> {
1239        let (bytes, _handles) = buf.split_mut();
1240        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1241        debug_assert_eq!(tx_header.tx_id, 0);
1242        match tx_header.ordinal {
1243            _ => Err(fidl::Error::UnknownOrdinal {
1244                ordinal: tx_header.ordinal,
1245                protocol_name:
1246                    <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1247            }),
1248        }
1249    }
1250}
1251
1252/// A Stream of incoming requests for fuchsia.ui.composition/ChildViewWatcher.
1253pub struct ChildViewWatcherRequestStream {
1254    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1255    is_terminated: bool,
1256}
1257
1258impl std::marker::Unpin for ChildViewWatcherRequestStream {}
1259
1260impl futures::stream::FusedStream for ChildViewWatcherRequestStream {
1261    fn is_terminated(&self) -> bool {
1262        self.is_terminated
1263    }
1264}
1265
1266impl fidl::endpoints::RequestStream for ChildViewWatcherRequestStream {
1267    type Protocol = ChildViewWatcherMarker;
1268    type ControlHandle = ChildViewWatcherControlHandle;
1269
1270    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1271        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1272    }
1273
1274    fn control_handle(&self) -> Self::ControlHandle {
1275        ChildViewWatcherControlHandle { inner: self.inner.clone() }
1276    }
1277
1278    fn into_inner(
1279        self,
1280    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1281    {
1282        (self.inner, self.is_terminated)
1283    }
1284
1285    fn from_inner(
1286        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1287        is_terminated: bool,
1288    ) -> Self {
1289        Self { inner, is_terminated }
1290    }
1291}
1292
1293impl futures::Stream for ChildViewWatcherRequestStream {
1294    type Item = Result<ChildViewWatcherRequest, fidl::Error>;
1295
1296    fn poll_next(
1297        mut self: std::pin::Pin<&mut Self>,
1298        cx: &mut std::task::Context<'_>,
1299    ) -> std::task::Poll<Option<Self::Item>> {
1300        let this = &mut *self;
1301        if this.inner.check_shutdown(cx) {
1302            this.is_terminated = true;
1303            return std::task::Poll::Ready(None);
1304        }
1305        if this.is_terminated {
1306            panic!("polled ChildViewWatcherRequestStream after completion");
1307        }
1308        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1309            |bytes, handles| {
1310                match this.inner.channel().read_etc(cx, bytes, handles) {
1311                    std::task::Poll::Ready(Ok(())) => {}
1312                    std::task::Poll::Pending => return std::task::Poll::Pending,
1313                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1314                        this.is_terminated = true;
1315                        return std::task::Poll::Ready(None);
1316                    }
1317                    std::task::Poll::Ready(Err(e)) => {
1318                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1319                            e.into(),
1320                        ))))
1321                    }
1322                }
1323
1324                // A message has been received from the channel
1325                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1326
1327                std::task::Poll::Ready(Some(match header.ordinal {
1328                    0x1d622075f4fc8243 => {
1329                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1330                        let mut req = fidl::new_empty!(
1331                            fidl::encoding::EmptyPayload,
1332                            fidl::encoding::DefaultFuchsiaResourceDialect
1333                        );
1334                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1335                        let control_handle =
1336                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1337                        Ok(ChildViewWatcherRequest::GetStatus {
1338                            responder: ChildViewWatcherGetStatusResponder {
1339                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1340                                tx_id: header.tx_id,
1341                            },
1342                        })
1343                    }
1344                    0x3b2f3ca31e8908b4 => {
1345                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1346                        let mut req = fidl::new_empty!(
1347                            fidl::encoding::EmptyPayload,
1348                            fidl::encoding::DefaultFuchsiaResourceDialect
1349                        );
1350                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1351                        let control_handle =
1352                            ChildViewWatcherControlHandle { inner: this.inner.clone() };
1353                        Ok(ChildViewWatcherRequest::GetViewRef {
1354                            responder: ChildViewWatcherGetViewRefResponder {
1355                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1356                                tx_id: header.tx_id,
1357                            },
1358                        })
1359                    }
1360                    _ => Err(fidl::Error::UnknownOrdinal {
1361                        ordinal: header.ordinal,
1362                        protocol_name:
1363                            <ChildViewWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1364                    }),
1365                }))
1366            },
1367        )
1368    }
1369}
1370
1371/// A protocol that provides information about a particular child View which is attached to the
1372/// Viewport owned by the parent client; connections to this protocol are estabished in
1373/// [`CreateViewport`].  Since a Flatland instance may contain any number of Viewports, each of
1374/// which may or may not be attached to a transform, the client can maintain connections to an
1375/// equal number of ChildViewWatcher instances.
1376///
1377/// Each ChildViewWatcher instance will remain connected as long as the corresponding child View
1378/// exists; the connection will also be closed if the child's ViewCreationToken is dropped without
1379/// using it to create a View.
1380#[derive(Debug)]
1381pub enum ChildViewWatcherRequest {
1382    /// A hanging get for receiving the status of a View. This provides information to the parent,
1383    /// such as whether or not the child has successfully presented content through this View.
1384    ///
1385    /// This hanging get will only fire when the ChildViewStatus is different than the previously
1386    /// returned ChildViewStatus.  This can happen immediately, and even if the creator of the
1387    /// Viewport hasn't yet called Present() after calling CreateViewport().  This allows the parent
1388    /// to know that the child has content ready to display before the parent modifies their own
1389    /// local scene graph to incorporate the child content.
1390    ///
1391    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
1392    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1393    /// closed.
1394    GetStatus { responder: ChildViewWatcherGetStatusResponder },
1395    /// Hanging get to receive the ViewRef of the child View. This will only fire when the View ref
1396    /// is different from the previously-returned View ref. Note: currently the View ref will not
1397    /// change after it is first received, but this will change if/when the API changes to allow
1398    /// relinking of views.
1399    ///
1400    /// The ViewRef is not returned until the View is included in the View tree, in other words when
1401    /// there is a chain of ancestor transforms all the way back up to the root of the scene graph,
1402    /// i.e. the display.
1403    ///
1404    /// It is invalid to call `GetViewRef` while a previous call is still pending. Doing so will
1405    /// cause both this channel and the Flatland channel that handed out ChildViewWatcher to be
1406    /// closed.
1407    ///
1408    /// A `GetViewRef` call will hang if the View was created using `CreateView`, but returns the
1409    /// View if the View was created using CreateView2. This is because `CreateView` does not mint
1410    /// a ViewRef for that View.
1411    GetViewRef { responder: ChildViewWatcherGetViewRefResponder },
1412}
1413
1414impl ChildViewWatcherRequest {
1415    #[allow(irrefutable_let_patterns)]
1416    pub fn into_get_status(self) -> Option<(ChildViewWatcherGetStatusResponder)> {
1417        if let ChildViewWatcherRequest::GetStatus { responder } = self {
1418            Some((responder))
1419        } else {
1420            None
1421        }
1422    }
1423
1424    #[allow(irrefutable_let_patterns)]
1425    pub fn into_get_view_ref(self) -> Option<(ChildViewWatcherGetViewRefResponder)> {
1426        if let ChildViewWatcherRequest::GetViewRef { responder } = self {
1427            Some((responder))
1428        } else {
1429            None
1430        }
1431    }
1432
1433    /// Name of the method defined in FIDL
1434    pub fn method_name(&self) -> &'static str {
1435        match *self {
1436            ChildViewWatcherRequest::GetStatus { .. } => "get_status",
1437            ChildViewWatcherRequest::GetViewRef { .. } => "get_view_ref",
1438        }
1439    }
1440}
1441
1442#[derive(Debug, Clone)]
1443pub struct ChildViewWatcherControlHandle {
1444    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1445}
1446
1447impl fidl::endpoints::ControlHandle for ChildViewWatcherControlHandle {
1448    fn shutdown(&self) {
1449        self.inner.shutdown()
1450    }
1451    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1452        self.inner.shutdown_with_epitaph(status)
1453    }
1454
1455    fn is_closed(&self) -> bool {
1456        self.inner.channel().is_closed()
1457    }
1458    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1459        self.inner.channel().on_closed()
1460    }
1461
1462    #[cfg(target_os = "fuchsia")]
1463    fn signal_peer(
1464        &self,
1465        clear_mask: zx::Signals,
1466        set_mask: zx::Signals,
1467    ) -> Result<(), zx_status::Status> {
1468        use fidl::Peered;
1469        self.inner.channel().signal_peer(clear_mask, set_mask)
1470    }
1471}
1472
1473impl ChildViewWatcherControlHandle {}
1474
1475#[must_use = "FIDL methods require a response to be sent"]
1476#[derive(Debug)]
1477pub struct ChildViewWatcherGetStatusResponder {
1478    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1479    tx_id: u32,
1480}
1481
1482/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1483/// if the responder is dropped without sending a response, so that the client
1484/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1485impl std::ops::Drop for ChildViewWatcherGetStatusResponder {
1486    fn drop(&mut self) {
1487        self.control_handle.shutdown();
1488        // Safety: drops once, never accessed again
1489        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1490    }
1491}
1492
1493impl fidl::endpoints::Responder for ChildViewWatcherGetStatusResponder {
1494    type ControlHandle = ChildViewWatcherControlHandle;
1495
1496    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1497        &self.control_handle
1498    }
1499
1500    fn drop_without_shutdown(mut self) {
1501        // Safety: drops once, never accessed again due to mem::forget
1502        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1503        // Prevent Drop from running (which would shut down the channel)
1504        std::mem::forget(self);
1505    }
1506}
1507
1508impl ChildViewWatcherGetStatusResponder {
1509    /// Sends a response to the FIDL transaction.
1510    ///
1511    /// Sets the channel to shutdown if an error occurs.
1512    pub fn send(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1513        let _result = self.send_raw(status);
1514        if _result.is_err() {
1515            self.control_handle.shutdown();
1516        }
1517        self.drop_without_shutdown();
1518        _result
1519    }
1520
1521    /// Similar to "send" but does not shutdown the channel if an error occurs.
1522    pub fn send_no_shutdown_on_err(self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1523        let _result = self.send_raw(status);
1524        self.drop_without_shutdown();
1525        _result
1526    }
1527
1528    fn send_raw(&self, mut status: ChildViewStatus) -> Result<(), fidl::Error> {
1529        self.control_handle.inner.send::<ChildViewWatcherGetStatusResponse>(
1530            (status,),
1531            self.tx_id,
1532            0x1d622075f4fc8243,
1533            fidl::encoding::DynamicFlags::empty(),
1534        )
1535    }
1536}
1537
1538#[must_use = "FIDL methods require a response to be sent"]
1539#[derive(Debug)]
1540pub struct ChildViewWatcherGetViewRefResponder {
1541    control_handle: std::mem::ManuallyDrop<ChildViewWatcherControlHandle>,
1542    tx_id: u32,
1543}
1544
1545/// Set the the channel to be shutdown (see [`ChildViewWatcherControlHandle::shutdown`])
1546/// if the responder is dropped without sending a response, so that the client
1547/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1548impl std::ops::Drop for ChildViewWatcherGetViewRefResponder {
1549    fn drop(&mut self) {
1550        self.control_handle.shutdown();
1551        // Safety: drops once, never accessed again
1552        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1553    }
1554}
1555
1556impl fidl::endpoints::Responder for ChildViewWatcherGetViewRefResponder {
1557    type ControlHandle = ChildViewWatcherControlHandle;
1558
1559    fn control_handle(&self) -> &ChildViewWatcherControlHandle {
1560        &self.control_handle
1561    }
1562
1563    fn drop_without_shutdown(mut self) {
1564        // Safety: drops once, never accessed again due to mem::forget
1565        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1566        // Prevent Drop from running (which would shut down the channel)
1567        std::mem::forget(self);
1568    }
1569}
1570
1571impl ChildViewWatcherGetViewRefResponder {
1572    /// Sends a response to the FIDL transaction.
1573    ///
1574    /// Sets the channel to shutdown if an error occurs.
1575    pub fn send(self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1576        let _result = self.send_raw(view_ref);
1577        if _result.is_err() {
1578            self.control_handle.shutdown();
1579        }
1580        self.drop_without_shutdown();
1581        _result
1582    }
1583
1584    /// Similar to "send" but does not shutdown the channel if an error occurs.
1585    pub fn send_no_shutdown_on_err(
1586        self,
1587        mut view_ref: fidl_fuchsia_ui_views::ViewRef,
1588    ) -> Result<(), fidl::Error> {
1589        let _result = self.send_raw(view_ref);
1590        self.drop_without_shutdown();
1591        _result
1592    }
1593
1594    fn send_raw(&self, mut view_ref: fidl_fuchsia_ui_views::ViewRef) -> Result<(), fidl::Error> {
1595        self.control_handle.inner.send::<ChildViewWatcherGetViewRefResponse>(
1596            (&mut view_ref,),
1597            self.tx_id,
1598            0x3b2f3ca31e8908b4,
1599            fidl::encoding::DynamicFlags::empty(),
1600        )
1601    }
1602}
1603
1604#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1605pub struct FlatlandMarker;
1606
1607impl fidl::endpoints::ProtocolMarker for FlatlandMarker {
1608    type Proxy = FlatlandProxy;
1609    type RequestStream = FlatlandRequestStream;
1610    #[cfg(target_os = "fuchsia")]
1611    type SynchronousProxy = FlatlandSynchronousProxy;
1612
1613    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Flatland";
1614}
1615impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandMarker {}
1616
1617pub trait FlatlandProxyInterface: Send + Sync {
1618    fn r#present(&self, args: PresentArgs) -> Result<(), fidl::Error>;
1619    fn r#create_view(
1620        &self,
1621        token: fidl_fuchsia_ui_views::ViewCreationToken,
1622        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1623    ) -> Result<(), fidl::Error>;
1624    fn r#create_view2(
1625        &self,
1626        token: fidl_fuchsia_ui_views::ViewCreationToken,
1627        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1628        protocols: ViewBoundProtocols,
1629        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1630    ) -> Result<(), fidl::Error>;
1631    fn r#create_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1632    fn r#set_translation(
1633        &self,
1634        transform_id: &TransformId,
1635        translation: &fidl_fuchsia_math::Vec_,
1636    ) -> Result<(), fidl::Error>;
1637    fn r#set_orientation(
1638        &self,
1639        transform_id: &TransformId,
1640        orientation: Orientation,
1641    ) -> Result<(), fidl::Error>;
1642    fn r#set_scale(
1643        &self,
1644        transform_id: &TransformId,
1645        scale: &fidl_fuchsia_math::VecF,
1646    ) -> Result<(), fidl::Error>;
1647    fn r#set_opacity(&self, transform_id: &TransformId, value: f32) -> Result<(), fidl::Error>;
1648    fn r#set_clip_boundary(
1649        &self,
1650        transform_id: &TransformId,
1651        rect: Option<&fidl_fuchsia_math::Rect>,
1652    ) -> Result<(), fidl::Error>;
1653    fn r#add_child(
1654        &self,
1655        parent_transform_id: &TransformId,
1656        child_transform_id: &TransformId,
1657    ) -> Result<(), fidl::Error>;
1658    fn r#remove_child(
1659        &self,
1660        parent_transform_id: &TransformId,
1661        child_transform_id: &TransformId,
1662    ) -> Result<(), fidl::Error>;
1663    fn r#replace_children(
1664        &self,
1665        parent_transform_id: &TransformId,
1666        new_child_transform_ids: &[TransformId],
1667    ) -> Result<(), fidl::Error>;
1668    fn r#set_root_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1669    fn r#set_hit_regions(
1670        &self,
1671        transform_id: &TransformId,
1672        regions: &[HitRegion],
1673    ) -> Result<(), fidl::Error>;
1674    fn r#set_infinite_hit_region(
1675        &self,
1676        transform_id: &TransformId,
1677        hit_test: HitTestInteraction,
1678    ) -> Result<(), fidl::Error>;
1679    fn r#create_viewport(
1680        &self,
1681        viewport_id: &ContentId,
1682        token: fidl_fuchsia_ui_views::ViewportCreationToken,
1683        properties: &ViewportProperties,
1684        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
1685    ) -> Result<(), fidl::Error>;
1686    fn r#create_image(
1687        &self,
1688        image_id: &ContentId,
1689        import_token: BufferCollectionImportToken,
1690        vmo_index: u32,
1691        properties: &ImageProperties,
1692    ) -> Result<(), fidl::Error>;
1693    fn r#set_image_sample_region(
1694        &self,
1695        image_id: &ContentId,
1696        rect: &fidl_fuchsia_math::RectF,
1697    ) -> Result<(), fidl::Error>;
1698    fn r#set_image_destination_size(
1699        &self,
1700        image_id: &ContentId,
1701        size: &fidl_fuchsia_math::SizeU,
1702    ) -> Result<(), fidl::Error>;
1703    fn r#set_image_blending_function(
1704        &self,
1705        image_id: &ContentId,
1706        blend_mode: BlendMode,
1707    ) -> Result<(), fidl::Error>;
1708    fn r#set_image_opacity(&self, image_id: &ContentId, val: f32) -> Result<(), fidl::Error>;
1709    fn r#set_image_flip(&self, image_id: &ContentId, flip: ImageFlip) -> Result<(), fidl::Error>;
1710    fn r#create_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1711    fn r#set_solid_fill(
1712        &self,
1713        rect_id: &ContentId,
1714        color: &ColorRgba,
1715        size: &fidl_fuchsia_math::SizeU,
1716    ) -> Result<(), fidl::Error>;
1717    fn r#release_filled_rect(&self, rect_id: &ContentId) -> Result<(), fidl::Error>;
1718    fn r#set_content(
1719        &self,
1720        transform_id: &TransformId,
1721        content_id: &ContentId,
1722    ) -> Result<(), fidl::Error>;
1723    fn r#set_viewport_properties(
1724        &self,
1725        viewport_id: &ContentId,
1726        properties: &ViewportProperties,
1727    ) -> Result<(), fidl::Error>;
1728    fn r#release_transform(&self, transform_id: &TransformId) -> Result<(), fidl::Error>;
1729    fn r#release_view(&self) -> Result<(), fidl::Error>;
1730    type ReleaseViewportResponseFut: std::future::Future<
1731            Output = Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error>,
1732        > + Send;
1733    fn r#release_viewport(&self, viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut;
1734    fn r#release_image(&self, image_id: &ContentId) -> Result<(), fidl::Error>;
1735    fn r#clear(&self) -> Result<(), fidl::Error>;
1736    fn r#set_debug_name(&self, name: &str) -> Result<(), fidl::Error>;
1737}
1738#[derive(Debug)]
1739#[cfg(target_os = "fuchsia")]
1740pub struct FlatlandSynchronousProxy {
1741    client: fidl::client::sync::Client,
1742}
1743
1744#[cfg(target_os = "fuchsia")]
1745impl fidl::endpoints::SynchronousProxy for FlatlandSynchronousProxy {
1746    type Proxy = FlatlandProxy;
1747    type Protocol = FlatlandMarker;
1748
1749    fn from_channel(inner: fidl::Channel) -> Self {
1750        Self::new(inner)
1751    }
1752
1753    fn into_channel(self) -> fidl::Channel {
1754        self.client.into_channel()
1755    }
1756
1757    fn as_channel(&self) -> &fidl::Channel {
1758        self.client.as_channel()
1759    }
1760}
1761
1762#[cfg(target_os = "fuchsia")]
1763impl FlatlandSynchronousProxy {
1764    pub fn new(channel: fidl::Channel) -> Self {
1765        let protocol_name = <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1766        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1767    }
1768
1769    pub fn into_channel(self) -> fidl::Channel {
1770        self.client.into_channel()
1771    }
1772
1773    /// Waits until an event arrives and returns it. It is safe for other
1774    /// threads to make concurrent requests while waiting for an event.
1775    pub fn wait_for_event(
1776        &self,
1777        deadline: zx::MonotonicInstant,
1778    ) -> Result<FlatlandEvent, fidl::Error> {
1779        FlatlandEvent::decode(self.client.wait_for_event(deadline)?)
1780    }
1781
1782    /// Complete execution of all feed-forward operations.
1783    ///
1784    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
1785    /// is emitted. Operations that produce errors are ignored and the channel is closed.
1786    ///
1787    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
1788    /// with other valid fields.
1789    ///
1790    /// The client may only call [`Present`] when they have a non-zero number of present credits,
1791    /// which are tracked by the server. The server may increment the number of credits when it
1792    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
1793    /// present credits. Each [`Present`] call uses one present credit and decrements the server
1794    /// count by one. If the client calls [`Present`] with no present credits, the server will
1795    /// return a `NO_PRESENTS_REMAINING` error.
1796    ///
1797    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
1798    /// one present credit.
1799    ///
1800    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
1801    /// [`OnFramePresented`] event, typically in that order.
1802    ///
1803    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
1804    /// is fired. This event includes information pertaining to all [`Present`]s that had content
1805    /// that were part of that frame.
1806    ///
1807    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
1808    /// on what arguments are passed in and their role.
1809    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
1810        self.client.send::<FlatlandPresentRequest>(
1811            (&mut args,),
1812            0x50acc2aa1f0acec7,
1813            fidl::encoding::DynamicFlags::empty(),
1814        )
1815    }
1816
1817    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
1818    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
1819    /// instance that creates a Viewport has control over how the child's View is integrated into
1820    /// its own View.
1821    ///
1822    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
1823    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
1824    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
1825    /// ViewCreationToken to the child, which calls [`CreateView`].
1826    ///
1827    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
1828    /// the parent's Viewport.
1829    ///
1830    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
1831    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
1832    /// only have one parent.
1833    ///
1834    /// This function is queued, meaning that the Root Transform will not be attached to the
1835    /// parent Viewport until [`Present`] is called. However, clients will receive information
1836    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
1837    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
1838    /// clients to wait for layout information from their parent before calling [`Present`].
1839    ///
1840    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
1841    /// channel and this Flatland channel to be torn down.
1842    ///
1843    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
1844    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
1845    /// channel is destroyed.
1846    ///
1847    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
1848    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
1849    /// such as touch, mouse or focus.
1850    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
1851    /// `CreateView` to know that they are excluded from the ViewTree.
1852    pub fn r#create_view(
1853        &self,
1854        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1855        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1856    ) -> Result<(), fidl::Error> {
1857        self.client.send::<FlatlandCreateViewRequest>(
1858            (&mut token, parent_viewport_watcher),
1859            0x504686eb25864780,
1860            fidl::encoding::DynamicFlags::empty(),
1861        )
1862    }
1863
1864    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
1865    /// view-bound protocols.
1866    pub fn r#create_view2(
1867        &self,
1868        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
1869        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
1870        mut protocols: ViewBoundProtocols,
1871        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
1872    ) -> Result<(), fidl::Error> {
1873        self.client.send::<FlatlandCreateView2Request>(
1874            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
1875            0x340a3a40c2fdbd5e,
1876            fidl::encoding::DynamicFlags::empty(),
1877        )
1878    }
1879
1880    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
1881    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
1882    /// descendants can be rendered to a display.
1883    ///
1884    /// Transforms are kept alive, even when released, as long as they are children of either an
1885    /// unreleased Transform, or the Root Transform.
1886    ///
1887    /// Each Transform can have a single piece of attached Content. Common types of Content include
1888    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
1889    /// instances.
1890    ///
1891    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
1892    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
1893    ///
1894    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
1895    /// with the Content on the root transform, and continuing recursively through all of its child
1896    /// Transforms in the order the children were added. See [`AddChild`] for more information.
1897    ///
1898    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
1899    /// in use (see [`ReleaseTransform`] for more details).
1900    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
1901        self.client.send::<FlatlandCreateTransformRequest>(
1902            (transform_id,),
1903            0x5e042a4d3de3efb0,
1904            fidl::encoding::DynamicFlags::empty(),
1905        )
1906    }
1907
1908    /// All Transform objects support all attributes.
1909    ///
1910    /// Geometric attributes are applied in the following order:
1911    /// 1. Scale (relative to the parent transform's coordinate space)
1912    /// 2. Orientation (relative to the parent transform's coordinate space)
1913    /// 3. Translation (relative to the parent transforms's coordinate space,
1914    ///    unaffected by scale applied to the current transform).
1915    /// 4. Clipping (relative to the current transform's coordinate space)
1916    ///
1917    /// The effects of each of these attributes are cumulative. This means the transform's position
1918    /// in the view space, and its clip boundary, will be calculated based on that chain of
1919    /// geometric attributes going up to the root transform.
1920    ///
1921    /// For instance, in a nested hierarchy such as the following:
1922    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
1923    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
1924    /// view-space position of CurrentTransform will be [2,1].
1925    ///
1926    /// Sets the translation on a Transform. The order of geometric attribute application is
1927    /// addressed above.
1928    pub fn r#set_translation(
1929        &self,
1930        mut transform_id: &TransformId,
1931        mut translation: &fidl_fuchsia_math::Vec_,
1932    ) -> Result<(), fidl::Error> {
1933        self.client.send::<FlatlandSetTranslationRequest>(
1934            (transform_id, translation),
1935            0x7863398291fba346,
1936            fidl::encoding::DynamicFlags::empty(),
1937        )
1938    }
1939
1940    /// Sets the orientation on a Transform. The order of geometric attribute application is
1941    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
1942    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
1943    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
1944    pub fn r#set_orientation(
1945        &self,
1946        mut transform_id: &TransformId,
1947        mut orientation: Orientation,
1948    ) -> Result<(), fidl::Error> {
1949        self.client.send::<FlatlandSetOrientationRequest>(
1950            (transform_id, orientation),
1951            0x4915310bc4928edc,
1952            fidl::encoding::DynamicFlags::empty(),
1953        )
1954    }
1955
1956    /// Sets the scale on a transform. The order of geometric attribute application is
1957    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
1958    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
1959    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
1960    pub fn r#set_scale(
1961        &self,
1962        mut transform_id: &TransformId,
1963        mut scale: &fidl_fuchsia_math::VecF,
1964    ) -> Result<(), fidl::Error> {
1965        self.client.send::<FlatlandSetScaleRequest>(
1966            (transform_id, scale),
1967            0x1ea1766fd8996bb4,
1968            fidl::encoding::DynamicFlags::empty(),
1969        )
1970    }
1971
1972    /// Sets an opacity in linear space to be applied to a transform and its descendents,
1973    /// which include other transforms and content. Opacity values must be in the range
1974    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
1975    /// Attempting to call this function with values outside that range will result in
1976    /// an error. A transform's opacity value is multiplied with that of its parent. This
1977    /// effect works differently from group opacity. Using group opacity, child nodes are
1978    /// rendered together first, and then have the parent's opacity applied as a post-effect.
1979    /// Here, opacity is applied to each child individually. This may result in a very
1980    /// different effect.
1981    pub fn r#set_opacity(
1982        &self,
1983        mut transform_id: &TransformId,
1984        mut value: f32,
1985    ) -> Result<(), fidl::Error> {
1986        self.client.send::<FlatlandSetOpacityRequest>(
1987            (transform_id, value),
1988            0x3775fc2c00b432fa,
1989            fidl::encoding::DynamicFlags::empty(),
1990        )
1991    }
1992
1993    /// Sets the bounds, expressed in the local coordinate space of the transform, that
1994    /// constrains the region that content attached to this transform can be rendered to.
1995    /// If the content's area exceeds the clip bounds, the area outside the bounds will
1996    /// not be rendered. These bounds are valid for all children of this transform node as
1997    /// well, which includes nested Flatland instances and their node hierarchies.
1998    /// If a child transform attempts to set clip bounds larger than that of its parent,
1999    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2000    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2001    /// The clip width/height must be positive. Negative values will result in an error.
2002    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2003    pub fn r#set_clip_boundary(
2004        &self,
2005        mut transform_id: &TransformId,
2006        mut rect: Option<&fidl_fuchsia_math::Rect>,
2007    ) -> Result<(), fidl::Error> {
2008        self.client.send::<FlatlandSetClipBoundaryRequest>(
2009            (transform_id, rect),
2010            0x6507843df12222d2,
2011            fidl::encoding::DynamicFlags::empty(),
2012        )
2013    }
2014
2015    /// Adds a child Transform to a parent Transform. The new child Transform, and any Content
2016    /// attached to it or its children, will be rendered on top of the parent's Content, as well as
2017    /// any previously added children.
2018    pub fn r#add_child(
2019        &self,
2020        mut parent_transform_id: &TransformId,
2021        mut child_transform_id: &TransformId,
2022    ) -> Result<(), fidl::Error> {
2023        self.client.send::<FlatlandAddChildRequest>(
2024            (parent_transform_id, child_transform_id),
2025            0x67a8abd2f19b1a74,
2026            fidl::encoding::DynamicFlags::empty(),
2027        )
2028    }
2029
2030    /// Removes a child Transform from a parent Transform.
2031    pub fn r#remove_child(
2032        &self,
2033        mut parent_transform_id: &TransformId,
2034        mut child_transform_id: &TransformId,
2035    ) -> Result<(), fidl::Error> {
2036        self.client.send::<FlatlandRemoveChildRequest>(
2037            (parent_transform_id, child_transform_id),
2038            0x41d6cd90b298b67a,
2039            fidl::encoding::DynamicFlags::empty(),
2040        )
2041    }
2042
2043    /// Removes all child Transforms from a parent Transform and replaces them with the new child
2044    /// transforms in `new_child_transform_ids`.
2045    pub fn r#replace_children(
2046        &self,
2047        mut parent_transform_id: &TransformId,
2048        mut new_child_transform_ids: &[TransformId],
2049    ) -> Result<(), fidl::Error> {
2050        self.client.send::<FlatlandReplaceChildrenRequest>(
2051            (parent_transform_id, new_child_transform_ids),
2052            0x5b6d86cbbff81316,
2053            fidl::encoding::DynamicFlags::empty(),
2054        )
2055    }
2056
2057    /// Sets the Root Transform for the graph.
2058    ///
2059    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2060    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2061    /// in this Graph will be ignored.
2062    ///
2063    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2064    /// released (see [`ReleaseTransform`] for more details).
2065    ///
2066    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2067    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2068    /// objects that are not referenced by the new root.
2069    ///
2070    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2071    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2072    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2073    /// corner.
2074    ///
2075    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2076    /// may remove this hit region if they don't want users to be able to interact with the root
2077    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2078    /// documentation.
2079    ///
2080    /// Default hit region rules
2081    ///
2082    ///   A default hit region follows these rules:
2083    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2084    ///   entire view.
2085    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2086    ///   then no default hit region is active and the client specified hit regions are used.
2087    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2088    ///   called, then the original transform no longer has its default hit region.
2089    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2090    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2091    ///   vector.
2092    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2093        self.client.send::<FlatlandSetRootTransformRequest>(
2094            (transform_id,),
2095            0x6e80ca5bcc566cd8,
2096            fidl::encoding::DynamicFlags::empty(),
2097        )
2098    }
2099
2100    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2101    /// regions must be placed for a user to interact with the Content in a View. Because hit
2102    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2103    /// and hit regions.
2104    ///
2105    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2106    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2107    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2108    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2109    /// that transitively connect to the root Transform have their hit regions interact with a hit
2110    /// test.
2111    ///
2112    /// Calling this function replaces any previous values set on this Transform. To reset a
2113    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2114    ///
2115    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2116    /// see the [`SetRootTransform`] documentation.
2117    ///
2118    /// Precedence rules
2119    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2120    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2121    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2122    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2123    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2124    ///   can cause confusing behavior.
2125    ///
2126    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2127    ///   precedence over those behind. This follows the expected reverse "render order" of
2128    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2129    ///   Content that is visible, or front-most.
2130    ///
2131    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2132    ///   Transform's hit regions take precedence over those behind. This follows the expected
2133    ///   reverse "render order" of views, where a user expects to interact with the View that is
2134    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2135    ///   the parent View, the user expects to interact with the child's Content.
2136    pub fn r#set_hit_regions(
2137        &self,
2138        mut transform_id: &TransformId,
2139        mut regions: &[HitRegion],
2140    ) -> Result<(), fidl::Error> {
2141        self.client.send::<FlatlandSetHitRegionsRequest>(
2142            (transform_id, regions),
2143            0x31c9d17b07c37ce4,
2144            fidl::encoding::DynamicFlags::empty(),
2145        )
2146    }
2147
2148    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2149    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2150    /// orientation of the Transform.
2151    ///
2152    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2153    /// finite hit region.
2154    ///
2155    /// Calling this function replaces any previous values set on this Transform. To reset a
2156    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2157    pub fn r#set_infinite_hit_region(
2158        &self,
2159        mut transform_id: &TransformId,
2160        mut hit_test: HitTestInteraction,
2161    ) -> Result<(), fidl::Error> {
2162        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
2163            (transform_id, hit_test),
2164            0x26d81af852d29562,
2165            fidl::encoding::DynamicFlags::empty(),
2166        )
2167    }
2168
2169    /// The Viewport and View pair, together, represent the connection between two Flatland
2170    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2171    /// parent has control over how the child's View is integrated into its own View.
2172    ///
2173    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2174    /// Flatland channel to be torn down.
2175    ///
2176    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
2177    /// the layout of the child. The logical_size is also used as the default Content size, but
2178    /// subsequent changes to the logical_size will have no effect on the Content size.
2179    ///
2180    /// `ViewportProperties` may have inset field not set. In that case, the default value of
2181    /// (0, 0, 0, 0) is used.
2182    ///
2183    /// The logical_size must have positive X and Y components.
2184    ///
2185    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
2186    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
2187    ///
2188    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
2189    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
2190    /// destroyed.
2191    pub fn r#create_viewport(
2192        &self,
2193        mut viewport_id: &ContentId,
2194        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
2195        mut properties: &ViewportProperties,
2196        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
2197    ) -> Result<(), fidl::Error> {
2198        self.client.send::<FlatlandCreateViewportRequest>(
2199            (viewport_id, &mut token, properties, child_view_watcher),
2200            0x2485fbcab7f943c,
2201            fidl::encoding::DynamicFlags::empty(),
2202        )
2203    }
2204
2205    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
2206    ///
2207    /// Image creation requires an allocated BufferCollection registered with Allocator. This
2208    /// function will fail unless all clients of the specified BufferCollection have set their
2209    /// constraints.
2210    ///
2211    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
2212    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
2213    /// valid range, etc.)
2214    ///
2215    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
2216    /// use for another piece of Content (see [`ReleaseImage`] for more details).
2217    pub fn r#create_image(
2218        &self,
2219        mut image_id: &ContentId,
2220        mut import_token: BufferCollectionImportToken,
2221        mut vmo_index: u32,
2222        mut properties: &ImageProperties,
2223    ) -> Result<(), fidl::Error> {
2224        self.client.send::<FlatlandCreateImageRequest>(
2225            (image_id, &mut import_token, vmo_index, properties),
2226            0x26fae823c4ebedad,
2227            fidl::encoding::DynamicFlags::empty(),
2228        )
2229    }
2230
2231    /// This function is used to determine the region (in texel space) of an image that will be used
2232    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
2233    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
2234    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
2235    /// on non-image content, or to sample a region outside of the texel space of the image. In
2236    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
2237    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
2238    /// image_height) or if any of the values are negative, this will result in an error.
2239    ///
2240    /// If this method is not called, the default sample region is the rectangle with origin at
2241    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
2242    pub fn r#set_image_sample_region(
2243        &self,
2244        mut image_id: &ContentId,
2245        mut rect: &fidl_fuchsia_math::RectF,
2246    ) -> Result<(), fidl::Error> {
2247        self.client.send::<FlatlandSetImageSampleRegionRequest>(
2248            (image_id, rect),
2249            0x8039391d715eb28,
2250            fidl::encoding::DynamicFlags::empty(),
2251        )
2252    }
2253
2254    /// The content size for an Image is the size of the rectangle in the parent's logical
2255    /// coordinate space that the image occupies. This combined with the global translation of the
2256    /// transform it is attached to determines the size and location of where the content is
2257    /// rendered on the display.
2258    ///
2259    /// If this method is not called, the default image destination size is the width and height set
2260    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
2261    /// [`SetScale`] is used on the attached Transform or its parents.
2262    pub fn r#set_image_destination_size(
2263        &self,
2264        mut image_id: &ContentId,
2265        mut size: &fidl_fuchsia_math::SizeU,
2266    ) -> Result<(), fidl::Error> {
2267        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
2268            (image_id, size),
2269            0x766cf99a2ec58446,
2270            fidl::encoding::DynamicFlags::empty(),
2271        )
2272    }
2273
2274    /// Determines the blend function to use when rendering the content specified by
2275    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2276    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2277    /// that are available, please refer to the BlendMode enum. If this function is not called, then
2278    /// the default blendmode is BlendMode::SRC.
2279    pub fn r#set_image_blending_function(
2280        &self,
2281        mut image_id: &ContentId,
2282        mut blend_mode: BlendMode,
2283    ) -> Result<(), fidl::Error> {
2284        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
2285            (image_id, blend_mode),
2286            0x10f5da1356275b7b,
2287            fidl::encoding::DynamicFlags::empty(),
2288        )
2289    }
2290
2291    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
2292    /// be in the range [0.0, 1.0].
2293    pub fn r#set_image_opacity(
2294        &self,
2295        mut image_id: &ContentId,
2296        mut val: f32,
2297    ) -> Result<(), fidl::Error> {
2298        self.client.send::<FlatlandSetImageOpacityRequest>(
2299            (image_id, val),
2300            0x2da9e4ef4c2cff6f,
2301            fidl::encoding::DynamicFlags::empty(),
2302        )
2303    }
2304
2305    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
2306    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
2307    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
2308    /// parent Transform Orientations. If this function is not called, then the default flip value
2309    /// is ImageFlip::NONE.
2310    pub fn r#set_image_flip(
2311        &self,
2312        mut image_id: &ContentId,
2313        mut flip: ImageFlip,
2314    ) -> Result<(), fidl::Error> {
2315        self.client.send::<FlatlandSetImageFlipRequest>(
2316            (image_id, flip),
2317            0x21b20f2c14aae6bc,
2318            fidl::encoding::DynamicFlags::empty(),
2319        )
2320    }
2321
2322    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
2323    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
2324    /// before a filled rect can be used for rendering. Not doing so will result the
2325    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2326        self.client.send::<FlatlandCreateFilledRectRequest>(
2327            (rect_id,),
2328            0x5e62355abc1c4c5d,
2329            fidl::encoding::DynamicFlags::empty(),
2330        )
2331    }
2332
2333    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
2334    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
2335    /// must be within the range [0,1] inclusive, and normal 32-bit
2336    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
2337    /// that do not conform to these specifications will cause the channel to close.
2338    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
2339    /// Hence, its bottom right corner will be at (size.width, size.height).
2340    pub fn r#set_solid_fill(
2341        &self,
2342        mut rect_id: &ContentId,
2343        mut color: &ColorRgba,
2344        mut size: &fidl_fuchsia_math::SizeU,
2345    ) -> Result<(), fidl::Error> {
2346        self.client.send::<FlatlandSetSolidFillRequest>(
2347            (rect_id, color, size),
2348            0x32d6ef41e182dfa5,
2349            fidl::encoding::DynamicFlags::empty(),
2350        )
2351    }
2352
2353    /// Automatically garbage collects the rectangle when it is no longer needed for
2354    /// rendering. |rect_id| must have been instantiated with a call to
2355    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
2356    /// to be used again.
2357    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
2358        self.client.send::<FlatlandReleaseFilledRectRequest>(
2359            (rect_id,),
2360            0x7392cabe45618f9b,
2361            fidl::encoding::DynamicFlags::empty(),
2362        )
2363    }
2364
2365    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
2366    /// long as the Transform is visible from the root Transform. The Content will be rendered
2367    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
2368    ///
2369    /// Because each Transform can have, at most, a single piece of Content on it, calling this
2370    /// function on a Transform that already has Content will replace that Content.
2371    ///
2372    /// A Content may be set on more than one Transform.
2373    ///
2374    /// Calling this function with a Content id of 0 will remove any Content currently on the
2375    /// Transform.
2376    pub fn r#set_content(
2377        &self,
2378        mut transform_id: &TransformId,
2379        mut content_id: &ContentId,
2380    ) -> Result<(), fidl::Error> {
2381        self.client.send::<FlatlandSetContentRequest>(
2382            (transform_id, content_id),
2383            0x4ed2cfc0ce130862,
2384            fidl::encoding::DynamicFlags::empty(),
2385        )
2386    }
2387
2388    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
2389    /// have special properties that are not part of the Transform hierarchy. Those properties can
2390    /// be set using this function.
2391    pub fn r#set_viewport_properties(
2392        &self,
2393        mut viewport_id: &ContentId,
2394        mut properties: &ViewportProperties,
2395    ) -> Result<(), fidl::Error> {
2396        self.client.send::<FlatlandSetViewportPropertiesRequest>(
2397            (viewport_id, properties),
2398            0x66ab67e9608ddb9f,
2399            fidl::encoding::DynamicFlags::empty(),
2400        )
2401    }
2402
2403    /// Released Transforms will be garbage collected by the system once they are no longer
2404    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
2405    /// Transform to the newly-released Transform.
2406    ///
2407    /// Once released, the id immediately goes out of scope for future function calls and can be
2408    /// reused when creating new Transforms.
2409    ///
2410    /// It is an error to call functions with a released id (unless that id has been reused to
2411    /// construct a new Transform).
2412    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2413        self.client.send::<FlatlandReleaseTransformRequest>(
2414            (transform_id,),
2415            0xab9328419451c22,
2416            fidl::encoding::DynamicFlags::empty(),
2417        )
2418    }
2419
2420    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
2421        self.client.send::<fidl::encoding::EmptyPayload>(
2422            (),
2423            0x5b35aab9baffecae,
2424            fidl::encoding::DynamicFlags::empty(),
2425        )
2426    }
2427
2428    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
2429    /// Unlike other resources, Viewports are garbage collected by the system during the next
2430    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
2431    ///
2432    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
2433    ///
2434    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
2435    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
2436    /// after the presented operations have been executed.
2437    pub fn r#release_viewport(
2438        &self,
2439        mut viewport_id: &ContentId,
2440        ___deadline: zx::MonotonicInstant,
2441    ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
2442        let _response = self
2443            .client
2444            .send_query::<FlatlandReleaseViewportRequest, FlatlandReleaseViewportResponse>(
2445                (viewport_id,),
2446                0xbad474aeb5293f9,
2447                fidl::encoding::DynamicFlags::empty(),
2448                ___deadline,
2449            )?;
2450        Ok(_response.token)
2451    }
2452
2453    /// Released Images will be garbage collected by the system once they are no longer necessary
2454    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
2455    /// any pending rendering that references the Image is complete.
2456    ///
2457    /// Use SetContent(transform_id, 0) to clean up references to released Images.
2458    ///
2459    /// Once released, the id immediately goes out of scope for future function calls and can be
2460    /// reused when creating new Images.
2461    ///
2462    /// It is an error to call functions with a released id (unless that id has been reused to
2463    /// construct a new Image).
2464    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
2465        self.client.send::<FlatlandReleaseImageRequest>(
2466            (image_id,),
2467            0xb884ffdbc72c111,
2468            fidl::encoding::DynamicFlags::empty(),
2469        )
2470    }
2471
2472    /// This function will reset all state on this interface. This includes destroying all existing
2473    /// View and Viewports without returning the associated Token to the caller.
2474    pub fn r#clear(&self) -> Result<(), fidl::Error> {
2475        self.client.send::<fidl::encoding::EmptyPayload>(
2476            (),
2477            0x4ec8817c02828c3e,
2478            fidl::encoding::DynamicFlags::empty(),
2479        )
2480    }
2481
2482    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
2483    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
2484    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
2485    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
2486        self.client.send::<FlatlandSetDebugNameRequest>(
2487            (name,),
2488            0x46a8b397e68a8888,
2489            fidl::encoding::DynamicFlags::empty(),
2490        )
2491    }
2492}
2493
2494#[cfg(target_os = "fuchsia")]
2495impl From<FlatlandSynchronousProxy> for zx::Handle {
2496    fn from(value: FlatlandSynchronousProxy) -> Self {
2497        value.into_channel().into()
2498    }
2499}
2500
2501#[cfg(target_os = "fuchsia")]
2502impl From<fidl::Channel> for FlatlandSynchronousProxy {
2503    fn from(value: fidl::Channel) -> Self {
2504        Self::new(value)
2505    }
2506}
2507
2508#[cfg(target_os = "fuchsia")]
2509impl fidl::endpoints::FromClient for FlatlandSynchronousProxy {
2510    type Protocol = FlatlandMarker;
2511
2512    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandMarker>) -> Self {
2513        Self::new(value.into_channel())
2514    }
2515}
2516
2517#[derive(Debug, Clone)]
2518pub struct FlatlandProxy {
2519    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2520}
2521
2522impl fidl::endpoints::Proxy for FlatlandProxy {
2523    type Protocol = FlatlandMarker;
2524
2525    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2526        Self::new(inner)
2527    }
2528
2529    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2530        self.client.into_channel().map_err(|client| Self { client })
2531    }
2532
2533    fn as_channel(&self) -> &::fidl::AsyncChannel {
2534        self.client.as_channel()
2535    }
2536}
2537
2538impl FlatlandProxy {
2539    /// Create a new Proxy for fuchsia.ui.composition/Flatland.
2540    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2541        let protocol_name = <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2542        Self { client: fidl::client::Client::new(channel, protocol_name) }
2543    }
2544
2545    /// Get a Stream of events from the remote end of the protocol.
2546    ///
2547    /// # Panics
2548    ///
2549    /// Panics if the event stream was already taken.
2550    pub fn take_event_stream(&self) -> FlatlandEventStream {
2551        FlatlandEventStream { event_receiver: self.client.take_event_receiver() }
2552    }
2553
2554    /// Complete execution of all feed-forward operations.
2555    ///
2556    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
2557    /// is emitted. Operations that produce errors are ignored and the channel is closed.
2558    ///
2559    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
2560    /// with other valid fields.
2561    ///
2562    /// The client may only call [`Present`] when they have a non-zero number of present credits,
2563    /// which are tracked by the server. The server may increment the number of credits when it
2564    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
2565    /// present credits. Each [`Present`] call uses one present credit and decrements the server
2566    /// count by one. If the client calls [`Present`] with no present credits, the server will
2567    /// return a `NO_PRESENTS_REMAINING` error.
2568    ///
2569    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
2570    /// one present credit.
2571    ///
2572    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
2573    /// [`OnFramePresented`] event, typically in that order.
2574    ///
2575    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
2576    /// is fired. This event includes information pertaining to all [`Present`]s that had content
2577    /// that were part of that frame.
2578    ///
2579    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
2580    /// on what arguments are passed in and their role.
2581    pub fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
2582        FlatlandProxyInterface::r#present(self, args)
2583    }
2584
2585    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
2586    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
2587    /// instance that creates a Viewport has control over how the child's View is integrated into
2588    /// its own View.
2589    ///
2590    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
2591    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
2592    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
2593    /// ViewCreationToken to the child, which calls [`CreateView`].
2594    ///
2595    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
2596    /// the parent's Viewport.
2597    ///
2598    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
2599    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
2600    /// only have one parent.
2601    ///
2602    /// This function is queued, meaning that the Root Transform will not be attached to the
2603    /// parent Viewport until [`Present`] is called. However, clients will receive information
2604    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
2605    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
2606    /// clients to wait for layout information from their parent before calling [`Present`].
2607    ///
2608    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
2609    /// channel and this Flatland channel to be torn down.
2610    ///
2611    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
2612    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
2613    /// channel is destroyed.
2614    ///
2615    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
2616    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
2617    /// such as touch, mouse or focus.
2618    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
2619    /// `CreateView` to know that they are excluded from the ViewTree.
2620    pub fn r#create_view(
2621        &self,
2622        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2623        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2624    ) -> Result<(), fidl::Error> {
2625        FlatlandProxyInterface::r#create_view(self, token, parent_viewport_watcher)
2626    }
2627
2628    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
2629    /// view-bound protocols.
2630    pub fn r#create_view2(
2631        &self,
2632        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
2633        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
2634        mut protocols: ViewBoundProtocols,
2635        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
2636    ) -> Result<(), fidl::Error> {
2637        FlatlandProxyInterface::r#create_view2(
2638            self,
2639            token,
2640            view_identity,
2641            protocols,
2642            parent_viewport_watcher,
2643        )
2644    }
2645
2646    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
2647    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
2648    /// descendants can be rendered to a display.
2649    ///
2650    /// Transforms are kept alive, even when released, as long as they are children of either an
2651    /// unreleased Transform, or the Root Transform.
2652    ///
2653    /// Each Transform can have a single piece of attached Content. Common types of Content include
2654    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
2655    /// instances.
2656    ///
2657    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
2658    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
2659    ///
2660    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
2661    /// with the Content on the root transform, and continuing recursively through all of its child
2662    /// Transforms in the order the children were added. See [`AddChild`] for more information.
2663    ///
2664    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
2665    /// in use (see [`ReleaseTransform`] for more details).
2666    pub fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2667        FlatlandProxyInterface::r#create_transform(self, transform_id)
2668    }
2669
2670    /// All Transform objects support all attributes.
2671    ///
2672    /// Geometric attributes are applied in the following order:
2673    /// 1. Scale (relative to the parent transform's coordinate space)
2674    /// 2. Orientation (relative to the parent transform's coordinate space)
2675    /// 3. Translation (relative to the parent transforms's coordinate space,
2676    ///    unaffected by scale applied to the current transform).
2677    /// 4. Clipping (relative to the current transform's coordinate space)
2678    ///
2679    /// The effects of each of these attributes are cumulative. This means the transform's position
2680    /// in the view space, and its clip boundary, will be calculated based on that chain of
2681    /// geometric attributes going up to the root transform.
2682    ///
2683    /// For instance, in a nested hierarchy such as the following:
2684    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
2685    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
2686    /// view-space position of CurrentTransform will be [2,1].
2687    ///
2688    /// Sets the translation on a Transform. The order of geometric attribute application is
2689    /// addressed above.
2690    pub fn r#set_translation(
2691        &self,
2692        mut transform_id: &TransformId,
2693        mut translation: &fidl_fuchsia_math::Vec_,
2694    ) -> Result<(), fidl::Error> {
2695        FlatlandProxyInterface::r#set_translation(self, transform_id, translation)
2696    }
2697
2698    /// Sets the orientation on a Transform. The order of geometric attribute application is
2699    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
2700    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
2701    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
2702    pub fn r#set_orientation(
2703        &self,
2704        mut transform_id: &TransformId,
2705        mut orientation: Orientation,
2706    ) -> Result<(), fidl::Error> {
2707        FlatlandProxyInterface::r#set_orientation(self, transform_id, orientation)
2708    }
2709
2710    /// Sets the scale on a transform. The order of geometric attribute application is
2711    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
2712    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
2713    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
2714    pub fn r#set_scale(
2715        &self,
2716        mut transform_id: &TransformId,
2717        mut scale: &fidl_fuchsia_math::VecF,
2718    ) -> Result<(), fidl::Error> {
2719        FlatlandProxyInterface::r#set_scale(self, transform_id, scale)
2720    }
2721
2722    /// Sets an opacity in linear space to be applied to a transform and its descendents,
2723    /// which include other transforms and content. Opacity values must be in the range
2724    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
2725    /// Attempting to call this function with values outside that range will result in
2726    /// an error. A transform's opacity value is multiplied with that of its parent. This
2727    /// effect works differently from group opacity. Using group opacity, child nodes are
2728    /// rendered together first, and then have the parent's opacity applied as a post-effect.
2729    /// Here, opacity is applied to each child individually. This may result in a very
2730    /// different effect.
2731    pub fn r#set_opacity(
2732        &self,
2733        mut transform_id: &TransformId,
2734        mut value: f32,
2735    ) -> Result<(), fidl::Error> {
2736        FlatlandProxyInterface::r#set_opacity(self, transform_id, value)
2737    }
2738
2739    /// Sets the bounds, expressed in the local coordinate space of the transform, that
2740    /// constrains the region that content attached to this transform can be rendered to.
2741    /// If the content's area exceeds the clip bounds, the area outside the bounds will
2742    /// not be rendered. These bounds are valid for all children of this transform node as
2743    /// well, which includes nested Flatland instances and their node hierarchies.
2744    /// If a child transform attempts to set clip bounds larger than that of its parent,
2745    /// it will be clipped to the parent's clip bounds. The default state is for a transform
2746    /// to be unclipped, meaning it will not have any bounds placed on its render region.
2747    /// The clip width/height must be positive. Negative values will result in an error.
2748    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
2749    pub fn r#set_clip_boundary(
2750        &self,
2751        mut transform_id: &TransformId,
2752        mut rect: Option<&fidl_fuchsia_math::Rect>,
2753    ) -> Result<(), fidl::Error> {
2754        FlatlandProxyInterface::r#set_clip_boundary(self, transform_id, rect)
2755    }
2756
2757    /// Adds a child Transform to a parent Transform. The new child Transform, and any Content
2758    /// attached to it or its children, will be rendered on top of the parent's Content, as well as
2759    /// any previously added children.
2760    pub fn r#add_child(
2761        &self,
2762        mut parent_transform_id: &TransformId,
2763        mut child_transform_id: &TransformId,
2764    ) -> Result<(), fidl::Error> {
2765        FlatlandProxyInterface::r#add_child(self, parent_transform_id, child_transform_id)
2766    }
2767
2768    /// Removes a child Transform from a parent Transform.
2769    pub fn r#remove_child(
2770        &self,
2771        mut parent_transform_id: &TransformId,
2772        mut child_transform_id: &TransformId,
2773    ) -> Result<(), fidl::Error> {
2774        FlatlandProxyInterface::r#remove_child(self, parent_transform_id, child_transform_id)
2775    }
2776
2777    /// Removes all child Transforms from a parent Transform and replaces them with the new child
2778    /// transforms in `new_child_transform_ids`.
2779    pub fn r#replace_children(
2780        &self,
2781        mut parent_transform_id: &TransformId,
2782        mut new_child_transform_ids: &[TransformId],
2783    ) -> Result<(), fidl::Error> {
2784        FlatlandProxyInterface::r#replace_children(
2785            self,
2786            parent_transform_id,
2787            new_child_transform_ids,
2788        )
2789    }
2790
2791    /// Sets the Root Transform for the graph.
2792    ///
2793    /// The sub-graph defined by the Root Transform and its children will be rendered as View
2794    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
2795    /// in this Graph will be ignored.
2796    ///
2797    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
2798    /// released (see [`ReleaseTransform`] for more details).
2799    ///
2800    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
2801    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
2802    /// objects that are not referenced by the new root.
2803    ///
2804    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
2805    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
2806    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
2807    /// corner.
2808    ///
2809    /// Setting the root transform installs a full screen hit region on the root transform. Clients
2810    /// may remove this hit region if they don't want users to be able to interact with the root
2811    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
2812    /// documentation.
2813    ///
2814    /// Default hit region rules
2815    ///
2816    ///   A default hit region follows these rules:
2817    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
2818    ///   entire view.
2819    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
2820    ///   then no default hit region is active and the client specified hit regions are used.
2821    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
2822    ///   called, then the original transform no longer has its default hit region.
2823    ///   - Clients can remove or modify the root transform's hit regions the same way they would
2824    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
2825    ///   vector.
2826    pub fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
2827        FlatlandProxyInterface::r#set_root_transform(self, transform_id)
2828    }
2829
2830    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
2831    /// regions must be placed for a user to interact with the Content in a View. Because hit
2832    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
2833    /// and hit regions.
2834    ///
2835    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
2836    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
2837    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
2838    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
2839    /// that transitively connect to the root Transform have their hit regions interact with a hit
2840    /// test.
2841    ///
2842    /// Calling this function replaces any previous values set on this Transform. To reset a
2843    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2844    ///
2845    /// Note that root transforms get a default hit region installed by Flatland. For more details,
2846    /// see the [`SetRootTransform`] documentation.
2847    ///
2848    /// Precedence rules
2849    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
2850    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
2851    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
2852    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
2853    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
2854    ///   can cause confusing behavior.
2855    ///
2856    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
2857    ///   precedence over those behind. This follows the expected reverse "render order" of
2858    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
2859    ///   Content that is visible, or front-most.
2860    ///
2861    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
2862    ///   Transform's hit regions take precedence over those behind. This follows the expected
2863    ///   reverse "render order" of views, where a user expects to interact with the View that is
2864    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
2865    ///   the parent View, the user expects to interact with the child's Content.
2866    pub fn r#set_hit_regions(
2867        &self,
2868        mut transform_id: &TransformId,
2869        mut regions: &[HitRegion],
2870    ) -> Result<(), fidl::Error> {
2871        FlatlandProxyInterface::r#set_hit_regions(self, transform_id, regions)
2872    }
2873
2874    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
2875    /// covers an infinite region. The hit region is invariant against translation, scaling, and
2876    /// orientation of the Transform.
2877    ///
2878    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
2879    /// finite hit region.
2880    ///
2881    /// Calling this function replaces any previous values set on this Transform. To reset a
2882    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
2883    pub fn r#set_infinite_hit_region(
2884        &self,
2885        mut transform_id: &TransformId,
2886        mut hit_test: HitTestInteraction,
2887    ) -> Result<(), fidl::Error> {
2888        FlatlandProxyInterface::r#set_infinite_hit_region(self, transform_id, hit_test)
2889    }
2890
2891    /// The Viewport and View pair, together, represent the connection between two Flatland
2892    /// instances. The Viewport is created in the parent, and the View is created in the child. The
2893    /// parent has control over how the child's View is integrated into its own View.
2894    ///
2895    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
2896    /// Flatland channel to be torn down.
2897    ///
2898    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
2899    /// the layout of the child. The logical_size is also used as the default Content size, but
2900    /// subsequent changes to the logical_size will have no effect on the Content size.
2901    ///
2902    /// `ViewportProperties` may have inset field not set. In that case, the default value of
2903    /// (0, 0, 0, 0) is used.
2904    ///
2905    /// The logical_size must have positive X and Y components.
2906    ///
2907    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
2908    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
2909    ///
2910    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
2911    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
2912    /// destroyed.
2913    pub fn r#create_viewport(
2914        &self,
2915        mut viewport_id: &ContentId,
2916        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
2917        mut properties: &ViewportProperties,
2918        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
2919    ) -> Result<(), fidl::Error> {
2920        FlatlandProxyInterface::r#create_viewport(
2921            self,
2922            viewport_id,
2923            token,
2924            properties,
2925            child_view_watcher,
2926        )
2927    }
2928
2929    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
2930    ///
2931    /// Image creation requires an allocated BufferCollection registered with Allocator. This
2932    /// function will fail unless all clients of the specified BufferCollection have set their
2933    /// constraints.
2934    ///
2935    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
2936    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
2937    /// valid range, etc.)
2938    ///
2939    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
2940    /// use for another piece of Content (see [`ReleaseImage`] for more details).
2941    pub fn r#create_image(
2942        &self,
2943        mut image_id: &ContentId,
2944        mut import_token: BufferCollectionImportToken,
2945        mut vmo_index: u32,
2946        mut properties: &ImageProperties,
2947    ) -> Result<(), fidl::Error> {
2948        FlatlandProxyInterface::r#create_image(self, image_id, import_token, vmo_index, properties)
2949    }
2950
2951    /// This function is used to determine the region (in texel space) of an image that will be used
2952    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
2953    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
2954    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
2955    /// on non-image content, or to sample a region outside of the texel space of the image. In
2956    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
2957    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
2958    /// image_height) or if any of the values are negative, this will result in an error.
2959    ///
2960    /// If this method is not called, the default sample region is the rectangle with origin at
2961    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
2962    pub fn r#set_image_sample_region(
2963        &self,
2964        mut image_id: &ContentId,
2965        mut rect: &fidl_fuchsia_math::RectF,
2966    ) -> Result<(), fidl::Error> {
2967        FlatlandProxyInterface::r#set_image_sample_region(self, image_id, rect)
2968    }
2969
2970    /// The content size for an Image is the size of the rectangle in the parent's logical
2971    /// coordinate space that the image occupies. This combined with the global translation of the
2972    /// transform it is attached to determines the size and location of where the content is
2973    /// rendered on the display.
2974    ///
2975    /// If this method is not called, the default image destination size is the width and height set
2976    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
2977    /// [`SetScale`] is used on the attached Transform or its parents.
2978    pub fn r#set_image_destination_size(
2979        &self,
2980        mut image_id: &ContentId,
2981        mut size: &fidl_fuchsia_math::SizeU,
2982    ) -> Result<(), fidl::Error> {
2983        FlatlandProxyInterface::r#set_image_destination_size(self, image_id, size)
2984    }
2985
2986    /// Determines the blend function to use when rendering the content specified by
2987    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
2988    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
2989    /// that are available, please refer to the BlendMode enum. If this function is not called, then
2990    /// the default blendmode is BlendMode::SRC.
2991    pub fn r#set_image_blending_function(
2992        &self,
2993        mut image_id: &ContentId,
2994        mut blend_mode: BlendMode,
2995    ) -> Result<(), fidl::Error> {
2996        FlatlandProxyInterface::r#set_image_blending_function(self, image_id, blend_mode)
2997    }
2998
2999    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
3000    /// be in the range [0.0, 1.0].
3001    pub fn r#set_image_opacity(
3002        &self,
3003        mut image_id: &ContentId,
3004        mut val: f32,
3005    ) -> Result<(), fidl::Error> {
3006        FlatlandProxyInterface::r#set_image_opacity(self, image_id, val)
3007    }
3008
3009    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
3010    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
3011    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
3012    /// parent Transform Orientations. If this function is not called, then the default flip value
3013    /// is ImageFlip::NONE.
3014    pub fn r#set_image_flip(
3015        &self,
3016        mut image_id: &ContentId,
3017        mut flip: ImageFlip,
3018    ) -> Result<(), fidl::Error> {
3019        FlatlandProxyInterface::r#set_image_flip(self, image_id, flip)
3020    }
3021
3022    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
3023    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
3024    /// before a filled rect can be used for rendering. Not doing so will result the
3025    pub fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3026        FlatlandProxyInterface::r#create_filled_rect(self, rect_id)
3027    }
3028
3029    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
3030    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
3031    /// must be within the range [0,1] inclusive, and normal 32-bit
3032    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
3033    /// that do not conform to these specifications will cause the channel to close.
3034    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
3035    /// Hence, its bottom right corner will be at (size.width, size.height).
3036    pub fn r#set_solid_fill(
3037        &self,
3038        mut rect_id: &ContentId,
3039        mut color: &ColorRgba,
3040        mut size: &fidl_fuchsia_math::SizeU,
3041    ) -> Result<(), fidl::Error> {
3042        FlatlandProxyInterface::r#set_solid_fill(self, rect_id, color, size)
3043    }
3044
3045    /// Automatically garbage collects the rectangle when it is no longer needed for
3046    /// rendering. |rect_id| must have been instantiated with a call to
3047    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
3048    /// to be used again.
3049    pub fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3050        FlatlandProxyInterface::r#release_filled_rect(self, rect_id)
3051    }
3052
3053    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
3054    /// long as the Transform is visible from the root Transform. The Content will be rendered
3055    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
3056    ///
3057    /// Because each Transform can have, at most, a single piece of Content on it, calling this
3058    /// function on a Transform that already has Content will replace that Content.
3059    ///
3060    /// A Content may be set on more than one Transform.
3061    ///
3062    /// Calling this function with a Content id of 0 will remove any Content currently on the
3063    /// Transform.
3064    pub fn r#set_content(
3065        &self,
3066        mut transform_id: &TransformId,
3067        mut content_id: &ContentId,
3068    ) -> Result<(), fidl::Error> {
3069        FlatlandProxyInterface::r#set_content(self, transform_id, content_id)
3070    }
3071
3072    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
3073    /// have special properties that are not part of the Transform hierarchy. Those properties can
3074    /// be set using this function.
3075    pub fn r#set_viewport_properties(
3076        &self,
3077        mut viewport_id: &ContentId,
3078        mut properties: &ViewportProperties,
3079    ) -> Result<(), fidl::Error> {
3080        FlatlandProxyInterface::r#set_viewport_properties(self, viewport_id, properties)
3081    }
3082
3083    /// Released Transforms will be garbage collected by the system once they are no longer
3084    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
3085    /// Transform to the newly-released Transform.
3086    ///
3087    /// Once released, the id immediately goes out of scope for future function calls and can be
3088    /// reused when creating new Transforms.
3089    ///
3090    /// It is an error to call functions with a released id (unless that id has been reused to
3091    /// construct a new Transform).
3092    pub fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3093        FlatlandProxyInterface::r#release_transform(self, transform_id)
3094    }
3095
3096    pub fn r#release_view(&self) -> Result<(), fidl::Error> {
3097        FlatlandProxyInterface::r#release_view(self)
3098    }
3099
3100    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
3101    /// Unlike other resources, Viewports are garbage collected by the system during the next
3102    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
3103    ///
3104    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
3105    ///
3106    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
3107    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
3108    /// after the presented operations have been executed.
3109    pub fn r#release_viewport(
3110        &self,
3111        mut viewport_id: &ContentId,
3112    ) -> fidl::client::QueryResponseFut<
3113        fidl_fuchsia_ui_views::ViewportCreationToken,
3114        fidl::encoding::DefaultFuchsiaResourceDialect,
3115    > {
3116        FlatlandProxyInterface::r#release_viewport(self, viewport_id)
3117    }
3118
3119    /// Released Images will be garbage collected by the system once they are no longer necessary
3120    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
3121    /// any pending rendering that references the Image is complete.
3122    ///
3123    /// Use SetContent(transform_id, 0) to clean up references to released Images.
3124    ///
3125    /// Once released, the id immediately goes out of scope for future function calls and can be
3126    /// reused when creating new Images.
3127    ///
3128    /// It is an error to call functions with a released id (unless that id has been reused to
3129    /// construct a new Image).
3130    pub fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3131        FlatlandProxyInterface::r#release_image(self, image_id)
3132    }
3133
3134    /// This function will reset all state on this interface. This includes destroying all existing
3135    /// View and Viewports without returning the associated Token to the caller.
3136    pub fn r#clear(&self) -> Result<(), fidl::Error> {
3137        FlatlandProxyInterface::r#clear(self)
3138    }
3139
3140    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
3141    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
3142    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
3143    pub fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3144        FlatlandProxyInterface::r#set_debug_name(self, name)
3145    }
3146}
3147
3148impl FlatlandProxyInterface for FlatlandProxy {
3149    fn r#present(&self, mut args: PresentArgs) -> Result<(), fidl::Error> {
3150        self.client.send::<FlatlandPresentRequest>(
3151            (&mut args,),
3152            0x50acc2aa1f0acec7,
3153            fidl::encoding::DynamicFlags::empty(),
3154        )
3155    }
3156
3157    fn r#create_view(
3158        &self,
3159        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3160        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3161    ) -> Result<(), fidl::Error> {
3162        self.client.send::<FlatlandCreateViewRequest>(
3163            (&mut token, parent_viewport_watcher),
3164            0x504686eb25864780,
3165            fidl::encoding::DynamicFlags::empty(),
3166        )
3167    }
3168
3169    fn r#create_view2(
3170        &self,
3171        mut token: fidl_fuchsia_ui_views::ViewCreationToken,
3172        mut view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
3173        mut protocols: ViewBoundProtocols,
3174        mut parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
3175    ) -> Result<(), fidl::Error> {
3176        self.client.send::<FlatlandCreateView2Request>(
3177            (&mut token, &mut view_identity, &mut protocols, parent_viewport_watcher),
3178            0x340a3a40c2fdbd5e,
3179            fidl::encoding::DynamicFlags::empty(),
3180        )
3181    }
3182
3183    fn r#create_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3184        self.client.send::<FlatlandCreateTransformRequest>(
3185            (transform_id,),
3186            0x5e042a4d3de3efb0,
3187            fidl::encoding::DynamicFlags::empty(),
3188        )
3189    }
3190
3191    fn r#set_translation(
3192        &self,
3193        mut transform_id: &TransformId,
3194        mut translation: &fidl_fuchsia_math::Vec_,
3195    ) -> Result<(), fidl::Error> {
3196        self.client.send::<FlatlandSetTranslationRequest>(
3197            (transform_id, translation),
3198            0x7863398291fba346,
3199            fidl::encoding::DynamicFlags::empty(),
3200        )
3201    }
3202
3203    fn r#set_orientation(
3204        &self,
3205        mut transform_id: &TransformId,
3206        mut orientation: Orientation,
3207    ) -> Result<(), fidl::Error> {
3208        self.client.send::<FlatlandSetOrientationRequest>(
3209            (transform_id, orientation),
3210            0x4915310bc4928edc,
3211            fidl::encoding::DynamicFlags::empty(),
3212        )
3213    }
3214
3215    fn r#set_scale(
3216        &self,
3217        mut transform_id: &TransformId,
3218        mut scale: &fidl_fuchsia_math::VecF,
3219    ) -> Result<(), fidl::Error> {
3220        self.client.send::<FlatlandSetScaleRequest>(
3221            (transform_id, scale),
3222            0x1ea1766fd8996bb4,
3223            fidl::encoding::DynamicFlags::empty(),
3224        )
3225    }
3226
3227    fn r#set_opacity(
3228        &self,
3229        mut transform_id: &TransformId,
3230        mut value: f32,
3231    ) -> Result<(), fidl::Error> {
3232        self.client.send::<FlatlandSetOpacityRequest>(
3233            (transform_id, value),
3234            0x3775fc2c00b432fa,
3235            fidl::encoding::DynamicFlags::empty(),
3236        )
3237    }
3238
3239    fn r#set_clip_boundary(
3240        &self,
3241        mut transform_id: &TransformId,
3242        mut rect: Option<&fidl_fuchsia_math::Rect>,
3243    ) -> Result<(), fidl::Error> {
3244        self.client.send::<FlatlandSetClipBoundaryRequest>(
3245            (transform_id, rect),
3246            0x6507843df12222d2,
3247            fidl::encoding::DynamicFlags::empty(),
3248        )
3249    }
3250
3251    fn r#add_child(
3252        &self,
3253        mut parent_transform_id: &TransformId,
3254        mut child_transform_id: &TransformId,
3255    ) -> Result<(), fidl::Error> {
3256        self.client.send::<FlatlandAddChildRequest>(
3257            (parent_transform_id, child_transform_id),
3258            0x67a8abd2f19b1a74,
3259            fidl::encoding::DynamicFlags::empty(),
3260        )
3261    }
3262
3263    fn r#remove_child(
3264        &self,
3265        mut parent_transform_id: &TransformId,
3266        mut child_transform_id: &TransformId,
3267    ) -> Result<(), fidl::Error> {
3268        self.client.send::<FlatlandRemoveChildRequest>(
3269            (parent_transform_id, child_transform_id),
3270            0x41d6cd90b298b67a,
3271            fidl::encoding::DynamicFlags::empty(),
3272        )
3273    }
3274
3275    fn r#replace_children(
3276        &self,
3277        mut parent_transform_id: &TransformId,
3278        mut new_child_transform_ids: &[TransformId],
3279    ) -> Result<(), fidl::Error> {
3280        self.client.send::<FlatlandReplaceChildrenRequest>(
3281            (parent_transform_id, new_child_transform_ids),
3282            0x5b6d86cbbff81316,
3283            fidl::encoding::DynamicFlags::empty(),
3284        )
3285    }
3286
3287    fn r#set_root_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3288        self.client.send::<FlatlandSetRootTransformRequest>(
3289            (transform_id,),
3290            0x6e80ca5bcc566cd8,
3291            fidl::encoding::DynamicFlags::empty(),
3292        )
3293    }
3294
3295    fn r#set_hit_regions(
3296        &self,
3297        mut transform_id: &TransformId,
3298        mut regions: &[HitRegion],
3299    ) -> Result<(), fidl::Error> {
3300        self.client.send::<FlatlandSetHitRegionsRequest>(
3301            (transform_id, regions),
3302            0x31c9d17b07c37ce4,
3303            fidl::encoding::DynamicFlags::empty(),
3304        )
3305    }
3306
3307    fn r#set_infinite_hit_region(
3308        &self,
3309        mut transform_id: &TransformId,
3310        mut hit_test: HitTestInteraction,
3311    ) -> Result<(), fidl::Error> {
3312        self.client.send::<FlatlandSetInfiniteHitRegionRequest>(
3313            (transform_id, hit_test),
3314            0x26d81af852d29562,
3315            fidl::encoding::DynamicFlags::empty(),
3316        )
3317    }
3318
3319    fn r#create_viewport(
3320        &self,
3321        mut viewport_id: &ContentId,
3322        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
3323        mut properties: &ViewportProperties,
3324        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
3325    ) -> Result<(), fidl::Error> {
3326        self.client.send::<FlatlandCreateViewportRequest>(
3327            (viewport_id, &mut token, properties, child_view_watcher),
3328            0x2485fbcab7f943c,
3329            fidl::encoding::DynamicFlags::empty(),
3330        )
3331    }
3332
3333    fn r#create_image(
3334        &self,
3335        mut image_id: &ContentId,
3336        mut import_token: BufferCollectionImportToken,
3337        mut vmo_index: u32,
3338        mut properties: &ImageProperties,
3339    ) -> Result<(), fidl::Error> {
3340        self.client.send::<FlatlandCreateImageRequest>(
3341            (image_id, &mut import_token, vmo_index, properties),
3342            0x26fae823c4ebedad,
3343            fidl::encoding::DynamicFlags::empty(),
3344        )
3345    }
3346
3347    fn r#set_image_sample_region(
3348        &self,
3349        mut image_id: &ContentId,
3350        mut rect: &fidl_fuchsia_math::RectF,
3351    ) -> Result<(), fidl::Error> {
3352        self.client.send::<FlatlandSetImageSampleRegionRequest>(
3353            (image_id, rect),
3354            0x8039391d715eb28,
3355            fidl::encoding::DynamicFlags::empty(),
3356        )
3357    }
3358
3359    fn r#set_image_destination_size(
3360        &self,
3361        mut image_id: &ContentId,
3362        mut size: &fidl_fuchsia_math::SizeU,
3363    ) -> Result<(), fidl::Error> {
3364        self.client.send::<FlatlandSetImageDestinationSizeRequest>(
3365            (image_id, size),
3366            0x766cf99a2ec58446,
3367            fidl::encoding::DynamicFlags::empty(),
3368        )
3369    }
3370
3371    fn r#set_image_blending_function(
3372        &self,
3373        mut image_id: &ContentId,
3374        mut blend_mode: BlendMode,
3375    ) -> Result<(), fidl::Error> {
3376        self.client.send::<FlatlandSetImageBlendingFunctionRequest>(
3377            (image_id, blend_mode),
3378            0x10f5da1356275b7b,
3379            fidl::encoding::DynamicFlags::empty(),
3380        )
3381    }
3382
3383    fn r#set_image_opacity(
3384        &self,
3385        mut image_id: &ContentId,
3386        mut val: f32,
3387    ) -> Result<(), fidl::Error> {
3388        self.client.send::<FlatlandSetImageOpacityRequest>(
3389            (image_id, val),
3390            0x2da9e4ef4c2cff6f,
3391            fidl::encoding::DynamicFlags::empty(),
3392        )
3393    }
3394
3395    fn r#set_image_flip(
3396        &self,
3397        mut image_id: &ContentId,
3398        mut flip: ImageFlip,
3399    ) -> Result<(), fidl::Error> {
3400        self.client.send::<FlatlandSetImageFlipRequest>(
3401            (image_id, flip),
3402            0x21b20f2c14aae6bc,
3403            fidl::encoding::DynamicFlags::empty(),
3404        )
3405    }
3406
3407    fn r#create_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3408        self.client.send::<FlatlandCreateFilledRectRequest>(
3409            (rect_id,),
3410            0x5e62355abc1c4c5d,
3411            fidl::encoding::DynamicFlags::empty(),
3412        )
3413    }
3414
3415    fn r#set_solid_fill(
3416        &self,
3417        mut rect_id: &ContentId,
3418        mut color: &ColorRgba,
3419        mut size: &fidl_fuchsia_math::SizeU,
3420    ) -> Result<(), fidl::Error> {
3421        self.client.send::<FlatlandSetSolidFillRequest>(
3422            (rect_id, color, size),
3423            0x32d6ef41e182dfa5,
3424            fidl::encoding::DynamicFlags::empty(),
3425        )
3426    }
3427
3428    fn r#release_filled_rect(&self, mut rect_id: &ContentId) -> Result<(), fidl::Error> {
3429        self.client.send::<FlatlandReleaseFilledRectRequest>(
3430            (rect_id,),
3431            0x7392cabe45618f9b,
3432            fidl::encoding::DynamicFlags::empty(),
3433        )
3434    }
3435
3436    fn r#set_content(
3437        &self,
3438        mut transform_id: &TransformId,
3439        mut content_id: &ContentId,
3440    ) -> Result<(), fidl::Error> {
3441        self.client.send::<FlatlandSetContentRequest>(
3442            (transform_id, content_id),
3443            0x4ed2cfc0ce130862,
3444            fidl::encoding::DynamicFlags::empty(),
3445        )
3446    }
3447
3448    fn r#set_viewport_properties(
3449        &self,
3450        mut viewport_id: &ContentId,
3451        mut properties: &ViewportProperties,
3452    ) -> Result<(), fidl::Error> {
3453        self.client.send::<FlatlandSetViewportPropertiesRequest>(
3454            (viewport_id, properties),
3455            0x66ab67e9608ddb9f,
3456            fidl::encoding::DynamicFlags::empty(),
3457        )
3458    }
3459
3460    fn r#release_transform(&self, mut transform_id: &TransformId) -> Result<(), fidl::Error> {
3461        self.client.send::<FlatlandReleaseTransformRequest>(
3462            (transform_id,),
3463            0xab9328419451c22,
3464            fidl::encoding::DynamicFlags::empty(),
3465        )
3466    }
3467
3468    fn r#release_view(&self) -> Result<(), fidl::Error> {
3469        self.client.send::<fidl::encoding::EmptyPayload>(
3470            (),
3471            0x5b35aab9baffecae,
3472            fidl::encoding::DynamicFlags::empty(),
3473        )
3474    }
3475
3476    type ReleaseViewportResponseFut = fidl::client::QueryResponseFut<
3477        fidl_fuchsia_ui_views::ViewportCreationToken,
3478        fidl::encoding::DefaultFuchsiaResourceDialect,
3479    >;
3480    fn r#release_viewport(&self, mut viewport_id: &ContentId) -> Self::ReleaseViewportResponseFut {
3481        fn _decode(
3482            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
3483        ) -> Result<fidl_fuchsia_ui_views::ViewportCreationToken, fidl::Error> {
3484            let _response = fidl::client::decode_transaction_body::<
3485                FlatlandReleaseViewportResponse,
3486                fidl::encoding::DefaultFuchsiaResourceDialect,
3487                0xbad474aeb5293f9,
3488            >(_buf?)?;
3489            Ok(_response.token)
3490        }
3491        self.client.send_query_and_decode::<
3492            FlatlandReleaseViewportRequest,
3493            fidl_fuchsia_ui_views::ViewportCreationToken,
3494        >(
3495            (viewport_id,),
3496            0xbad474aeb5293f9,
3497            fidl::encoding::DynamicFlags::empty(),
3498            _decode,
3499        )
3500    }
3501
3502    fn r#release_image(&self, mut image_id: &ContentId) -> Result<(), fidl::Error> {
3503        self.client.send::<FlatlandReleaseImageRequest>(
3504            (image_id,),
3505            0xb884ffdbc72c111,
3506            fidl::encoding::DynamicFlags::empty(),
3507        )
3508    }
3509
3510    fn r#clear(&self) -> Result<(), fidl::Error> {
3511        self.client.send::<fidl::encoding::EmptyPayload>(
3512            (),
3513            0x4ec8817c02828c3e,
3514            fidl::encoding::DynamicFlags::empty(),
3515        )
3516    }
3517
3518    fn r#set_debug_name(&self, mut name: &str) -> Result<(), fidl::Error> {
3519        self.client.send::<FlatlandSetDebugNameRequest>(
3520            (name,),
3521            0x46a8b397e68a8888,
3522            fidl::encoding::DynamicFlags::empty(),
3523        )
3524    }
3525}
3526
3527pub struct FlatlandEventStream {
3528    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
3529}
3530
3531impl std::marker::Unpin for FlatlandEventStream {}
3532
3533impl futures::stream::FusedStream for FlatlandEventStream {
3534    fn is_terminated(&self) -> bool {
3535        self.event_receiver.is_terminated()
3536    }
3537}
3538
3539impl futures::Stream for FlatlandEventStream {
3540    type Item = Result<FlatlandEvent, fidl::Error>;
3541
3542    fn poll_next(
3543        mut self: std::pin::Pin<&mut Self>,
3544        cx: &mut std::task::Context<'_>,
3545    ) -> std::task::Poll<Option<Self::Item>> {
3546        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
3547            &mut self.event_receiver,
3548            cx
3549        )?) {
3550            Some(buf) => std::task::Poll::Ready(Some(FlatlandEvent::decode(buf))),
3551            None => std::task::Poll::Ready(None),
3552        }
3553    }
3554}
3555
3556#[derive(Debug)]
3557pub enum FlatlandEvent {
3558    OnNextFrameBegin { values: OnNextFrameBeginValues },
3559    OnFramePresented { frame_presented_info: fidl_fuchsia_scenic_scheduling::FramePresentedInfo },
3560    OnError { error: FlatlandError },
3561}
3562
3563impl FlatlandEvent {
3564    #[allow(irrefutable_let_patterns)]
3565    pub fn into_on_next_frame_begin(self) -> Option<OnNextFrameBeginValues> {
3566        if let FlatlandEvent::OnNextFrameBegin { values } = self {
3567            Some((values))
3568        } else {
3569            None
3570        }
3571    }
3572    #[allow(irrefutable_let_patterns)]
3573    pub fn into_on_frame_presented(
3574        self,
3575    ) -> Option<fidl_fuchsia_scenic_scheduling::FramePresentedInfo> {
3576        if let FlatlandEvent::OnFramePresented { frame_presented_info } = self {
3577            Some((frame_presented_info))
3578        } else {
3579            None
3580        }
3581    }
3582    #[allow(irrefutable_let_patterns)]
3583    pub fn into_on_error(self) -> Option<FlatlandError> {
3584        if let FlatlandEvent::OnError { error } = self {
3585            Some((error))
3586        } else {
3587            None
3588        }
3589    }
3590
3591    /// Decodes a message buffer as a [`FlatlandEvent`].
3592    fn decode(
3593        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
3594    ) -> Result<FlatlandEvent, fidl::Error> {
3595        let (bytes, _handles) = buf.split_mut();
3596        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3597        debug_assert_eq!(tx_header.tx_id, 0);
3598        match tx_header.ordinal {
3599            0x10f69a5cdeece84a => {
3600                let mut out = fidl::new_empty!(
3601                    FlatlandOnNextFrameBeginRequest,
3602                    fidl::encoding::DefaultFuchsiaResourceDialect
3603                );
3604                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnNextFrameBeginRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3605                Ok((FlatlandEvent::OnNextFrameBegin { values: out.values }))
3606            }
3607            0x56e43e1a5f30216d => {
3608                let mut out = fidl::new_empty!(
3609                    FlatlandOnFramePresentedRequest,
3610                    fidl::encoding::DefaultFuchsiaResourceDialect
3611                );
3612                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnFramePresentedRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3613                Ok((FlatlandEvent::OnFramePresented {
3614                    frame_presented_info: out.frame_presented_info,
3615                }))
3616            }
3617            0x1ebf39e90cd8b8d => {
3618                let mut out = fidl::new_empty!(
3619                    FlatlandOnErrorRequest,
3620                    fidl::encoding::DefaultFuchsiaResourceDialect
3621                );
3622                fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandOnErrorRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
3623                Ok((FlatlandEvent::OnError { error: out.error }))
3624            }
3625            _ => Err(fidl::Error::UnknownOrdinal {
3626                ordinal: tx_header.ordinal,
3627                protocol_name: <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
3628            }),
3629        }
3630    }
3631}
3632
3633/// A Stream of incoming requests for fuchsia.ui.composition/Flatland.
3634pub struct FlatlandRequestStream {
3635    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3636    is_terminated: bool,
3637}
3638
3639impl std::marker::Unpin for FlatlandRequestStream {}
3640
3641impl futures::stream::FusedStream for FlatlandRequestStream {
3642    fn is_terminated(&self) -> bool {
3643        self.is_terminated
3644    }
3645}
3646
3647impl fidl::endpoints::RequestStream for FlatlandRequestStream {
3648    type Protocol = FlatlandMarker;
3649    type ControlHandle = FlatlandControlHandle;
3650
3651    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
3652        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
3653    }
3654
3655    fn control_handle(&self) -> Self::ControlHandle {
3656        FlatlandControlHandle { inner: self.inner.clone() }
3657    }
3658
3659    fn into_inner(
3660        self,
3661    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
3662    {
3663        (self.inner, self.is_terminated)
3664    }
3665
3666    fn from_inner(
3667        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
3668        is_terminated: bool,
3669    ) -> Self {
3670        Self { inner, is_terminated }
3671    }
3672}
3673
3674impl futures::Stream for FlatlandRequestStream {
3675    type Item = Result<FlatlandRequest, fidl::Error>;
3676
3677    fn poll_next(
3678        mut self: std::pin::Pin<&mut Self>,
3679        cx: &mut std::task::Context<'_>,
3680    ) -> std::task::Poll<Option<Self::Item>> {
3681        let this = &mut *self;
3682        if this.inner.check_shutdown(cx) {
3683            this.is_terminated = true;
3684            return std::task::Poll::Ready(None);
3685        }
3686        if this.is_terminated {
3687            panic!("polled FlatlandRequestStream after completion");
3688        }
3689        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
3690            |bytes, handles| {
3691                match this.inner.channel().read_etc(cx, bytes, handles) {
3692                    std::task::Poll::Ready(Ok(())) => {}
3693                    std::task::Poll::Pending => return std::task::Poll::Pending,
3694                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
3695                        this.is_terminated = true;
3696                        return std::task::Poll::Ready(None);
3697                    }
3698                    std::task::Poll::Ready(Err(e)) => {
3699                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
3700                            e.into(),
3701                        ))))
3702                    }
3703                }
3704
3705                // A message has been received from the channel
3706                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
3707
3708                std::task::Poll::Ready(Some(match header.ordinal {
3709                    0x50acc2aa1f0acec7 => {
3710                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3711                        let mut req = fidl::new_empty!(
3712                            FlatlandPresentRequest,
3713                            fidl::encoding::DefaultFuchsiaResourceDialect
3714                        );
3715                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandPresentRequest>(&header, _body_bytes, handles, &mut req)?;
3716                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3717                        Ok(FlatlandRequest::Present { args: req.args, control_handle })
3718                    }
3719                    0x504686eb25864780 => {
3720                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3721                        let mut req = fidl::new_empty!(
3722                            FlatlandCreateViewRequest,
3723                            fidl::encoding::DefaultFuchsiaResourceDialect
3724                        );
3725                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewRequest>(&header, _body_bytes, handles, &mut req)?;
3726                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3727                        Ok(FlatlandRequest::CreateView {
3728                            token: req.token,
3729                            parent_viewport_watcher: req.parent_viewport_watcher,
3730
3731                            control_handle,
3732                        })
3733                    }
3734                    0x340a3a40c2fdbd5e => {
3735                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3736                        let mut req = fidl::new_empty!(
3737                            FlatlandCreateView2Request,
3738                            fidl::encoding::DefaultFuchsiaResourceDialect
3739                        );
3740                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateView2Request>(&header, _body_bytes, handles, &mut req)?;
3741                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3742                        Ok(FlatlandRequest::CreateView2 {
3743                            token: req.token,
3744                            view_identity: req.view_identity,
3745                            protocols: req.protocols,
3746                            parent_viewport_watcher: req.parent_viewport_watcher,
3747
3748                            control_handle,
3749                        })
3750                    }
3751                    0x5e042a4d3de3efb0 => {
3752                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3753                        let mut req = fidl::new_empty!(
3754                            FlatlandCreateTransformRequest,
3755                            fidl::encoding::DefaultFuchsiaResourceDialect
3756                        );
3757                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateTransformRequest>(&header, _body_bytes, handles, &mut req)?;
3758                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3759                        Ok(FlatlandRequest::CreateTransform {
3760                            transform_id: req.transform_id,
3761
3762                            control_handle,
3763                        })
3764                    }
3765                    0x7863398291fba346 => {
3766                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3767                        let mut req = fidl::new_empty!(
3768                            FlatlandSetTranslationRequest,
3769                            fidl::encoding::DefaultFuchsiaResourceDialect
3770                        );
3771                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetTranslationRequest>(&header, _body_bytes, handles, &mut req)?;
3772                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3773                        Ok(FlatlandRequest::SetTranslation {
3774                            transform_id: req.transform_id,
3775                            translation: req.translation,
3776
3777                            control_handle,
3778                        })
3779                    }
3780                    0x4915310bc4928edc => {
3781                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3782                        let mut req = fidl::new_empty!(
3783                            FlatlandSetOrientationRequest,
3784                            fidl::encoding::DefaultFuchsiaResourceDialect
3785                        );
3786                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOrientationRequest>(&header, _body_bytes, handles, &mut req)?;
3787                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3788                        Ok(FlatlandRequest::SetOrientation {
3789                            transform_id: req.transform_id,
3790                            orientation: req.orientation,
3791
3792                            control_handle,
3793                        })
3794                    }
3795                    0x1ea1766fd8996bb4 => {
3796                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3797                        let mut req = fidl::new_empty!(
3798                            FlatlandSetScaleRequest,
3799                            fidl::encoding::DefaultFuchsiaResourceDialect
3800                        );
3801                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetScaleRequest>(&header, _body_bytes, handles, &mut req)?;
3802                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3803                        Ok(FlatlandRequest::SetScale {
3804                            transform_id: req.transform_id,
3805                            scale: req.scale,
3806
3807                            control_handle,
3808                        })
3809                    }
3810                    0x3775fc2c00b432fa => {
3811                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3812                        let mut req = fidl::new_empty!(
3813                            FlatlandSetOpacityRequest,
3814                            fidl::encoding::DefaultFuchsiaResourceDialect
3815                        );
3816                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
3817                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3818                        Ok(FlatlandRequest::SetOpacity {
3819                            transform_id: req.transform_id,
3820                            value: req.value,
3821
3822                            control_handle,
3823                        })
3824                    }
3825                    0x6507843df12222d2 => {
3826                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3827                        let mut req = fidl::new_empty!(
3828                            FlatlandSetClipBoundaryRequest,
3829                            fidl::encoding::DefaultFuchsiaResourceDialect
3830                        );
3831                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetClipBoundaryRequest>(&header, _body_bytes, handles, &mut req)?;
3832                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3833                        Ok(FlatlandRequest::SetClipBoundary {
3834                            transform_id: req.transform_id,
3835                            rect: req.rect,
3836
3837                            control_handle,
3838                        })
3839                    }
3840                    0x67a8abd2f19b1a74 => {
3841                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3842                        let mut req = fidl::new_empty!(
3843                            FlatlandAddChildRequest,
3844                            fidl::encoding::DefaultFuchsiaResourceDialect
3845                        );
3846                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandAddChildRequest>(&header, _body_bytes, handles, &mut req)?;
3847                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3848                        Ok(FlatlandRequest::AddChild {
3849                            parent_transform_id: req.parent_transform_id,
3850                            child_transform_id: req.child_transform_id,
3851
3852                            control_handle,
3853                        })
3854                    }
3855                    0x41d6cd90b298b67a => {
3856                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3857                        let mut req = fidl::new_empty!(
3858                            FlatlandRemoveChildRequest,
3859                            fidl::encoding::DefaultFuchsiaResourceDialect
3860                        );
3861                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandRemoveChildRequest>(&header, _body_bytes, handles, &mut req)?;
3862                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3863                        Ok(FlatlandRequest::RemoveChild {
3864                            parent_transform_id: req.parent_transform_id,
3865                            child_transform_id: req.child_transform_id,
3866
3867                            control_handle,
3868                        })
3869                    }
3870                    0x5b6d86cbbff81316 => {
3871                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3872                        let mut req = fidl::new_empty!(
3873                            FlatlandReplaceChildrenRequest,
3874                            fidl::encoding::DefaultFuchsiaResourceDialect
3875                        );
3876                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReplaceChildrenRequest>(&header, _body_bytes, handles, &mut req)?;
3877                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3878                        Ok(FlatlandRequest::ReplaceChildren {
3879                            parent_transform_id: req.parent_transform_id,
3880                            new_child_transform_ids: req.new_child_transform_ids,
3881
3882                            control_handle,
3883                        })
3884                    }
3885                    0x6e80ca5bcc566cd8 => {
3886                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3887                        let mut req = fidl::new_empty!(
3888                            FlatlandSetRootTransformRequest,
3889                            fidl::encoding::DefaultFuchsiaResourceDialect
3890                        );
3891                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetRootTransformRequest>(&header, _body_bytes, handles, &mut req)?;
3892                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3893                        Ok(FlatlandRequest::SetRootTransform {
3894                            transform_id: req.transform_id,
3895
3896                            control_handle,
3897                        })
3898                    }
3899                    0x31c9d17b07c37ce4 => {
3900                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3901                        let mut req = fidl::new_empty!(
3902                            FlatlandSetHitRegionsRequest,
3903                            fidl::encoding::DefaultFuchsiaResourceDialect
3904                        );
3905                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetHitRegionsRequest>(&header, _body_bytes, handles, &mut req)?;
3906                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3907                        Ok(FlatlandRequest::SetHitRegions {
3908                            transform_id: req.transform_id,
3909                            regions: req.regions,
3910
3911                            control_handle,
3912                        })
3913                    }
3914                    0x26d81af852d29562 => {
3915                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3916                        let mut req = fidl::new_empty!(
3917                            FlatlandSetInfiniteHitRegionRequest,
3918                            fidl::encoding::DefaultFuchsiaResourceDialect
3919                        );
3920                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetInfiniteHitRegionRequest>(&header, _body_bytes, handles, &mut req)?;
3921                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3922                        Ok(FlatlandRequest::SetInfiniteHitRegion {
3923                            transform_id: req.transform_id,
3924                            hit_test: req.hit_test,
3925
3926                            control_handle,
3927                        })
3928                    }
3929                    0x2485fbcab7f943c => {
3930                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3931                        let mut req = fidl::new_empty!(
3932                            FlatlandCreateViewportRequest,
3933                            fidl::encoding::DefaultFuchsiaResourceDialect
3934                        );
3935                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateViewportRequest>(&header, _body_bytes, handles, &mut req)?;
3936                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3937                        Ok(FlatlandRequest::CreateViewport {
3938                            viewport_id: req.viewport_id,
3939                            token: req.token,
3940                            properties: req.properties,
3941                            child_view_watcher: req.child_view_watcher,
3942
3943                            control_handle,
3944                        })
3945                    }
3946                    0x26fae823c4ebedad => {
3947                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3948                        let mut req = fidl::new_empty!(
3949                            FlatlandCreateImageRequest,
3950                            fidl::encoding::DefaultFuchsiaResourceDialect
3951                        );
3952                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateImageRequest>(&header, _body_bytes, handles, &mut req)?;
3953                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3954                        Ok(FlatlandRequest::CreateImage {
3955                            image_id: req.image_id,
3956                            import_token: req.import_token,
3957                            vmo_index: req.vmo_index,
3958                            properties: req.properties,
3959
3960                            control_handle,
3961                        })
3962                    }
3963                    0x8039391d715eb28 => {
3964                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3965                        let mut req = fidl::new_empty!(
3966                            FlatlandSetImageSampleRegionRequest,
3967                            fidl::encoding::DefaultFuchsiaResourceDialect
3968                        );
3969                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageSampleRegionRequest>(&header, _body_bytes, handles, &mut req)?;
3970                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3971                        Ok(FlatlandRequest::SetImageSampleRegion {
3972                            image_id: req.image_id,
3973                            rect: req.rect,
3974
3975                            control_handle,
3976                        })
3977                    }
3978                    0x766cf99a2ec58446 => {
3979                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3980                        let mut req = fidl::new_empty!(
3981                            FlatlandSetImageDestinationSizeRequest,
3982                            fidl::encoding::DefaultFuchsiaResourceDialect
3983                        );
3984                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageDestinationSizeRequest>(&header, _body_bytes, handles, &mut req)?;
3985                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
3986                        Ok(FlatlandRequest::SetImageDestinationSize {
3987                            image_id: req.image_id,
3988                            size: req.size,
3989
3990                            control_handle,
3991                        })
3992                    }
3993                    0x10f5da1356275b7b => {
3994                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
3995                        let mut req = fidl::new_empty!(
3996                            FlatlandSetImageBlendingFunctionRequest,
3997                            fidl::encoding::DefaultFuchsiaResourceDialect
3998                        );
3999                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageBlendingFunctionRequest>(&header, _body_bytes, handles, &mut req)?;
4000                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4001                        Ok(FlatlandRequest::SetImageBlendingFunction {
4002                            image_id: req.image_id,
4003                            blend_mode: req.blend_mode,
4004
4005                            control_handle,
4006                        })
4007                    }
4008                    0x2da9e4ef4c2cff6f => {
4009                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4010                        let mut req = fidl::new_empty!(
4011                            FlatlandSetImageOpacityRequest,
4012                            fidl::encoding::DefaultFuchsiaResourceDialect
4013                        );
4014                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageOpacityRequest>(&header, _body_bytes, handles, &mut req)?;
4015                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4016                        Ok(FlatlandRequest::SetImageOpacity {
4017                            image_id: req.image_id,
4018                            val: req.val,
4019
4020                            control_handle,
4021                        })
4022                    }
4023                    0x21b20f2c14aae6bc => {
4024                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4025                        let mut req = fidl::new_empty!(
4026                            FlatlandSetImageFlipRequest,
4027                            fidl::encoding::DefaultFuchsiaResourceDialect
4028                        );
4029                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetImageFlipRequest>(&header, _body_bytes, handles, &mut req)?;
4030                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4031                        Ok(FlatlandRequest::SetImageFlip {
4032                            image_id: req.image_id,
4033                            flip: req.flip,
4034
4035                            control_handle,
4036                        })
4037                    }
4038                    0x5e62355abc1c4c5d => {
4039                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4040                        let mut req = fidl::new_empty!(
4041                            FlatlandCreateFilledRectRequest,
4042                            fidl::encoding::DefaultFuchsiaResourceDialect
4043                        );
4044                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandCreateFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4045                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4046                        Ok(FlatlandRequest::CreateFilledRect {
4047                            rect_id: req.rect_id,
4048
4049                            control_handle,
4050                        })
4051                    }
4052                    0x32d6ef41e182dfa5 => {
4053                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4054                        let mut req = fidl::new_empty!(
4055                            FlatlandSetSolidFillRequest,
4056                            fidl::encoding::DefaultFuchsiaResourceDialect
4057                        );
4058                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetSolidFillRequest>(&header, _body_bytes, handles, &mut req)?;
4059                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4060                        Ok(FlatlandRequest::SetSolidFill {
4061                            rect_id: req.rect_id,
4062                            color: req.color,
4063                            size: req.size,
4064
4065                            control_handle,
4066                        })
4067                    }
4068                    0x7392cabe45618f9b => {
4069                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4070                        let mut req = fidl::new_empty!(
4071                            FlatlandReleaseFilledRectRequest,
4072                            fidl::encoding::DefaultFuchsiaResourceDialect
4073                        );
4074                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseFilledRectRequest>(&header, _body_bytes, handles, &mut req)?;
4075                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4076                        Ok(FlatlandRequest::ReleaseFilledRect {
4077                            rect_id: req.rect_id,
4078
4079                            control_handle,
4080                        })
4081                    }
4082                    0x4ed2cfc0ce130862 => {
4083                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4084                        let mut req = fidl::new_empty!(
4085                            FlatlandSetContentRequest,
4086                            fidl::encoding::DefaultFuchsiaResourceDialect
4087                        );
4088                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetContentRequest>(&header, _body_bytes, handles, &mut req)?;
4089                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4090                        Ok(FlatlandRequest::SetContent {
4091                            transform_id: req.transform_id,
4092                            content_id: req.content_id,
4093
4094                            control_handle,
4095                        })
4096                    }
4097                    0x66ab67e9608ddb9f => {
4098                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4099                        let mut req = fidl::new_empty!(
4100                            FlatlandSetViewportPropertiesRequest,
4101                            fidl::encoding::DefaultFuchsiaResourceDialect
4102                        );
4103                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetViewportPropertiesRequest>(&header, _body_bytes, handles, &mut req)?;
4104                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4105                        Ok(FlatlandRequest::SetViewportProperties {
4106                            viewport_id: req.viewport_id,
4107                            properties: req.properties,
4108
4109                            control_handle,
4110                        })
4111                    }
4112                    0xab9328419451c22 => {
4113                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4114                        let mut req = fidl::new_empty!(
4115                            FlatlandReleaseTransformRequest,
4116                            fidl::encoding::DefaultFuchsiaResourceDialect
4117                        );
4118                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseTransformRequest>(&header, _body_bytes, handles, &mut req)?;
4119                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4120                        Ok(FlatlandRequest::ReleaseTransform {
4121                            transform_id: req.transform_id,
4122
4123                            control_handle,
4124                        })
4125                    }
4126                    0x5b35aab9baffecae => {
4127                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4128                        let mut req = fidl::new_empty!(
4129                            fidl::encoding::EmptyPayload,
4130                            fidl::encoding::DefaultFuchsiaResourceDialect
4131                        );
4132                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4133                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4134                        Ok(FlatlandRequest::ReleaseView { control_handle })
4135                    }
4136                    0xbad474aeb5293f9 => {
4137                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
4138                        let mut req = fidl::new_empty!(
4139                            FlatlandReleaseViewportRequest,
4140                            fidl::encoding::DefaultFuchsiaResourceDialect
4141                        );
4142                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseViewportRequest>(&header, _body_bytes, handles, &mut req)?;
4143                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4144                        Ok(FlatlandRequest::ReleaseViewport {
4145                            viewport_id: req.viewport_id,
4146
4147                            responder: FlatlandReleaseViewportResponder {
4148                                control_handle: std::mem::ManuallyDrop::new(control_handle),
4149                                tx_id: header.tx_id,
4150                            },
4151                        })
4152                    }
4153                    0xb884ffdbc72c111 => {
4154                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4155                        let mut req = fidl::new_empty!(
4156                            FlatlandReleaseImageRequest,
4157                            fidl::encoding::DefaultFuchsiaResourceDialect
4158                        );
4159                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandReleaseImageRequest>(&header, _body_bytes, handles, &mut req)?;
4160                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4161                        Ok(FlatlandRequest::ReleaseImage { image_id: req.image_id, control_handle })
4162                    }
4163                    0x4ec8817c02828c3e => {
4164                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4165                        let mut req = fidl::new_empty!(
4166                            fidl::encoding::EmptyPayload,
4167                            fidl::encoding::DefaultFuchsiaResourceDialect
4168                        );
4169                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
4170                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4171                        Ok(FlatlandRequest::Clear { control_handle })
4172                    }
4173                    0x46a8b397e68a8888 => {
4174                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
4175                        let mut req = fidl::new_empty!(
4176                            FlatlandSetDebugNameRequest,
4177                            fidl::encoding::DefaultFuchsiaResourceDialect
4178                        );
4179                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandSetDebugNameRequest>(&header, _body_bytes, handles, &mut req)?;
4180                        let control_handle = FlatlandControlHandle { inner: this.inner.clone() };
4181                        Ok(FlatlandRequest::SetDebugName { name: req.name, control_handle })
4182                    }
4183                    _ => Err(fidl::Error::UnknownOrdinal {
4184                        ordinal: header.ordinal,
4185                        protocol_name:
4186                            <FlatlandMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
4187                    }),
4188                }))
4189            },
4190        )
4191    }
4192}
4193
4194/// Each Flatland instance contains a Graph, which consists of a set of objects, and the
4195/// relationships between those objects. The client can specify a subset of those objects
4196/// (specifically, the directed acyclic graph starting at the root transform) to be presented as
4197/// content to some kind of output -- usually, a display.
4198///
4199/// Flatland Graphs are both hierarchical, and distributed. Graphs from different Flatland instances
4200/// may be connected together, allowing multiple processes to be involved in authoring content for a
4201/// particular output.
4202///
4203/// All functions in this protocol are feed-forward. The operations they represent are not fully
4204/// executed until [`Present`] is called.
4205#[derive(Debug)]
4206pub enum FlatlandRequest {
4207    /// Complete execution of all feed-forward operations.
4208    ///
4209    /// If executing an operation produces an error (e.g., CreateTransform(0)), an [`OnError`] event
4210    /// is emitted. Operations that produce errors are ignored and the channel is closed.
4211    ///
4212    /// If the execution is completed successfully, [`OnNextFrameBegin`] emits NO_ERROR along
4213    /// with other valid fields.
4214    ///
4215    /// The client may only call [`Present`] when they have a non-zero number of present credits,
4216    /// which are tracked by the server. The server may increment the number of credits when it
4217    /// fires the [`OnNextFrameBegin`] event, which informs the client when it receives additional
4218    /// present credits. Each [`Present`] call uses one present credit and decrements the server
4219    /// count by one. If the client calls [`Present`] with no present credits, the server will
4220    /// return a `NO_PRESENTS_REMAINING` error.
4221    ///
4222    /// The client should assume that prior to receiving any [`OnNextFrameBegin`] events, they have
4223    /// one present credit.
4224    ///
4225    /// Every [`Present`] call results in one [`OnNextFrameBegin`] event, and one
4226    /// [`OnFramePresented`] event, typically in that order.
4227    ///
4228    /// When the commands flushed by [`Present`] make it to display, an [`OnFramePresented`] event
4229    /// is fired. This event includes information pertaining to all [`Present`]s that had content
4230    /// that were part of that frame.
4231    ///
4232    /// See [`fuchsia.ui.composition/PresentArgs`] documentation above for more detailed information
4233    /// on what arguments are passed in and their role.
4234    Present {
4235        args: PresentArgs,
4236        control_handle: FlatlandControlHandle,
4237    },
4238    /// Two Flatland instances may be connected in a parent-child relationship. The parent endpoint
4239    /// is held in a Viewport, and the child endpoint is held in a View. The parent Flatland
4240    /// instance that creates a Viewport has control over how the child's View is integrated into
4241    /// its own View.
4242    ///
4243    /// The lifecycle of a parent-child connection starts with two endpoints of a channel object:
4244    /// a ViewportCreationToken and a ViewCreationToken. Out-of-band protocols pass the
4245    /// ViewportCreationToken to the parent, which calls [`CreateViewport`], and the
4246    /// ViewCreationToken to the child, which calls [`CreateView`].
4247    ///
4248    /// Only nodes connected to the Root Transform in this Flatland instance will be rendered into
4249    /// the parent's Viewport.
4250    ///
4251    /// Calling [`CreateView`] a second time will disconnect the Root Transform from the existing
4252    /// parent's Viewport, and attach it to a new parent's Viewport. In other words, each View can
4253    /// only have one parent.
4254    ///
4255    /// This function is queued, meaning that the Root Transform will not be attached to the
4256    /// parent Viewport until [`Present`] is called. However, clients will receive information
4257    /// through their ParentViewportWatcher (e.g., LayoutInfo) immediately after calling this
4258    /// function, even if they have not called [`Present`] or [`SetRootTransform`]. This allows
4259    /// clients to wait for layout information from their parent before calling [`Present`].
4260    ///
4261    /// Any illegal operations on ParentViewportWatcher will cause both ParentViewportWatcher
4262    /// channel and this Flatland channel to be torn down.
4263    ///
4264    /// Lifecycle note. The lifetime of the ParentViewportWatcher channel is bound by the peer
4265    /// ViewportCreationToken. When the ViewportCreationToken dies, this ParentViewportWatcher
4266    /// channel is destroyed.
4267    ///
4268    /// Views and subgraphs of Views created using `CreateView` will not be represented in the
4269    /// ViewTree, and hence will not be able to participate in any ViewTree-dependent interactions
4270    /// such as touch, mouse or focus.
4271    /// The Flatland protocol provides no way for Views in the subgraph of a View created with
4272    /// `CreateView` to know that they are excluded from the ViewTree.
4273    CreateView {
4274        token: fidl_fuchsia_ui_views::ViewCreationToken,
4275        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4276        control_handle: FlatlandControlHandle,
4277    },
4278    /// Identical to [`CreateView`], except it allows association of View identity (ViewRef) and
4279    /// view-bound protocols.
4280    CreateView2 {
4281        token: fidl_fuchsia_ui_views::ViewCreationToken,
4282        view_identity: fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4283        protocols: ViewBoundProtocols,
4284        parent_viewport_watcher: fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4285        control_handle: FlatlandControlHandle,
4286    },
4287    /// Creates a new Transform node. Transforms are a hierarchical piece of a Flatland graph. They
4288    /// can have children, and can reference Content. A sub-graph represented by a Transform and its
4289    /// descendants can be rendered to a display.
4290    ///
4291    /// Transforms are kept alive, even when released, as long as they are children of either an
4292    /// unreleased Transform, or the Root Transform.
4293    ///
4294    /// Each Transform can have a single piece of attached Content. Common types of Content include
4295    /// bitmaps, asynchronous streams of images, and Viewports to Views hosted in other Flatland
4296    /// instances.
4297    ///
4298    /// Transforms have attributes. Child Transforms inherit the combined attributes of their
4299    /// parents. Content attached to a Transform is also affected by that Transform's attributes.
4300    ///
4301    /// When a sub-graph of Transforms is rendered, Content will be rendered back-to-front, starting
4302    /// with the Content on the root transform, and continuing recursively through all of its child
4303    /// Transforms in the order the children were added. See [`AddChild`] for more information.
4304    ///
4305    /// Zero is not a valid transform id. All other values are valid, assuming they are not already
4306    /// in use (see [`ReleaseTransform`] for more details).
4307    CreateTransform {
4308        transform_id: TransformId,
4309        control_handle: FlatlandControlHandle,
4310    },
4311    /// All Transform objects support all attributes.
4312    ///
4313    /// Geometric attributes are applied in the following order:
4314    /// 1. Scale (relative to the parent transform's coordinate space)
4315    /// 2. Orientation (relative to the parent transform's coordinate space)
4316    /// 3. Translation (relative to the parent transforms's coordinate space,
4317    ///    unaffected by scale applied to the current transform).
4318    /// 4. Clipping (relative to the current transform's coordinate space)
4319    ///
4320    /// The effects of each of these attributes are cumulative. This means the transform's position
4321    /// in the view space, and its clip boundary, will be calculated based on that chain of
4322    /// geometric attributes going up to the root transform.
4323    ///
4324    /// For instance, in a nested hierarchy such as the following:
4325    ///     [Root-Transform -> Transform1 -> Transform2 -> CurrentTransform]
4326    /// If Transform1 is translated by [2,0] and Transform2 is translated by [0,1] then the
4327    /// view-space position of CurrentTransform will be [2,1].
4328    ///
4329    /// Sets the translation on a Transform. The order of geometric attribute application is
4330    /// addressed above.
4331    SetTranslation {
4332        transform_id: TransformId,
4333        translation: fidl_fuchsia_math::Vec_,
4334        control_handle: FlatlandControlHandle,
4335    },
4336    /// Sets the orientation on a Transform. The order of geometric attribute application is
4337    /// addressed in the documentation for [`SetTranslation`]. In Flatland, the +X axis is
4338    /// to the right and the +Y axis is down. There is no notion of a Z axis. CCW is defined
4339    /// from the POV of the user, as if a skeuomorphoic clock is displayed on the screen.
4340    SetOrientation {
4341        transform_id: TransformId,
4342        orientation: Orientation,
4343        control_handle: FlatlandControlHandle,
4344    },
4345    /// Sets the scale on a transform. The order of geometric attribute application is
4346    /// addressed above. The (x,y) values in the VecF |scale| refer to the scale factor in the
4347    /// x-axis (width) and y-axis (height) respectively. Scale values must be normal 32-bit
4348    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29
4349    SetScale {
4350        transform_id: TransformId,
4351        scale: fidl_fuchsia_math::VecF,
4352        control_handle: FlatlandControlHandle,
4353    },
4354    /// Sets an opacity in linear space to be applied to a transform and its descendents,
4355    /// which include other transforms and content. Opacity values must be in the range
4356    /// of [0.0, 1.0], where 0.0 is completely transparent and 1.0 is completely opaque.
4357    /// Attempting to call this function with values outside that range will result in
4358    /// an error. A transform's opacity value is multiplied with that of its parent. This
4359    /// effect works differently from group opacity. Using group opacity, child nodes are
4360    /// rendered together first, and then have the parent's opacity applied as a post-effect.
4361    /// Here, opacity is applied to each child individually. This may result in a very
4362    /// different effect.
4363    SetOpacity {
4364        transform_id: TransformId,
4365        value: f32,
4366        control_handle: FlatlandControlHandle,
4367    },
4368    /// Sets the bounds, expressed in the local coordinate space of the transform, that
4369    /// constrains the region that content attached to this transform can be rendered to.
4370    /// If the content's area exceeds the clip bounds, the area outside the bounds will
4371    /// not be rendered. These bounds are valid for all children of this transform node as
4372    /// well, which includes nested Flatland instances and their node hierarchies.
4373    /// If a child transform attempts to set clip bounds larger than that of its parent,
4374    /// it will be clipped to the parent's clip bounds. The default state is for a transform
4375    /// to be unclipped, meaning it will not have any bounds placed on its render region.
4376    /// The clip width/height must be positive. Negative values will result in an error.
4377    /// Passing in an empty box to the |rect| parameter will remove the clip bounds.
4378    SetClipBoundary {
4379        transform_id: TransformId,
4380        rect: Option<Box<fidl_fuchsia_math::Rect>>,
4381        control_handle: FlatlandControlHandle,
4382    },
4383    /// Adds a child Transform to a parent Transform. The new child Transform, and any Content
4384    /// attached to it or its children, will be rendered on top of the parent's Content, as well as
4385    /// any previously added children.
4386    AddChild {
4387        parent_transform_id: TransformId,
4388        child_transform_id: TransformId,
4389        control_handle: FlatlandControlHandle,
4390    },
4391    /// Removes a child Transform from a parent Transform.
4392    RemoveChild {
4393        parent_transform_id: TransformId,
4394        child_transform_id: TransformId,
4395        control_handle: FlatlandControlHandle,
4396    },
4397    /// Removes all child Transforms from a parent Transform and replaces them with the new child
4398    /// transforms in `new_child_transform_ids`.
4399    ReplaceChildren {
4400        parent_transform_id: TransformId,
4401        new_child_transform_ids: Vec<TransformId>,
4402        control_handle: FlatlandControlHandle,
4403    },
4404    /// Sets the Root Transform for the graph.
4405    ///
4406    /// The sub-graph defined by the Root Transform and its children will be rendered as View
4407    /// in the connected parent's Viewport (see [`CreateView`]). Any parents of the Root Transform
4408    /// in this Graph will be ignored.
4409    ///
4410    /// The Root Transform, and all children of the Root Transform, are kept alive if they are
4411    /// released (see [`ReleaseTransform`] for more details).
4412    ///
4413    /// There is only ever one Root. Since 0 is not a valid transform id (see [`CreateTransform`]),
4414    /// calling SetRootTransform(0) clears the current Root, destroying any previously released
4415    /// objects that are not referenced by the new root.
4416    ///
4417    /// Note that every View has a clip boundary equivalent to its logical size. Anything outside
4418    /// that clip boundary will not be rendered. Hence, the Root Transform has a useful coordinate
4419    /// space of (0, 0) to (logical_size.width, logical_size.height), where (0, 0) is the upper left
4420    /// corner.
4421    ///
4422    /// Setting the root transform installs a full screen hit region on the root transform. Clients
4423    /// may remove this hit region if they don't want users to be able to interact with the root
4424    /// transform's content. For additional details on hit regions, see the [`SetHitRegions`]
4425    /// documentation.
4426    ///
4427    /// Default hit region rules
4428    ///
4429    ///   A default hit region follows these rules:
4430    ///   - When [`SetRootTransform`](T) is called, T receives a maximal hit region, covering the
4431    ///   entire view.
4432    ///   - If [`SetHitRegions`] is called on T, either before or after [`SetRootTransform`](T),
4433    ///   then no default hit region is active and the client specified hit regions are used.
4434    ///   - If a transform is no longer the root transform, i.e., [`SetRootTransform`](U) is
4435    ///   called, then the original transform no longer has its default hit region.
4436    ///   - Clients can remove or modify the root transform's hit regions the same way they would
4437    ///   reset any other transform's hit regions, by calling [`SetHitRegions`] with the appropriate
4438    ///   vector.
4439    SetRootTransform {
4440        transform_id: TransformId,
4441        control_handle: FlatlandControlHandle,
4442    },
4443    /// Sets the interactive areas for a Transform. By default, Content is not interactive; hit
4444    /// regions must be placed for a user to interact with the Content in a View. Because hit
4445    /// regions are described in the Flatland protocol, a Flatland instance can synchronize Content
4446    /// and hit regions.
4447    ///
4448    /// Each hit region is placed in the coordinate space of the owning Transform, and may or may
4449    /// not interact with different types of hit testing, depending on its [`HitTestInteraction`]
4450    /// type. When there are multiple hit regions that intersect with a hit test, the precedence
4451    /// rules given below dictate which hit region has interacted with the hit test. Only Transforms
4452    /// that transitively connect to the root Transform have their hit regions interact with a hit
4453    /// test.
4454    ///
4455    /// Calling this function replaces any previous values set on this Transform. To reset a
4456    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4457    ///
4458    /// Note that root transforms get a default hit region installed by Flatland. For more details,
4459    /// see the [`SetRootTransform`] documentation.
4460    ///
4461    /// Precedence rules
4462    ///   Within a Transform, if multiple hit regions overlap, the hit test examines each
4463    ///   intersecting hit region for a possible interaction. Thus, for a regular hit test R and an
4464    ///   accessibility hit test A, where R and A both intersect two hit regions D ([`DEFAULT`]) and
4465    ///   S ([`SEMANTICALLY_INVISIBLE`]) on the same Transform, (1) R interacts with both D and S,
4466    ///   and (2) A only interacts with D. Generally, hit regions that overlap in a single Transform
4467    ///   can cause confusing behavior.
4468    ///
4469    ///   Within a View, for a given hit test, the front-most Transform's hit regions take
4470    ///   precedence over those behind. This follows the expected reverse "render order" of
4471    ///   Transforms (described in [`CreateTransform`]), where a user expects to interact with
4472    ///   Content that is visible, or front-most.
4473    ///
4474    ///   Across Flatland instances, for a given hit test, the front-most instance's front-most
4475    ///   Transform's hit regions take precedence over those behind. This follows the expected
4476    ///   reverse "render order" of views, where a user expects to interact with the View that is
4477    ///   visible, or front-most. For example, if a child View owns Content that is rendered over
4478    ///   the parent View, the user expects to interact with the child's Content.
4479    SetHitRegions {
4480        transform_id: TransformId,
4481        regions: Vec<HitRegion>,
4482        control_handle: FlatlandControlHandle,
4483    },
4484    /// Identical to [`SetHitRegions`], except the hit region associated with [`transform_id`]
4485    /// covers an infinite region. The hit region is invariant against translation, scaling, and
4486    /// orientation of the Transform.
4487    ///
4488    /// An infinite hit region is still limited in extent by the View's clip boundary, just like a
4489    /// finite hit region.
4490    ///
4491    /// Calling this function replaces any previous values set on this Transform. To reset a
4492    /// Transform to "no hit testing": send an empty vector with [`SetHitRegions`].
4493    SetInfiniteHitRegion {
4494        transform_id: TransformId,
4495        hit_test: HitTestInteraction,
4496        control_handle: FlatlandControlHandle,
4497    },
4498    /// The Viewport and View pair, together, represent the connection between two Flatland
4499    /// instances. The Viewport is created in the parent, and the View is created in the child. The
4500    /// parent has control over how the child's View is integrated into its own View.
4501    ///
4502    /// Any illegal operations on ChildViewWatcher will cause both ChildViewWatcher channel and this
4503    /// Flatland channel to be torn down.
4504    ///
4505    /// `ViewportProperties` must have logical_size set. This is the initial size that will drive
4506    /// the layout of the child. The logical_size is also used as the default Content size, but
4507    /// subsequent changes to the logical_size will have no effect on the Content size.
4508    ///
4509    /// `ViewportProperties` may have inset field not set. In that case, the default value of
4510    /// (0, 0, 0, 0) is used.
4511    ///
4512    /// The logical_size must have positive X and Y components.
4513    ///
4514    /// Zero is not a valid ContentId. All other values are valid, assuming they are not already
4515    /// in use for another piece of Content (see [`ReleaseViewport`] for more details).
4516    ///
4517    /// Lifecycle note. The lifetime of the ChildViewWatcher channel is bound by the peer
4518    /// ViewCreationToken. When the ViewCreationToken dies, this ChildViewWatcher channel is
4519    /// destroyed.
4520    CreateViewport {
4521        viewport_id: ContentId,
4522        token: fidl_fuchsia_ui_views::ViewportCreationToken,
4523        properties: ViewportProperties,
4524        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
4525        control_handle: FlatlandControlHandle,
4526    },
4527    /// An Image is a bitmap backed by a specific VMO in a BufferCollection.
4528    ///
4529    /// Image creation requires an allocated BufferCollection registered with Allocator. This
4530    /// function will fail unless all clients of the specified BufferCollection have set their
4531    /// constraints.
4532    ///
4533    /// The Image must reference a valid VMO index and must have ImageProperties that fall within
4534    /// the constraints specified by the backing BufferCollection (i.e. width and height within a
4535    /// valid range, etc.)
4536    ///
4537    /// Zero is not a valid Image id. All other values are valid, assuming they are not already in
4538    /// use for another piece of Content (see [`ReleaseImage`] for more details).
4539    CreateImage {
4540        image_id: ContentId,
4541        import_token: BufferCollectionImportToken,
4542        vmo_index: u32,
4543        properties: ImageProperties,
4544        control_handle: FlatlandControlHandle,
4545    },
4546    /// This function is used to determine the region (in texel space) of an image that will be used
4547    /// by Flatland when rendering. The image to be sampled is referenced by [`image_id`] and the
4548    /// sample region is specified by [`rect`] which itself is comprised of an origin point (x,y) as
4549    /// well as a width and height, in unnormalized coordinates. It is illegal to call this function
4550    /// on non-image content, or to sample a region outside of the texel space of the image. In
4551    /// other words, the region specifed by [`rect`] must not exceed the ranges (0, image_width) and
4552    /// (0, image_height). If (rect.x + rect.width > image_width) or (rect.y + rect.height >
4553    /// image_height) or if any of the values are negative, this will result in an error.
4554    ///
4555    /// If this method is not called, the default sample region is the rectangle with origin at
4556    /// (0, 0) and width and height set at ImageProperties from [`CreateImage`].
4557    SetImageSampleRegion {
4558        image_id: ContentId,
4559        rect: fidl_fuchsia_math::RectF,
4560        control_handle: FlatlandControlHandle,
4561    },
4562    /// The content size for an Image is the size of the rectangle in the parent's logical
4563    /// coordinate space that the image occupies. This combined with the global translation of the
4564    /// transform it is attached to determines the size and location of where the content is
4565    /// rendered on the display.
4566    ///
4567    /// If this method is not called, the default image destination size is the width and height set
4568    /// at ImageProperties from [`CreateImage`]. The destination size will be affected by scaling if
4569    /// [`SetScale`] is used on the attached Transform or its parents.
4570    SetImageDestinationSize {
4571        image_id: ContentId,
4572        size: fidl_fuchsia_math::SizeU,
4573        control_handle: FlatlandControlHandle,
4574    },
4575    /// Determines the blend function to use when rendering the content specified by
4576    /// |image_id|. |image_id| must be a valid ContentId associated to a transform through
4577    /// a call to |CreateImage| or |CreateFilledRect|. For details on the different blend functions
4578    /// that are available, please refer to the BlendMode enum. If this function is not called, then
4579    /// the default blendmode is BlendMode::SRC.
4580    SetImageBlendingFunction {
4581        image_id: ContentId,
4582        blend_mode: BlendMode,
4583        control_handle: FlatlandControlHandle,
4584    },
4585    /// Sets an opacity in linear space to be applied to a flatland image. Opacity values must
4586    /// be in the range [0.0, 1.0].
4587    SetImageOpacity {
4588        image_id: ContentId,
4589        val: f32,
4590        control_handle: FlatlandControlHandle,
4591    },
4592    /// Sets the image flip to be applied to a flatland image. This call must be performed after a
4593    /// successful |CreateImage| call. If an invalid |image_id| is supplied, the channel will be
4594    /// closed due to FlatlandError::BAD_OPERATION. This flip will be applied to the Image before
4595    /// parent Transform Orientations. If this function is not called, then the default flip value
4596    /// is ImageFlip::NONE.
4597    SetImageFlip {
4598        image_id: ContentId,
4599        flip: ImageFlip,
4600        control_handle: FlatlandControlHandle,
4601    },
4602    /// Creates a solid-color rectangle. By default a filled-rect does not have a defined
4603    /// color or size. It is necessary to call |SetSolidFill| to specify a color and size
4604    /// before a filled rect can be used for rendering. Not doing so will result the
4605    CreateFilledRect {
4606        rect_id: ContentId,
4607        control_handle: FlatlandControlHandle,
4608    },
4609    /// Defines the color and size of a filled rect. |rect_id| must refer to content that
4610    /// was created via a call to CreateFilledRect. The color is not premultiplied. Color values
4611    /// must be within the range [0,1] inclusive, and normal 32-bit
4612    /// floating point values: https://en.wikipedia.org/wiki/Normal_number_%28computing%29. Values
4613    /// that do not conform to these specifications will cause the channel to close.
4614    /// The rectangle's top left corner will be at (0, 0) in its transform's coordinate space.
4615    /// Hence, its bottom right corner will be at (size.width, size.height).
4616    SetSolidFill {
4617        rect_id: ContentId,
4618        color: ColorRgba,
4619        size: fidl_fuchsia_math::SizeU,
4620        control_handle: FlatlandControlHandle,
4621    },
4622    /// Automatically garbage collects the rectangle when it is no longer needed for
4623    /// rendering. |rect_id| must have been instantiated with a call to
4624    /// |CreateFilledRect|. Once released, the ID immediately goes out of scope and is free
4625    /// to be used again.
4626    ReleaseFilledRect {
4627        rect_id: ContentId,
4628        control_handle: FlatlandControlHandle,
4629    },
4630    /// Setting a piece of Content on a Transform makes that Content visible in the render tree as
4631    /// long as the Transform is visible from the root Transform. The Content will be rendered
4632    /// before, and therefore "behind", any Content attached to the descendants of the Transform.
4633    ///
4634    /// Because each Transform can have, at most, a single piece of Content on it, calling this
4635    /// function on a Transform that already has Content will replace that Content.
4636    ///
4637    /// A Content may be set on more than one Transform.
4638    ///
4639    /// Calling this function with a Content id of 0 will remove any Content currently on the
4640    /// Transform.
4641    SetContent {
4642        transform_id: TransformId,
4643        content_id: ContentId,
4644        control_handle: FlatlandControlHandle,
4645    },
4646    /// Transforms are usually sufficient to change how Content is presented. Viewports, however,
4647    /// have special properties that are not part of the Transform hierarchy. Those properties can
4648    /// be set using this function.
4649    SetViewportProperties {
4650        viewport_id: ContentId,
4651        properties: ViewportProperties,
4652        control_handle: FlatlandControlHandle,
4653    },
4654    /// Released Transforms will be garbage collected by the system once they are no longer
4655    /// necessary for rendering. For Transforms, this means there is no path from any unreleased
4656    /// Transform to the newly-released Transform.
4657    ///
4658    /// Once released, the id immediately goes out of scope for future function calls and can be
4659    /// reused when creating new Transforms.
4660    ///
4661    /// It is an error to call functions with a released id (unless that id has been reused to
4662    /// construct a new Transform).
4663    ReleaseTransform {
4664        transform_id: TransformId,
4665        control_handle: FlatlandControlHandle,
4666    },
4667    ReleaseView {
4668        control_handle: FlatlandControlHandle,
4669    },
4670    /// Releases a Viewport from the scene, even if the Viewport is still connected to a Transform.
4671    /// Unlike other resources, Viewports are garbage collected by the system during the next
4672    /// [`Present`] because a removed Viewport is guaranteed to provide no renderable content.
4673    ///
4674    /// Use SetContent(transform_id, 0) to clean up references to released Viewports.
4675    ///
4676    /// Despite having a return type, this function is still feed-forward like [`CreateView`] and
4677    /// requires a call to [`Present`] to be executed. The ViewportCreationToken will be returned
4678    /// after the presented operations have been executed.
4679    ReleaseViewport {
4680        viewport_id: ContentId,
4681        responder: FlatlandReleaseViewportResponder,
4682    },
4683    /// Released Images will be garbage collected by the system once they are no longer necessary
4684    /// for rendering. For Images, this means the Image is no longer attached to any Transform and
4685    /// any pending rendering that references the Image is complete.
4686    ///
4687    /// Use SetContent(transform_id, 0) to clean up references to released Images.
4688    ///
4689    /// Once released, the id immediately goes out of scope for future function calls and can be
4690    /// reused when creating new Images.
4691    ///
4692    /// It is an error to call functions with a released id (unless that id has been reused to
4693    /// construct a new Image).
4694    ReleaseImage {
4695        image_id: ContentId,
4696        control_handle: FlatlandControlHandle,
4697    },
4698    /// This function will reset all state on this interface. This includes destroying all existing
4699    /// View and Viewports without returning the associated Token to the caller.
4700    Clear {
4701        control_handle: FlatlandControlHandle,
4702    },
4703    /// Set debug name of the current client that can be used by Flatland to print as a prefix to
4704    /// logs to help client distinguish what is theirs. [`name`] can be an arbitrary string, but the
4705    /// current process name (see fsl::GetCurrentProcessName()) is a good default.
4706    SetDebugName {
4707        name: String,
4708        control_handle: FlatlandControlHandle,
4709    },
4710}
4711
4712impl FlatlandRequest {
4713    #[allow(irrefutable_let_patterns)]
4714    pub fn into_present(self) -> Option<(PresentArgs, FlatlandControlHandle)> {
4715        if let FlatlandRequest::Present { args, control_handle } = self {
4716            Some((args, control_handle))
4717        } else {
4718            None
4719        }
4720    }
4721
4722    #[allow(irrefutable_let_patterns)]
4723    pub fn into_create_view(
4724        self,
4725    ) -> Option<(
4726        fidl_fuchsia_ui_views::ViewCreationToken,
4727        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4728        FlatlandControlHandle,
4729    )> {
4730        if let FlatlandRequest::CreateView { token, parent_viewport_watcher, control_handle } = self
4731        {
4732            Some((token, parent_viewport_watcher, control_handle))
4733        } else {
4734            None
4735        }
4736    }
4737
4738    #[allow(irrefutable_let_patterns)]
4739    pub fn into_create_view2(
4740        self,
4741    ) -> Option<(
4742        fidl_fuchsia_ui_views::ViewCreationToken,
4743        fidl_fuchsia_ui_views::ViewIdentityOnCreation,
4744        ViewBoundProtocols,
4745        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
4746        FlatlandControlHandle,
4747    )> {
4748        if let FlatlandRequest::CreateView2 {
4749            token,
4750            view_identity,
4751            protocols,
4752            parent_viewport_watcher,
4753            control_handle,
4754        } = self
4755        {
4756            Some((token, view_identity, protocols, parent_viewport_watcher, control_handle))
4757        } else {
4758            None
4759        }
4760    }
4761
4762    #[allow(irrefutable_let_patterns)]
4763    pub fn into_create_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
4764        if let FlatlandRequest::CreateTransform { transform_id, control_handle } = self {
4765            Some((transform_id, control_handle))
4766        } else {
4767            None
4768        }
4769    }
4770
4771    #[allow(irrefutable_let_patterns)]
4772    pub fn into_set_translation(
4773        self,
4774    ) -> Option<(TransformId, fidl_fuchsia_math::Vec_, FlatlandControlHandle)> {
4775        if let FlatlandRequest::SetTranslation { transform_id, translation, control_handle } = self
4776        {
4777            Some((transform_id, translation, control_handle))
4778        } else {
4779            None
4780        }
4781    }
4782
4783    #[allow(irrefutable_let_patterns)]
4784    pub fn into_set_orientation(self) -> Option<(TransformId, Orientation, FlatlandControlHandle)> {
4785        if let FlatlandRequest::SetOrientation { transform_id, orientation, control_handle } = self
4786        {
4787            Some((transform_id, orientation, control_handle))
4788        } else {
4789            None
4790        }
4791    }
4792
4793    #[allow(irrefutable_let_patterns)]
4794    pub fn into_set_scale(
4795        self,
4796    ) -> Option<(TransformId, fidl_fuchsia_math::VecF, FlatlandControlHandle)> {
4797        if let FlatlandRequest::SetScale { transform_id, scale, control_handle } = self {
4798            Some((transform_id, scale, control_handle))
4799        } else {
4800            None
4801        }
4802    }
4803
4804    #[allow(irrefutable_let_patterns)]
4805    pub fn into_set_opacity(self) -> Option<(TransformId, f32, FlatlandControlHandle)> {
4806        if let FlatlandRequest::SetOpacity { transform_id, value, control_handle } = self {
4807            Some((transform_id, value, control_handle))
4808        } else {
4809            None
4810        }
4811    }
4812
4813    #[allow(irrefutable_let_patterns)]
4814    pub fn into_set_clip_boundary(
4815        self,
4816    ) -> Option<(TransformId, Option<Box<fidl_fuchsia_math::Rect>>, FlatlandControlHandle)> {
4817        if let FlatlandRequest::SetClipBoundary { transform_id, rect, control_handle } = self {
4818            Some((transform_id, rect, control_handle))
4819        } else {
4820            None
4821        }
4822    }
4823
4824    #[allow(irrefutable_let_patterns)]
4825    pub fn into_add_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
4826        if let FlatlandRequest::AddChild {
4827            parent_transform_id,
4828            child_transform_id,
4829            control_handle,
4830        } = self
4831        {
4832            Some((parent_transform_id, child_transform_id, control_handle))
4833        } else {
4834            None
4835        }
4836    }
4837
4838    #[allow(irrefutable_let_patterns)]
4839    pub fn into_remove_child(self) -> Option<(TransformId, TransformId, FlatlandControlHandle)> {
4840        if let FlatlandRequest::RemoveChild {
4841            parent_transform_id,
4842            child_transform_id,
4843            control_handle,
4844        } = self
4845        {
4846            Some((parent_transform_id, child_transform_id, control_handle))
4847        } else {
4848            None
4849        }
4850    }
4851
4852    #[allow(irrefutable_let_patterns)]
4853    pub fn into_replace_children(
4854        self,
4855    ) -> Option<(TransformId, Vec<TransformId>, FlatlandControlHandle)> {
4856        if let FlatlandRequest::ReplaceChildren {
4857            parent_transform_id,
4858            new_child_transform_ids,
4859            control_handle,
4860        } = self
4861        {
4862            Some((parent_transform_id, new_child_transform_ids, control_handle))
4863        } else {
4864            None
4865        }
4866    }
4867
4868    #[allow(irrefutable_let_patterns)]
4869    pub fn into_set_root_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
4870        if let FlatlandRequest::SetRootTransform { transform_id, control_handle } = self {
4871            Some((transform_id, control_handle))
4872        } else {
4873            None
4874        }
4875    }
4876
4877    #[allow(irrefutable_let_patterns)]
4878    pub fn into_set_hit_regions(
4879        self,
4880    ) -> Option<(TransformId, Vec<HitRegion>, FlatlandControlHandle)> {
4881        if let FlatlandRequest::SetHitRegions { transform_id, regions, control_handle } = self {
4882            Some((transform_id, regions, control_handle))
4883        } else {
4884            None
4885        }
4886    }
4887
4888    #[allow(irrefutable_let_patterns)]
4889    pub fn into_set_infinite_hit_region(
4890        self,
4891    ) -> Option<(TransformId, HitTestInteraction, FlatlandControlHandle)> {
4892        if let FlatlandRequest::SetInfiniteHitRegion { transform_id, hit_test, control_handle } =
4893            self
4894        {
4895            Some((transform_id, hit_test, control_handle))
4896        } else {
4897            None
4898        }
4899    }
4900
4901    #[allow(irrefutable_let_patterns)]
4902    pub fn into_create_viewport(
4903        self,
4904    ) -> Option<(
4905        ContentId,
4906        fidl_fuchsia_ui_views::ViewportCreationToken,
4907        ViewportProperties,
4908        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
4909        FlatlandControlHandle,
4910    )> {
4911        if let FlatlandRequest::CreateViewport {
4912            viewport_id,
4913            token,
4914            properties,
4915            child_view_watcher,
4916            control_handle,
4917        } = self
4918        {
4919            Some((viewport_id, token, properties, child_view_watcher, control_handle))
4920        } else {
4921            None
4922        }
4923    }
4924
4925    #[allow(irrefutable_let_patterns)]
4926    pub fn into_create_image(
4927        self,
4928    ) -> Option<(ContentId, BufferCollectionImportToken, u32, ImageProperties, FlatlandControlHandle)>
4929    {
4930        if let FlatlandRequest::CreateImage {
4931            image_id,
4932            import_token,
4933            vmo_index,
4934            properties,
4935            control_handle,
4936        } = self
4937        {
4938            Some((image_id, import_token, vmo_index, properties, control_handle))
4939        } else {
4940            None
4941        }
4942    }
4943
4944    #[allow(irrefutable_let_patterns)]
4945    pub fn into_set_image_sample_region(
4946        self,
4947    ) -> Option<(ContentId, fidl_fuchsia_math::RectF, FlatlandControlHandle)> {
4948        if let FlatlandRequest::SetImageSampleRegion { image_id, rect, control_handle } = self {
4949            Some((image_id, rect, control_handle))
4950        } else {
4951            None
4952        }
4953    }
4954
4955    #[allow(irrefutable_let_patterns)]
4956    pub fn into_set_image_destination_size(
4957        self,
4958    ) -> Option<(ContentId, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
4959        if let FlatlandRequest::SetImageDestinationSize { image_id, size, control_handle } = self {
4960            Some((image_id, size, control_handle))
4961        } else {
4962            None
4963        }
4964    }
4965
4966    #[allow(irrefutable_let_patterns)]
4967    pub fn into_set_image_blending_function(
4968        self,
4969    ) -> Option<(ContentId, BlendMode, FlatlandControlHandle)> {
4970        if let FlatlandRequest::SetImageBlendingFunction { image_id, blend_mode, control_handle } =
4971            self
4972        {
4973            Some((image_id, blend_mode, control_handle))
4974        } else {
4975            None
4976        }
4977    }
4978
4979    #[allow(irrefutable_let_patterns)]
4980    pub fn into_set_image_opacity(self) -> Option<(ContentId, f32, FlatlandControlHandle)> {
4981        if let FlatlandRequest::SetImageOpacity { image_id, val, control_handle } = self {
4982            Some((image_id, val, control_handle))
4983        } else {
4984            None
4985        }
4986    }
4987
4988    #[allow(irrefutable_let_patterns)]
4989    pub fn into_set_image_flip(self) -> Option<(ContentId, ImageFlip, FlatlandControlHandle)> {
4990        if let FlatlandRequest::SetImageFlip { image_id, flip, control_handle } = self {
4991            Some((image_id, flip, control_handle))
4992        } else {
4993            None
4994        }
4995    }
4996
4997    #[allow(irrefutable_let_patterns)]
4998    pub fn into_create_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
4999        if let FlatlandRequest::CreateFilledRect { rect_id, control_handle } = self {
5000            Some((rect_id, control_handle))
5001        } else {
5002            None
5003        }
5004    }
5005
5006    #[allow(irrefutable_let_patterns)]
5007    pub fn into_set_solid_fill(
5008        self,
5009    ) -> Option<(ContentId, ColorRgba, fidl_fuchsia_math::SizeU, FlatlandControlHandle)> {
5010        if let FlatlandRequest::SetSolidFill { rect_id, color, size, control_handle } = self {
5011            Some((rect_id, color, size, control_handle))
5012        } else {
5013            None
5014        }
5015    }
5016
5017    #[allow(irrefutable_let_patterns)]
5018    pub fn into_release_filled_rect(self) -> Option<(ContentId, FlatlandControlHandle)> {
5019        if let FlatlandRequest::ReleaseFilledRect { rect_id, control_handle } = self {
5020            Some((rect_id, control_handle))
5021        } else {
5022            None
5023        }
5024    }
5025
5026    #[allow(irrefutable_let_patterns)]
5027    pub fn into_set_content(self) -> Option<(TransformId, ContentId, FlatlandControlHandle)> {
5028        if let FlatlandRequest::SetContent { transform_id, content_id, control_handle } = self {
5029            Some((transform_id, content_id, control_handle))
5030        } else {
5031            None
5032        }
5033    }
5034
5035    #[allow(irrefutable_let_patterns)]
5036    pub fn into_set_viewport_properties(
5037        self,
5038    ) -> Option<(ContentId, ViewportProperties, FlatlandControlHandle)> {
5039        if let FlatlandRequest::SetViewportProperties { viewport_id, properties, control_handle } =
5040            self
5041        {
5042            Some((viewport_id, properties, control_handle))
5043        } else {
5044            None
5045        }
5046    }
5047
5048    #[allow(irrefutable_let_patterns)]
5049    pub fn into_release_transform(self) -> Option<(TransformId, FlatlandControlHandle)> {
5050        if let FlatlandRequest::ReleaseTransform { transform_id, control_handle } = self {
5051            Some((transform_id, control_handle))
5052        } else {
5053            None
5054        }
5055    }
5056
5057    #[allow(irrefutable_let_patterns)]
5058    pub fn into_release_view(self) -> Option<(FlatlandControlHandle)> {
5059        if let FlatlandRequest::ReleaseView { control_handle } = self {
5060            Some((control_handle))
5061        } else {
5062            None
5063        }
5064    }
5065
5066    #[allow(irrefutable_let_patterns)]
5067    pub fn into_release_viewport(self) -> Option<(ContentId, FlatlandReleaseViewportResponder)> {
5068        if let FlatlandRequest::ReleaseViewport { viewport_id, responder } = self {
5069            Some((viewport_id, responder))
5070        } else {
5071            None
5072        }
5073    }
5074
5075    #[allow(irrefutable_let_patterns)]
5076    pub fn into_release_image(self) -> Option<(ContentId, FlatlandControlHandle)> {
5077        if let FlatlandRequest::ReleaseImage { image_id, control_handle } = self {
5078            Some((image_id, control_handle))
5079        } else {
5080            None
5081        }
5082    }
5083
5084    #[allow(irrefutable_let_patterns)]
5085    pub fn into_clear(self) -> Option<(FlatlandControlHandle)> {
5086        if let FlatlandRequest::Clear { control_handle } = self {
5087            Some((control_handle))
5088        } else {
5089            None
5090        }
5091    }
5092
5093    #[allow(irrefutable_let_patterns)]
5094    pub fn into_set_debug_name(self) -> Option<(String, FlatlandControlHandle)> {
5095        if let FlatlandRequest::SetDebugName { name, control_handle } = self {
5096            Some((name, control_handle))
5097        } else {
5098            None
5099        }
5100    }
5101
5102    /// Name of the method defined in FIDL
5103    pub fn method_name(&self) -> &'static str {
5104        match *self {
5105            FlatlandRequest::Present { .. } => "present",
5106            FlatlandRequest::CreateView { .. } => "create_view",
5107            FlatlandRequest::CreateView2 { .. } => "create_view2",
5108            FlatlandRequest::CreateTransform { .. } => "create_transform",
5109            FlatlandRequest::SetTranslation { .. } => "set_translation",
5110            FlatlandRequest::SetOrientation { .. } => "set_orientation",
5111            FlatlandRequest::SetScale { .. } => "set_scale",
5112            FlatlandRequest::SetOpacity { .. } => "set_opacity",
5113            FlatlandRequest::SetClipBoundary { .. } => "set_clip_boundary",
5114            FlatlandRequest::AddChild { .. } => "add_child",
5115            FlatlandRequest::RemoveChild { .. } => "remove_child",
5116            FlatlandRequest::ReplaceChildren { .. } => "replace_children",
5117            FlatlandRequest::SetRootTransform { .. } => "set_root_transform",
5118            FlatlandRequest::SetHitRegions { .. } => "set_hit_regions",
5119            FlatlandRequest::SetInfiniteHitRegion { .. } => "set_infinite_hit_region",
5120            FlatlandRequest::CreateViewport { .. } => "create_viewport",
5121            FlatlandRequest::CreateImage { .. } => "create_image",
5122            FlatlandRequest::SetImageSampleRegion { .. } => "set_image_sample_region",
5123            FlatlandRequest::SetImageDestinationSize { .. } => "set_image_destination_size",
5124            FlatlandRequest::SetImageBlendingFunction { .. } => "set_image_blending_function",
5125            FlatlandRequest::SetImageOpacity { .. } => "set_image_opacity",
5126            FlatlandRequest::SetImageFlip { .. } => "set_image_flip",
5127            FlatlandRequest::CreateFilledRect { .. } => "create_filled_rect",
5128            FlatlandRequest::SetSolidFill { .. } => "set_solid_fill",
5129            FlatlandRequest::ReleaseFilledRect { .. } => "release_filled_rect",
5130            FlatlandRequest::SetContent { .. } => "set_content",
5131            FlatlandRequest::SetViewportProperties { .. } => "set_viewport_properties",
5132            FlatlandRequest::ReleaseTransform { .. } => "release_transform",
5133            FlatlandRequest::ReleaseView { .. } => "release_view",
5134            FlatlandRequest::ReleaseViewport { .. } => "release_viewport",
5135            FlatlandRequest::ReleaseImage { .. } => "release_image",
5136            FlatlandRequest::Clear { .. } => "clear",
5137            FlatlandRequest::SetDebugName { .. } => "set_debug_name",
5138        }
5139    }
5140}
5141
5142#[derive(Debug, Clone)]
5143pub struct FlatlandControlHandle {
5144    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5145}
5146
5147impl fidl::endpoints::ControlHandle for FlatlandControlHandle {
5148    fn shutdown(&self) {
5149        self.inner.shutdown()
5150    }
5151    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5152        self.inner.shutdown_with_epitaph(status)
5153    }
5154
5155    fn is_closed(&self) -> bool {
5156        self.inner.channel().is_closed()
5157    }
5158    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5159        self.inner.channel().on_closed()
5160    }
5161
5162    #[cfg(target_os = "fuchsia")]
5163    fn signal_peer(
5164        &self,
5165        clear_mask: zx::Signals,
5166        set_mask: zx::Signals,
5167    ) -> Result<(), zx_status::Status> {
5168        use fidl::Peered;
5169        self.inner.channel().signal_peer(clear_mask, set_mask)
5170    }
5171}
5172
5173impl FlatlandControlHandle {
5174    pub fn send_on_next_frame_begin(
5175        &self,
5176        mut values: &OnNextFrameBeginValues,
5177    ) -> Result<(), fidl::Error> {
5178        self.inner.send::<FlatlandOnNextFrameBeginRequest>(
5179            (values,),
5180            0,
5181            0x10f69a5cdeece84a,
5182            fidl::encoding::DynamicFlags::empty(),
5183        )
5184    }
5185
5186    pub fn send_on_frame_presented(
5187        &self,
5188        mut frame_presented_info: &fidl_fuchsia_scenic_scheduling::FramePresentedInfo,
5189    ) -> Result<(), fidl::Error> {
5190        self.inner.send::<FlatlandOnFramePresentedRequest>(
5191            (frame_presented_info,),
5192            0,
5193            0x56e43e1a5f30216d,
5194            fidl::encoding::DynamicFlags::empty(),
5195        )
5196    }
5197
5198    pub fn send_on_error(&self, mut error: FlatlandError) -> Result<(), fidl::Error> {
5199        self.inner.send::<FlatlandOnErrorRequest>(
5200            (error,),
5201            0,
5202            0x1ebf39e90cd8b8d,
5203            fidl::encoding::DynamicFlags::empty(),
5204        )
5205    }
5206}
5207
5208#[must_use = "FIDL methods require a response to be sent"]
5209#[derive(Debug)]
5210pub struct FlatlandReleaseViewportResponder {
5211    control_handle: std::mem::ManuallyDrop<FlatlandControlHandle>,
5212    tx_id: u32,
5213}
5214
5215/// Set the the channel to be shutdown (see [`FlatlandControlHandle::shutdown`])
5216/// if the responder is dropped without sending a response, so that the client
5217/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
5218impl std::ops::Drop for FlatlandReleaseViewportResponder {
5219    fn drop(&mut self) {
5220        self.control_handle.shutdown();
5221        // Safety: drops once, never accessed again
5222        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5223    }
5224}
5225
5226impl fidl::endpoints::Responder for FlatlandReleaseViewportResponder {
5227    type ControlHandle = FlatlandControlHandle;
5228
5229    fn control_handle(&self) -> &FlatlandControlHandle {
5230        &self.control_handle
5231    }
5232
5233    fn drop_without_shutdown(mut self) {
5234        // Safety: drops once, never accessed again due to mem::forget
5235        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
5236        // Prevent Drop from running (which would shut down the channel)
5237        std::mem::forget(self);
5238    }
5239}
5240
5241impl FlatlandReleaseViewportResponder {
5242    /// Sends a response to the FIDL transaction.
5243    ///
5244    /// Sets the channel to shutdown if an error occurs.
5245    pub fn send(
5246        self,
5247        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5248    ) -> Result<(), fidl::Error> {
5249        let _result = self.send_raw(token);
5250        if _result.is_err() {
5251            self.control_handle.shutdown();
5252        }
5253        self.drop_without_shutdown();
5254        _result
5255    }
5256
5257    /// Similar to "send" but does not shutdown the channel if an error occurs.
5258    pub fn send_no_shutdown_on_err(
5259        self,
5260        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5261    ) -> Result<(), fidl::Error> {
5262        let _result = self.send_raw(token);
5263        self.drop_without_shutdown();
5264        _result
5265    }
5266
5267    fn send_raw(
5268        &self,
5269        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5270    ) -> Result<(), fidl::Error> {
5271        self.control_handle.inner.send::<FlatlandReleaseViewportResponse>(
5272            (&mut token,),
5273            self.tx_id,
5274            0xbad474aeb5293f9,
5275            fidl::encoding::DynamicFlags::empty(),
5276        )
5277    }
5278}
5279
5280#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5281pub struct FlatlandDisplayMarker;
5282
5283impl fidl::endpoints::ProtocolMarker for FlatlandDisplayMarker {
5284    type Proxy = FlatlandDisplayProxy;
5285    type RequestStream = FlatlandDisplayRequestStream;
5286    #[cfg(target_os = "fuchsia")]
5287    type SynchronousProxy = FlatlandDisplaySynchronousProxy;
5288
5289    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.FlatlandDisplay";
5290}
5291impl fidl::endpoints::DiscoverableProtocolMarker for FlatlandDisplayMarker {}
5292
5293pub trait FlatlandDisplayProxyInterface: Send + Sync {
5294    fn r#set_content(
5295        &self,
5296        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5297        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5298    ) -> Result<(), fidl::Error>;
5299    fn r#set_device_pixel_ratio(
5300        &self,
5301        device_pixel_ratio: &fidl_fuchsia_math::VecF,
5302    ) -> Result<(), fidl::Error>;
5303}
5304#[derive(Debug)]
5305#[cfg(target_os = "fuchsia")]
5306pub struct FlatlandDisplaySynchronousProxy {
5307    client: fidl::client::sync::Client,
5308}
5309
5310#[cfg(target_os = "fuchsia")]
5311impl fidl::endpoints::SynchronousProxy for FlatlandDisplaySynchronousProxy {
5312    type Proxy = FlatlandDisplayProxy;
5313    type Protocol = FlatlandDisplayMarker;
5314
5315    fn from_channel(inner: fidl::Channel) -> Self {
5316        Self::new(inner)
5317    }
5318
5319    fn into_channel(self) -> fidl::Channel {
5320        self.client.into_channel()
5321    }
5322
5323    fn as_channel(&self) -> &fidl::Channel {
5324        self.client.as_channel()
5325    }
5326}
5327
5328#[cfg(target_os = "fuchsia")]
5329impl FlatlandDisplaySynchronousProxy {
5330    pub fn new(channel: fidl::Channel) -> Self {
5331        let protocol_name = <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5332        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5333    }
5334
5335    pub fn into_channel(self) -> fidl::Channel {
5336        self.client.into_channel()
5337    }
5338
5339    /// Waits until an event arrives and returns it. It is safe for other
5340    /// threads to make concurrent requests while waiting for an event.
5341    pub fn wait_for_event(
5342        &self,
5343        deadline: zx::MonotonicInstant,
5344    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5345        FlatlandDisplayEvent::decode(self.client.wait_for_event(deadline)?)
5346    }
5347
5348    pub fn r#set_content(
5349        &self,
5350        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5351        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5352    ) -> Result<(), fidl::Error> {
5353        self.client.send::<FlatlandDisplaySetContentRequest>(
5354            (&mut token, child_view_watcher),
5355            0x6748193a39918298,
5356            fidl::encoding::DynamicFlags::empty(),
5357        )
5358    }
5359
5360    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5361    /// for the tree of Flatland content that are attached to this display. See
5362    /// [`LayoutInfo.device_pixel_ratio`] for details.
5363    ///
5364    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5365    pub fn r#set_device_pixel_ratio(
5366        &self,
5367        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5368    ) -> Result<(), fidl::Error> {
5369        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5370            (device_pixel_ratio,),
5371            0x392c3e70cc0a81a4,
5372            fidl::encoding::DynamicFlags::empty(),
5373        )
5374    }
5375}
5376
5377#[cfg(target_os = "fuchsia")]
5378impl From<FlatlandDisplaySynchronousProxy> for zx::Handle {
5379    fn from(value: FlatlandDisplaySynchronousProxy) -> Self {
5380        value.into_channel().into()
5381    }
5382}
5383
5384#[cfg(target_os = "fuchsia")]
5385impl From<fidl::Channel> for FlatlandDisplaySynchronousProxy {
5386    fn from(value: fidl::Channel) -> Self {
5387        Self::new(value)
5388    }
5389}
5390
5391#[cfg(target_os = "fuchsia")]
5392impl fidl::endpoints::FromClient for FlatlandDisplaySynchronousProxy {
5393    type Protocol = FlatlandDisplayMarker;
5394
5395    fn from_client(value: fidl::endpoints::ClientEnd<FlatlandDisplayMarker>) -> Self {
5396        Self::new(value.into_channel())
5397    }
5398}
5399
5400#[derive(Debug, Clone)]
5401pub struct FlatlandDisplayProxy {
5402    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5403}
5404
5405impl fidl::endpoints::Proxy for FlatlandDisplayProxy {
5406    type Protocol = FlatlandDisplayMarker;
5407
5408    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5409        Self::new(inner)
5410    }
5411
5412    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5413        self.client.into_channel().map_err(|client| Self { client })
5414    }
5415
5416    fn as_channel(&self) -> &::fidl::AsyncChannel {
5417        self.client.as_channel()
5418    }
5419}
5420
5421impl FlatlandDisplayProxy {
5422    /// Create a new Proxy for fuchsia.ui.composition/FlatlandDisplay.
5423    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5424        let protocol_name = <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5425        Self { client: fidl::client::Client::new(channel, protocol_name) }
5426    }
5427
5428    /// Get a Stream of events from the remote end of the protocol.
5429    ///
5430    /// # Panics
5431    ///
5432    /// Panics if the event stream was already taken.
5433    pub fn take_event_stream(&self) -> FlatlandDisplayEventStream {
5434        FlatlandDisplayEventStream { event_receiver: self.client.take_event_receiver() }
5435    }
5436
5437    pub fn r#set_content(
5438        &self,
5439        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5440        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5441    ) -> Result<(), fidl::Error> {
5442        FlatlandDisplayProxyInterface::r#set_content(self, token, child_view_watcher)
5443    }
5444
5445    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5446    /// for the tree of Flatland content that are attached to this display. See
5447    /// [`LayoutInfo.device_pixel_ratio`] for details.
5448    ///
5449    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5450    pub fn r#set_device_pixel_ratio(
5451        &self,
5452        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5453    ) -> Result<(), fidl::Error> {
5454        FlatlandDisplayProxyInterface::r#set_device_pixel_ratio(self, device_pixel_ratio)
5455    }
5456}
5457
5458impl FlatlandDisplayProxyInterface for FlatlandDisplayProxy {
5459    fn r#set_content(
5460        &self,
5461        mut token: fidl_fuchsia_ui_views::ViewportCreationToken,
5462        mut child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5463    ) -> Result<(), fidl::Error> {
5464        self.client.send::<FlatlandDisplaySetContentRequest>(
5465            (&mut token, child_view_watcher),
5466            0x6748193a39918298,
5467            fidl::encoding::DynamicFlags::empty(),
5468        )
5469    }
5470
5471    fn r#set_device_pixel_ratio(
5472        &self,
5473        mut device_pixel_ratio: &fidl_fuchsia_math::VecF,
5474    ) -> Result<(), fidl::Error> {
5475        self.client.send::<FlatlandDisplaySetDevicePixelRatioRequest>(
5476            (device_pixel_ratio,),
5477            0x392c3e70cc0a81a4,
5478            fidl::encoding::DynamicFlags::empty(),
5479        )
5480    }
5481}
5482
5483pub struct FlatlandDisplayEventStream {
5484    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
5485}
5486
5487impl std::marker::Unpin for FlatlandDisplayEventStream {}
5488
5489impl futures::stream::FusedStream for FlatlandDisplayEventStream {
5490    fn is_terminated(&self) -> bool {
5491        self.event_receiver.is_terminated()
5492    }
5493}
5494
5495impl futures::Stream for FlatlandDisplayEventStream {
5496    type Item = Result<FlatlandDisplayEvent, fidl::Error>;
5497
5498    fn poll_next(
5499        mut self: std::pin::Pin<&mut Self>,
5500        cx: &mut std::task::Context<'_>,
5501    ) -> std::task::Poll<Option<Self::Item>> {
5502        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
5503            &mut self.event_receiver,
5504            cx
5505        )?) {
5506            Some(buf) => std::task::Poll::Ready(Some(FlatlandDisplayEvent::decode(buf))),
5507            None => std::task::Poll::Ready(None),
5508        }
5509    }
5510}
5511
5512#[derive(Debug)]
5513pub enum FlatlandDisplayEvent {}
5514
5515impl FlatlandDisplayEvent {
5516    /// Decodes a message buffer as a [`FlatlandDisplayEvent`].
5517    fn decode(
5518        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
5519    ) -> Result<FlatlandDisplayEvent, fidl::Error> {
5520        let (bytes, _handles) = buf.split_mut();
5521        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5522        debug_assert_eq!(tx_header.tx_id, 0);
5523        match tx_header.ordinal {
5524            _ => Err(fidl::Error::UnknownOrdinal {
5525                ordinal: tx_header.ordinal,
5526                protocol_name:
5527                    <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5528            }),
5529        }
5530    }
5531}
5532
5533/// A Stream of incoming requests for fuchsia.ui.composition/FlatlandDisplay.
5534pub struct FlatlandDisplayRequestStream {
5535    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5536    is_terminated: bool,
5537}
5538
5539impl std::marker::Unpin for FlatlandDisplayRequestStream {}
5540
5541impl futures::stream::FusedStream for FlatlandDisplayRequestStream {
5542    fn is_terminated(&self) -> bool {
5543        self.is_terminated
5544    }
5545}
5546
5547impl fidl::endpoints::RequestStream for FlatlandDisplayRequestStream {
5548    type Protocol = FlatlandDisplayMarker;
5549    type ControlHandle = FlatlandDisplayControlHandle;
5550
5551    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
5552        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
5553    }
5554
5555    fn control_handle(&self) -> Self::ControlHandle {
5556        FlatlandDisplayControlHandle { inner: self.inner.clone() }
5557    }
5558
5559    fn into_inner(
5560        self,
5561    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
5562    {
5563        (self.inner, self.is_terminated)
5564    }
5565
5566    fn from_inner(
5567        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5568        is_terminated: bool,
5569    ) -> Self {
5570        Self { inner, is_terminated }
5571    }
5572}
5573
5574impl futures::Stream for FlatlandDisplayRequestStream {
5575    type Item = Result<FlatlandDisplayRequest, fidl::Error>;
5576
5577    fn poll_next(
5578        mut self: std::pin::Pin<&mut Self>,
5579        cx: &mut std::task::Context<'_>,
5580    ) -> std::task::Poll<Option<Self::Item>> {
5581        let this = &mut *self;
5582        if this.inner.check_shutdown(cx) {
5583            this.is_terminated = true;
5584            return std::task::Poll::Ready(None);
5585        }
5586        if this.is_terminated {
5587            panic!("polled FlatlandDisplayRequestStream after completion");
5588        }
5589        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
5590            |bytes, handles| {
5591                match this.inner.channel().read_etc(cx, bytes, handles) {
5592                    std::task::Poll::Ready(Ok(())) => {}
5593                    std::task::Poll::Pending => return std::task::Poll::Pending,
5594                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
5595                        this.is_terminated = true;
5596                        return std::task::Poll::Ready(None);
5597                    }
5598                    std::task::Poll::Ready(Err(e)) => {
5599                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
5600                            e.into(),
5601                        ))))
5602                    }
5603                }
5604
5605                // A message has been received from the channel
5606                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
5607
5608                std::task::Poll::Ready(Some(match header.ordinal {
5609                    0x6748193a39918298 => {
5610                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5611                        let mut req = fidl::new_empty!(
5612                            FlatlandDisplaySetContentRequest,
5613                            fidl::encoding::DefaultFuchsiaResourceDialect
5614                        );
5615                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetContentRequest>(&header, _body_bytes, handles, &mut req)?;
5616                        let control_handle =
5617                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5618                        Ok(FlatlandDisplayRequest::SetContent {
5619                            token: req.token,
5620                            child_view_watcher: req.child_view_watcher,
5621
5622                            control_handle,
5623                        })
5624                    }
5625                    0x392c3e70cc0a81a4 => {
5626                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
5627                        let mut req = fidl::new_empty!(
5628                            FlatlandDisplaySetDevicePixelRatioRequest,
5629                            fidl::encoding::DefaultFuchsiaResourceDialect
5630                        );
5631                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FlatlandDisplaySetDevicePixelRatioRequest>(&header, _body_bytes, handles, &mut req)?;
5632                        let control_handle =
5633                            FlatlandDisplayControlHandle { inner: this.inner.clone() };
5634                        Ok(FlatlandDisplayRequest::SetDevicePixelRatio {
5635                            device_pixel_ratio: req.device_pixel_ratio,
5636
5637                            control_handle,
5638                        })
5639                    }
5640                    _ => Err(fidl::Error::UnknownOrdinal {
5641                        ordinal: header.ordinal,
5642                        protocol_name:
5643                            <FlatlandDisplayMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
5644                    }),
5645                }))
5646            },
5647        )
5648    }
5649}
5650
5651/// This API connects to the singleton "primary display", and allows a tree of Flatland content to
5652/// be attached underneath.  Only one FlatlandDisplay client connection is allowed at one time.
5653#[derive(Debug)]
5654pub enum FlatlandDisplayRequest {
5655    SetContent {
5656        token: fidl_fuchsia_ui_views::ViewportCreationToken,
5657        child_view_watcher: fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5658        control_handle: FlatlandDisplayControlHandle,
5659    },
5660    /// Sets the ratio of display's physical pixels to device independent pixels that should be used
5661    /// for the tree of Flatland content that are attached to this display. See
5662    /// [`LayoutInfo.device_pixel_ratio`] for details.
5663    ///
5664    /// The default value is (1.0, 1.0). The valid values are 1.0 and above.
5665    SetDevicePixelRatio {
5666        device_pixel_ratio: fidl_fuchsia_math::VecF,
5667        control_handle: FlatlandDisplayControlHandle,
5668    },
5669}
5670
5671impl FlatlandDisplayRequest {
5672    #[allow(irrefutable_let_patterns)]
5673    pub fn into_set_content(
5674        self,
5675    ) -> Option<(
5676        fidl_fuchsia_ui_views::ViewportCreationToken,
5677        fidl::endpoints::ServerEnd<ChildViewWatcherMarker>,
5678        FlatlandDisplayControlHandle,
5679    )> {
5680        if let FlatlandDisplayRequest::SetContent { token, child_view_watcher, control_handle } =
5681            self
5682        {
5683            Some((token, child_view_watcher, control_handle))
5684        } else {
5685            None
5686        }
5687    }
5688
5689    #[allow(irrefutable_let_patterns)]
5690    pub fn into_set_device_pixel_ratio(
5691        self,
5692    ) -> Option<(fidl_fuchsia_math::VecF, FlatlandDisplayControlHandle)> {
5693        if let FlatlandDisplayRequest::SetDevicePixelRatio { device_pixel_ratio, control_handle } =
5694            self
5695        {
5696            Some((device_pixel_ratio, control_handle))
5697        } else {
5698            None
5699        }
5700    }
5701
5702    /// Name of the method defined in FIDL
5703    pub fn method_name(&self) -> &'static str {
5704        match *self {
5705            FlatlandDisplayRequest::SetContent { .. } => "set_content",
5706            FlatlandDisplayRequest::SetDevicePixelRatio { .. } => "set_device_pixel_ratio",
5707        }
5708    }
5709}
5710
5711#[derive(Debug, Clone)]
5712pub struct FlatlandDisplayControlHandle {
5713    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
5714}
5715
5716impl fidl::endpoints::ControlHandle for FlatlandDisplayControlHandle {
5717    fn shutdown(&self) {
5718        self.inner.shutdown()
5719    }
5720    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
5721        self.inner.shutdown_with_epitaph(status)
5722    }
5723
5724    fn is_closed(&self) -> bool {
5725        self.inner.channel().is_closed()
5726    }
5727    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
5728        self.inner.channel().on_closed()
5729    }
5730
5731    #[cfg(target_os = "fuchsia")]
5732    fn signal_peer(
5733        &self,
5734        clear_mask: zx::Signals,
5735        set_mask: zx::Signals,
5736    ) -> Result<(), zx_status::Status> {
5737        use fidl::Peered;
5738        self.inner.channel().signal_peer(clear_mask, set_mask)
5739    }
5740}
5741
5742impl FlatlandDisplayControlHandle {}
5743
5744#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
5745pub struct ParentViewportWatcherMarker;
5746
5747impl fidl::endpoints::ProtocolMarker for ParentViewportWatcherMarker {
5748    type Proxy = ParentViewportWatcherProxy;
5749    type RequestStream = ParentViewportWatcherRequestStream;
5750    #[cfg(target_os = "fuchsia")]
5751    type SynchronousProxy = ParentViewportWatcherSynchronousProxy;
5752
5753    const DEBUG_NAME: &'static str = "(anonymous) ParentViewportWatcher";
5754}
5755
5756pub trait ParentViewportWatcherProxyInterface: Send + Sync {
5757    type GetLayoutResponseFut: std::future::Future<Output = Result<LayoutInfo, fidl::Error>> + Send;
5758    fn r#get_layout(&self) -> Self::GetLayoutResponseFut;
5759    type GetStatusResponseFut: std::future::Future<Output = Result<ParentViewportStatus, fidl::Error>>
5760        + Send;
5761    fn r#get_status(&self) -> Self::GetStatusResponseFut;
5762}
5763#[derive(Debug)]
5764#[cfg(target_os = "fuchsia")]
5765pub struct ParentViewportWatcherSynchronousProxy {
5766    client: fidl::client::sync::Client,
5767}
5768
5769#[cfg(target_os = "fuchsia")]
5770impl fidl::endpoints::SynchronousProxy for ParentViewportWatcherSynchronousProxy {
5771    type Proxy = ParentViewportWatcherProxy;
5772    type Protocol = ParentViewportWatcherMarker;
5773
5774    fn from_channel(inner: fidl::Channel) -> Self {
5775        Self::new(inner)
5776    }
5777
5778    fn into_channel(self) -> fidl::Channel {
5779        self.client.into_channel()
5780    }
5781
5782    fn as_channel(&self) -> &fidl::Channel {
5783        self.client.as_channel()
5784    }
5785}
5786
5787#[cfg(target_os = "fuchsia")]
5788impl ParentViewportWatcherSynchronousProxy {
5789    pub fn new(channel: fidl::Channel) -> Self {
5790        let protocol_name =
5791            <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5792        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
5793    }
5794
5795    pub fn into_channel(self) -> fidl::Channel {
5796        self.client.into_channel()
5797    }
5798
5799    /// Waits until an event arrives and returns it. It is safe for other
5800    /// threads to make concurrent requests while waiting for an event.
5801    pub fn wait_for_event(
5802        &self,
5803        deadline: zx::MonotonicInstant,
5804    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
5805        ParentViewportWatcherEvent::decode(self.client.wait_for_event(deadline)?)
5806    }
5807
5808    /// A hanging get for receiving layout information. Clients may receive layout information
5809    /// before the ParentViewportWatcher operation has been presented. This allows children to
5810    /// layout their content before their first call to [`Present`]. In transition cases where two
5811    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
5812    /// receiving different layout information.
5813    ///
5814    /// This hanging get will only fire when the LayoutInfo is different than the previously
5815    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
5816    /// changed.
5817    ///
5818    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
5819    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
5820    /// closed.
5821    pub fn r#get_layout(
5822        &self,
5823        ___deadline: zx::MonotonicInstant,
5824    ) -> Result<LayoutInfo, fidl::Error> {
5825        let _response = self
5826            .client
5827            .send_query::<fidl::encoding::EmptyPayload, ParentViewportWatcherGetLayoutResponse>(
5828                (),
5829                0x3cbe5d9638e032,
5830                fidl::encoding::DynamicFlags::empty(),
5831                ___deadline,
5832            )?;
5833        Ok(_response.info)
5834    }
5835
5836    /// A hanging get for receiving the status of the parent Viewport. This provides global
5837    /// connectivity information to the child.
5838    ///
5839    /// This hanging get will only fire when the ParentViewportStatus is different than the
5840    /// previously returned ParentViewportStatus.
5841    ///
5842    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
5843    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
5844    /// closed.
5845    pub fn r#get_status(
5846        &self,
5847        ___deadline: zx::MonotonicInstant,
5848    ) -> Result<ParentViewportStatus, fidl::Error> {
5849        let _response = self
5850            .client
5851            .send_query::<fidl::encoding::EmptyPayload, ParentViewportWatcherGetStatusResponse>(
5852                (),
5853                0x7caa022f050d9ea6,
5854                fidl::encoding::DynamicFlags::empty(),
5855                ___deadline,
5856            )?;
5857        Ok(_response.status)
5858    }
5859}
5860
5861#[cfg(target_os = "fuchsia")]
5862impl From<ParentViewportWatcherSynchronousProxy> for zx::Handle {
5863    fn from(value: ParentViewportWatcherSynchronousProxy) -> Self {
5864        value.into_channel().into()
5865    }
5866}
5867
5868#[cfg(target_os = "fuchsia")]
5869impl From<fidl::Channel> for ParentViewportWatcherSynchronousProxy {
5870    fn from(value: fidl::Channel) -> Self {
5871        Self::new(value)
5872    }
5873}
5874
5875#[cfg(target_os = "fuchsia")]
5876impl fidl::endpoints::FromClient for ParentViewportWatcherSynchronousProxy {
5877    type Protocol = ParentViewportWatcherMarker;
5878
5879    fn from_client(value: fidl::endpoints::ClientEnd<ParentViewportWatcherMarker>) -> Self {
5880        Self::new(value.into_channel())
5881    }
5882}
5883
5884#[derive(Debug, Clone)]
5885pub struct ParentViewportWatcherProxy {
5886    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
5887}
5888
5889impl fidl::endpoints::Proxy for ParentViewportWatcherProxy {
5890    type Protocol = ParentViewportWatcherMarker;
5891
5892    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
5893        Self::new(inner)
5894    }
5895
5896    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
5897        self.client.into_channel().map_err(|client| Self { client })
5898    }
5899
5900    fn as_channel(&self) -> &::fidl::AsyncChannel {
5901        self.client.as_channel()
5902    }
5903}
5904
5905impl ParentViewportWatcherProxy {
5906    /// Create a new Proxy for fuchsia.ui.composition/ParentViewportWatcher.
5907    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
5908        let protocol_name =
5909            <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
5910        Self { client: fidl::client::Client::new(channel, protocol_name) }
5911    }
5912
5913    /// Get a Stream of events from the remote end of the protocol.
5914    ///
5915    /// # Panics
5916    ///
5917    /// Panics if the event stream was already taken.
5918    pub fn take_event_stream(&self) -> ParentViewportWatcherEventStream {
5919        ParentViewportWatcherEventStream { event_receiver: self.client.take_event_receiver() }
5920    }
5921
5922    /// A hanging get for receiving layout information. Clients may receive layout information
5923    /// before the ParentViewportWatcher operation has been presented. This allows children to
5924    /// layout their content before their first call to [`Present`]. In transition cases where two
5925    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
5926    /// receiving different layout information.
5927    ///
5928    /// This hanging get will only fire when the LayoutInfo is different than the previously
5929    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
5930    /// changed.
5931    ///
5932    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
5933    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
5934    /// closed.
5935    pub fn r#get_layout(
5936        &self,
5937    ) -> fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
5938    {
5939        ParentViewportWatcherProxyInterface::r#get_layout(self)
5940    }
5941
5942    /// A hanging get for receiving the status of the parent Viewport. This provides global
5943    /// connectivity information to the child.
5944    ///
5945    /// This hanging get will only fire when the ParentViewportStatus is different than the
5946    /// previously returned ParentViewportStatus.
5947    ///
5948    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
5949    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
5950    /// closed.
5951    pub fn r#get_status(
5952        &self,
5953    ) -> fidl::client::QueryResponseFut<
5954        ParentViewportStatus,
5955        fidl::encoding::DefaultFuchsiaResourceDialect,
5956    > {
5957        ParentViewportWatcherProxyInterface::r#get_status(self)
5958    }
5959}
5960
5961impl ParentViewportWatcherProxyInterface for ParentViewportWatcherProxy {
5962    type GetLayoutResponseFut =
5963        fidl::client::QueryResponseFut<LayoutInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
5964    fn r#get_layout(&self) -> Self::GetLayoutResponseFut {
5965        fn _decode(
5966            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5967        ) -> Result<LayoutInfo, fidl::Error> {
5968            let _response = fidl::client::decode_transaction_body::<
5969                ParentViewportWatcherGetLayoutResponse,
5970                fidl::encoding::DefaultFuchsiaResourceDialect,
5971                0x3cbe5d9638e032,
5972            >(_buf?)?;
5973            Ok(_response.info)
5974        }
5975        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LayoutInfo>(
5976            (),
5977            0x3cbe5d9638e032,
5978            fidl::encoding::DynamicFlags::empty(),
5979            _decode,
5980        )
5981    }
5982
5983    type GetStatusResponseFut = fidl::client::QueryResponseFut<
5984        ParentViewportStatus,
5985        fidl::encoding::DefaultFuchsiaResourceDialect,
5986    >;
5987    fn r#get_status(&self) -> Self::GetStatusResponseFut {
5988        fn _decode(
5989            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
5990        ) -> Result<ParentViewportStatus, fidl::Error> {
5991            let _response = fidl::client::decode_transaction_body::<
5992                ParentViewportWatcherGetStatusResponse,
5993                fidl::encoding::DefaultFuchsiaResourceDialect,
5994                0x7caa022f050d9ea6,
5995            >(_buf?)?;
5996            Ok(_response.status)
5997        }
5998        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ParentViewportStatus>(
5999            (),
6000            0x7caa022f050d9ea6,
6001            fidl::encoding::DynamicFlags::empty(),
6002            _decode,
6003        )
6004    }
6005}
6006
6007pub struct ParentViewportWatcherEventStream {
6008    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6009}
6010
6011impl std::marker::Unpin for ParentViewportWatcherEventStream {}
6012
6013impl futures::stream::FusedStream for ParentViewportWatcherEventStream {
6014    fn is_terminated(&self) -> bool {
6015        self.event_receiver.is_terminated()
6016    }
6017}
6018
6019impl futures::Stream for ParentViewportWatcherEventStream {
6020    type Item = Result<ParentViewportWatcherEvent, fidl::Error>;
6021
6022    fn poll_next(
6023        mut self: std::pin::Pin<&mut Self>,
6024        cx: &mut std::task::Context<'_>,
6025    ) -> std::task::Poll<Option<Self::Item>> {
6026        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6027            &mut self.event_receiver,
6028            cx
6029        )?) {
6030            Some(buf) => std::task::Poll::Ready(Some(ParentViewportWatcherEvent::decode(buf))),
6031            None => std::task::Poll::Ready(None),
6032        }
6033    }
6034}
6035
6036#[derive(Debug)]
6037pub enum ParentViewportWatcherEvent {}
6038
6039impl ParentViewportWatcherEvent {
6040    /// Decodes a message buffer as a [`ParentViewportWatcherEvent`].
6041    fn decode(
6042        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6043    ) -> Result<ParentViewportWatcherEvent, fidl::Error> {
6044        let (bytes, _handles) = buf.split_mut();
6045        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6046        debug_assert_eq!(tx_header.tx_id, 0);
6047        match tx_header.ordinal {
6048            _ => Err(fidl::Error::UnknownOrdinal {
6049                ordinal: tx_header.ordinal,
6050                protocol_name:
6051                    <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6052            }),
6053        }
6054    }
6055}
6056
6057/// A Stream of incoming requests for fuchsia.ui.composition/ParentViewportWatcher.
6058pub struct ParentViewportWatcherRequestStream {
6059    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6060    is_terminated: bool,
6061}
6062
6063impl std::marker::Unpin for ParentViewportWatcherRequestStream {}
6064
6065impl futures::stream::FusedStream for ParentViewportWatcherRequestStream {
6066    fn is_terminated(&self) -> bool {
6067        self.is_terminated
6068    }
6069}
6070
6071impl fidl::endpoints::RequestStream for ParentViewportWatcherRequestStream {
6072    type Protocol = ParentViewportWatcherMarker;
6073    type ControlHandle = ParentViewportWatcherControlHandle;
6074
6075    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6076        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6077    }
6078
6079    fn control_handle(&self) -> Self::ControlHandle {
6080        ParentViewportWatcherControlHandle { inner: self.inner.clone() }
6081    }
6082
6083    fn into_inner(
6084        self,
6085    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6086    {
6087        (self.inner, self.is_terminated)
6088    }
6089
6090    fn from_inner(
6091        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6092        is_terminated: bool,
6093    ) -> Self {
6094        Self { inner, is_terminated }
6095    }
6096}
6097
6098impl futures::Stream for ParentViewportWatcherRequestStream {
6099    type Item = Result<ParentViewportWatcherRequest, fidl::Error>;
6100
6101    fn poll_next(
6102        mut self: std::pin::Pin<&mut Self>,
6103        cx: &mut std::task::Context<'_>,
6104    ) -> std::task::Poll<Option<Self::Item>> {
6105        let this = &mut *self;
6106        if this.inner.check_shutdown(cx) {
6107            this.is_terminated = true;
6108            return std::task::Poll::Ready(None);
6109        }
6110        if this.is_terminated {
6111            panic!("polled ParentViewportWatcherRequestStream after completion");
6112        }
6113        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6114            |bytes, handles| {
6115                match this.inner.channel().read_etc(cx, bytes, handles) {
6116                    std::task::Poll::Ready(Ok(())) => {}
6117                    std::task::Poll::Pending => return std::task::Poll::Pending,
6118                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6119                        this.is_terminated = true;
6120                        return std::task::Poll::Ready(None);
6121                    }
6122                    std::task::Poll::Ready(Err(e)) => {
6123                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6124                            e.into(),
6125                        ))))
6126                    }
6127                }
6128
6129                // A message has been received from the channel
6130                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6131
6132                std::task::Poll::Ready(Some(match header.ordinal {
6133                0x3cbe5d9638e032 => {
6134                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6135                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6136                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6137                    let control_handle = ParentViewportWatcherControlHandle {
6138                        inner: this.inner.clone(),
6139                    };
6140                    Ok(ParentViewportWatcherRequest::GetLayout {
6141                        responder: ParentViewportWatcherGetLayoutResponder {
6142                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6143                            tx_id: header.tx_id,
6144                        },
6145                    })
6146                }
6147                0x7caa022f050d9ea6 => {
6148                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6149                    let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
6150                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
6151                    let control_handle = ParentViewportWatcherControlHandle {
6152                        inner: this.inner.clone(),
6153                    };
6154                    Ok(ParentViewportWatcherRequest::GetStatus {
6155                        responder: ParentViewportWatcherGetStatusResponder {
6156                            control_handle: std::mem::ManuallyDrop::new(control_handle),
6157                            tx_id: header.tx_id,
6158                        },
6159                    })
6160                }
6161                _ => Err(fidl::Error::UnknownOrdinal {
6162                    ordinal: header.ordinal,
6163                    protocol_name: <ParentViewportWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6164                }),
6165            }))
6166            },
6167        )
6168    }
6169}
6170
6171/// A protocol that provides information about the parent Viewport attached to a Flatland instance's
6172/// sole View.  Although Flatland instances can have at most one view, it is possible to have
6173/// multiple ParentViewportWatchers during the brief transition period when replacing the instance's
6174/// View with another, e.g. via [`CreateView`].  During this period, certain updates may be
6175/// duplicated and sent to each ParentViewportWatcher connection.
6176///
6177/// A ParentViewportWatcher will remain connected as long as the corresponding parent Viewport
6178/// exists; the connection will also be closed if the parents's ViewportCreationToken is dropped
6179/// without using it to create a Viewport.
6180#[derive(Debug)]
6181pub enum ParentViewportWatcherRequest {
6182    /// A hanging get for receiving layout information. Clients may receive layout information
6183    /// before the ParentViewportWatcher operation has been presented. This allows children to
6184    /// layout their content before their first call to [`Present`]. In transition cases where two
6185    /// ParentViewportWatcher channels exist at the same time, both protocol instances will be
6186    /// receiving different layout information.
6187    ///
6188    /// This hanging get will only fire when the LayoutInfo is different than the previously
6189    /// returned LayoutInfo. Note that, since LayoutInfo is a table, only some fields may have
6190    /// changed.
6191    ///
6192    /// It is invalid to call `GetLayout` while a previous call is still pending. Doing so will
6193    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6194    /// closed.
6195    GetLayout { responder: ParentViewportWatcherGetLayoutResponder },
6196    /// A hanging get for receiving the status of the parent Viewport. This provides global
6197    /// connectivity information to the child.
6198    ///
6199    /// This hanging get will only fire when the ParentViewportStatus is different than the
6200    /// previously returned ParentViewportStatus.
6201    ///
6202    /// It is invalid to call `GetStatus` while a previous call is still pending. Doing so will
6203    /// cause both this channel and the Flatland channel that handed out ParentViewportWatcher to be
6204    /// closed.
6205    GetStatus { responder: ParentViewportWatcherGetStatusResponder },
6206}
6207
6208impl ParentViewportWatcherRequest {
6209    #[allow(irrefutable_let_patterns)]
6210    pub fn into_get_layout(self) -> Option<(ParentViewportWatcherGetLayoutResponder)> {
6211        if let ParentViewportWatcherRequest::GetLayout { responder } = self {
6212            Some((responder))
6213        } else {
6214            None
6215        }
6216    }
6217
6218    #[allow(irrefutable_let_patterns)]
6219    pub fn into_get_status(self) -> Option<(ParentViewportWatcherGetStatusResponder)> {
6220        if let ParentViewportWatcherRequest::GetStatus { responder } = self {
6221            Some((responder))
6222        } else {
6223            None
6224        }
6225    }
6226
6227    /// Name of the method defined in FIDL
6228    pub fn method_name(&self) -> &'static str {
6229        match *self {
6230            ParentViewportWatcherRequest::GetLayout { .. } => "get_layout",
6231            ParentViewportWatcherRequest::GetStatus { .. } => "get_status",
6232        }
6233    }
6234}
6235
6236#[derive(Debug, Clone)]
6237pub struct ParentViewportWatcherControlHandle {
6238    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6239}
6240
6241impl fidl::endpoints::ControlHandle for ParentViewportWatcherControlHandle {
6242    fn shutdown(&self) {
6243        self.inner.shutdown()
6244    }
6245    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
6246        self.inner.shutdown_with_epitaph(status)
6247    }
6248
6249    fn is_closed(&self) -> bool {
6250        self.inner.channel().is_closed()
6251    }
6252    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
6253        self.inner.channel().on_closed()
6254    }
6255
6256    #[cfg(target_os = "fuchsia")]
6257    fn signal_peer(
6258        &self,
6259        clear_mask: zx::Signals,
6260        set_mask: zx::Signals,
6261    ) -> Result<(), zx_status::Status> {
6262        use fidl::Peered;
6263        self.inner.channel().signal_peer(clear_mask, set_mask)
6264    }
6265}
6266
6267impl ParentViewportWatcherControlHandle {}
6268
6269#[must_use = "FIDL methods require a response to be sent"]
6270#[derive(Debug)]
6271pub struct ParentViewportWatcherGetLayoutResponder {
6272    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6273    tx_id: u32,
6274}
6275
6276/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6277/// if the responder is dropped without sending a response, so that the client
6278/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6279impl std::ops::Drop for ParentViewportWatcherGetLayoutResponder {
6280    fn drop(&mut self) {
6281        self.control_handle.shutdown();
6282        // Safety: drops once, never accessed again
6283        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6284    }
6285}
6286
6287impl fidl::endpoints::Responder for ParentViewportWatcherGetLayoutResponder {
6288    type ControlHandle = ParentViewportWatcherControlHandle;
6289
6290    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6291        &self.control_handle
6292    }
6293
6294    fn drop_without_shutdown(mut self) {
6295        // Safety: drops once, never accessed again due to mem::forget
6296        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6297        // Prevent Drop from running (which would shut down the channel)
6298        std::mem::forget(self);
6299    }
6300}
6301
6302impl ParentViewportWatcherGetLayoutResponder {
6303    /// Sends a response to the FIDL transaction.
6304    ///
6305    /// Sets the channel to shutdown if an error occurs.
6306    pub fn send(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6307        let _result = self.send_raw(info);
6308        if _result.is_err() {
6309            self.control_handle.shutdown();
6310        }
6311        self.drop_without_shutdown();
6312        _result
6313    }
6314
6315    /// Similar to "send" but does not shutdown the channel if an error occurs.
6316    pub fn send_no_shutdown_on_err(self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6317        let _result = self.send_raw(info);
6318        self.drop_without_shutdown();
6319        _result
6320    }
6321
6322    fn send_raw(&self, mut info: &LayoutInfo) -> Result<(), fidl::Error> {
6323        self.control_handle.inner.send::<ParentViewportWatcherGetLayoutResponse>(
6324            (info,),
6325            self.tx_id,
6326            0x3cbe5d9638e032,
6327            fidl::encoding::DynamicFlags::empty(),
6328        )
6329    }
6330}
6331
6332#[must_use = "FIDL methods require a response to be sent"]
6333#[derive(Debug)]
6334pub struct ParentViewportWatcherGetStatusResponder {
6335    control_handle: std::mem::ManuallyDrop<ParentViewportWatcherControlHandle>,
6336    tx_id: u32,
6337}
6338
6339/// Set the the channel to be shutdown (see [`ParentViewportWatcherControlHandle::shutdown`])
6340/// if the responder is dropped without sending a response, so that the client
6341/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
6342impl std::ops::Drop for ParentViewportWatcherGetStatusResponder {
6343    fn drop(&mut self) {
6344        self.control_handle.shutdown();
6345        // Safety: drops once, never accessed again
6346        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6347    }
6348}
6349
6350impl fidl::endpoints::Responder for ParentViewportWatcherGetStatusResponder {
6351    type ControlHandle = ParentViewportWatcherControlHandle;
6352
6353    fn control_handle(&self) -> &ParentViewportWatcherControlHandle {
6354        &self.control_handle
6355    }
6356
6357    fn drop_without_shutdown(mut self) {
6358        // Safety: drops once, never accessed again due to mem::forget
6359        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
6360        // Prevent Drop from running (which would shut down the channel)
6361        std::mem::forget(self);
6362    }
6363}
6364
6365impl ParentViewportWatcherGetStatusResponder {
6366    /// Sends a response to the FIDL transaction.
6367    ///
6368    /// Sets the channel to shutdown if an error occurs.
6369    pub fn send(self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6370        let _result = self.send_raw(status);
6371        if _result.is_err() {
6372            self.control_handle.shutdown();
6373        }
6374        self.drop_without_shutdown();
6375        _result
6376    }
6377
6378    /// Similar to "send" but does not shutdown the channel if an error occurs.
6379    pub fn send_no_shutdown_on_err(
6380        self,
6381        mut status: ParentViewportStatus,
6382    ) -> Result<(), fidl::Error> {
6383        let _result = self.send_raw(status);
6384        self.drop_without_shutdown();
6385        _result
6386    }
6387
6388    fn send_raw(&self, mut status: ParentViewportStatus) -> Result<(), fidl::Error> {
6389        self.control_handle.inner.send::<ParentViewportWatcherGetStatusResponse>(
6390            (status,),
6391            self.tx_id,
6392            0x7caa022f050d9ea6,
6393            fidl::encoding::DynamicFlags::empty(),
6394        )
6395    }
6396}
6397
6398#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
6399pub struct ScreenCaptureMarker;
6400
6401impl fidl::endpoints::ProtocolMarker for ScreenCaptureMarker {
6402    type Proxy = ScreenCaptureProxy;
6403    type RequestStream = ScreenCaptureRequestStream;
6404    #[cfg(target_os = "fuchsia")]
6405    type SynchronousProxy = ScreenCaptureSynchronousProxy;
6406
6407    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.ScreenCapture";
6408}
6409impl fidl::endpoints::DiscoverableProtocolMarker for ScreenCaptureMarker {}
6410pub type ScreenCaptureConfigureResult = Result<(), ScreenCaptureError>;
6411pub type ScreenCaptureGetNextFrameResult = Result<FrameInfo, ScreenCaptureError>;
6412pub type ScreenCaptureReleaseFrameResult = Result<(), ScreenCaptureError>;
6413
6414pub trait ScreenCaptureProxyInterface: Send + Sync {
6415    type ConfigureResponseFut: std::future::Future<Output = Result<ScreenCaptureConfigureResult, fidl::Error>>
6416        + Send;
6417    fn r#configure(&self, payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut;
6418    type GetNextFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureGetNextFrameResult, fidl::Error>>
6419        + Send;
6420    fn r#get_next_frame(&self, payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut;
6421    type ReleaseFrameResponseFut: std::future::Future<Output = Result<ScreenCaptureReleaseFrameResult, fidl::Error>>
6422        + Send;
6423    fn r#release_frame(&self, buffer_id: u32) -> Self::ReleaseFrameResponseFut;
6424}
6425#[derive(Debug)]
6426#[cfg(target_os = "fuchsia")]
6427pub struct ScreenCaptureSynchronousProxy {
6428    client: fidl::client::sync::Client,
6429}
6430
6431#[cfg(target_os = "fuchsia")]
6432impl fidl::endpoints::SynchronousProxy for ScreenCaptureSynchronousProxy {
6433    type Proxy = ScreenCaptureProxy;
6434    type Protocol = ScreenCaptureMarker;
6435
6436    fn from_channel(inner: fidl::Channel) -> Self {
6437        Self::new(inner)
6438    }
6439
6440    fn into_channel(self) -> fidl::Channel {
6441        self.client.into_channel()
6442    }
6443
6444    fn as_channel(&self) -> &fidl::Channel {
6445        self.client.as_channel()
6446    }
6447}
6448
6449#[cfg(target_os = "fuchsia")]
6450impl ScreenCaptureSynchronousProxy {
6451    pub fn new(channel: fidl::Channel) -> Self {
6452        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6453        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
6454    }
6455
6456    pub fn into_channel(self) -> fidl::Channel {
6457        self.client.into_channel()
6458    }
6459
6460    /// Waits until an event arrives and returns it. It is safe for other
6461    /// threads to make concurrent requests while waiting for an event.
6462    pub fn wait_for_event(
6463        &self,
6464        deadline: zx::MonotonicInstant,
6465    ) -> Result<ScreenCaptureEvent, fidl::Error> {
6466        ScreenCaptureEvent::decode(self.client.wait_for_event(deadline)?)
6467    }
6468
6469    /// Clients should first use the Allocator protocol to register a
6470    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6471    /// BufferCollection have set their constraints.
6472    ///
6473    /// Afterwards, clients should create and configure the images that will
6474    /// eventually be rendered to using this method. All the buffers in the
6475    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6476    ///
6477    /// Clients are responsible for determining the rotation of the display,
6478    /// and applying the corrective rotation. For instance, if the display is
6479    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6480    /// at the display), then the client should specify a 270 degree rotation
6481    /// to account for it.
6482    ///
6483    /// Similarly, the clients are responsible for specifying a buffer big
6484    /// enough for the rotated image. If the buffer is too small, a best effort
6485    /// attempt will be made to render the image.
6486    ///
6487    /// Finally, clients request the server to render the current screen to the
6488    /// shared buffers using [`GetNextFrame`].
6489    ///
6490    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6491    /// if the client wishes to change any of the configuration settings. In
6492    /// this case all the buffers from the previous call to [`Configure`] will
6493    /// be released.
6494    pub fn r#configure(
6495        &self,
6496        mut payload: ScreenCaptureConfig,
6497        ___deadline: zx::MonotonicInstant,
6498    ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6499        let _response = self.client.send_query::<ScreenCaptureConfig, fidl::encoding::ResultType<
6500            fidl::encoding::EmptyStruct,
6501            ScreenCaptureError,
6502        >>(
6503            &mut payload,
6504            0x3b6e5af1d294afd9,
6505            fidl::encoding::DynamicFlags::empty(),
6506            ___deadline,
6507        )?;
6508        Ok(_response.map(|x| x))
6509    }
6510
6511    /// Following a successful call to [`Configure`], clients can call
6512    /// GetNextFrame. This will populate a buffer with the most recent frame.
6513    ///
6514    /// Clients should wait on the zx::event they pass for successful
6515    /// completion of the screenshot. It is not guaranteed that the screenshot
6516    /// will be completed by the time this function returns.
6517    ///
6518    /// The requested image will be in the BufferCollection that the client set
6519    /// up in the VMO at the index specified by buffer_id.
6520    ///
6521    /// When ScreenCapture is used to provide a stream, the rate that the
6522    /// client calls GetNextFrame will drive the frame rate.
6523    ///
6524    /// Errors:
6525    /// BAD_OPERATION if Configure was not called, or not called successfully
6526    /// MISSING_ARGS if a required argument is not present
6527    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6528    /// must be called to make a buffer available before this function can be called successfully.
6529    pub fn r#get_next_frame(
6530        &self,
6531        mut payload: GetNextFrameArgs,
6532        ___deadline: zx::MonotonicInstant,
6533    ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6534        let _response = self.client.send_query::<
6535            GetNextFrameArgs,
6536            fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6537        >(
6538            &mut payload,
6539            0x552c1580aab8c4a7,
6540            fidl::encoding::DynamicFlags::empty(),
6541            ___deadline,
6542        )?;
6543        Ok(_response.map(|x| x))
6544    }
6545
6546    /// Once the client no longer needs an image, they can call ReleaseFrame on
6547    /// the VMO index of the buffer so that the server can reuse it in the future.
6548    pub fn r#release_frame(
6549        &self,
6550        mut buffer_id: u32,
6551        ___deadline: zx::MonotonicInstant,
6552    ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6553        let _response =
6554            self.client.send_query::<ScreenCaptureReleaseFrameRequest, fidl::encoding::ResultType<
6555                fidl::encoding::EmptyStruct,
6556                ScreenCaptureError,
6557            >>(
6558                (buffer_id,),
6559                0x46704dce24e35950,
6560                fidl::encoding::DynamicFlags::empty(),
6561                ___deadline,
6562            )?;
6563        Ok(_response.map(|x| x))
6564    }
6565}
6566
6567#[cfg(target_os = "fuchsia")]
6568impl From<ScreenCaptureSynchronousProxy> for zx::Handle {
6569    fn from(value: ScreenCaptureSynchronousProxy) -> Self {
6570        value.into_channel().into()
6571    }
6572}
6573
6574#[cfg(target_os = "fuchsia")]
6575impl From<fidl::Channel> for ScreenCaptureSynchronousProxy {
6576    fn from(value: fidl::Channel) -> Self {
6577        Self::new(value)
6578    }
6579}
6580
6581#[cfg(target_os = "fuchsia")]
6582impl fidl::endpoints::FromClient for ScreenCaptureSynchronousProxy {
6583    type Protocol = ScreenCaptureMarker;
6584
6585    fn from_client(value: fidl::endpoints::ClientEnd<ScreenCaptureMarker>) -> Self {
6586        Self::new(value.into_channel())
6587    }
6588}
6589
6590#[derive(Debug, Clone)]
6591pub struct ScreenCaptureProxy {
6592    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
6593}
6594
6595impl fidl::endpoints::Proxy for ScreenCaptureProxy {
6596    type Protocol = ScreenCaptureMarker;
6597
6598    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
6599        Self::new(inner)
6600    }
6601
6602    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
6603        self.client.into_channel().map_err(|client| Self { client })
6604    }
6605
6606    fn as_channel(&self) -> &::fidl::AsyncChannel {
6607        self.client.as_channel()
6608    }
6609}
6610
6611impl ScreenCaptureProxy {
6612    /// Create a new Proxy for fuchsia.ui.composition/ScreenCapture.
6613    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
6614        let protocol_name = <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
6615        Self { client: fidl::client::Client::new(channel, protocol_name) }
6616    }
6617
6618    /// Get a Stream of events from the remote end of the protocol.
6619    ///
6620    /// # Panics
6621    ///
6622    /// Panics if the event stream was already taken.
6623    pub fn take_event_stream(&self) -> ScreenCaptureEventStream {
6624        ScreenCaptureEventStream { event_receiver: self.client.take_event_receiver() }
6625    }
6626
6627    /// Clients should first use the Allocator protocol to register a
6628    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6629    /// BufferCollection have set their constraints.
6630    ///
6631    /// Afterwards, clients should create and configure the images that will
6632    /// eventually be rendered to using this method. All the buffers in the
6633    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6634    ///
6635    /// Clients are responsible for determining the rotation of the display,
6636    /// and applying the corrective rotation. For instance, if the display is
6637    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6638    /// at the display), then the client should specify a 270 degree rotation
6639    /// to account for it.
6640    ///
6641    /// Similarly, the clients are responsible for specifying a buffer big
6642    /// enough for the rotated image. If the buffer is too small, a best effort
6643    /// attempt will be made to render the image.
6644    ///
6645    /// Finally, clients request the server to render the current screen to the
6646    /// shared buffers using [`GetNextFrame`].
6647    ///
6648    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6649    /// if the client wishes to change any of the configuration settings. In
6650    /// this case all the buffers from the previous call to [`Configure`] will
6651    /// be released.
6652    pub fn r#configure(
6653        &self,
6654        mut payload: ScreenCaptureConfig,
6655    ) -> fidl::client::QueryResponseFut<
6656        ScreenCaptureConfigureResult,
6657        fidl::encoding::DefaultFuchsiaResourceDialect,
6658    > {
6659        ScreenCaptureProxyInterface::r#configure(self, payload)
6660    }
6661
6662    /// Following a successful call to [`Configure`], clients can call
6663    /// GetNextFrame. This will populate a buffer with the most recent frame.
6664    ///
6665    /// Clients should wait on the zx::event they pass for successful
6666    /// completion of the screenshot. It is not guaranteed that the screenshot
6667    /// will be completed by the time this function returns.
6668    ///
6669    /// The requested image will be in the BufferCollection that the client set
6670    /// up in the VMO at the index specified by buffer_id.
6671    ///
6672    /// When ScreenCapture is used to provide a stream, the rate that the
6673    /// client calls GetNextFrame will drive the frame rate.
6674    ///
6675    /// Errors:
6676    /// BAD_OPERATION if Configure was not called, or not called successfully
6677    /// MISSING_ARGS if a required argument is not present
6678    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
6679    /// must be called to make a buffer available before this function can be called successfully.
6680    pub fn r#get_next_frame(
6681        &self,
6682        mut payload: GetNextFrameArgs,
6683    ) -> fidl::client::QueryResponseFut<
6684        ScreenCaptureGetNextFrameResult,
6685        fidl::encoding::DefaultFuchsiaResourceDialect,
6686    > {
6687        ScreenCaptureProxyInterface::r#get_next_frame(self, payload)
6688    }
6689
6690    /// Once the client no longer needs an image, they can call ReleaseFrame on
6691    /// the VMO index of the buffer so that the server can reuse it in the future.
6692    pub fn r#release_frame(
6693        &self,
6694        mut buffer_id: u32,
6695    ) -> fidl::client::QueryResponseFut<
6696        ScreenCaptureReleaseFrameResult,
6697        fidl::encoding::DefaultFuchsiaResourceDialect,
6698    > {
6699        ScreenCaptureProxyInterface::r#release_frame(self, buffer_id)
6700    }
6701}
6702
6703impl ScreenCaptureProxyInterface for ScreenCaptureProxy {
6704    type ConfigureResponseFut = fidl::client::QueryResponseFut<
6705        ScreenCaptureConfigureResult,
6706        fidl::encoding::DefaultFuchsiaResourceDialect,
6707    >;
6708    fn r#configure(&self, mut payload: ScreenCaptureConfig) -> Self::ConfigureResponseFut {
6709        fn _decode(
6710            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6711        ) -> Result<ScreenCaptureConfigureResult, fidl::Error> {
6712            let _response = fidl::client::decode_transaction_body::<
6713                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6714                fidl::encoding::DefaultFuchsiaResourceDialect,
6715                0x3b6e5af1d294afd9,
6716            >(_buf?)?;
6717            Ok(_response.map(|x| x))
6718        }
6719        self.client.send_query_and_decode::<ScreenCaptureConfig, ScreenCaptureConfigureResult>(
6720            &mut payload,
6721            0x3b6e5af1d294afd9,
6722            fidl::encoding::DynamicFlags::empty(),
6723            _decode,
6724        )
6725    }
6726
6727    type GetNextFrameResponseFut = fidl::client::QueryResponseFut<
6728        ScreenCaptureGetNextFrameResult,
6729        fidl::encoding::DefaultFuchsiaResourceDialect,
6730    >;
6731    fn r#get_next_frame(&self, mut payload: GetNextFrameArgs) -> Self::GetNextFrameResponseFut {
6732        fn _decode(
6733            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6734        ) -> Result<ScreenCaptureGetNextFrameResult, fidl::Error> {
6735            let _response = fidl::client::decode_transaction_body::<
6736                fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>,
6737                fidl::encoding::DefaultFuchsiaResourceDialect,
6738                0x552c1580aab8c4a7,
6739            >(_buf?)?;
6740            Ok(_response.map(|x| x))
6741        }
6742        self.client.send_query_and_decode::<GetNextFrameArgs, ScreenCaptureGetNextFrameResult>(
6743            &mut payload,
6744            0x552c1580aab8c4a7,
6745            fidl::encoding::DynamicFlags::empty(),
6746            _decode,
6747        )
6748    }
6749
6750    type ReleaseFrameResponseFut = fidl::client::QueryResponseFut<
6751        ScreenCaptureReleaseFrameResult,
6752        fidl::encoding::DefaultFuchsiaResourceDialect,
6753    >;
6754    fn r#release_frame(&self, mut buffer_id: u32) -> Self::ReleaseFrameResponseFut {
6755        fn _decode(
6756            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
6757        ) -> Result<ScreenCaptureReleaseFrameResult, fidl::Error> {
6758            let _response = fidl::client::decode_transaction_body::<
6759                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ScreenCaptureError>,
6760                fidl::encoding::DefaultFuchsiaResourceDialect,
6761                0x46704dce24e35950,
6762            >(_buf?)?;
6763            Ok(_response.map(|x| x))
6764        }
6765        self.client.send_query_and_decode::<
6766            ScreenCaptureReleaseFrameRequest,
6767            ScreenCaptureReleaseFrameResult,
6768        >(
6769            (buffer_id,),
6770            0x46704dce24e35950,
6771            fidl::encoding::DynamicFlags::empty(),
6772            _decode,
6773        )
6774    }
6775}
6776
6777pub struct ScreenCaptureEventStream {
6778    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
6779}
6780
6781impl std::marker::Unpin for ScreenCaptureEventStream {}
6782
6783impl futures::stream::FusedStream for ScreenCaptureEventStream {
6784    fn is_terminated(&self) -> bool {
6785        self.event_receiver.is_terminated()
6786    }
6787}
6788
6789impl futures::Stream for ScreenCaptureEventStream {
6790    type Item = Result<ScreenCaptureEvent, fidl::Error>;
6791
6792    fn poll_next(
6793        mut self: std::pin::Pin<&mut Self>,
6794        cx: &mut std::task::Context<'_>,
6795    ) -> std::task::Poll<Option<Self::Item>> {
6796        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
6797            &mut self.event_receiver,
6798            cx
6799        )?) {
6800            Some(buf) => std::task::Poll::Ready(Some(ScreenCaptureEvent::decode(buf))),
6801            None => std::task::Poll::Ready(None),
6802        }
6803    }
6804}
6805
6806#[derive(Debug)]
6807pub enum ScreenCaptureEvent {}
6808
6809impl ScreenCaptureEvent {
6810    /// Decodes a message buffer as a [`ScreenCaptureEvent`].
6811    fn decode(
6812        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
6813    ) -> Result<ScreenCaptureEvent, fidl::Error> {
6814        let (bytes, _handles) = buf.split_mut();
6815        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6816        debug_assert_eq!(tx_header.tx_id, 0);
6817        match tx_header.ordinal {
6818            _ => Err(fidl::Error::UnknownOrdinal {
6819                ordinal: tx_header.ordinal,
6820                protocol_name: <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6821            }),
6822        }
6823    }
6824}
6825
6826/// A Stream of incoming requests for fuchsia.ui.composition/ScreenCapture.
6827pub struct ScreenCaptureRequestStream {
6828    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6829    is_terminated: bool,
6830}
6831
6832impl std::marker::Unpin for ScreenCaptureRequestStream {}
6833
6834impl futures::stream::FusedStream for ScreenCaptureRequestStream {
6835    fn is_terminated(&self) -> bool {
6836        self.is_terminated
6837    }
6838}
6839
6840impl fidl::endpoints::RequestStream for ScreenCaptureRequestStream {
6841    type Protocol = ScreenCaptureMarker;
6842    type ControlHandle = ScreenCaptureControlHandle;
6843
6844    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
6845        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
6846    }
6847
6848    fn control_handle(&self) -> Self::ControlHandle {
6849        ScreenCaptureControlHandle { inner: self.inner.clone() }
6850    }
6851
6852    fn into_inner(
6853        self,
6854    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
6855    {
6856        (self.inner, self.is_terminated)
6857    }
6858
6859    fn from_inner(
6860        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
6861        is_terminated: bool,
6862    ) -> Self {
6863        Self { inner, is_terminated }
6864    }
6865}
6866
6867impl futures::Stream for ScreenCaptureRequestStream {
6868    type Item = Result<ScreenCaptureRequest, fidl::Error>;
6869
6870    fn poll_next(
6871        mut self: std::pin::Pin<&mut Self>,
6872        cx: &mut std::task::Context<'_>,
6873    ) -> std::task::Poll<Option<Self::Item>> {
6874        let this = &mut *self;
6875        if this.inner.check_shutdown(cx) {
6876            this.is_terminated = true;
6877            return std::task::Poll::Ready(None);
6878        }
6879        if this.is_terminated {
6880            panic!("polled ScreenCaptureRequestStream after completion");
6881        }
6882        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
6883            |bytes, handles| {
6884                match this.inner.channel().read_etc(cx, bytes, handles) {
6885                    std::task::Poll::Ready(Ok(())) => {}
6886                    std::task::Poll::Pending => return std::task::Poll::Pending,
6887                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
6888                        this.is_terminated = true;
6889                        return std::task::Poll::Ready(None);
6890                    }
6891                    std::task::Poll::Ready(Err(e)) => {
6892                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
6893                            e.into(),
6894                        ))))
6895                    }
6896                }
6897
6898                // A message has been received from the channel
6899                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
6900
6901                std::task::Poll::Ready(Some(match header.ordinal {
6902                    0x3b6e5af1d294afd9 => {
6903                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6904                        let mut req = fidl::new_empty!(
6905                            ScreenCaptureConfig,
6906                            fidl::encoding::DefaultFuchsiaResourceDialect
6907                        );
6908                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureConfig>(&header, _body_bytes, handles, &mut req)?;
6909                        let control_handle =
6910                            ScreenCaptureControlHandle { inner: this.inner.clone() };
6911                        Ok(ScreenCaptureRequest::Configure {
6912                            payload: req,
6913                            responder: ScreenCaptureConfigureResponder {
6914                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6915                                tx_id: header.tx_id,
6916                            },
6917                        })
6918                    }
6919                    0x552c1580aab8c4a7 => {
6920                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6921                        let mut req = fidl::new_empty!(
6922                            GetNextFrameArgs,
6923                            fidl::encoding::DefaultFuchsiaResourceDialect
6924                        );
6925                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<GetNextFrameArgs>(&header, _body_bytes, handles, &mut req)?;
6926                        let control_handle =
6927                            ScreenCaptureControlHandle { inner: this.inner.clone() };
6928                        Ok(ScreenCaptureRequest::GetNextFrame {
6929                            payload: req,
6930                            responder: ScreenCaptureGetNextFrameResponder {
6931                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6932                                tx_id: header.tx_id,
6933                            },
6934                        })
6935                    }
6936                    0x46704dce24e35950 => {
6937                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
6938                        let mut req = fidl::new_empty!(
6939                            ScreenCaptureReleaseFrameRequest,
6940                            fidl::encoding::DefaultFuchsiaResourceDialect
6941                        );
6942                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenCaptureReleaseFrameRequest>(&header, _body_bytes, handles, &mut req)?;
6943                        let control_handle =
6944                            ScreenCaptureControlHandle { inner: this.inner.clone() };
6945                        Ok(ScreenCaptureRequest::ReleaseFrame {
6946                            buffer_id: req.buffer_id,
6947
6948                            responder: ScreenCaptureReleaseFrameResponder {
6949                                control_handle: std::mem::ManuallyDrop::new(control_handle),
6950                                tx_id: header.tx_id,
6951                            },
6952                        })
6953                    }
6954                    _ => Err(fidl::Error::UnknownOrdinal {
6955                        ordinal: header.ordinal,
6956                        protocol_name:
6957                            <ScreenCaptureMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
6958                    }),
6959                }))
6960            },
6961        )
6962    }
6963}
6964
6965/// This protocol provides a low-level ScreenCapture API for clients to use.
6966/// ScreenCapture clients should familiarize themselves with the
6967/// [`fuchsia.sysmem/BufferCollection`] and [`fuchsia.ui.composition/Allocator`] protocols
6968/// as those are necessary to create the BufferCollections and images ScreenCapture uses.
6969#[derive(Debug)]
6970pub enum ScreenCaptureRequest {
6971    /// Clients should first use the Allocator protocol to register a
6972    /// BufferCollection. This function will fail with BAD_OPERATION unless all clients of the
6973    /// BufferCollection have set their constraints.
6974    ///
6975    /// Afterwards, clients should create and configure the images that will
6976    /// eventually be rendered to using this method. All the buffers in the
6977    /// collection from 0 to (buffer_count-1) may be used for screen capture.
6978    ///
6979    /// Clients are responsible for determining the rotation of the display,
6980    /// and applying the corrective rotation. For instance, if the display is
6981    /// mounted 90 degrees clockwise (the "top" is on the right, when looking
6982    /// at the display), then the client should specify a 270 degree rotation
6983    /// to account for it.
6984    ///
6985    /// Similarly, the clients are responsible for specifying a buffer big
6986    /// enough for the rotated image. If the buffer is too small, a best effort
6987    /// attempt will be made to render the image.
6988    ///
6989    /// Finally, clients request the server to render the current screen to the
6990    /// shared buffers using [`GetNextFrame`].
6991    ///
6992    /// [`Configure`] can be called again with a new BufferCollectionImportToken
6993    /// if the client wishes to change any of the configuration settings. In
6994    /// this case all the buffers from the previous call to [`Configure`] will
6995    /// be released.
6996    Configure { payload: ScreenCaptureConfig, responder: ScreenCaptureConfigureResponder },
6997    /// Following a successful call to [`Configure`], clients can call
6998    /// GetNextFrame. This will populate a buffer with the most recent frame.
6999    ///
7000    /// Clients should wait on the zx::event they pass for successful
7001    /// completion of the screenshot. It is not guaranteed that the screenshot
7002    /// will be completed by the time this function returns.
7003    ///
7004    /// The requested image will be in the BufferCollection that the client set
7005    /// up in the VMO at the index specified by buffer_id.
7006    ///
7007    /// When ScreenCapture is used to provide a stream, the rate that the
7008    /// client calls GetNextFrame will drive the frame rate.
7009    ///
7010    /// Errors:
7011    /// BAD_OPERATION if Configure was not called, or not called successfully
7012    /// MISSING_ARGS if a required argument is not present
7013    /// BUFFER_FULL if all buffers in the BufferCollection are in use. In this case, ReleaseFrame
7014    /// must be called to make a buffer available before this function can be called successfully.
7015    GetNextFrame { payload: GetNextFrameArgs, responder: ScreenCaptureGetNextFrameResponder },
7016    /// Once the client no longer needs an image, they can call ReleaseFrame on
7017    /// the VMO index of the buffer so that the server can reuse it in the future.
7018    ReleaseFrame { buffer_id: u32, responder: ScreenCaptureReleaseFrameResponder },
7019}
7020
7021impl ScreenCaptureRequest {
7022    #[allow(irrefutable_let_patterns)]
7023    pub fn into_configure(self) -> Option<(ScreenCaptureConfig, ScreenCaptureConfigureResponder)> {
7024        if let ScreenCaptureRequest::Configure { payload, responder } = self {
7025            Some((payload, responder))
7026        } else {
7027            None
7028        }
7029    }
7030
7031    #[allow(irrefutable_let_patterns)]
7032    pub fn into_get_next_frame(
7033        self,
7034    ) -> Option<(GetNextFrameArgs, ScreenCaptureGetNextFrameResponder)> {
7035        if let ScreenCaptureRequest::GetNextFrame { payload, responder } = self {
7036            Some((payload, responder))
7037        } else {
7038            None
7039        }
7040    }
7041
7042    #[allow(irrefutable_let_patterns)]
7043    pub fn into_release_frame(self) -> Option<(u32, ScreenCaptureReleaseFrameResponder)> {
7044        if let ScreenCaptureRequest::ReleaseFrame { buffer_id, responder } = self {
7045            Some((buffer_id, responder))
7046        } else {
7047            None
7048        }
7049    }
7050
7051    /// Name of the method defined in FIDL
7052    pub fn method_name(&self) -> &'static str {
7053        match *self {
7054            ScreenCaptureRequest::Configure { .. } => "configure",
7055            ScreenCaptureRequest::GetNextFrame { .. } => "get_next_frame",
7056            ScreenCaptureRequest::ReleaseFrame { .. } => "release_frame",
7057        }
7058    }
7059}
7060
7061#[derive(Debug, Clone)]
7062pub struct ScreenCaptureControlHandle {
7063    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7064}
7065
7066impl fidl::endpoints::ControlHandle for ScreenCaptureControlHandle {
7067    fn shutdown(&self) {
7068        self.inner.shutdown()
7069    }
7070    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7071        self.inner.shutdown_with_epitaph(status)
7072    }
7073
7074    fn is_closed(&self) -> bool {
7075        self.inner.channel().is_closed()
7076    }
7077    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7078        self.inner.channel().on_closed()
7079    }
7080
7081    #[cfg(target_os = "fuchsia")]
7082    fn signal_peer(
7083        &self,
7084        clear_mask: zx::Signals,
7085        set_mask: zx::Signals,
7086    ) -> Result<(), zx_status::Status> {
7087        use fidl::Peered;
7088        self.inner.channel().signal_peer(clear_mask, set_mask)
7089    }
7090}
7091
7092impl ScreenCaptureControlHandle {}
7093
7094#[must_use = "FIDL methods require a response to be sent"]
7095#[derive(Debug)]
7096pub struct ScreenCaptureConfigureResponder {
7097    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7098    tx_id: u32,
7099}
7100
7101/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7102/// if the responder is dropped without sending a response, so that the client
7103/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7104impl std::ops::Drop for ScreenCaptureConfigureResponder {
7105    fn drop(&mut self) {
7106        self.control_handle.shutdown();
7107        // Safety: drops once, never accessed again
7108        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7109    }
7110}
7111
7112impl fidl::endpoints::Responder for ScreenCaptureConfigureResponder {
7113    type ControlHandle = ScreenCaptureControlHandle;
7114
7115    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7116        &self.control_handle
7117    }
7118
7119    fn drop_without_shutdown(mut self) {
7120        // Safety: drops once, never accessed again due to mem::forget
7121        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7122        // Prevent Drop from running (which would shut down the channel)
7123        std::mem::forget(self);
7124    }
7125}
7126
7127impl ScreenCaptureConfigureResponder {
7128    /// Sends a response to the FIDL transaction.
7129    ///
7130    /// Sets the channel to shutdown if an error occurs.
7131    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7132        let _result = self.send_raw(result);
7133        if _result.is_err() {
7134            self.control_handle.shutdown();
7135        }
7136        self.drop_without_shutdown();
7137        _result
7138    }
7139
7140    /// Similar to "send" but does not shutdown the channel if an error occurs.
7141    pub fn send_no_shutdown_on_err(
7142        self,
7143        mut result: Result<(), ScreenCaptureError>,
7144    ) -> Result<(), fidl::Error> {
7145        let _result = self.send_raw(result);
7146        self.drop_without_shutdown();
7147        _result
7148    }
7149
7150    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7151        self.control_handle.inner.send::<fidl::encoding::ResultType<
7152            fidl::encoding::EmptyStruct,
7153            ScreenCaptureError,
7154        >>(
7155            result,
7156            self.tx_id,
7157            0x3b6e5af1d294afd9,
7158            fidl::encoding::DynamicFlags::empty(),
7159        )
7160    }
7161}
7162
7163#[must_use = "FIDL methods require a response to be sent"]
7164#[derive(Debug)]
7165pub struct ScreenCaptureGetNextFrameResponder {
7166    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7167    tx_id: u32,
7168}
7169
7170/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7171/// if the responder is dropped without sending a response, so that the client
7172/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7173impl std::ops::Drop for ScreenCaptureGetNextFrameResponder {
7174    fn drop(&mut self) {
7175        self.control_handle.shutdown();
7176        // Safety: drops once, never accessed again
7177        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7178    }
7179}
7180
7181impl fidl::endpoints::Responder for ScreenCaptureGetNextFrameResponder {
7182    type ControlHandle = ScreenCaptureControlHandle;
7183
7184    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7185        &self.control_handle
7186    }
7187
7188    fn drop_without_shutdown(mut self) {
7189        // Safety: drops once, never accessed again due to mem::forget
7190        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7191        // Prevent Drop from running (which would shut down the channel)
7192        std::mem::forget(self);
7193    }
7194}
7195
7196impl ScreenCaptureGetNextFrameResponder {
7197    /// Sends a response to the FIDL transaction.
7198    ///
7199    /// Sets the channel to shutdown if an error occurs.
7200    pub fn send(
7201        self,
7202        mut result: Result<FrameInfo, ScreenCaptureError>,
7203    ) -> Result<(), fidl::Error> {
7204        let _result = self.send_raw(result);
7205        if _result.is_err() {
7206            self.control_handle.shutdown();
7207        }
7208        self.drop_without_shutdown();
7209        _result
7210    }
7211
7212    /// Similar to "send" but does not shutdown the channel if an error occurs.
7213    pub fn send_no_shutdown_on_err(
7214        self,
7215        mut result: Result<FrameInfo, ScreenCaptureError>,
7216    ) -> Result<(), fidl::Error> {
7217        let _result = self.send_raw(result);
7218        self.drop_without_shutdown();
7219        _result
7220    }
7221
7222    fn send_raw(
7223        &self,
7224        mut result: Result<FrameInfo, ScreenCaptureError>,
7225    ) -> Result<(), fidl::Error> {
7226        self.control_handle.inner.send::<fidl::encoding::ResultType<FrameInfo, ScreenCaptureError>>(
7227            result.as_mut().map_err(|e| *e),
7228            self.tx_id,
7229            0x552c1580aab8c4a7,
7230            fidl::encoding::DynamicFlags::empty(),
7231        )
7232    }
7233}
7234
7235#[must_use = "FIDL methods require a response to be sent"]
7236#[derive(Debug)]
7237pub struct ScreenCaptureReleaseFrameResponder {
7238    control_handle: std::mem::ManuallyDrop<ScreenCaptureControlHandle>,
7239    tx_id: u32,
7240}
7241
7242/// Set the the channel to be shutdown (see [`ScreenCaptureControlHandle::shutdown`])
7243/// if the responder is dropped without sending a response, so that the client
7244/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7245impl std::ops::Drop for ScreenCaptureReleaseFrameResponder {
7246    fn drop(&mut self) {
7247        self.control_handle.shutdown();
7248        // Safety: drops once, never accessed again
7249        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7250    }
7251}
7252
7253impl fidl::endpoints::Responder for ScreenCaptureReleaseFrameResponder {
7254    type ControlHandle = ScreenCaptureControlHandle;
7255
7256    fn control_handle(&self) -> &ScreenCaptureControlHandle {
7257        &self.control_handle
7258    }
7259
7260    fn drop_without_shutdown(mut self) {
7261        // Safety: drops once, never accessed again due to mem::forget
7262        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7263        // Prevent Drop from running (which would shut down the channel)
7264        std::mem::forget(self);
7265    }
7266}
7267
7268impl ScreenCaptureReleaseFrameResponder {
7269    /// Sends a response to the FIDL transaction.
7270    ///
7271    /// Sets the channel to shutdown if an error occurs.
7272    pub fn send(self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7273        let _result = self.send_raw(result);
7274        if _result.is_err() {
7275            self.control_handle.shutdown();
7276        }
7277        self.drop_without_shutdown();
7278        _result
7279    }
7280
7281    /// Similar to "send" but does not shutdown the channel if an error occurs.
7282    pub fn send_no_shutdown_on_err(
7283        self,
7284        mut result: Result<(), ScreenCaptureError>,
7285    ) -> Result<(), fidl::Error> {
7286        let _result = self.send_raw(result);
7287        self.drop_without_shutdown();
7288        _result
7289    }
7290
7291    fn send_raw(&self, mut result: Result<(), ScreenCaptureError>) -> Result<(), fidl::Error> {
7292        self.control_handle.inner.send::<fidl::encoding::ResultType<
7293            fidl::encoding::EmptyStruct,
7294            ScreenCaptureError,
7295        >>(
7296            result,
7297            self.tx_id,
7298            0x46704dce24e35950,
7299            fidl::encoding::DynamicFlags::empty(),
7300        )
7301    }
7302}
7303
7304#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
7305pub struct ScreenshotMarker;
7306
7307impl fidl::endpoints::ProtocolMarker for ScreenshotMarker {
7308    type Proxy = ScreenshotProxy;
7309    type RequestStream = ScreenshotRequestStream;
7310    #[cfg(target_os = "fuchsia")]
7311    type SynchronousProxy = ScreenshotSynchronousProxy;
7312
7313    const DEBUG_NAME: &'static str = "fuchsia.ui.composition.Screenshot";
7314}
7315impl fidl::endpoints::DiscoverableProtocolMarker for ScreenshotMarker {}
7316
7317pub trait ScreenshotProxyInterface: Send + Sync {
7318    type TakeResponseFut: std::future::Future<Output = Result<ScreenshotTakeResponse, fidl::Error>>
7319        + Send;
7320    fn r#take(&self, payload: ScreenshotTakeRequest) -> Self::TakeResponseFut;
7321    type TakeFileResponseFut: std::future::Future<Output = Result<ScreenshotTakeFileResponse, fidl::Error>>
7322        + Send;
7323    fn r#take_file(&self, payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut;
7324}
7325#[derive(Debug)]
7326#[cfg(target_os = "fuchsia")]
7327pub struct ScreenshotSynchronousProxy {
7328    client: fidl::client::sync::Client,
7329}
7330
7331#[cfg(target_os = "fuchsia")]
7332impl fidl::endpoints::SynchronousProxy for ScreenshotSynchronousProxy {
7333    type Proxy = ScreenshotProxy;
7334    type Protocol = ScreenshotMarker;
7335
7336    fn from_channel(inner: fidl::Channel) -> Self {
7337        Self::new(inner)
7338    }
7339
7340    fn into_channel(self) -> fidl::Channel {
7341        self.client.into_channel()
7342    }
7343
7344    fn as_channel(&self) -> &fidl::Channel {
7345        self.client.as_channel()
7346    }
7347}
7348
7349#[cfg(target_os = "fuchsia")]
7350impl ScreenshotSynchronousProxy {
7351    pub fn new(channel: fidl::Channel) -> Self {
7352        let protocol_name = <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7353        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
7354    }
7355
7356    pub fn into_channel(self) -> fidl::Channel {
7357        self.client.into_channel()
7358    }
7359
7360    /// Waits until an event arrives and returns it. It is safe for other
7361    /// threads to make concurrent requests while waiting for an event.
7362    pub fn wait_for_event(
7363        &self,
7364        deadline: zx::MonotonicInstant,
7365    ) -> Result<ScreenshotEvent, fidl::Error> {
7366        ScreenshotEvent::decode(self.client.wait_for_event(deadline)?)
7367    }
7368
7369    /// Collects the current graphical content of a display in a specified buffer `format` in the
7370    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7371    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7372    /// linear color space.
7373    ///
7374    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7375    ///
7376    /// Screenshot is taken immediately, populated with the display's content from the most recent
7377    /// VSYNC.
7378    ///
7379    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7380    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7381    ///
7382    /// If capture fails due to an internal error, the server will close the Screenshot connection
7383    /// with a ZX_ERR_INTERNAL epitaph.
7384    pub fn r#take(
7385        &self,
7386        mut payload: ScreenshotTakeRequest,
7387        ___deadline: zx::MonotonicInstant,
7388    ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7389        let _response = self.client.send_query::<ScreenshotTakeRequest, ScreenshotTakeResponse>(
7390            &mut payload,
7391            0x51341396e9fd2fd0,
7392            fidl::encoding::DynamicFlags::empty(),
7393            ___deadline,
7394        )?;
7395        Ok(_response)
7396    }
7397
7398    /// Collects the current graphical content of a display in a specified buffer `format` in the
7399    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7400    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7401    /// linear color space.
7402    ///
7403    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7404    ///
7405    /// Screenshot is taken immediately, populated with the display's content from the most recent
7406    /// VSYNC.
7407    ///
7408    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7409    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7410    ///
7411    /// If capture fails due to an internal error, the server will close the Screenshot connection
7412    /// with a ZX_ERR_INTERNAL epitaph.
7413    ///
7414    /// This call should be used if the client is on the host and does not support VMOs,
7415    /// as is the case for ffx tools.
7416    pub fn r#take_file(
7417        &self,
7418        mut payload: ScreenshotTakeFileRequest,
7419        ___deadline: zx::MonotonicInstant,
7420    ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7421        let _response =
7422            self.client.send_query::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse>(
7423                &mut payload,
7424                0x470aeea0a4d32903,
7425                fidl::encoding::DynamicFlags::empty(),
7426                ___deadline,
7427            )?;
7428        Ok(_response)
7429    }
7430}
7431
7432#[cfg(target_os = "fuchsia")]
7433impl From<ScreenshotSynchronousProxy> for zx::Handle {
7434    fn from(value: ScreenshotSynchronousProxy) -> Self {
7435        value.into_channel().into()
7436    }
7437}
7438
7439#[cfg(target_os = "fuchsia")]
7440impl From<fidl::Channel> for ScreenshotSynchronousProxy {
7441    fn from(value: fidl::Channel) -> Self {
7442        Self::new(value)
7443    }
7444}
7445
7446#[cfg(target_os = "fuchsia")]
7447impl fidl::endpoints::FromClient for ScreenshotSynchronousProxy {
7448    type Protocol = ScreenshotMarker;
7449
7450    fn from_client(value: fidl::endpoints::ClientEnd<ScreenshotMarker>) -> Self {
7451        Self::new(value.into_channel())
7452    }
7453}
7454
7455#[derive(Debug, Clone)]
7456pub struct ScreenshotProxy {
7457    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
7458}
7459
7460impl fidl::endpoints::Proxy for ScreenshotProxy {
7461    type Protocol = ScreenshotMarker;
7462
7463    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
7464        Self::new(inner)
7465    }
7466
7467    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
7468        self.client.into_channel().map_err(|client| Self { client })
7469    }
7470
7471    fn as_channel(&self) -> &::fidl::AsyncChannel {
7472        self.client.as_channel()
7473    }
7474}
7475
7476impl ScreenshotProxy {
7477    /// Create a new Proxy for fuchsia.ui.composition/Screenshot.
7478    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
7479        let protocol_name = <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
7480        Self { client: fidl::client::Client::new(channel, protocol_name) }
7481    }
7482
7483    /// Get a Stream of events from the remote end of the protocol.
7484    ///
7485    /// # Panics
7486    ///
7487    /// Panics if the event stream was already taken.
7488    pub fn take_event_stream(&self) -> ScreenshotEventStream {
7489        ScreenshotEventStream { event_receiver: self.client.take_event_receiver() }
7490    }
7491
7492    /// Collects the current graphical content of a display in a specified buffer `format` in the
7493    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7494    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7495    /// linear color space.
7496    ///
7497    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7498    ///
7499    /// Screenshot is taken immediately, populated with the display's content from the most recent
7500    /// VSYNC.
7501    ///
7502    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7503    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7504    ///
7505    /// If capture fails due to an internal error, the server will close the Screenshot connection
7506    /// with a ZX_ERR_INTERNAL epitaph.
7507    pub fn r#take(
7508        &self,
7509        mut payload: ScreenshotTakeRequest,
7510    ) -> fidl::client::QueryResponseFut<
7511        ScreenshotTakeResponse,
7512        fidl::encoding::DefaultFuchsiaResourceDialect,
7513    > {
7514        ScreenshotProxyInterface::r#take(self, payload)
7515    }
7516
7517    /// Collects the current graphical content of a display in a specified buffer `format` in the
7518    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7519    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7520    /// linear color space.
7521    ///
7522    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7523    ///
7524    /// Screenshot is taken immediately, populated with the display's content from the most recent
7525    /// VSYNC.
7526    ///
7527    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7528    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7529    ///
7530    /// If capture fails due to an internal error, the server will close the Screenshot connection
7531    /// with a ZX_ERR_INTERNAL epitaph.
7532    ///
7533    /// This call should be used if the client is on the host and does not support VMOs,
7534    /// as is the case for ffx tools.
7535    pub fn r#take_file(
7536        &self,
7537        mut payload: ScreenshotTakeFileRequest,
7538    ) -> fidl::client::QueryResponseFut<
7539        ScreenshotTakeFileResponse,
7540        fidl::encoding::DefaultFuchsiaResourceDialect,
7541    > {
7542        ScreenshotProxyInterface::r#take_file(self, payload)
7543    }
7544}
7545
7546impl ScreenshotProxyInterface for ScreenshotProxy {
7547    type TakeResponseFut = fidl::client::QueryResponseFut<
7548        ScreenshotTakeResponse,
7549        fidl::encoding::DefaultFuchsiaResourceDialect,
7550    >;
7551    fn r#take(&self, mut payload: ScreenshotTakeRequest) -> Self::TakeResponseFut {
7552        fn _decode(
7553            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7554        ) -> Result<ScreenshotTakeResponse, fidl::Error> {
7555            let _response = fidl::client::decode_transaction_body::<
7556                ScreenshotTakeResponse,
7557                fidl::encoding::DefaultFuchsiaResourceDialect,
7558                0x51341396e9fd2fd0,
7559            >(_buf?)?;
7560            Ok(_response)
7561        }
7562        self.client.send_query_and_decode::<ScreenshotTakeRequest, ScreenshotTakeResponse>(
7563            &mut payload,
7564            0x51341396e9fd2fd0,
7565            fidl::encoding::DynamicFlags::empty(),
7566            _decode,
7567        )
7568    }
7569
7570    type TakeFileResponseFut = fidl::client::QueryResponseFut<
7571        ScreenshotTakeFileResponse,
7572        fidl::encoding::DefaultFuchsiaResourceDialect,
7573    >;
7574    fn r#take_file(&self, mut payload: ScreenshotTakeFileRequest) -> Self::TakeFileResponseFut {
7575        fn _decode(
7576            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
7577        ) -> Result<ScreenshotTakeFileResponse, fidl::Error> {
7578            let _response = fidl::client::decode_transaction_body::<
7579                ScreenshotTakeFileResponse,
7580                fidl::encoding::DefaultFuchsiaResourceDialect,
7581                0x470aeea0a4d32903,
7582            >(_buf?)?;
7583            Ok(_response)
7584        }
7585        self.client.send_query_and_decode::<ScreenshotTakeFileRequest, ScreenshotTakeFileResponse>(
7586            &mut payload,
7587            0x470aeea0a4d32903,
7588            fidl::encoding::DynamicFlags::empty(),
7589            _decode,
7590        )
7591    }
7592}
7593
7594pub struct ScreenshotEventStream {
7595    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
7596}
7597
7598impl std::marker::Unpin for ScreenshotEventStream {}
7599
7600impl futures::stream::FusedStream for ScreenshotEventStream {
7601    fn is_terminated(&self) -> bool {
7602        self.event_receiver.is_terminated()
7603    }
7604}
7605
7606impl futures::Stream for ScreenshotEventStream {
7607    type Item = Result<ScreenshotEvent, fidl::Error>;
7608
7609    fn poll_next(
7610        mut self: std::pin::Pin<&mut Self>,
7611        cx: &mut std::task::Context<'_>,
7612    ) -> std::task::Poll<Option<Self::Item>> {
7613        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
7614            &mut self.event_receiver,
7615            cx
7616        )?) {
7617            Some(buf) => std::task::Poll::Ready(Some(ScreenshotEvent::decode(buf))),
7618            None => std::task::Poll::Ready(None),
7619        }
7620    }
7621}
7622
7623#[derive(Debug)]
7624pub enum ScreenshotEvent {}
7625
7626impl ScreenshotEvent {
7627    /// Decodes a message buffer as a [`ScreenshotEvent`].
7628    fn decode(
7629        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
7630    ) -> Result<ScreenshotEvent, fidl::Error> {
7631        let (bytes, _handles) = buf.split_mut();
7632        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7633        debug_assert_eq!(tx_header.tx_id, 0);
7634        match tx_header.ordinal {
7635            _ => Err(fidl::Error::UnknownOrdinal {
7636                ordinal: tx_header.ordinal,
7637                protocol_name: <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7638            }),
7639        }
7640    }
7641}
7642
7643/// A Stream of incoming requests for fuchsia.ui.composition/Screenshot.
7644pub struct ScreenshotRequestStream {
7645    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7646    is_terminated: bool,
7647}
7648
7649impl std::marker::Unpin for ScreenshotRequestStream {}
7650
7651impl futures::stream::FusedStream for ScreenshotRequestStream {
7652    fn is_terminated(&self) -> bool {
7653        self.is_terminated
7654    }
7655}
7656
7657impl fidl::endpoints::RequestStream for ScreenshotRequestStream {
7658    type Protocol = ScreenshotMarker;
7659    type ControlHandle = ScreenshotControlHandle;
7660
7661    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
7662        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
7663    }
7664
7665    fn control_handle(&self) -> Self::ControlHandle {
7666        ScreenshotControlHandle { inner: self.inner.clone() }
7667    }
7668
7669    fn into_inner(
7670        self,
7671    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
7672    {
7673        (self.inner, self.is_terminated)
7674    }
7675
7676    fn from_inner(
7677        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7678        is_terminated: bool,
7679    ) -> Self {
7680        Self { inner, is_terminated }
7681    }
7682}
7683
7684impl futures::Stream for ScreenshotRequestStream {
7685    type Item = Result<ScreenshotRequest, fidl::Error>;
7686
7687    fn poll_next(
7688        mut self: std::pin::Pin<&mut Self>,
7689        cx: &mut std::task::Context<'_>,
7690    ) -> std::task::Poll<Option<Self::Item>> {
7691        let this = &mut *self;
7692        if this.inner.check_shutdown(cx) {
7693            this.is_terminated = true;
7694            return std::task::Poll::Ready(None);
7695        }
7696        if this.is_terminated {
7697            panic!("polled ScreenshotRequestStream after completion");
7698        }
7699        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
7700            |bytes, handles| {
7701                match this.inner.channel().read_etc(cx, bytes, handles) {
7702                    std::task::Poll::Ready(Ok(())) => {}
7703                    std::task::Poll::Pending => return std::task::Poll::Pending,
7704                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
7705                        this.is_terminated = true;
7706                        return std::task::Poll::Ready(None);
7707                    }
7708                    std::task::Poll::Ready(Err(e)) => {
7709                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
7710                            e.into(),
7711                        ))))
7712                    }
7713                }
7714
7715                // A message has been received from the channel
7716                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
7717
7718                std::task::Poll::Ready(Some(match header.ordinal {
7719                    0x51341396e9fd2fd0 => {
7720                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7721                        let mut req = fidl::new_empty!(
7722                            ScreenshotTakeRequest,
7723                            fidl::encoding::DefaultFuchsiaResourceDialect
7724                        );
7725                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeRequest>(&header, _body_bytes, handles, &mut req)?;
7726                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7727                        Ok(ScreenshotRequest::Take {
7728                            payload: req,
7729                            responder: ScreenshotTakeResponder {
7730                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7731                                tx_id: header.tx_id,
7732                            },
7733                        })
7734                    }
7735                    0x470aeea0a4d32903 => {
7736                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
7737                        let mut req = fidl::new_empty!(
7738                            ScreenshotTakeFileRequest,
7739                            fidl::encoding::DefaultFuchsiaResourceDialect
7740                        );
7741                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ScreenshotTakeFileRequest>(&header, _body_bytes, handles, &mut req)?;
7742                        let control_handle = ScreenshotControlHandle { inner: this.inner.clone() };
7743                        Ok(ScreenshotRequest::TakeFile {
7744                            payload: req,
7745                            responder: ScreenshotTakeFileResponder {
7746                                control_handle: std::mem::ManuallyDrop::new(control_handle),
7747                                tx_id: header.tx_id,
7748                            },
7749                        })
7750                    }
7751                    _ => Err(fidl::Error::UnknownOrdinal {
7752                        ordinal: header.ordinal,
7753                        protocol_name:
7754                            <ScreenshotMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
7755                    }),
7756                }))
7757            },
7758        )
7759    }
7760}
7761
7762/// Collects the current graphical content of a display.
7763#[derive(Debug)]
7764pub enum ScreenshotRequest {
7765    /// Collects the current graphical content of a display in a specified buffer `format` in the
7766    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7767    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7768    /// linear color space.
7769    ///
7770    /// See https://fuchsia.dev/fuchsia-src/concepts/ui/scenic/color_spaces for more information.
7771    ///
7772    /// Screenshot is taken immediately, populated with the display's content from the most recent
7773    /// VSYNC.
7774    ///
7775    /// If the client calls [`Take`] a second time before a first [`Take`] call returns, the server
7776    /// will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7777    ///
7778    /// If capture fails due to an internal error, the server will close the Screenshot connection
7779    /// with a ZX_ERR_INTERNAL epitaph.
7780    Take { payload: ScreenshotTakeRequest, responder: ScreenshotTakeResponder },
7781    /// Collects the current graphical content of a display in a specified buffer `format` in the
7782    /// sRGB color space. Note that the sRGB color space is non-linear, meaning that unit tests
7783    /// doing pixel equality checks making use of non-fully saturated colors should convert to a
7784    /// linear color space.
7785    ///
7786    /// TODO(https://fxbug.dev/42065844): Link to fuchsia.dev documentation when it's up.
7787    ///
7788    /// Screenshot is taken immediately, populated with the display's content from the most recent
7789    /// VSYNC.
7790    ///
7791    /// If the client calls [`TakeFile`] a second time before a first [`TakeFile`] call returns,
7792    /// the server will close the Screenshot connection with a ZX_ERR_SHOULD_WAIT epitaph.
7793    ///
7794    /// If capture fails due to an internal error, the server will close the Screenshot connection
7795    /// with a ZX_ERR_INTERNAL epitaph.
7796    ///
7797    /// This call should be used if the client is on the host and does not support VMOs,
7798    /// as is the case for ffx tools.
7799    TakeFile { payload: ScreenshotTakeFileRequest, responder: ScreenshotTakeFileResponder },
7800}
7801
7802impl ScreenshotRequest {
7803    #[allow(irrefutable_let_patterns)]
7804    pub fn into_take(self) -> Option<(ScreenshotTakeRequest, ScreenshotTakeResponder)> {
7805        if let ScreenshotRequest::Take { payload, responder } = self {
7806            Some((payload, responder))
7807        } else {
7808            None
7809        }
7810    }
7811
7812    #[allow(irrefutable_let_patterns)]
7813    pub fn into_take_file(
7814        self,
7815    ) -> Option<(ScreenshotTakeFileRequest, ScreenshotTakeFileResponder)> {
7816        if let ScreenshotRequest::TakeFile { payload, responder } = self {
7817            Some((payload, responder))
7818        } else {
7819            None
7820        }
7821    }
7822
7823    /// Name of the method defined in FIDL
7824    pub fn method_name(&self) -> &'static str {
7825        match *self {
7826            ScreenshotRequest::Take { .. } => "take",
7827            ScreenshotRequest::TakeFile { .. } => "take_file",
7828        }
7829    }
7830}
7831
7832#[derive(Debug, Clone)]
7833pub struct ScreenshotControlHandle {
7834    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
7835}
7836
7837impl fidl::endpoints::ControlHandle for ScreenshotControlHandle {
7838    fn shutdown(&self) {
7839        self.inner.shutdown()
7840    }
7841    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
7842        self.inner.shutdown_with_epitaph(status)
7843    }
7844
7845    fn is_closed(&self) -> bool {
7846        self.inner.channel().is_closed()
7847    }
7848    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
7849        self.inner.channel().on_closed()
7850    }
7851
7852    #[cfg(target_os = "fuchsia")]
7853    fn signal_peer(
7854        &self,
7855        clear_mask: zx::Signals,
7856        set_mask: zx::Signals,
7857    ) -> Result<(), zx_status::Status> {
7858        use fidl::Peered;
7859        self.inner.channel().signal_peer(clear_mask, set_mask)
7860    }
7861}
7862
7863impl ScreenshotControlHandle {}
7864
7865#[must_use = "FIDL methods require a response to be sent"]
7866#[derive(Debug)]
7867pub struct ScreenshotTakeResponder {
7868    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
7869    tx_id: u32,
7870}
7871
7872/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
7873/// if the responder is dropped without sending a response, so that the client
7874/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7875impl std::ops::Drop for ScreenshotTakeResponder {
7876    fn drop(&mut self) {
7877        self.control_handle.shutdown();
7878        // Safety: drops once, never accessed again
7879        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7880    }
7881}
7882
7883impl fidl::endpoints::Responder for ScreenshotTakeResponder {
7884    type ControlHandle = ScreenshotControlHandle;
7885
7886    fn control_handle(&self) -> &ScreenshotControlHandle {
7887        &self.control_handle
7888    }
7889
7890    fn drop_without_shutdown(mut self) {
7891        // Safety: drops once, never accessed again due to mem::forget
7892        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7893        // Prevent Drop from running (which would shut down the channel)
7894        std::mem::forget(self);
7895    }
7896}
7897
7898impl ScreenshotTakeResponder {
7899    /// Sends a response to the FIDL transaction.
7900    ///
7901    /// Sets the channel to shutdown if an error occurs.
7902    pub fn send(self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
7903        let _result = self.send_raw(payload);
7904        if _result.is_err() {
7905            self.control_handle.shutdown();
7906        }
7907        self.drop_without_shutdown();
7908        _result
7909    }
7910
7911    /// Similar to "send" but does not shutdown the channel if an error occurs.
7912    pub fn send_no_shutdown_on_err(
7913        self,
7914        mut payload: ScreenshotTakeResponse,
7915    ) -> Result<(), fidl::Error> {
7916        let _result = self.send_raw(payload);
7917        self.drop_without_shutdown();
7918        _result
7919    }
7920
7921    fn send_raw(&self, mut payload: ScreenshotTakeResponse) -> Result<(), fidl::Error> {
7922        self.control_handle.inner.send::<ScreenshotTakeResponse>(
7923            &mut payload,
7924            self.tx_id,
7925            0x51341396e9fd2fd0,
7926            fidl::encoding::DynamicFlags::empty(),
7927        )
7928    }
7929}
7930
7931#[must_use = "FIDL methods require a response to be sent"]
7932#[derive(Debug)]
7933pub struct ScreenshotTakeFileResponder {
7934    control_handle: std::mem::ManuallyDrop<ScreenshotControlHandle>,
7935    tx_id: u32,
7936}
7937
7938/// Set the the channel to be shutdown (see [`ScreenshotControlHandle::shutdown`])
7939/// if the responder is dropped without sending a response, so that the client
7940/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
7941impl std::ops::Drop for ScreenshotTakeFileResponder {
7942    fn drop(&mut self) {
7943        self.control_handle.shutdown();
7944        // Safety: drops once, never accessed again
7945        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7946    }
7947}
7948
7949impl fidl::endpoints::Responder for ScreenshotTakeFileResponder {
7950    type ControlHandle = ScreenshotControlHandle;
7951
7952    fn control_handle(&self) -> &ScreenshotControlHandle {
7953        &self.control_handle
7954    }
7955
7956    fn drop_without_shutdown(mut self) {
7957        // Safety: drops once, never accessed again due to mem::forget
7958        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
7959        // Prevent Drop from running (which would shut down the channel)
7960        std::mem::forget(self);
7961    }
7962}
7963
7964impl ScreenshotTakeFileResponder {
7965    /// Sends a response to the FIDL transaction.
7966    ///
7967    /// Sets the channel to shutdown if an error occurs.
7968    pub fn send(self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
7969        let _result = self.send_raw(payload);
7970        if _result.is_err() {
7971            self.control_handle.shutdown();
7972        }
7973        self.drop_without_shutdown();
7974        _result
7975    }
7976
7977    /// Similar to "send" but does not shutdown the channel if an error occurs.
7978    pub fn send_no_shutdown_on_err(
7979        self,
7980        mut payload: ScreenshotTakeFileResponse,
7981    ) -> Result<(), fidl::Error> {
7982        let _result = self.send_raw(payload);
7983        self.drop_without_shutdown();
7984        _result
7985    }
7986
7987    fn send_raw(&self, mut payload: ScreenshotTakeFileResponse) -> Result<(), fidl::Error> {
7988        self.control_handle.inner.send::<ScreenshotTakeFileResponse>(
7989            &mut payload,
7990            self.tx_id,
7991            0x470aeea0a4d32903,
7992            fidl::encoding::DynamicFlags::empty(),
7993        )
7994    }
7995}
7996
7997mod internal {
7998    use super::*;
7999
8000    impl fidl::encoding::ResourceTypeMarker for AllocatorRegisterBufferCollectionRequest {
8001        type Borrowed<'a> = &'a mut Self;
8002        fn take_or_borrow<'a>(
8003            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8004        ) -> Self::Borrowed<'a> {
8005            value
8006        }
8007    }
8008
8009    unsafe impl fidl::encoding::TypeMarker for AllocatorRegisterBufferCollectionRequest {
8010        type Owned = Self;
8011
8012        #[inline(always)]
8013        fn inline_align(_context: fidl::encoding::Context) -> usize {
8014            8
8015        }
8016
8017        #[inline(always)]
8018        fn inline_size(_context: fidl::encoding::Context) -> usize {
8019            16
8020        }
8021    }
8022
8023    unsafe impl
8024        fidl::encoding::Encode<
8025            AllocatorRegisterBufferCollectionRequest,
8026            fidl::encoding::DefaultFuchsiaResourceDialect,
8027        > for &mut AllocatorRegisterBufferCollectionRequest
8028    {
8029        #[inline]
8030        unsafe fn encode(
8031            self,
8032            encoder: &mut fidl::encoding::Encoder<
8033                '_,
8034                fidl::encoding::DefaultFuchsiaResourceDialect,
8035            >,
8036            offset: usize,
8037            _depth: fidl::encoding::Depth,
8038        ) -> fidl::Result<()> {
8039            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
8040            // Delegate to tuple encoding.
8041            fidl::encoding::Encode::<AllocatorRegisterBufferCollectionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8042                (
8043                    <RegisterBufferCollectionArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.args),
8044                ),
8045                encoder, offset, _depth
8046            )
8047        }
8048    }
8049    unsafe impl<
8050            T0: fidl::encoding::Encode<
8051                RegisterBufferCollectionArgs,
8052                fidl::encoding::DefaultFuchsiaResourceDialect,
8053            >,
8054        >
8055        fidl::encoding::Encode<
8056            AllocatorRegisterBufferCollectionRequest,
8057            fidl::encoding::DefaultFuchsiaResourceDialect,
8058        > for (T0,)
8059    {
8060        #[inline]
8061        unsafe fn encode(
8062            self,
8063            encoder: &mut fidl::encoding::Encoder<
8064                '_,
8065                fidl::encoding::DefaultFuchsiaResourceDialect,
8066            >,
8067            offset: usize,
8068            depth: fidl::encoding::Depth,
8069        ) -> fidl::Result<()> {
8070            encoder.debug_check_bounds::<AllocatorRegisterBufferCollectionRequest>(offset);
8071            // Zero out padding regions. There's no need to apply masks
8072            // because the unmasked parts will be overwritten by fields.
8073            // Write the fields.
8074            self.0.encode(encoder, offset + 0, depth)?;
8075            Ok(())
8076        }
8077    }
8078
8079    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8080        for AllocatorRegisterBufferCollectionRequest
8081    {
8082        #[inline(always)]
8083        fn new_empty() -> Self {
8084            Self {
8085                args: fidl::new_empty!(
8086                    RegisterBufferCollectionArgs,
8087                    fidl::encoding::DefaultFuchsiaResourceDialect
8088                ),
8089            }
8090        }
8091
8092        #[inline]
8093        unsafe fn decode(
8094            &mut self,
8095            decoder: &mut fidl::encoding::Decoder<
8096                '_,
8097                fidl::encoding::DefaultFuchsiaResourceDialect,
8098            >,
8099            offset: usize,
8100            _depth: fidl::encoding::Depth,
8101        ) -> fidl::Result<()> {
8102            decoder.debug_check_bounds::<Self>(offset);
8103            // Verify that padding bytes are zero.
8104            fidl::decode!(
8105                RegisterBufferCollectionArgs,
8106                fidl::encoding::DefaultFuchsiaResourceDialect,
8107                &mut self.args,
8108                decoder,
8109                offset + 0,
8110                _depth
8111            )?;
8112            Ok(())
8113        }
8114    }
8115
8116    impl fidl::encoding::ResourceTypeMarker for BufferCollectionExportToken {
8117        type Borrowed<'a> = &'a mut Self;
8118        fn take_or_borrow<'a>(
8119            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8120        ) -> Self::Borrowed<'a> {
8121            value
8122        }
8123    }
8124
8125    unsafe impl fidl::encoding::TypeMarker for BufferCollectionExportToken {
8126        type Owned = Self;
8127
8128        #[inline(always)]
8129        fn inline_align(_context: fidl::encoding::Context) -> usize {
8130            4
8131        }
8132
8133        #[inline(always)]
8134        fn inline_size(_context: fidl::encoding::Context) -> usize {
8135            4
8136        }
8137    }
8138
8139    unsafe impl
8140        fidl::encoding::Encode<
8141            BufferCollectionExportToken,
8142            fidl::encoding::DefaultFuchsiaResourceDialect,
8143        > for &mut BufferCollectionExportToken
8144    {
8145        #[inline]
8146        unsafe fn encode(
8147            self,
8148            encoder: &mut fidl::encoding::Encoder<
8149                '_,
8150                fidl::encoding::DefaultFuchsiaResourceDialect,
8151            >,
8152            offset: usize,
8153            _depth: fidl::encoding::Depth,
8154        ) -> fidl::Result<()> {
8155            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
8156            // Delegate to tuple encoding.
8157            fidl::encoding::Encode::<
8158                BufferCollectionExportToken,
8159                fidl::encoding::DefaultFuchsiaResourceDialect,
8160            >::encode(
8161                (<fidl::encoding::HandleType<
8162                    fidl::EventPair,
8163                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8164                    2147483648,
8165                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8166                    &mut self.value
8167                ),),
8168                encoder,
8169                offset,
8170                _depth,
8171            )
8172        }
8173    }
8174    unsafe impl<
8175            T0: fidl::encoding::Encode<
8176                fidl::encoding::HandleType<
8177                    fidl::EventPair,
8178                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8179                    2147483648,
8180                >,
8181                fidl::encoding::DefaultFuchsiaResourceDialect,
8182            >,
8183        >
8184        fidl::encoding::Encode<
8185            BufferCollectionExportToken,
8186            fidl::encoding::DefaultFuchsiaResourceDialect,
8187        > for (T0,)
8188    {
8189        #[inline]
8190        unsafe fn encode(
8191            self,
8192            encoder: &mut fidl::encoding::Encoder<
8193                '_,
8194                fidl::encoding::DefaultFuchsiaResourceDialect,
8195            >,
8196            offset: usize,
8197            depth: fidl::encoding::Depth,
8198        ) -> fidl::Result<()> {
8199            encoder.debug_check_bounds::<BufferCollectionExportToken>(offset);
8200            // Zero out padding regions. There's no need to apply masks
8201            // because the unmasked parts will be overwritten by fields.
8202            // Write the fields.
8203            self.0.encode(encoder, offset + 0, depth)?;
8204            Ok(())
8205        }
8206    }
8207
8208    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8209        for BufferCollectionExportToken
8210    {
8211        #[inline(always)]
8212        fn new_empty() -> Self {
8213            Self {
8214                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8215            }
8216        }
8217
8218        #[inline]
8219        unsafe fn decode(
8220            &mut self,
8221            decoder: &mut fidl::encoding::Decoder<
8222                '_,
8223                fidl::encoding::DefaultFuchsiaResourceDialect,
8224            >,
8225            offset: usize,
8226            _depth: fidl::encoding::Depth,
8227        ) -> fidl::Result<()> {
8228            decoder.debug_check_bounds::<Self>(offset);
8229            // Verify that padding bytes are zero.
8230            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
8231            Ok(())
8232        }
8233    }
8234
8235    impl fidl::encoding::ResourceTypeMarker for BufferCollectionImportToken {
8236        type Borrowed<'a> = &'a mut Self;
8237        fn take_or_borrow<'a>(
8238            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8239        ) -> Self::Borrowed<'a> {
8240            value
8241        }
8242    }
8243
8244    unsafe impl fidl::encoding::TypeMarker for BufferCollectionImportToken {
8245        type Owned = Self;
8246
8247        #[inline(always)]
8248        fn inline_align(_context: fidl::encoding::Context) -> usize {
8249            4
8250        }
8251
8252        #[inline(always)]
8253        fn inline_size(_context: fidl::encoding::Context) -> usize {
8254            4
8255        }
8256    }
8257
8258    unsafe impl
8259        fidl::encoding::Encode<
8260            BufferCollectionImportToken,
8261            fidl::encoding::DefaultFuchsiaResourceDialect,
8262        > for &mut BufferCollectionImportToken
8263    {
8264        #[inline]
8265        unsafe fn encode(
8266            self,
8267            encoder: &mut fidl::encoding::Encoder<
8268                '_,
8269                fidl::encoding::DefaultFuchsiaResourceDialect,
8270            >,
8271            offset: usize,
8272            _depth: fidl::encoding::Depth,
8273        ) -> fidl::Result<()> {
8274            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
8275            // Delegate to tuple encoding.
8276            fidl::encoding::Encode::<
8277                BufferCollectionImportToken,
8278                fidl::encoding::DefaultFuchsiaResourceDialect,
8279            >::encode(
8280                (<fidl::encoding::HandleType<
8281                    fidl::EventPair,
8282                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8283                    2147483648,
8284                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
8285                    &mut self.value
8286                ),),
8287                encoder,
8288                offset,
8289                _depth,
8290            )
8291        }
8292    }
8293    unsafe impl<
8294            T0: fidl::encoding::Encode<
8295                fidl::encoding::HandleType<
8296                    fidl::EventPair,
8297                    { fidl::ObjectType::EVENTPAIR.into_raw() },
8298                    2147483648,
8299                >,
8300                fidl::encoding::DefaultFuchsiaResourceDialect,
8301            >,
8302        >
8303        fidl::encoding::Encode<
8304            BufferCollectionImportToken,
8305            fidl::encoding::DefaultFuchsiaResourceDialect,
8306        > for (T0,)
8307    {
8308        #[inline]
8309        unsafe fn encode(
8310            self,
8311            encoder: &mut fidl::encoding::Encoder<
8312                '_,
8313                fidl::encoding::DefaultFuchsiaResourceDialect,
8314            >,
8315            offset: usize,
8316            depth: fidl::encoding::Depth,
8317        ) -> fidl::Result<()> {
8318            encoder.debug_check_bounds::<BufferCollectionImportToken>(offset);
8319            // Zero out padding regions. There's no need to apply masks
8320            // because the unmasked parts will be overwritten by fields.
8321            // Write the fields.
8322            self.0.encode(encoder, offset + 0, depth)?;
8323            Ok(())
8324        }
8325    }
8326
8327    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8328        for BufferCollectionImportToken
8329    {
8330        #[inline(always)]
8331        fn new_empty() -> Self {
8332            Self {
8333                value: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
8334            }
8335        }
8336
8337        #[inline]
8338        unsafe fn decode(
8339            &mut self,
8340            decoder: &mut fidl::encoding::Decoder<
8341                '_,
8342                fidl::encoding::DefaultFuchsiaResourceDialect,
8343            >,
8344            offset: usize,
8345            _depth: fidl::encoding::Depth,
8346        ) -> fidl::Result<()> {
8347            decoder.debug_check_bounds::<Self>(offset);
8348            // Verify that padding bytes are zero.
8349            fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.value, decoder, offset + 0, _depth)?;
8350            Ok(())
8351        }
8352    }
8353
8354    impl fidl::encoding::ResourceTypeMarker for ChildViewWatcherGetViewRefResponse {
8355        type Borrowed<'a> = &'a mut Self;
8356        fn take_or_borrow<'a>(
8357            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8358        ) -> Self::Borrowed<'a> {
8359            value
8360        }
8361    }
8362
8363    unsafe impl fidl::encoding::TypeMarker for ChildViewWatcherGetViewRefResponse {
8364        type Owned = Self;
8365
8366        #[inline(always)]
8367        fn inline_align(_context: fidl::encoding::Context) -> usize {
8368            4
8369        }
8370
8371        #[inline(always)]
8372        fn inline_size(_context: fidl::encoding::Context) -> usize {
8373            4
8374        }
8375    }
8376
8377    unsafe impl
8378        fidl::encoding::Encode<
8379            ChildViewWatcherGetViewRefResponse,
8380            fidl::encoding::DefaultFuchsiaResourceDialect,
8381        > for &mut ChildViewWatcherGetViewRefResponse
8382    {
8383        #[inline]
8384        unsafe fn encode(
8385            self,
8386            encoder: &mut fidl::encoding::Encoder<
8387                '_,
8388                fidl::encoding::DefaultFuchsiaResourceDialect,
8389            >,
8390            offset: usize,
8391            _depth: fidl::encoding::Depth,
8392        ) -> fidl::Result<()> {
8393            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
8394            // Delegate to tuple encoding.
8395            fidl::encoding::Encode::<ChildViewWatcherGetViewRefResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8396                (
8397                    <fidl_fuchsia_ui_views::ViewRef as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_ref),
8398                ),
8399                encoder, offset, _depth
8400            )
8401        }
8402    }
8403    unsafe impl<
8404            T0: fidl::encoding::Encode<
8405                fidl_fuchsia_ui_views::ViewRef,
8406                fidl::encoding::DefaultFuchsiaResourceDialect,
8407            >,
8408        >
8409        fidl::encoding::Encode<
8410            ChildViewWatcherGetViewRefResponse,
8411            fidl::encoding::DefaultFuchsiaResourceDialect,
8412        > for (T0,)
8413    {
8414        #[inline]
8415        unsafe fn encode(
8416            self,
8417            encoder: &mut fidl::encoding::Encoder<
8418                '_,
8419                fidl::encoding::DefaultFuchsiaResourceDialect,
8420            >,
8421            offset: usize,
8422            depth: fidl::encoding::Depth,
8423        ) -> fidl::Result<()> {
8424            encoder.debug_check_bounds::<ChildViewWatcherGetViewRefResponse>(offset);
8425            // Zero out padding regions. There's no need to apply masks
8426            // because the unmasked parts will be overwritten by fields.
8427            // Write the fields.
8428            self.0.encode(encoder, offset + 0, depth)?;
8429            Ok(())
8430        }
8431    }
8432
8433    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8434        for ChildViewWatcherGetViewRefResponse
8435    {
8436        #[inline(always)]
8437        fn new_empty() -> Self {
8438            Self {
8439                view_ref: fidl::new_empty!(
8440                    fidl_fuchsia_ui_views::ViewRef,
8441                    fidl::encoding::DefaultFuchsiaResourceDialect
8442                ),
8443            }
8444        }
8445
8446        #[inline]
8447        unsafe fn decode(
8448            &mut self,
8449            decoder: &mut fidl::encoding::Decoder<
8450                '_,
8451                fidl::encoding::DefaultFuchsiaResourceDialect,
8452            >,
8453            offset: usize,
8454            _depth: fidl::encoding::Depth,
8455        ) -> fidl::Result<()> {
8456            decoder.debug_check_bounds::<Self>(offset);
8457            // Verify that padding bytes are zero.
8458            fidl::decode!(
8459                fidl_fuchsia_ui_views::ViewRef,
8460                fidl::encoding::DefaultFuchsiaResourceDialect,
8461                &mut self.view_ref,
8462                decoder,
8463                offset + 0,
8464                _depth
8465            )?;
8466            Ok(())
8467        }
8468    }
8469
8470    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateFilledRectRequest {
8471        type Borrowed<'a> = &'a mut Self;
8472        fn take_or_borrow<'a>(
8473            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8474        ) -> Self::Borrowed<'a> {
8475            value
8476        }
8477    }
8478
8479    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateFilledRectRequest {
8480        type Owned = Self;
8481
8482        #[inline(always)]
8483        fn inline_align(_context: fidl::encoding::Context) -> usize {
8484            8
8485        }
8486
8487        #[inline(always)]
8488        fn inline_size(_context: fidl::encoding::Context) -> usize {
8489            8
8490        }
8491        #[inline(always)]
8492        fn encode_is_copy() -> bool {
8493            true
8494        }
8495
8496        #[inline(always)]
8497        fn decode_is_copy() -> bool {
8498            true
8499        }
8500    }
8501
8502    unsafe impl
8503        fidl::encoding::Encode<
8504            FlatlandCreateFilledRectRequest,
8505            fidl::encoding::DefaultFuchsiaResourceDialect,
8506        > for &mut FlatlandCreateFilledRectRequest
8507    {
8508        #[inline]
8509        unsafe fn encode(
8510            self,
8511            encoder: &mut fidl::encoding::Encoder<
8512                '_,
8513                fidl::encoding::DefaultFuchsiaResourceDialect,
8514            >,
8515            offset: usize,
8516            _depth: fidl::encoding::Depth,
8517        ) -> fidl::Result<()> {
8518            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
8519            unsafe {
8520                // Copy the object into the buffer.
8521                let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
8522                (buf_ptr as *mut FlatlandCreateFilledRectRequest)
8523                    .write_unaligned((self as *const FlatlandCreateFilledRectRequest).read());
8524                // Zero out padding regions. Unlike `fidl_struct_impl_noncopy!`, this must be
8525                // done second because the memcpy will write garbage to these bytes.
8526            }
8527            Ok(())
8528        }
8529    }
8530    unsafe impl<T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>>
8531        fidl::encoding::Encode<
8532            FlatlandCreateFilledRectRequest,
8533            fidl::encoding::DefaultFuchsiaResourceDialect,
8534        > for (T0,)
8535    {
8536        #[inline]
8537        unsafe fn encode(
8538            self,
8539            encoder: &mut fidl::encoding::Encoder<
8540                '_,
8541                fidl::encoding::DefaultFuchsiaResourceDialect,
8542            >,
8543            offset: usize,
8544            depth: fidl::encoding::Depth,
8545        ) -> fidl::Result<()> {
8546            encoder.debug_check_bounds::<FlatlandCreateFilledRectRequest>(offset);
8547            // Zero out padding regions. There's no need to apply masks
8548            // because the unmasked parts will be overwritten by fields.
8549            // Write the fields.
8550            self.0.encode(encoder, offset + 0, depth)?;
8551            Ok(())
8552        }
8553    }
8554
8555    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8556        for FlatlandCreateFilledRectRequest
8557    {
8558        #[inline(always)]
8559        fn new_empty() -> Self {
8560            Self {
8561                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
8562            }
8563        }
8564
8565        #[inline]
8566        unsafe fn decode(
8567            &mut self,
8568            decoder: &mut fidl::encoding::Decoder<
8569                '_,
8570                fidl::encoding::DefaultFuchsiaResourceDialect,
8571            >,
8572            offset: usize,
8573            _depth: fidl::encoding::Depth,
8574        ) -> fidl::Result<()> {
8575            decoder.debug_check_bounds::<Self>(offset);
8576            let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
8577            // Verify that padding bytes are zero.
8578            // Copy from the buffer into the object.
8579            unsafe {
8580                std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
8581            }
8582            Ok(())
8583        }
8584    }
8585
8586    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateImageRequest {
8587        type Borrowed<'a> = &'a mut Self;
8588        fn take_or_borrow<'a>(
8589            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8590        ) -> Self::Borrowed<'a> {
8591            value
8592        }
8593    }
8594
8595    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateImageRequest {
8596        type Owned = Self;
8597
8598        #[inline(always)]
8599        fn inline_align(_context: fidl::encoding::Context) -> usize {
8600            8
8601        }
8602
8603        #[inline(always)]
8604        fn inline_size(_context: fidl::encoding::Context) -> usize {
8605            32
8606        }
8607    }
8608
8609    unsafe impl
8610        fidl::encoding::Encode<
8611            FlatlandCreateImageRequest,
8612            fidl::encoding::DefaultFuchsiaResourceDialect,
8613        > for &mut FlatlandCreateImageRequest
8614    {
8615        #[inline]
8616        unsafe fn encode(
8617            self,
8618            encoder: &mut fidl::encoding::Encoder<
8619                '_,
8620                fidl::encoding::DefaultFuchsiaResourceDialect,
8621            >,
8622            offset: usize,
8623            _depth: fidl::encoding::Depth,
8624        ) -> fidl::Result<()> {
8625            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
8626            // Delegate to tuple encoding.
8627            fidl::encoding::Encode::<FlatlandCreateImageRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8628                (
8629                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.image_id),
8630                    <BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.import_token),
8631                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.vmo_index),
8632                    <ImageProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
8633                ),
8634                encoder, offset, _depth
8635            )
8636        }
8637    }
8638    unsafe impl<
8639            T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
8640            T1: fidl::encoding::Encode<
8641                BufferCollectionImportToken,
8642                fidl::encoding::DefaultFuchsiaResourceDialect,
8643            >,
8644            T2: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
8645            T3: fidl::encoding::Encode<ImageProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
8646        >
8647        fidl::encoding::Encode<
8648            FlatlandCreateImageRequest,
8649            fidl::encoding::DefaultFuchsiaResourceDialect,
8650        > for (T0, T1, T2, T3)
8651    {
8652        #[inline]
8653        unsafe fn encode(
8654            self,
8655            encoder: &mut fidl::encoding::Encoder<
8656                '_,
8657                fidl::encoding::DefaultFuchsiaResourceDialect,
8658            >,
8659            offset: usize,
8660            depth: fidl::encoding::Depth,
8661        ) -> fidl::Result<()> {
8662            encoder.debug_check_bounds::<FlatlandCreateImageRequest>(offset);
8663            // Zero out padding regions. There's no need to apply masks
8664            // because the unmasked parts will be overwritten by fields.
8665            // Write the fields.
8666            self.0.encode(encoder, offset + 0, depth)?;
8667            self.1.encode(encoder, offset + 8, depth)?;
8668            self.2.encode(encoder, offset + 12, depth)?;
8669            self.3.encode(encoder, offset + 16, depth)?;
8670            Ok(())
8671        }
8672    }
8673
8674    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8675        for FlatlandCreateImageRequest
8676    {
8677        #[inline(always)]
8678        fn new_empty() -> Self {
8679            Self {
8680                image_id: fidl::new_empty!(
8681                    ContentId,
8682                    fidl::encoding::DefaultFuchsiaResourceDialect
8683                ),
8684                import_token: fidl::new_empty!(
8685                    BufferCollectionImportToken,
8686                    fidl::encoding::DefaultFuchsiaResourceDialect
8687                ),
8688                vmo_index: fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect),
8689                properties: fidl::new_empty!(
8690                    ImageProperties,
8691                    fidl::encoding::DefaultFuchsiaResourceDialect
8692                ),
8693            }
8694        }
8695
8696        #[inline]
8697        unsafe fn decode(
8698            &mut self,
8699            decoder: &mut fidl::encoding::Decoder<
8700                '_,
8701                fidl::encoding::DefaultFuchsiaResourceDialect,
8702            >,
8703            offset: usize,
8704            _depth: fidl::encoding::Depth,
8705        ) -> fidl::Result<()> {
8706            decoder.debug_check_bounds::<Self>(offset);
8707            // Verify that padding bytes are zero.
8708            fidl::decode!(
8709                ContentId,
8710                fidl::encoding::DefaultFuchsiaResourceDialect,
8711                &mut self.image_id,
8712                decoder,
8713                offset + 0,
8714                _depth
8715            )?;
8716            fidl::decode!(
8717                BufferCollectionImportToken,
8718                fidl::encoding::DefaultFuchsiaResourceDialect,
8719                &mut self.import_token,
8720                decoder,
8721                offset + 8,
8722                _depth
8723            )?;
8724            fidl::decode!(
8725                u32,
8726                fidl::encoding::DefaultFuchsiaResourceDialect,
8727                &mut self.vmo_index,
8728                decoder,
8729                offset + 12,
8730                _depth
8731            )?;
8732            fidl::decode!(
8733                ImageProperties,
8734                fidl::encoding::DefaultFuchsiaResourceDialect,
8735                &mut self.properties,
8736                decoder,
8737                offset + 16,
8738                _depth
8739            )?;
8740            Ok(())
8741        }
8742    }
8743
8744    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateView2Request {
8745        type Borrowed<'a> = &'a mut Self;
8746        fn take_or_borrow<'a>(
8747            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8748        ) -> Self::Borrowed<'a> {
8749            value
8750        }
8751    }
8752
8753    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateView2Request {
8754        type Owned = Self;
8755
8756        #[inline(always)]
8757        fn inline_align(_context: fidl::encoding::Context) -> usize {
8758            8
8759        }
8760
8761        #[inline(always)]
8762        fn inline_size(_context: fidl::encoding::Context) -> usize {
8763            40
8764        }
8765    }
8766
8767    unsafe impl
8768        fidl::encoding::Encode<
8769            FlatlandCreateView2Request,
8770            fidl::encoding::DefaultFuchsiaResourceDialect,
8771        > for &mut FlatlandCreateView2Request
8772    {
8773        #[inline]
8774        unsafe fn encode(
8775            self,
8776            encoder: &mut fidl::encoding::Encoder<
8777                '_,
8778                fidl::encoding::DefaultFuchsiaResourceDialect,
8779            >,
8780            offset: usize,
8781            _depth: fidl::encoding::Depth,
8782        ) -> fidl::Result<()> {
8783            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
8784            // Delegate to tuple encoding.
8785            fidl::encoding::Encode::<FlatlandCreateView2Request, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8786                (
8787                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
8788                    <fidl_fuchsia_ui_views::ViewIdentityOnCreation as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.view_identity),
8789                    <ViewBoundProtocols as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.protocols),
8790                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
8791                ),
8792                encoder, offset, _depth
8793            )
8794        }
8795    }
8796    unsafe impl<
8797            T0: fidl::encoding::Encode<
8798                fidl_fuchsia_ui_views::ViewCreationToken,
8799                fidl::encoding::DefaultFuchsiaResourceDialect,
8800            >,
8801            T1: fidl::encoding::Encode<
8802                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
8803                fidl::encoding::DefaultFuchsiaResourceDialect,
8804            >,
8805            T2: fidl::encoding::Encode<
8806                ViewBoundProtocols,
8807                fidl::encoding::DefaultFuchsiaResourceDialect,
8808            >,
8809            T3: fidl::encoding::Encode<
8810                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
8811                fidl::encoding::DefaultFuchsiaResourceDialect,
8812            >,
8813        >
8814        fidl::encoding::Encode<
8815            FlatlandCreateView2Request,
8816            fidl::encoding::DefaultFuchsiaResourceDialect,
8817        > for (T0, T1, T2, T3)
8818    {
8819        #[inline]
8820        unsafe fn encode(
8821            self,
8822            encoder: &mut fidl::encoding::Encoder<
8823                '_,
8824                fidl::encoding::DefaultFuchsiaResourceDialect,
8825            >,
8826            offset: usize,
8827            depth: fidl::encoding::Depth,
8828        ) -> fidl::Result<()> {
8829            encoder.debug_check_bounds::<FlatlandCreateView2Request>(offset);
8830            // Zero out padding regions. There's no need to apply masks
8831            // because the unmasked parts will be overwritten by fields.
8832            unsafe {
8833                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
8834                (ptr as *mut u64).write_unaligned(0);
8835            }
8836            unsafe {
8837                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
8838                (ptr as *mut u64).write_unaligned(0);
8839            }
8840            // Write the fields.
8841            self.0.encode(encoder, offset + 0, depth)?;
8842            self.1.encode(encoder, offset + 4, depth)?;
8843            self.2.encode(encoder, offset + 16, depth)?;
8844            self.3.encode(encoder, offset + 32, depth)?;
8845            Ok(())
8846        }
8847    }
8848
8849    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
8850        for FlatlandCreateView2Request
8851    {
8852        #[inline(always)]
8853        fn new_empty() -> Self {
8854            Self {
8855                token: fidl::new_empty!(
8856                    fidl_fuchsia_ui_views::ViewCreationToken,
8857                    fidl::encoding::DefaultFuchsiaResourceDialect
8858                ),
8859                view_identity: fidl::new_empty!(
8860                    fidl_fuchsia_ui_views::ViewIdentityOnCreation,
8861                    fidl::encoding::DefaultFuchsiaResourceDialect
8862                ),
8863                protocols: fidl::new_empty!(
8864                    ViewBoundProtocols,
8865                    fidl::encoding::DefaultFuchsiaResourceDialect
8866                ),
8867                parent_viewport_watcher: fidl::new_empty!(
8868                    fidl::encoding::Endpoint<
8869                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
8870                    >,
8871                    fidl::encoding::DefaultFuchsiaResourceDialect
8872                ),
8873            }
8874        }
8875
8876        #[inline]
8877        unsafe fn decode(
8878            &mut self,
8879            decoder: &mut fidl::encoding::Decoder<
8880                '_,
8881                fidl::encoding::DefaultFuchsiaResourceDialect,
8882            >,
8883            offset: usize,
8884            _depth: fidl::encoding::Depth,
8885        ) -> fidl::Result<()> {
8886            decoder.debug_check_bounds::<Self>(offset);
8887            // Verify that padding bytes are zero.
8888            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
8889            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8890            let mask = 0xffffffff00000000u64;
8891            let maskedval = padval & mask;
8892            if maskedval != 0 {
8893                return Err(fidl::Error::NonZeroPadding {
8894                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
8895                });
8896            }
8897            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
8898            let padval = unsafe { (ptr as *const u64).read_unaligned() };
8899            let mask = 0xffffffff00000000u64;
8900            let maskedval = padval & mask;
8901            if maskedval != 0 {
8902                return Err(fidl::Error::NonZeroPadding {
8903                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
8904                });
8905            }
8906            fidl::decode!(
8907                fidl_fuchsia_ui_views::ViewCreationToken,
8908                fidl::encoding::DefaultFuchsiaResourceDialect,
8909                &mut self.token,
8910                decoder,
8911                offset + 0,
8912                _depth
8913            )?;
8914            fidl::decode!(
8915                fidl_fuchsia_ui_views::ViewIdentityOnCreation,
8916                fidl::encoding::DefaultFuchsiaResourceDialect,
8917                &mut self.view_identity,
8918                decoder,
8919                offset + 4,
8920                _depth
8921            )?;
8922            fidl::decode!(
8923                ViewBoundProtocols,
8924                fidl::encoding::DefaultFuchsiaResourceDialect,
8925                &mut self.protocols,
8926                decoder,
8927                offset + 16,
8928                _depth
8929            )?;
8930            fidl::decode!(
8931                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
8932                fidl::encoding::DefaultFuchsiaResourceDialect,
8933                &mut self.parent_viewport_watcher,
8934                decoder,
8935                offset + 32,
8936                _depth
8937            )?;
8938            Ok(())
8939        }
8940    }
8941
8942    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewRequest {
8943        type Borrowed<'a> = &'a mut Self;
8944        fn take_or_borrow<'a>(
8945            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
8946        ) -> Self::Borrowed<'a> {
8947            value
8948        }
8949    }
8950
8951    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewRequest {
8952        type Owned = Self;
8953
8954        #[inline(always)]
8955        fn inline_align(_context: fidl::encoding::Context) -> usize {
8956            4
8957        }
8958
8959        #[inline(always)]
8960        fn inline_size(_context: fidl::encoding::Context) -> usize {
8961            8
8962        }
8963    }
8964
8965    unsafe impl
8966        fidl::encoding::Encode<
8967            FlatlandCreateViewRequest,
8968            fidl::encoding::DefaultFuchsiaResourceDialect,
8969        > for &mut FlatlandCreateViewRequest
8970    {
8971        #[inline]
8972        unsafe fn encode(
8973            self,
8974            encoder: &mut fidl::encoding::Encoder<
8975                '_,
8976                fidl::encoding::DefaultFuchsiaResourceDialect,
8977            >,
8978            offset: usize,
8979            _depth: fidl::encoding::Depth,
8980        ) -> fidl::Result<()> {
8981            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
8982            // Delegate to tuple encoding.
8983            fidl::encoding::Encode::<FlatlandCreateViewRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
8984                (
8985                    <fidl_fuchsia_ui_views::ViewCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
8986                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.parent_viewport_watcher),
8987                ),
8988                encoder, offset, _depth
8989            )
8990        }
8991    }
8992    unsafe impl<
8993            T0: fidl::encoding::Encode<
8994                fidl_fuchsia_ui_views::ViewCreationToken,
8995                fidl::encoding::DefaultFuchsiaResourceDialect,
8996            >,
8997            T1: fidl::encoding::Encode<
8998                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
8999                fidl::encoding::DefaultFuchsiaResourceDialect,
9000            >,
9001        >
9002        fidl::encoding::Encode<
9003            FlatlandCreateViewRequest,
9004            fidl::encoding::DefaultFuchsiaResourceDialect,
9005        > for (T0, T1)
9006    {
9007        #[inline]
9008        unsafe fn encode(
9009            self,
9010            encoder: &mut fidl::encoding::Encoder<
9011                '_,
9012                fidl::encoding::DefaultFuchsiaResourceDialect,
9013            >,
9014            offset: usize,
9015            depth: fidl::encoding::Depth,
9016        ) -> fidl::Result<()> {
9017            encoder.debug_check_bounds::<FlatlandCreateViewRequest>(offset);
9018            // Zero out padding regions. There's no need to apply masks
9019            // because the unmasked parts will be overwritten by fields.
9020            // Write the fields.
9021            self.0.encode(encoder, offset + 0, depth)?;
9022            self.1.encode(encoder, offset + 4, depth)?;
9023            Ok(())
9024        }
9025    }
9026
9027    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9028        for FlatlandCreateViewRequest
9029    {
9030        #[inline(always)]
9031        fn new_empty() -> Self {
9032            Self {
9033                token: fidl::new_empty!(
9034                    fidl_fuchsia_ui_views::ViewCreationToken,
9035                    fidl::encoding::DefaultFuchsiaResourceDialect
9036                ),
9037                parent_viewport_watcher: fidl::new_empty!(
9038                    fidl::encoding::Endpoint<
9039                        fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>,
9040                    >,
9041                    fidl::encoding::DefaultFuchsiaResourceDialect
9042                ),
9043            }
9044        }
9045
9046        #[inline]
9047        unsafe fn decode(
9048            &mut self,
9049            decoder: &mut fidl::encoding::Decoder<
9050                '_,
9051                fidl::encoding::DefaultFuchsiaResourceDialect,
9052            >,
9053            offset: usize,
9054            _depth: fidl::encoding::Depth,
9055        ) -> fidl::Result<()> {
9056            decoder.debug_check_bounds::<Self>(offset);
9057            // Verify that padding bytes are zero.
9058            fidl::decode!(
9059                fidl_fuchsia_ui_views::ViewCreationToken,
9060                fidl::encoding::DefaultFuchsiaResourceDialect,
9061                &mut self.token,
9062                decoder,
9063                offset + 0,
9064                _depth
9065            )?;
9066            fidl::decode!(
9067                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ParentViewportWatcherMarker>>,
9068                fidl::encoding::DefaultFuchsiaResourceDialect,
9069                &mut self.parent_viewport_watcher,
9070                decoder,
9071                offset + 4,
9072                _depth
9073            )?;
9074            Ok(())
9075        }
9076    }
9077
9078    impl fidl::encoding::ResourceTypeMarker for FlatlandCreateViewportRequest {
9079        type Borrowed<'a> = &'a mut Self;
9080        fn take_or_borrow<'a>(
9081            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9082        ) -> Self::Borrowed<'a> {
9083            value
9084        }
9085    }
9086
9087    unsafe impl fidl::encoding::TypeMarker for FlatlandCreateViewportRequest {
9088        type Owned = Self;
9089
9090        #[inline(always)]
9091        fn inline_align(_context: fidl::encoding::Context) -> usize {
9092            8
9093        }
9094
9095        #[inline(always)]
9096        fn inline_size(_context: fidl::encoding::Context) -> usize {
9097            40
9098        }
9099    }
9100
9101    unsafe impl
9102        fidl::encoding::Encode<
9103            FlatlandCreateViewportRequest,
9104            fidl::encoding::DefaultFuchsiaResourceDialect,
9105        > for &mut FlatlandCreateViewportRequest
9106    {
9107        #[inline]
9108        unsafe fn encode(
9109            self,
9110            encoder: &mut fidl::encoding::Encoder<
9111                '_,
9112                fidl::encoding::DefaultFuchsiaResourceDialect,
9113            >,
9114            offset: usize,
9115            _depth: fidl::encoding::Depth,
9116        ) -> fidl::Result<()> {
9117            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
9118            // Delegate to tuple encoding.
9119            fidl::encoding::Encode::<FlatlandCreateViewportRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9120                (
9121                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.viewport_id),
9122                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
9123                    <ViewportProperties as fidl::encoding::ValueTypeMarker>::borrow(&self.properties),
9124                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
9125                ),
9126                encoder, offset, _depth
9127            )
9128        }
9129    }
9130    unsafe impl<
9131            T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9132            T1: fidl::encoding::Encode<
9133                fidl_fuchsia_ui_views::ViewportCreationToken,
9134                fidl::encoding::DefaultFuchsiaResourceDialect,
9135            >,
9136            T2: fidl::encoding::Encode<
9137                ViewportProperties,
9138                fidl::encoding::DefaultFuchsiaResourceDialect,
9139            >,
9140            T3: fidl::encoding::Encode<
9141                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9142                fidl::encoding::DefaultFuchsiaResourceDialect,
9143            >,
9144        >
9145        fidl::encoding::Encode<
9146            FlatlandCreateViewportRequest,
9147            fidl::encoding::DefaultFuchsiaResourceDialect,
9148        > for (T0, T1, T2, T3)
9149    {
9150        #[inline]
9151        unsafe fn encode(
9152            self,
9153            encoder: &mut fidl::encoding::Encoder<
9154                '_,
9155                fidl::encoding::DefaultFuchsiaResourceDialect,
9156            >,
9157            offset: usize,
9158            depth: fidl::encoding::Depth,
9159        ) -> fidl::Result<()> {
9160            encoder.debug_check_bounds::<FlatlandCreateViewportRequest>(offset);
9161            // Zero out padding regions. There's no need to apply masks
9162            // because the unmasked parts will be overwritten by fields.
9163            unsafe {
9164                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
9165                (ptr as *mut u64).write_unaligned(0);
9166            }
9167            unsafe {
9168                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
9169                (ptr as *mut u64).write_unaligned(0);
9170            }
9171            // Write the fields.
9172            self.0.encode(encoder, offset + 0, depth)?;
9173            self.1.encode(encoder, offset + 8, depth)?;
9174            self.2.encode(encoder, offset + 16, depth)?;
9175            self.3.encode(encoder, offset + 32, depth)?;
9176            Ok(())
9177        }
9178    }
9179
9180    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9181        for FlatlandCreateViewportRequest
9182    {
9183        #[inline(always)]
9184        fn new_empty() -> Self {
9185            Self {
9186                viewport_id: fidl::new_empty!(
9187                    ContentId,
9188                    fidl::encoding::DefaultFuchsiaResourceDialect
9189                ),
9190                token: fidl::new_empty!(
9191                    fidl_fuchsia_ui_views::ViewportCreationToken,
9192                    fidl::encoding::DefaultFuchsiaResourceDialect
9193                ),
9194                properties: fidl::new_empty!(
9195                    ViewportProperties,
9196                    fidl::encoding::DefaultFuchsiaResourceDialect
9197                ),
9198                child_view_watcher: fidl::new_empty!(
9199                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9200                    fidl::encoding::DefaultFuchsiaResourceDialect
9201                ),
9202            }
9203        }
9204
9205        #[inline]
9206        unsafe fn decode(
9207            &mut self,
9208            decoder: &mut fidl::encoding::Decoder<
9209                '_,
9210                fidl::encoding::DefaultFuchsiaResourceDialect,
9211            >,
9212            offset: usize,
9213            _depth: fidl::encoding::Depth,
9214        ) -> fidl::Result<()> {
9215            decoder.debug_check_bounds::<Self>(offset);
9216            // Verify that padding bytes are zero.
9217            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
9218            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9219            let mask = 0xffffffff00000000u64;
9220            let maskedval = padval & mask;
9221            if maskedval != 0 {
9222                return Err(fidl::Error::NonZeroPadding {
9223                    padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
9224                });
9225            }
9226            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
9227            let padval = unsafe { (ptr as *const u64).read_unaligned() };
9228            let mask = 0xffffffff00000000u64;
9229            let maskedval = padval & mask;
9230            if maskedval != 0 {
9231                return Err(fidl::Error::NonZeroPadding {
9232                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
9233                });
9234            }
9235            fidl::decode!(
9236                ContentId,
9237                fidl::encoding::DefaultFuchsiaResourceDialect,
9238                &mut self.viewport_id,
9239                decoder,
9240                offset + 0,
9241                _depth
9242            )?;
9243            fidl::decode!(
9244                fidl_fuchsia_ui_views::ViewportCreationToken,
9245                fidl::encoding::DefaultFuchsiaResourceDialect,
9246                &mut self.token,
9247                decoder,
9248                offset + 8,
9249                _depth
9250            )?;
9251            fidl::decode!(
9252                ViewportProperties,
9253                fidl::encoding::DefaultFuchsiaResourceDialect,
9254                &mut self.properties,
9255                decoder,
9256                offset + 16,
9257                _depth
9258            )?;
9259            fidl::decode!(
9260                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9261                fidl::encoding::DefaultFuchsiaResourceDialect,
9262                &mut self.child_view_watcher,
9263                decoder,
9264                offset + 32,
9265                _depth
9266            )?;
9267            Ok(())
9268        }
9269    }
9270
9271    impl fidl::encoding::ResourceTypeMarker for FlatlandDisplaySetContentRequest {
9272        type Borrowed<'a> = &'a mut Self;
9273        fn take_or_borrow<'a>(
9274            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9275        ) -> Self::Borrowed<'a> {
9276            value
9277        }
9278    }
9279
9280    unsafe impl fidl::encoding::TypeMarker for FlatlandDisplaySetContentRequest {
9281        type Owned = Self;
9282
9283        #[inline(always)]
9284        fn inline_align(_context: fidl::encoding::Context) -> usize {
9285            4
9286        }
9287
9288        #[inline(always)]
9289        fn inline_size(_context: fidl::encoding::Context) -> usize {
9290            8
9291        }
9292    }
9293
9294    unsafe impl
9295        fidl::encoding::Encode<
9296            FlatlandDisplaySetContentRequest,
9297            fidl::encoding::DefaultFuchsiaResourceDialect,
9298        > for &mut FlatlandDisplaySetContentRequest
9299    {
9300        #[inline]
9301        unsafe fn encode(
9302            self,
9303            encoder: &mut fidl::encoding::Encoder<
9304                '_,
9305                fidl::encoding::DefaultFuchsiaResourceDialect,
9306            >,
9307            offset: usize,
9308            _depth: fidl::encoding::Depth,
9309        ) -> fidl::Result<()> {
9310            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
9311            // Delegate to tuple encoding.
9312            fidl::encoding::Encode::<FlatlandDisplaySetContentRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9313                (
9314                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
9315                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.child_view_watcher),
9316                ),
9317                encoder, offset, _depth
9318            )
9319        }
9320    }
9321    unsafe impl<
9322            T0: fidl::encoding::Encode<
9323                fidl_fuchsia_ui_views::ViewportCreationToken,
9324                fidl::encoding::DefaultFuchsiaResourceDialect,
9325            >,
9326            T1: fidl::encoding::Encode<
9327                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9328                fidl::encoding::DefaultFuchsiaResourceDialect,
9329            >,
9330        >
9331        fidl::encoding::Encode<
9332            FlatlandDisplaySetContentRequest,
9333            fidl::encoding::DefaultFuchsiaResourceDialect,
9334        > for (T0, T1)
9335    {
9336        #[inline]
9337        unsafe fn encode(
9338            self,
9339            encoder: &mut fidl::encoding::Encoder<
9340                '_,
9341                fidl::encoding::DefaultFuchsiaResourceDialect,
9342            >,
9343            offset: usize,
9344            depth: fidl::encoding::Depth,
9345        ) -> fidl::Result<()> {
9346            encoder.debug_check_bounds::<FlatlandDisplaySetContentRequest>(offset);
9347            // Zero out padding regions. There's no need to apply masks
9348            // because the unmasked parts will be overwritten by fields.
9349            // Write the fields.
9350            self.0.encode(encoder, offset + 0, depth)?;
9351            self.1.encode(encoder, offset + 4, depth)?;
9352            Ok(())
9353        }
9354    }
9355
9356    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9357        for FlatlandDisplaySetContentRequest
9358    {
9359        #[inline(always)]
9360        fn new_empty() -> Self {
9361            Self {
9362                token: fidl::new_empty!(
9363                    fidl_fuchsia_ui_views::ViewportCreationToken,
9364                    fidl::encoding::DefaultFuchsiaResourceDialect
9365                ),
9366                child_view_watcher: fidl::new_empty!(
9367                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9368                    fidl::encoding::DefaultFuchsiaResourceDialect
9369                ),
9370            }
9371        }
9372
9373        #[inline]
9374        unsafe fn decode(
9375            &mut self,
9376            decoder: &mut fidl::encoding::Decoder<
9377                '_,
9378                fidl::encoding::DefaultFuchsiaResourceDialect,
9379            >,
9380            offset: usize,
9381            _depth: fidl::encoding::Depth,
9382        ) -> fidl::Result<()> {
9383            decoder.debug_check_bounds::<Self>(offset);
9384            // Verify that padding bytes are zero.
9385            fidl::decode!(
9386                fidl_fuchsia_ui_views::ViewportCreationToken,
9387                fidl::encoding::DefaultFuchsiaResourceDialect,
9388                &mut self.token,
9389                decoder,
9390                offset + 0,
9391                _depth
9392            )?;
9393            fidl::decode!(
9394                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<ChildViewWatcherMarker>>,
9395                fidl::encoding::DefaultFuchsiaResourceDialect,
9396                &mut self.child_view_watcher,
9397                decoder,
9398                offset + 4,
9399                _depth
9400            )?;
9401            Ok(())
9402        }
9403    }
9404
9405    impl fidl::encoding::ResourceTypeMarker for FlatlandPresentRequest {
9406        type Borrowed<'a> = &'a mut Self;
9407        fn take_or_borrow<'a>(
9408            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9409        ) -> Self::Borrowed<'a> {
9410            value
9411        }
9412    }
9413
9414    unsafe impl fidl::encoding::TypeMarker for FlatlandPresentRequest {
9415        type Owned = Self;
9416
9417        #[inline(always)]
9418        fn inline_align(_context: fidl::encoding::Context) -> usize {
9419            8
9420        }
9421
9422        #[inline(always)]
9423        fn inline_size(_context: fidl::encoding::Context) -> usize {
9424            16
9425        }
9426    }
9427
9428    unsafe impl
9429        fidl::encoding::Encode<
9430            FlatlandPresentRequest,
9431            fidl::encoding::DefaultFuchsiaResourceDialect,
9432        > for &mut FlatlandPresentRequest
9433    {
9434        #[inline]
9435        unsafe fn encode(
9436            self,
9437            encoder: &mut fidl::encoding::Encoder<
9438                '_,
9439                fidl::encoding::DefaultFuchsiaResourceDialect,
9440            >,
9441            offset: usize,
9442            _depth: fidl::encoding::Depth,
9443        ) -> fidl::Result<()> {
9444            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
9445            // Delegate to tuple encoding.
9446            fidl::encoding::Encode::<
9447                FlatlandPresentRequest,
9448                fidl::encoding::DefaultFuchsiaResourceDialect,
9449            >::encode(
9450                (<PresentArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
9451                    &mut self.args,
9452                ),),
9453                encoder,
9454                offset,
9455                _depth,
9456            )
9457        }
9458    }
9459    unsafe impl<
9460            T0: fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>,
9461        >
9462        fidl::encoding::Encode<
9463            FlatlandPresentRequest,
9464            fidl::encoding::DefaultFuchsiaResourceDialect,
9465        > for (T0,)
9466    {
9467        #[inline]
9468        unsafe fn encode(
9469            self,
9470            encoder: &mut fidl::encoding::Encoder<
9471                '_,
9472                fidl::encoding::DefaultFuchsiaResourceDialect,
9473            >,
9474            offset: usize,
9475            depth: fidl::encoding::Depth,
9476        ) -> fidl::Result<()> {
9477            encoder.debug_check_bounds::<FlatlandPresentRequest>(offset);
9478            // Zero out padding regions. There's no need to apply masks
9479            // because the unmasked parts will be overwritten by fields.
9480            // Write the fields.
9481            self.0.encode(encoder, offset + 0, depth)?;
9482            Ok(())
9483        }
9484    }
9485
9486    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9487        for FlatlandPresentRequest
9488    {
9489        #[inline(always)]
9490        fn new_empty() -> Self {
9491            Self {
9492                args: fidl::new_empty!(PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect),
9493            }
9494        }
9495
9496        #[inline]
9497        unsafe fn decode(
9498            &mut self,
9499            decoder: &mut fidl::encoding::Decoder<
9500                '_,
9501                fidl::encoding::DefaultFuchsiaResourceDialect,
9502            >,
9503            offset: usize,
9504            _depth: fidl::encoding::Depth,
9505        ) -> fidl::Result<()> {
9506            decoder.debug_check_bounds::<Self>(offset);
9507            // Verify that padding bytes are zero.
9508            fidl::decode!(
9509                PresentArgs,
9510                fidl::encoding::DefaultFuchsiaResourceDialect,
9511                &mut self.args,
9512                decoder,
9513                offset + 0,
9514                _depth
9515            )?;
9516            Ok(())
9517        }
9518    }
9519
9520    impl fidl::encoding::ResourceTypeMarker for FlatlandReleaseViewportResponse {
9521        type Borrowed<'a> = &'a mut Self;
9522        fn take_or_borrow<'a>(
9523            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9524        ) -> Self::Borrowed<'a> {
9525            value
9526        }
9527    }
9528
9529    unsafe impl fidl::encoding::TypeMarker for FlatlandReleaseViewportResponse {
9530        type Owned = Self;
9531
9532        #[inline(always)]
9533        fn inline_align(_context: fidl::encoding::Context) -> usize {
9534            4
9535        }
9536
9537        #[inline(always)]
9538        fn inline_size(_context: fidl::encoding::Context) -> usize {
9539            4
9540        }
9541    }
9542
9543    unsafe impl
9544        fidl::encoding::Encode<
9545            FlatlandReleaseViewportResponse,
9546            fidl::encoding::DefaultFuchsiaResourceDialect,
9547        > for &mut FlatlandReleaseViewportResponse
9548    {
9549        #[inline]
9550        unsafe fn encode(
9551            self,
9552            encoder: &mut fidl::encoding::Encoder<
9553                '_,
9554                fidl::encoding::DefaultFuchsiaResourceDialect,
9555            >,
9556            offset: usize,
9557            _depth: fidl::encoding::Depth,
9558        ) -> fidl::Result<()> {
9559            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
9560            // Delegate to tuple encoding.
9561            fidl::encoding::Encode::<FlatlandReleaseViewportResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
9562                (
9563                    <fidl_fuchsia_ui_views::ViewportCreationToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.token),
9564                ),
9565                encoder, offset, _depth
9566            )
9567        }
9568    }
9569    unsafe impl<
9570            T0: fidl::encoding::Encode<
9571                fidl_fuchsia_ui_views::ViewportCreationToken,
9572                fidl::encoding::DefaultFuchsiaResourceDialect,
9573            >,
9574        >
9575        fidl::encoding::Encode<
9576            FlatlandReleaseViewportResponse,
9577            fidl::encoding::DefaultFuchsiaResourceDialect,
9578        > for (T0,)
9579    {
9580        #[inline]
9581        unsafe fn encode(
9582            self,
9583            encoder: &mut fidl::encoding::Encoder<
9584                '_,
9585                fidl::encoding::DefaultFuchsiaResourceDialect,
9586            >,
9587            offset: usize,
9588            depth: fidl::encoding::Depth,
9589        ) -> fidl::Result<()> {
9590            encoder.debug_check_bounds::<FlatlandReleaseViewportResponse>(offset);
9591            // Zero out padding regions. There's no need to apply masks
9592            // because the unmasked parts will be overwritten by fields.
9593            // Write the fields.
9594            self.0.encode(encoder, offset + 0, depth)?;
9595            Ok(())
9596        }
9597    }
9598
9599    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9600        for FlatlandReleaseViewportResponse
9601    {
9602        #[inline(always)]
9603        fn new_empty() -> Self {
9604            Self {
9605                token: fidl::new_empty!(
9606                    fidl_fuchsia_ui_views::ViewportCreationToken,
9607                    fidl::encoding::DefaultFuchsiaResourceDialect
9608                ),
9609            }
9610        }
9611
9612        #[inline]
9613        unsafe fn decode(
9614            &mut self,
9615            decoder: &mut fidl::encoding::Decoder<
9616                '_,
9617                fidl::encoding::DefaultFuchsiaResourceDialect,
9618            >,
9619            offset: usize,
9620            _depth: fidl::encoding::Depth,
9621        ) -> fidl::Result<()> {
9622            decoder.debug_check_bounds::<Self>(offset);
9623            // Verify that padding bytes are zero.
9624            fidl::decode!(
9625                fidl_fuchsia_ui_views::ViewportCreationToken,
9626                fidl::encoding::DefaultFuchsiaResourceDialect,
9627                &mut self.token,
9628                decoder,
9629                offset + 0,
9630                _depth
9631            )?;
9632            Ok(())
9633        }
9634    }
9635
9636    impl fidl::encoding::ResourceTypeMarker for FlatlandSetSolidFillRequest {
9637        type Borrowed<'a> = &'a mut Self;
9638        fn take_or_borrow<'a>(
9639            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9640        ) -> Self::Borrowed<'a> {
9641            value
9642        }
9643    }
9644
9645    unsafe impl fidl::encoding::TypeMarker for FlatlandSetSolidFillRequest {
9646        type Owned = Self;
9647
9648        #[inline(always)]
9649        fn inline_align(_context: fidl::encoding::Context) -> usize {
9650            8
9651        }
9652
9653        #[inline(always)]
9654        fn inline_size(_context: fidl::encoding::Context) -> usize {
9655            32
9656        }
9657    }
9658
9659    unsafe impl
9660        fidl::encoding::Encode<
9661            FlatlandSetSolidFillRequest,
9662            fidl::encoding::DefaultFuchsiaResourceDialect,
9663        > for &mut FlatlandSetSolidFillRequest
9664    {
9665        #[inline]
9666        unsafe fn encode(
9667            self,
9668            encoder: &mut fidl::encoding::Encoder<
9669                '_,
9670                fidl::encoding::DefaultFuchsiaResourceDialect,
9671            >,
9672            offset: usize,
9673            _depth: fidl::encoding::Depth,
9674        ) -> fidl::Result<()> {
9675            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
9676            // Delegate to tuple encoding.
9677            fidl::encoding::Encode::<
9678                FlatlandSetSolidFillRequest,
9679                fidl::encoding::DefaultFuchsiaResourceDialect,
9680            >::encode(
9681                (
9682                    <ContentId as fidl::encoding::ValueTypeMarker>::borrow(&self.rect_id),
9683                    <ColorRgba as fidl::encoding::ValueTypeMarker>::borrow(&self.color),
9684                    <fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow(
9685                        &self.size,
9686                    ),
9687                ),
9688                encoder,
9689                offset,
9690                _depth,
9691            )
9692        }
9693    }
9694    unsafe impl<
9695            T0: fidl::encoding::Encode<ContentId, fidl::encoding::DefaultFuchsiaResourceDialect>,
9696            T1: fidl::encoding::Encode<ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect>,
9697            T2: fidl::encoding::Encode<
9698                fidl_fuchsia_math::SizeU,
9699                fidl::encoding::DefaultFuchsiaResourceDialect,
9700            >,
9701        >
9702        fidl::encoding::Encode<
9703            FlatlandSetSolidFillRequest,
9704            fidl::encoding::DefaultFuchsiaResourceDialect,
9705        > for (T0, T1, T2)
9706    {
9707        #[inline]
9708        unsafe fn encode(
9709            self,
9710            encoder: &mut fidl::encoding::Encoder<
9711                '_,
9712                fidl::encoding::DefaultFuchsiaResourceDialect,
9713            >,
9714            offset: usize,
9715            depth: fidl::encoding::Depth,
9716        ) -> fidl::Result<()> {
9717            encoder.debug_check_bounds::<FlatlandSetSolidFillRequest>(offset);
9718            // Zero out padding regions. There's no need to apply masks
9719            // because the unmasked parts will be overwritten by fields.
9720            // Write the fields.
9721            self.0.encode(encoder, offset + 0, depth)?;
9722            self.1.encode(encoder, offset + 8, depth)?;
9723            self.2.encode(encoder, offset + 24, depth)?;
9724            Ok(())
9725        }
9726    }
9727
9728    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
9729        for FlatlandSetSolidFillRequest
9730    {
9731        #[inline(always)]
9732        fn new_empty() -> Self {
9733            Self {
9734                rect_id: fidl::new_empty!(ContentId, fidl::encoding::DefaultFuchsiaResourceDialect),
9735                color: fidl::new_empty!(ColorRgba, fidl::encoding::DefaultFuchsiaResourceDialect),
9736                size: fidl::new_empty!(
9737                    fidl_fuchsia_math::SizeU,
9738                    fidl::encoding::DefaultFuchsiaResourceDialect
9739                ),
9740            }
9741        }
9742
9743        #[inline]
9744        unsafe fn decode(
9745            &mut self,
9746            decoder: &mut fidl::encoding::Decoder<
9747                '_,
9748                fidl::encoding::DefaultFuchsiaResourceDialect,
9749            >,
9750            offset: usize,
9751            _depth: fidl::encoding::Depth,
9752        ) -> fidl::Result<()> {
9753            decoder.debug_check_bounds::<Self>(offset);
9754            // Verify that padding bytes are zero.
9755            fidl::decode!(
9756                ContentId,
9757                fidl::encoding::DefaultFuchsiaResourceDialect,
9758                &mut self.rect_id,
9759                decoder,
9760                offset + 0,
9761                _depth
9762            )?;
9763            fidl::decode!(
9764                ColorRgba,
9765                fidl::encoding::DefaultFuchsiaResourceDialect,
9766                &mut self.color,
9767                decoder,
9768                offset + 8,
9769                _depth
9770            )?;
9771            fidl::decode!(
9772                fidl_fuchsia_math::SizeU,
9773                fidl::encoding::DefaultFuchsiaResourceDialect,
9774                &mut self.size,
9775                decoder,
9776                offset + 24,
9777                _depth
9778            )?;
9779            Ok(())
9780        }
9781    }
9782
9783    impl FrameInfo {
9784        #[inline(always)]
9785        fn max_ordinal_present(&self) -> u64 {
9786            if let Some(_) = self.buffer_id {
9787                return 1;
9788            }
9789            0
9790        }
9791    }
9792
9793    impl fidl::encoding::ResourceTypeMarker for FrameInfo {
9794        type Borrowed<'a> = &'a mut Self;
9795        fn take_or_borrow<'a>(
9796            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9797        ) -> Self::Borrowed<'a> {
9798            value
9799        }
9800    }
9801
9802    unsafe impl fidl::encoding::TypeMarker for FrameInfo {
9803        type Owned = Self;
9804
9805        #[inline(always)]
9806        fn inline_align(_context: fidl::encoding::Context) -> usize {
9807            8
9808        }
9809
9810        #[inline(always)]
9811        fn inline_size(_context: fidl::encoding::Context) -> usize {
9812            16
9813        }
9814    }
9815
9816    unsafe impl fidl::encoding::Encode<FrameInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
9817        for &mut FrameInfo
9818    {
9819        unsafe fn encode(
9820            self,
9821            encoder: &mut fidl::encoding::Encoder<
9822                '_,
9823                fidl::encoding::DefaultFuchsiaResourceDialect,
9824            >,
9825            offset: usize,
9826            mut depth: fidl::encoding::Depth,
9827        ) -> fidl::Result<()> {
9828            encoder.debug_check_bounds::<FrameInfo>(offset);
9829            // Vector header
9830            let max_ordinal: u64 = self.max_ordinal_present();
9831            encoder.write_num(max_ordinal, offset);
9832            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
9833            // Calling encoder.out_of_line_offset(0) is not allowed.
9834            if max_ordinal == 0 {
9835                return Ok(());
9836            }
9837            depth.increment()?;
9838            let envelope_size = 8;
9839            let bytes_len = max_ordinal as usize * envelope_size;
9840            #[allow(unused_variables)]
9841            let offset = encoder.out_of_line_offset(bytes_len);
9842            let mut _prev_end_offset: usize = 0;
9843            if 1 > max_ordinal {
9844                return Ok(());
9845            }
9846
9847            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
9848            // are envelope_size bytes.
9849            let cur_offset: usize = (1 - 1) * envelope_size;
9850
9851            // Zero reserved fields.
9852            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
9853
9854            // Safety:
9855            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
9856            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
9857            //   envelope_size bytes, there is always sufficient room.
9858            fidl::encoding::encode_in_envelope_optional::<
9859                u32,
9860                fidl::encoding::DefaultFuchsiaResourceDialect,
9861            >(
9862                self.buffer_id.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
9863                encoder,
9864                offset + cur_offset,
9865                depth,
9866            )?;
9867
9868            _prev_end_offset = cur_offset + envelope_size;
9869
9870            Ok(())
9871        }
9872    }
9873
9874    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for FrameInfo {
9875        #[inline(always)]
9876        fn new_empty() -> Self {
9877            Self::default()
9878        }
9879
9880        unsafe fn decode(
9881            &mut self,
9882            decoder: &mut fidl::encoding::Decoder<
9883                '_,
9884                fidl::encoding::DefaultFuchsiaResourceDialect,
9885            >,
9886            offset: usize,
9887            mut depth: fidl::encoding::Depth,
9888        ) -> fidl::Result<()> {
9889            decoder.debug_check_bounds::<Self>(offset);
9890            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
9891                None => return Err(fidl::Error::NotNullable),
9892                Some(len) => len,
9893            };
9894            // Calling decoder.out_of_line_offset(0) is not allowed.
9895            if len == 0 {
9896                return Ok(());
9897            };
9898            depth.increment()?;
9899            let envelope_size = 8;
9900            let bytes_len = len * envelope_size;
9901            let offset = decoder.out_of_line_offset(bytes_len)?;
9902            // Decode the envelope for each type.
9903            let mut _next_ordinal_to_read = 0;
9904            let mut next_offset = offset;
9905            let end_offset = offset + bytes_len;
9906            _next_ordinal_to_read += 1;
9907            if next_offset >= end_offset {
9908                return Ok(());
9909            }
9910
9911            // Decode unknown envelopes for gaps in ordinals.
9912            while _next_ordinal_to_read < 1 {
9913                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9914                _next_ordinal_to_read += 1;
9915                next_offset += envelope_size;
9916            }
9917
9918            let next_out_of_line = decoder.next_out_of_line();
9919            let handles_before = decoder.remaining_handles();
9920            if let Some((inlined, num_bytes, num_handles)) =
9921                fidl::encoding::decode_envelope_header(decoder, next_offset)?
9922            {
9923                let member_inline_size =
9924                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
9925                if inlined != (member_inline_size <= 4) {
9926                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
9927                }
9928                let inner_offset;
9929                let mut inner_depth = depth.clone();
9930                if inlined {
9931                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
9932                    inner_offset = next_offset;
9933                } else {
9934                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
9935                    inner_depth.increment()?;
9936                }
9937                let val_ref = self.buffer_id.get_or_insert_with(|| {
9938                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
9939                });
9940                fidl::decode!(
9941                    u32,
9942                    fidl::encoding::DefaultFuchsiaResourceDialect,
9943                    val_ref,
9944                    decoder,
9945                    inner_offset,
9946                    inner_depth
9947                )?;
9948                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
9949                {
9950                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
9951                }
9952                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
9953                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
9954                }
9955            }
9956
9957            next_offset += envelope_size;
9958
9959            // Decode the remaining unknown envelopes.
9960            while next_offset < end_offset {
9961                _next_ordinal_to_read += 1;
9962                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
9963                next_offset += envelope_size;
9964            }
9965
9966            Ok(())
9967        }
9968    }
9969
9970    impl GetNextFrameArgs {
9971        #[inline(always)]
9972        fn max_ordinal_present(&self) -> u64 {
9973            if let Some(_) = self.event {
9974                return 1;
9975            }
9976            0
9977        }
9978    }
9979
9980    impl fidl::encoding::ResourceTypeMarker for GetNextFrameArgs {
9981        type Borrowed<'a> = &'a mut Self;
9982        fn take_or_borrow<'a>(
9983            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
9984        ) -> Self::Borrowed<'a> {
9985            value
9986        }
9987    }
9988
9989    unsafe impl fidl::encoding::TypeMarker for GetNextFrameArgs {
9990        type Owned = Self;
9991
9992        #[inline(always)]
9993        fn inline_align(_context: fidl::encoding::Context) -> usize {
9994            8
9995        }
9996
9997        #[inline(always)]
9998        fn inline_size(_context: fidl::encoding::Context) -> usize {
9999            16
10000        }
10001    }
10002
10003    unsafe impl
10004        fidl::encoding::Encode<GetNextFrameArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
10005        for &mut GetNextFrameArgs
10006    {
10007        unsafe fn encode(
10008            self,
10009            encoder: &mut fidl::encoding::Encoder<
10010                '_,
10011                fidl::encoding::DefaultFuchsiaResourceDialect,
10012            >,
10013            offset: usize,
10014            mut depth: fidl::encoding::Depth,
10015        ) -> fidl::Result<()> {
10016            encoder.debug_check_bounds::<GetNextFrameArgs>(offset);
10017            // Vector header
10018            let max_ordinal: u64 = self.max_ordinal_present();
10019            encoder.write_num(max_ordinal, offset);
10020            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10021            // Calling encoder.out_of_line_offset(0) is not allowed.
10022            if max_ordinal == 0 {
10023                return Ok(());
10024            }
10025            depth.increment()?;
10026            let envelope_size = 8;
10027            let bytes_len = max_ordinal as usize * envelope_size;
10028            #[allow(unused_variables)]
10029            let offset = encoder.out_of_line_offset(bytes_len);
10030            let mut _prev_end_offset: usize = 0;
10031            if 1 > max_ordinal {
10032                return Ok(());
10033            }
10034
10035            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10036            // are envelope_size bytes.
10037            let cur_offset: usize = (1 - 1) * envelope_size;
10038
10039            // Zero reserved fields.
10040            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10041
10042            // Safety:
10043            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10044            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10045            //   envelope_size bytes, there is always sufficient room.
10046            fidl::encoding::encode_in_envelope_optional::<
10047                fidl::encoding::HandleType<
10048                    fidl::Event,
10049                    { fidl::ObjectType::EVENT.into_raw() },
10050                    2147483648,
10051                >,
10052                fidl::encoding::DefaultFuchsiaResourceDialect,
10053            >(
10054                self.event.as_mut().map(
10055                    <fidl::encoding::HandleType<
10056                        fidl::Event,
10057                        { fidl::ObjectType::EVENT.into_raw() },
10058                        2147483648,
10059                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10060                ),
10061                encoder,
10062                offset + cur_offset,
10063                depth,
10064            )?;
10065
10066            _prev_end_offset = cur_offset + envelope_size;
10067
10068            Ok(())
10069        }
10070    }
10071
10072    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
10073        for GetNextFrameArgs
10074    {
10075        #[inline(always)]
10076        fn new_empty() -> Self {
10077            Self::default()
10078        }
10079
10080        unsafe fn decode(
10081            &mut self,
10082            decoder: &mut fidl::encoding::Decoder<
10083                '_,
10084                fidl::encoding::DefaultFuchsiaResourceDialect,
10085            >,
10086            offset: usize,
10087            mut depth: fidl::encoding::Depth,
10088        ) -> fidl::Result<()> {
10089            decoder.debug_check_bounds::<Self>(offset);
10090            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10091                None => return Err(fidl::Error::NotNullable),
10092                Some(len) => len,
10093            };
10094            // Calling decoder.out_of_line_offset(0) is not allowed.
10095            if len == 0 {
10096                return Ok(());
10097            };
10098            depth.increment()?;
10099            let envelope_size = 8;
10100            let bytes_len = len * envelope_size;
10101            let offset = decoder.out_of_line_offset(bytes_len)?;
10102            // Decode the envelope for each type.
10103            let mut _next_ordinal_to_read = 0;
10104            let mut next_offset = offset;
10105            let end_offset = offset + bytes_len;
10106            _next_ordinal_to_read += 1;
10107            if next_offset >= end_offset {
10108                return Ok(());
10109            }
10110
10111            // Decode unknown envelopes for gaps in ordinals.
10112            while _next_ordinal_to_read < 1 {
10113                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10114                _next_ordinal_to_read += 1;
10115                next_offset += envelope_size;
10116            }
10117
10118            let next_out_of_line = decoder.next_out_of_line();
10119            let handles_before = decoder.remaining_handles();
10120            if let Some((inlined, num_bytes, num_handles)) =
10121                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10122            {
10123                let member_inline_size = <fidl::encoding::HandleType<
10124                    fidl::Event,
10125                    { fidl::ObjectType::EVENT.into_raw() },
10126                    2147483648,
10127                > as fidl::encoding::TypeMarker>::inline_size(
10128                    decoder.context
10129                );
10130                if inlined != (member_inline_size <= 4) {
10131                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10132                }
10133                let inner_offset;
10134                let mut inner_depth = depth.clone();
10135                if inlined {
10136                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10137                    inner_offset = next_offset;
10138                } else {
10139                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10140                    inner_depth.increment()?;
10141                }
10142                let val_ref =
10143                self.event.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
10144                fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
10145                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10146                {
10147                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10148                }
10149                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10150                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10151                }
10152            }
10153
10154            next_offset += envelope_size;
10155
10156            // Decode the remaining unknown envelopes.
10157            while next_offset < end_offset {
10158                _next_ordinal_to_read += 1;
10159                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10160                next_offset += envelope_size;
10161            }
10162
10163            Ok(())
10164        }
10165    }
10166
10167    impl PresentArgs {
10168        #[inline(always)]
10169        fn max_ordinal_present(&self) -> u64 {
10170            if let Some(_) = self.server_signal_fences {
10171                return 6;
10172            }
10173            if let Some(_) = self.server_wait_fences {
10174                return 5;
10175            }
10176            if let Some(_) = self.unsquashable {
10177                return 4;
10178            }
10179            if let Some(_) = self.release_fences {
10180                return 3;
10181            }
10182            if let Some(_) = self.acquire_fences {
10183                return 2;
10184            }
10185            if let Some(_) = self.requested_presentation_time {
10186                return 1;
10187            }
10188            0
10189        }
10190    }
10191
10192    impl fidl::encoding::ResourceTypeMarker for PresentArgs {
10193        type Borrowed<'a> = &'a mut Self;
10194        fn take_or_borrow<'a>(
10195            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10196        ) -> Self::Borrowed<'a> {
10197            value
10198        }
10199    }
10200
10201    unsafe impl fidl::encoding::TypeMarker for PresentArgs {
10202        type Owned = Self;
10203
10204        #[inline(always)]
10205        fn inline_align(_context: fidl::encoding::Context) -> usize {
10206            8
10207        }
10208
10209        #[inline(always)]
10210        fn inline_size(_context: fidl::encoding::Context) -> usize {
10211            16
10212        }
10213    }
10214
10215    unsafe impl fidl::encoding::Encode<PresentArgs, fidl::encoding::DefaultFuchsiaResourceDialect>
10216        for &mut PresentArgs
10217    {
10218        unsafe fn encode(
10219            self,
10220            encoder: &mut fidl::encoding::Encoder<
10221                '_,
10222                fidl::encoding::DefaultFuchsiaResourceDialect,
10223            >,
10224            offset: usize,
10225            mut depth: fidl::encoding::Depth,
10226        ) -> fidl::Result<()> {
10227            encoder.debug_check_bounds::<PresentArgs>(offset);
10228            // Vector header
10229            let max_ordinal: u64 = self.max_ordinal_present();
10230            encoder.write_num(max_ordinal, offset);
10231            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10232            // Calling encoder.out_of_line_offset(0) is not allowed.
10233            if max_ordinal == 0 {
10234                return Ok(());
10235            }
10236            depth.increment()?;
10237            let envelope_size = 8;
10238            let bytes_len = max_ordinal as usize * envelope_size;
10239            #[allow(unused_variables)]
10240            let offset = encoder.out_of_line_offset(bytes_len);
10241            let mut _prev_end_offset: usize = 0;
10242            if 1 > max_ordinal {
10243                return Ok(());
10244            }
10245
10246            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10247            // are envelope_size bytes.
10248            let cur_offset: usize = (1 - 1) * envelope_size;
10249
10250            // Zero reserved fields.
10251            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10252
10253            // Safety:
10254            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10255            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10256            //   envelope_size bytes, there is always sufficient room.
10257            fidl::encoding::encode_in_envelope_optional::<
10258                i64,
10259                fidl::encoding::DefaultFuchsiaResourceDialect,
10260            >(
10261                self.requested_presentation_time
10262                    .as_ref()
10263                    .map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
10264                encoder,
10265                offset + cur_offset,
10266                depth,
10267            )?;
10268
10269            _prev_end_offset = cur_offset + envelope_size;
10270            if 2 > max_ordinal {
10271                return Ok(());
10272            }
10273
10274            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10275            // are envelope_size bytes.
10276            let cur_offset: usize = (2 - 1) * envelope_size;
10277
10278            // Zero reserved fields.
10279            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10280
10281            // Safety:
10282            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10283            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10284            //   envelope_size bytes, there is always sufficient room.
10285            fidl::encoding::encode_in_envelope_optional::<
10286                fidl::encoding::Vector<
10287                    fidl::encoding::HandleType<
10288                        fidl::Event,
10289                        { fidl::ObjectType::EVENT.into_raw() },
10290                        2147483648,
10291                    >,
10292                    16,
10293                >,
10294                fidl::encoding::DefaultFuchsiaResourceDialect,
10295            >(
10296                self.acquire_fences.as_mut().map(
10297                    <fidl::encoding::Vector<
10298                        fidl::encoding::HandleType<
10299                            fidl::Event,
10300                            { fidl::ObjectType::EVENT.into_raw() },
10301                            2147483648,
10302                        >,
10303                        16,
10304                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10305                ),
10306                encoder,
10307                offset + cur_offset,
10308                depth,
10309            )?;
10310
10311            _prev_end_offset = cur_offset + envelope_size;
10312            if 3 > max_ordinal {
10313                return Ok(());
10314            }
10315
10316            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10317            // are envelope_size bytes.
10318            let cur_offset: usize = (3 - 1) * envelope_size;
10319
10320            // Zero reserved fields.
10321            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10322
10323            // Safety:
10324            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10325            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10326            //   envelope_size bytes, there is always sufficient room.
10327            fidl::encoding::encode_in_envelope_optional::<
10328                fidl::encoding::Vector<
10329                    fidl::encoding::HandleType<
10330                        fidl::Event,
10331                        { fidl::ObjectType::EVENT.into_raw() },
10332                        2147483648,
10333                    >,
10334                    16,
10335                >,
10336                fidl::encoding::DefaultFuchsiaResourceDialect,
10337            >(
10338                self.release_fences.as_mut().map(
10339                    <fidl::encoding::Vector<
10340                        fidl::encoding::HandleType<
10341                            fidl::Event,
10342                            { fidl::ObjectType::EVENT.into_raw() },
10343                            2147483648,
10344                        >,
10345                        16,
10346                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10347                ),
10348                encoder,
10349                offset + cur_offset,
10350                depth,
10351            )?;
10352
10353            _prev_end_offset = cur_offset + envelope_size;
10354            if 4 > max_ordinal {
10355                return Ok(());
10356            }
10357
10358            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10359            // are envelope_size bytes.
10360            let cur_offset: usize = (4 - 1) * envelope_size;
10361
10362            // Zero reserved fields.
10363            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10364
10365            // Safety:
10366            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10367            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10368            //   envelope_size bytes, there is always sufficient room.
10369            fidl::encoding::encode_in_envelope_optional::<
10370                bool,
10371                fidl::encoding::DefaultFuchsiaResourceDialect,
10372            >(
10373                self.unsquashable.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
10374                encoder,
10375                offset + cur_offset,
10376                depth,
10377            )?;
10378
10379            _prev_end_offset = cur_offset + envelope_size;
10380            if 5 > max_ordinal {
10381                return Ok(());
10382            }
10383
10384            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10385            // are envelope_size bytes.
10386            let cur_offset: usize = (5 - 1) * envelope_size;
10387
10388            // Zero reserved fields.
10389            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10390
10391            // Safety:
10392            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10393            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10394            //   envelope_size bytes, there is always sufficient room.
10395            fidl::encoding::encode_in_envelope_optional::<
10396                fidl::encoding::Vector<
10397                    fidl::encoding::HandleType<
10398                        fidl::Event,
10399                        { fidl::ObjectType::EVENT.into_raw() },
10400                        2147483648,
10401                    >,
10402                    16,
10403                >,
10404                fidl::encoding::DefaultFuchsiaResourceDialect,
10405            >(
10406                self.server_wait_fences.as_mut().map(
10407                    <fidl::encoding::Vector<
10408                        fidl::encoding::HandleType<
10409                            fidl::Event,
10410                            { fidl::ObjectType::EVENT.into_raw() },
10411                            2147483648,
10412                        >,
10413                        16,
10414                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10415                ),
10416                encoder,
10417                offset + cur_offset,
10418                depth,
10419            )?;
10420
10421            _prev_end_offset = cur_offset + envelope_size;
10422            if 6 > max_ordinal {
10423                return Ok(());
10424            }
10425
10426            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
10427            // are envelope_size bytes.
10428            let cur_offset: usize = (6 - 1) * envelope_size;
10429
10430            // Zero reserved fields.
10431            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
10432
10433            // Safety:
10434            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
10435            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
10436            //   envelope_size bytes, there is always sufficient room.
10437            fidl::encoding::encode_in_envelope_optional::<
10438                fidl::encoding::Vector<
10439                    fidl::encoding::HandleType<
10440                        fidl::Event,
10441                        { fidl::ObjectType::EVENT.into_raw() },
10442                        2147483648,
10443                    >,
10444                    16,
10445                >,
10446                fidl::encoding::DefaultFuchsiaResourceDialect,
10447            >(
10448                self.server_signal_fences.as_mut().map(
10449                    <fidl::encoding::Vector<
10450                        fidl::encoding::HandleType<
10451                            fidl::Event,
10452                            { fidl::ObjectType::EVENT.into_raw() },
10453                            2147483648,
10454                        >,
10455                        16,
10456                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
10457                ),
10458                encoder,
10459                offset + cur_offset,
10460                depth,
10461            )?;
10462
10463            _prev_end_offset = cur_offset + envelope_size;
10464
10465            Ok(())
10466        }
10467    }
10468
10469    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for PresentArgs {
10470        #[inline(always)]
10471        fn new_empty() -> Self {
10472            Self::default()
10473        }
10474
10475        unsafe fn decode(
10476            &mut self,
10477            decoder: &mut fidl::encoding::Decoder<
10478                '_,
10479                fidl::encoding::DefaultFuchsiaResourceDialect,
10480            >,
10481            offset: usize,
10482            mut depth: fidl::encoding::Depth,
10483        ) -> fidl::Result<()> {
10484            decoder.debug_check_bounds::<Self>(offset);
10485            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
10486                None => return Err(fidl::Error::NotNullable),
10487                Some(len) => len,
10488            };
10489            // Calling decoder.out_of_line_offset(0) is not allowed.
10490            if len == 0 {
10491                return Ok(());
10492            };
10493            depth.increment()?;
10494            let envelope_size = 8;
10495            let bytes_len = len * envelope_size;
10496            let offset = decoder.out_of_line_offset(bytes_len)?;
10497            // Decode the envelope for each type.
10498            let mut _next_ordinal_to_read = 0;
10499            let mut next_offset = offset;
10500            let end_offset = offset + bytes_len;
10501            _next_ordinal_to_read += 1;
10502            if next_offset >= end_offset {
10503                return Ok(());
10504            }
10505
10506            // Decode unknown envelopes for gaps in ordinals.
10507            while _next_ordinal_to_read < 1 {
10508                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10509                _next_ordinal_to_read += 1;
10510                next_offset += envelope_size;
10511            }
10512
10513            let next_out_of_line = decoder.next_out_of_line();
10514            let handles_before = decoder.remaining_handles();
10515            if let Some((inlined, num_bytes, num_handles)) =
10516                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10517            {
10518                let member_inline_size =
10519                    <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10520                if inlined != (member_inline_size <= 4) {
10521                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10522                }
10523                let inner_offset;
10524                let mut inner_depth = depth.clone();
10525                if inlined {
10526                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10527                    inner_offset = next_offset;
10528                } else {
10529                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10530                    inner_depth.increment()?;
10531                }
10532                let val_ref = self.requested_presentation_time.get_or_insert_with(|| {
10533                    fidl::new_empty!(i64, fidl::encoding::DefaultFuchsiaResourceDialect)
10534                });
10535                fidl::decode!(
10536                    i64,
10537                    fidl::encoding::DefaultFuchsiaResourceDialect,
10538                    val_ref,
10539                    decoder,
10540                    inner_offset,
10541                    inner_depth
10542                )?;
10543                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10544                {
10545                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10546                }
10547                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10548                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10549                }
10550            }
10551
10552            next_offset += envelope_size;
10553            _next_ordinal_to_read += 1;
10554            if next_offset >= end_offset {
10555                return Ok(());
10556            }
10557
10558            // Decode unknown envelopes for gaps in ordinals.
10559            while _next_ordinal_to_read < 2 {
10560                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10561                _next_ordinal_to_read += 1;
10562                next_offset += envelope_size;
10563            }
10564
10565            let next_out_of_line = decoder.next_out_of_line();
10566            let handles_before = decoder.remaining_handles();
10567            if let Some((inlined, num_bytes, num_handles)) =
10568                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10569            {
10570                let member_inline_size = <fidl::encoding::Vector<
10571                    fidl::encoding::HandleType<
10572                        fidl::Event,
10573                        { fidl::ObjectType::EVENT.into_raw() },
10574                        2147483648,
10575                    >,
10576                    16,
10577                > as fidl::encoding::TypeMarker>::inline_size(
10578                    decoder.context
10579                );
10580                if inlined != (member_inline_size <= 4) {
10581                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10582                }
10583                let inner_offset;
10584                let mut inner_depth = depth.clone();
10585                if inlined {
10586                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10587                    inner_offset = next_offset;
10588                } else {
10589                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10590                    inner_depth.increment()?;
10591                }
10592                let val_ref = self.acquire_fences.get_or_insert_with(|| {
10593                    fidl::new_empty!(
10594                        fidl::encoding::Vector<
10595                            fidl::encoding::HandleType<
10596                                fidl::Event,
10597                                { fidl::ObjectType::EVENT.into_raw() },
10598                                2147483648,
10599                            >,
10600                            16,
10601                        >,
10602                        fidl::encoding::DefaultFuchsiaResourceDialect
10603                    )
10604                });
10605                fidl::decode!(
10606                    fidl::encoding::Vector<
10607                        fidl::encoding::HandleType<
10608                            fidl::Event,
10609                            { fidl::ObjectType::EVENT.into_raw() },
10610                            2147483648,
10611                        >,
10612                        16,
10613                    >,
10614                    fidl::encoding::DefaultFuchsiaResourceDialect,
10615                    val_ref,
10616                    decoder,
10617                    inner_offset,
10618                    inner_depth
10619                )?;
10620                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10621                {
10622                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10623                }
10624                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10625                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10626                }
10627            }
10628
10629            next_offset += envelope_size;
10630            _next_ordinal_to_read += 1;
10631            if next_offset >= end_offset {
10632                return Ok(());
10633            }
10634
10635            // Decode unknown envelopes for gaps in ordinals.
10636            while _next_ordinal_to_read < 3 {
10637                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10638                _next_ordinal_to_read += 1;
10639                next_offset += envelope_size;
10640            }
10641
10642            let next_out_of_line = decoder.next_out_of_line();
10643            let handles_before = decoder.remaining_handles();
10644            if let Some((inlined, num_bytes, num_handles)) =
10645                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10646            {
10647                let member_inline_size = <fidl::encoding::Vector<
10648                    fidl::encoding::HandleType<
10649                        fidl::Event,
10650                        { fidl::ObjectType::EVENT.into_raw() },
10651                        2147483648,
10652                    >,
10653                    16,
10654                > as fidl::encoding::TypeMarker>::inline_size(
10655                    decoder.context
10656                );
10657                if inlined != (member_inline_size <= 4) {
10658                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10659                }
10660                let inner_offset;
10661                let mut inner_depth = depth.clone();
10662                if inlined {
10663                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10664                    inner_offset = next_offset;
10665                } else {
10666                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10667                    inner_depth.increment()?;
10668                }
10669                let val_ref = self.release_fences.get_or_insert_with(|| {
10670                    fidl::new_empty!(
10671                        fidl::encoding::Vector<
10672                            fidl::encoding::HandleType<
10673                                fidl::Event,
10674                                { fidl::ObjectType::EVENT.into_raw() },
10675                                2147483648,
10676                            >,
10677                            16,
10678                        >,
10679                        fidl::encoding::DefaultFuchsiaResourceDialect
10680                    )
10681                });
10682                fidl::decode!(
10683                    fidl::encoding::Vector<
10684                        fidl::encoding::HandleType<
10685                            fidl::Event,
10686                            { fidl::ObjectType::EVENT.into_raw() },
10687                            2147483648,
10688                        >,
10689                        16,
10690                    >,
10691                    fidl::encoding::DefaultFuchsiaResourceDialect,
10692                    val_ref,
10693                    decoder,
10694                    inner_offset,
10695                    inner_depth
10696                )?;
10697                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10698                {
10699                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10700                }
10701                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10702                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10703                }
10704            }
10705
10706            next_offset += envelope_size;
10707            _next_ordinal_to_read += 1;
10708            if next_offset >= end_offset {
10709                return Ok(());
10710            }
10711
10712            // Decode unknown envelopes for gaps in ordinals.
10713            while _next_ordinal_to_read < 4 {
10714                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10715                _next_ordinal_to_read += 1;
10716                next_offset += envelope_size;
10717            }
10718
10719            let next_out_of_line = decoder.next_out_of_line();
10720            let handles_before = decoder.remaining_handles();
10721            if let Some((inlined, num_bytes, num_handles)) =
10722                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10723            {
10724                let member_inline_size =
10725                    <bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
10726                if inlined != (member_inline_size <= 4) {
10727                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10728                }
10729                let inner_offset;
10730                let mut inner_depth = depth.clone();
10731                if inlined {
10732                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10733                    inner_offset = next_offset;
10734                } else {
10735                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10736                    inner_depth.increment()?;
10737                }
10738                let val_ref = self.unsquashable.get_or_insert_with(|| {
10739                    fidl::new_empty!(bool, fidl::encoding::DefaultFuchsiaResourceDialect)
10740                });
10741                fidl::decode!(
10742                    bool,
10743                    fidl::encoding::DefaultFuchsiaResourceDialect,
10744                    val_ref,
10745                    decoder,
10746                    inner_offset,
10747                    inner_depth
10748                )?;
10749                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10750                {
10751                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10752                }
10753                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10754                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10755                }
10756            }
10757
10758            next_offset += envelope_size;
10759            _next_ordinal_to_read += 1;
10760            if next_offset >= end_offset {
10761                return Ok(());
10762            }
10763
10764            // Decode unknown envelopes for gaps in ordinals.
10765            while _next_ordinal_to_read < 5 {
10766                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10767                _next_ordinal_to_read += 1;
10768                next_offset += envelope_size;
10769            }
10770
10771            let next_out_of_line = decoder.next_out_of_line();
10772            let handles_before = decoder.remaining_handles();
10773            if let Some((inlined, num_bytes, num_handles)) =
10774                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10775            {
10776                let member_inline_size = <fidl::encoding::Vector<
10777                    fidl::encoding::HandleType<
10778                        fidl::Event,
10779                        { fidl::ObjectType::EVENT.into_raw() },
10780                        2147483648,
10781                    >,
10782                    16,
10783                > as fidl::encoding::TypeMarker>::inline_size(
10784                    decoder.context
10785                );
10786                if inlined != (member_inline_size <= 4) {
10787                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10788                }
10789                let inner_offset;
10790                let mut inner_depth = depth.clone();
10791                if inlined {
10792                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10793                    inner_offset = next_offset;
10794                } else {
10795                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10796                    inner_depth.increment()?;
10797                }
10798                let val_ref = self.server_wait_fences.get_or_insert_with(|| {
10799                    fidl::new_empty!(
10800                        fidl::encoding::Vector<
10801                            fidl::encoding::HandleType<
10802                                fidl::Event,
10803                                { fidl::ObjectType::EVENT.into_raw() },
10804                                2147483648,
10805                            >,
10806                            16,
10807                        >,
10808                        fidl::encoding::DefaultFuchsiaResourceDialect
10809                    )
10810                });
10811                fidl::decode!(
10812                    fidl::encoding::Vector<
10813                        fidl::encoding::HandleType<
10814                            fidl::Event,
10815                            { fidl::ObjectType::EVENT.into_raw() },
10816                            2147483648,
10817                        >,
10818                        16,
10819                    >,
10820                    fidl::encoding::DefaultFuchsiaResourceDialect,
10821                    val_ref,
10822                    decoder,
10823                    inner_offset,
10824                    inner_depth
10825                )?;
10826                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10827                {
10828                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10829                }
10830                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10831                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10832                }
10833            }
10834
10835            next_offset += envelope_size;
10836            _next_ordinal_to_read += 1;
10837            if next_offset >= end_offset {
10838                return Ok(());
10839            }
10840
10841            // Decode unknown envelopes for gaps in ordinals.
10842            while _next_ordinal_to_read < 6 {
10843                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10844                _next_ordinal_to_read += 1;
10845                next_offset += envelope_size;
10846            }
10847
10848            let next_out_of_line = decoder.next_out_of_line();
10849            let handles_before = decoder.remaining_handles();
10850            if let Some((inlined, num_bytes, num_handles)) =
10851                fidl::encoding::decode_envelope_header(decoder, next_offset)?
10852            {
10853                let member_inline_size = <fidl::encoding::Vector<
10854                    fidl::encoding::HandleType<
10855                        fidl::Event,
10856                        { fidl::ObjectType::EVENT.into_raw() },
10857                        2147483648,
10858                    >,
10859                    16,
10860                > as fidl::encoding::TypeMarker>::inline_size(
10861                    decoder.context
10862                );
10863                if inlined != (member_inline_size <= 4) {
10864                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
10865                }
10866                let inner_offset;
10867                let mut inner_depth = depth.clone();
10868                if inlined {
10869                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
10870                    inner_offset = next_offset;
10871                } else {
10872                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
10873                    inner_depth.increment()?;
10874                }
10875                let val_ref = self.server_signal_fences.get_or_insert_with(|| {
10876                    fidl::new_empty!(
10877                        fidl::encoding::Vector<
10878                            fidl::encoding::HandleType<
10879                                fidl::Event,
10880                                { fidl::ObjectType::EVENT.into_raw() },
10881                                2147483648,
10882                            >,
10883                            16,
10884                        >,
10885                        fidl::encoding::DefaultFuchsiaResourceDialect
10886                    )
10887                });
10888                fidl::decode!(
10889                    fidl::encoding::Vector<
10890                        fidl::encoding::HandleType<
10891                            fidl::Event,
10892                            { fidl::ObjectType::EVENT.into_raw() },
10893                            2147483648,
10894                        >,
10895                        16,
10896                    >,
10897                    fidl::encoding::DefaultFuchsiaResourceDialect,
10898                    val_ref,
10899                    decoder,
10900                    inner_offset,
10901                    inner_depth
10902                )?;
10903                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
10904                {
10905                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
10906                }
10907                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
10908                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
10909                }
10910            }
10911
10912            next_offset += envelope_size;
10913
10914            // Decode the remaining unknown envelopes.
10915            while next_offset < end_offset {
10916                _next_ordinal_to_read += 1;
10917                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
10918                next_offset += envelope_size;
10919            }
10920
10921            Ok(())
10922        }
10923    }
10924
10925    impl RegisterBufferCollectionArgs {
10926        #[inline(always)]
10927        fn max_ordinal_present(&self) -> u64 {
10928            if let Some(_) = self.buffer_collection_token2 {
10929                return 5;
10930            }
10931            if let Some(_) = self.usages {
10932                return 4;
10933            }
10934            if let Some(_) = self.usage {
10935                return 3;
10936            }
10937            if let Some(_) = self.buffer_collection_token {
10938                return 2;
10939            }
10940            if let Some(_) = self.export_token {
10941                return 1;
10942            }
10943            0
10944        }
10945    }
10946
10947    impl fidl::encoding::ResourceTypeMarker for RegisterBufferCollectionArgs {
10948        type Borrowed<'a> = &'a mut Self;
10949        fn take_or_borrow<'a>(
10950            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
10951        ) -> Self::Borrowed<'a> {
10952            value
10953        }
10954    }
10955
10956    unsafe impl fidl::encoding::TypeMarker for RegisterBufferCollectionArgs {
10957        type Owned = Self;
10958
10959        #[inline(always)]
10960        fn inline_align(_context: fidl::encoding::Context) -> usize {
10961            8
10962        }
10963
10964        #[inline(always)]
10965        fn inline_size(_context: fidl::encoding::Context) -> usize {
10966            16
10967        }
10968    }
10969
10970    unsafe impl
10971        fidl::encoding::Encode<
10972            RegisterBufferCollectionArgs,
10973            fidl::encoding::DefaultFuchsiaResourceDialect,
10974        > for &mut RegisterBufferCollectionArgs
10975    {
10976        unsafe fn encode(
10977            self,
10978            encoder: &mut fidl::encoding::Encoder<
10979                '_,
10980                fidl::encoding::DefaultFuchsiaResourceDialect,
10981            >,
10982            offset: usize,
10983            mut depth: fidl::encoding::Depth,
10984        ) -> fidl::Result<()> {
10985            encoder.debug_check_bounds::<RegisterBufferCollectionArgs>(offset);
10986            // Vector header
10987            let max_ordinal: u64 = self.max_ordinal_present();
10988            encoder.write_num(max_ordinal, offset);
10989            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
10990            // Calling encoder.out_of_line_offset(0) is not allowed.
10991            if max_ordinal == 0 {
10992                return Ok(());
10993            }
10994            depth.increment()?;
10995            let envelope_size = 8;
10996            let bytes_len = max_ordinal as usize * envelope_size;
10997            #[allow(unused_variables)]
10998            let offset = encoder.out_of_line_offset(bytes_len);
10999            let mut _prev_end_offset: usize = 0;
11000            if 1 > max_ordinal {
11001                return Ok(());
11002            }
11003
11004            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11005            // are envelope_size bytes.
11006            let cur_offset: usize = (1 - 1) * envelope_size;
11007
11008            // Zero reserved fields.
11009            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11010
11011            // Safety:
11012            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11013            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11014            //   envelope_size bytes, there is always sufficient room.
11015            fidl::encoding::encode_in_envelope_optional::<BufferCollectionExportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
11016            self.export_token.as_mut().map(<BufferCollectionExportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11017            encoder, offset + cur_offset, depth
11018        )?;
11019
11020            _prev_end_offset = cur_offset + envelope_size;
11021            if 2 > max_ordinal {
11022                return Ok(());
11023            }
11024
11025            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11026            // are envelope_size bytes.
11027            let cur_offset: usize = (2 - 1) * envelope_size;
11028
11029            // Zero reserved fields.
11030            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11031
11032            // Safety:
11033            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11034            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11035            //   envelope_size bytes, there is always sufficient room.
11036            fidl::encoding::encode_in_envelope_optional::<
11037                fidl::encoding::Endpoint<
11038                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
11039                >,
11040                fidl::encoding::DefaultFuchsiaResourceDialect,
11041            >(
11042                self.buffer_collection_token.as_mut().map(
11043                    <fidl::encoding::Endpoint<
11044                        fidl::endpoints::ClientEnd<
11045                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
11046                        >,
11047                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11048                ),
11049                encoder,
11050                offset + cur_offset,
11051                depth,
11052            )?;
11053
11054            _prev_end_offset = cur_offset + envelope_size;
11055            if 3 > max_ordinal {
11056                return Ok(());
11057            }
11058
11059            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11060            // are envelope_size bytes.
11061            let cur_offset: usize = (3 - 1) * envelope_size;
11062
11063            // Zero reserved fields.
11064            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11065
11066            // Safety:
11067            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11068            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11069            //   envelope_size bytes, there is always sufficient room.
11070            fidl::encoding::encode_in_envelope_optional::<
11071                RegisterBufferCollectionUsage,
11072                fidl::encoding::DefaultFuchsiaResourceDialect,
11073            >(
11074                self.usage.as_ref().map(
11075                    <RegisterBufferCollectionUsage as fidl::encoding::ValueTypeMarker>::borrow,
11076                ),
11077                encoder,
11078                offset + cur_offset,
11079                depth,
11080            )?;
11081
11082            _prev_end_offset = cur_offset + envelope_size;
11083            if 4 > max_ordinal {
11084                return Ok(());
11085            }
11086
11087            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11088            // are envelope_size bytes.
11089            let cur_offset: usize = (4 - 1) * envelope_size;
11090
11091            // Zero reserved fields.
11092            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11093
11094            // Safety:
11095            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11096            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11097            //   envelope_size bytes, there is always sufficient room.
11098            fidl::encoding::encode_in_envelope_optional::<
11099                RegisterBufferCollectionUsages,
11100                fidl::encoding::DefaultFuchsiaResourceDialect,
11101            >(
11102                self.usages.as_ref().map(
11103                    <RegisterBufferCollectionUsages as fidl::encoding::ValueTypeMarker>::borrow,
11104                ),
11105                encoder,
11106                offset + cur_offset,
11107                depth,
11108            )?;
11109
11110            _prev_end_offset = cur_offset + envelope_size;
11111            if 5 > max_ordinal {
11112                return Ok(());
11113            }
11114
11115            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11116            // are envelope_size bytes.
11117            let cur_offset: usize = (5 - 1) * envelope_size;
11118
11119            // Zero reserved fields.
11120            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11121
11122            // Safety:
11123            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11124            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11125            //   envelope_size bytes, there is always sufficient room.
11126            fidl::encoding::encode_in_envelope_optional::<
11127                fidl::encoding::Endpoint<
11128                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
11129                >,
11130                fidl::encoding::DefaultFuchsiaResourceDialect,
11131            >(
11132                self.buffer_collection_token2.as_mut().map(
11133                    <fidl::encoding::Endpoint<
11134                        fidl::endpoints::ClientEnd<
11135                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
11136                        >,
11137                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
11138                ),
11139                encoder,
11140                offset + cur_offset,
11141                depth,
11142            )?;
11143
11144            _prev_end_offset = cur_offset + envelope_size;
11145
11146            Ok(())
11147        }
11148    }
11149
11150    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11151        for RegisterBufferCollectionArgs
11152    {
11153        #[inline(always)]
11154        fn new_empty() -> Self {
11155            Self::default()
11156        }
11157
11158        unsafe fn decode(
11159            &mut self,
11160            decoder: &mut fidl::encoding::Decoder<
11161                '_,
11162                fidl::encoding::DefaultFuchsiaResourceDialect,
11163            >,
11164            offset: usize,
11165            mut depth: fidl::encoding::Depth,
11166        ) -> fidl::Result<()> {
11167            decoder.debug_check_bounds::<Self>(offset);
11168            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11169                None => return Err(fidl::Error::NotNullable),
11170                Some(len) => len,
11171            };
11172            // Calling decoder.out_of_line_offset(0) is not allowed.
11173            if len == 0 {
11174                return Ok(());
11175            };
11176            depth.increment()?;
11177            let envelope_size = 8;
11178            let bytes_len = len * envelope_size;
11179            let offset = decoder.out_of_line_offset(bytes_len)?;
11180            // Decode the envelope for each type.
11181            let mut _next_ordinal_to_read = 0;
11182            let mut next_offset = offset;
11183            let end_offset = offset + bytes_len;
11184            _next_ordinal_to_read += 1;
11185            if next_offset >= end_offset {
11186                return Ok(());
11187            }
11188
11189            // Decode unknown envelopes for gaps in ordinals.
11190            while _next_ordinal_to_read < 1 {
11191                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11192                _next_ordinal_to_read += 1;
11193                next_offset += envelope_size;
11194            }
11195
11196            let next_out_of_line = decoder.next_out_of_line();
11197            let handles_before = decoder.remaining_handles();
11198            if let Some((inlined, num_bytes, num_handles)) =
11199                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11200            {
11201                let member_inline_size =
11202                    <BufferCollectionExportToken as fidl::encoding::TypeMarker>::inline_size(
11203                        decoder.context,
11204                    );
11205                if inlined != (member_inline_size <= 4) {
11206                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11207                }
11208                let inner_offset;
11209                let mut inner_depth = depth.clone();
11210                if inlined {
11211                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11212                    inner_offset = next_offset;
11213                } else {
11214                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11215                    inner_depth.increment()?;
11216                }
11217                let val_ref = self.export_token.get_or_insert_with(|| {
11218                    fidl::new_empty!(
11219                        BufferCollectionExportToken,
11220                        fidl::encoding::DefaultFuchsiaResourceDialect
11221                    )
11222                });
11223                fidl::decode!(
11224                    BufferCollectionExportToken,
11225                    fidl::encoding::DefaultFuchsiaResourceDialect,
11226                    val_ref,
11227                    decoder,
11228                    inner_offset,
11229                    inner_depth
11230                )?;
11231                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11232                {
11233                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11234                }
11235                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11236                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11237                }
11238            }
11239
11240            next_offset += envelope_size;
11241            _next_ordinal_to_read += 1;
11242            if next_offset >= end_offset {
11243                return Ok(());
11244            }
11245
11246            // Decode unknown envelopes for gaps in ordinals.
11247            while _next_ordinal_to_read < 2 {
11248                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11249                _next_ordinal_to_read += 1;
11250                next_offset += envelope_size;
11251            }
11252
11253            let next_out_of_line = decoder.next_out_of_line();
11254            let handles_before = decoder.remaining_handles();
11255            if let Some((inlined, num_bytes, num_handles)) =
11256                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11257            {
11258                let member_inline_size = <fidl::encoding::Endpoint<
11259                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem::BufferCollectionTokenMarker>,
11260                > as fidl::encoding::TypeMarker>::inline_size(
11261                    decoder.context
11262                );
11263                if inlined != (member_inline_size <= 4) {
11264                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11265                }
11266                let inner_offset;
11267                let mut inner_depth = depth.clone();
11268                if inlined {
11269                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11270                    inner_offset = next_offset;
11271                } else {
11272                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11273                    inner_depth.increment()?;
11274                }
11275                let val_ref = self.buffer_collection_token.get_or_insert_with(|| {
11276                    fidl::new_empty!(
11277                        fidl::encoding::Endpoint<
11278                            fidl::endpoints::ClientEnd<
11279                                fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
11280                            >,
11281                        >,
11282                        fidl::encoding::DefaultFuchsiaResourceDialect
11283                    )
11284                });
11285                fidl::decode!(
11286                    fidl::encoding::Endpoint<
11287                        fidl::endpoints::ClientEnd<
11288                            fidl_fuchsia_sysmem::BufferCollectionTokenMarker,
11289                        >,
11290                    >,
11291                    fidl::encoding::DefaultFuchsiaResourceDialect,
11292                    val_ref,
11293                    decoder,
11294                    inner_offset,
11295                    inner_depth
11296                )?;
11297                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11298                {
11299                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11300                }
11301                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11302                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11303                }
11304            }
11305
11306            next_offset += envelope_size;
11307            _next_ordinal_to_read += 1;
11308            if next_offset >= end_offset {
11309                return Ok(());
11310            }
11311
11312            // Decode unknown envelopes for gaps in ordinals.
11313            while _next_ordinal_to_read < 3 {
11314                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11315                _next_ordinal_to_read += 1;
11316                next_offset += envelope_size;
11317            }
11318
11319            let next_out_of_line = decoder.next_out_of_line();
11320            let handles_before = decoder.remaining_handles();
11321            if let Some((inlined, num_bytes, num_handles)) =
11322                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11323            {
11324                let member_inline_size =
11325                    <RegisterBufferCollectionUsage as fidl::encoding::TypeMarker>::inline_size(
11326                        decoder.context,
11327                    );
11328                if inlined != (member_inline_size <= 4) {
11329                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11330                }
11331                let inner_offset;
11332                let mut inner_depth = depth.clone();
11333                if inlined {
11334                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11335                    inner_offset = next_offset;
11336                } else {
11337                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11338                    inner_depth.increment()?;
11339                }
11340                let val_ref = self.usage.get_or_insert_with(|| {
11341                    fidl::new_empty!(
11342                        RegisterBufferCollectionUsage,
11343                        fidl::encoding::DefaultFuchsiaResourceDialect
11344                    )
11345                });
11346                fidl::decode!(
11347                    RegisterBufferCollectionUsage,
11348                    fidl::encoding::DefaultFuchsiaResourceDialect,
11349                    val_ref,
11350                    decoder,
11351                    inner_offset,
11352                    inner_depth
11353                )?;
11354                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11355                {
11356                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11357                }
11358                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11359                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11360                }
11361            }
11362
11363            next_offset += envelope_size;
11364            _next_ordinal_to_read += 1;
11365            if next_offset >= end_offset {
11366                return Ok(());
11367            }
11368
11369            // Decode unknown envelopes for gaps in ordinals.
11370            while _next_ordinal_to_read < 4 {
11371                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11372                _next_ordinal_to_read += 1;
11373                next_offset += envelope_size;
11374            }
11375
11376            let next_out_of_line = decoder.next_out_of_line();
11377            let handles_before = decoder.remaining_handles();
11378            if let Some((inlined, num_bytes, num_handles)) =
11379                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11380            {
11381                let member_inline_size =
11382                    <RegisterBufferCollectionUsages as fidl::encoding::TypeMarker>::inline_size(
11383                        decoder.context,
11384                    );
11385                if inlined != (member_inline_size <= 4) {
11386                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11387                }
11388                let inner_offset;
11389                let mut inner_depth = depth.clone();
11390                if inlined {
11391                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11392                    inner_offset = next_offset;
11393                } else {
11394                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11395                    inner_depth.increment()?;
11396                }
11397                let val_ref = self.usages.get_or_insert_with(|| {
11398                    fidl::new_empty!(
11399                        RegisterBufferCollectionUsages,
11400                        fidl::encoding::DefaultFuchsiaResourceDialect
11401                    )
11402                });
11403                fidl::decode!(
11404                    RegisterBufferCollectionUsages,
11405                    fidl::encoding::DefaultFuchsiaResourceDialect,
11406                    val_ref,
11407                    decoder,
11408                    inner_offset,
11409                    inner_depth
11410                )?;
11411                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11412                {
11413                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11414                }
11415                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11416                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11417                }
11418            }
11419
11420            next_offset += envelope_size;
11421            _next_ordinal_to_read += 1;
11422            if next_offset >= end_offset {
11423                return Ok(());
11424            }
11425
11426            // Decode unknown envelopes for gaps in ordinals.
11427            while _next_ordinal_to_read < 5 {
11428                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11429                _next_ordinal_to_read += 1;
11430                next_offset += envelope_size;
11431            }
11432
11433            let next_out_of_line = decoder.next_out_of_line();
11434            let handles_before = decoder.remaining_handles();
11435            if let Some((inlined, num_bytes, num_handles)) =
11436                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11437            {
11438                let member_inline_size = <fidl::encoding::Endpoint<
11439                    fidl::endpoints::ClientEnd<fidl_fuchsia_sysmem2::BufferCollectionTokenMarker>,
11440                > as fidl::encoding::TypeMarker>::inline_size(
11441                    decoder.context
11442                );
11443                if inlined != (member_inline_size <= 4) {
11444                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11445                }
11446                let inner_offset;
11447                let mut inner_depth = depth.clone();
11448                if inlined {
11449                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11450                    inner_offset = next_offset;
11451                } else {
11452                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11453                    inner_depth.increment()?;
11454                }
11455                let val_ref = self.buffer_collection_token2.get_or_insert_with(|| {
11456                    fidl::new_empty!(
11457                        fidl::encoding::Endpoint<
11458                            fidl::endpoints::ClientEnd<
11459                                fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
11460                            >,
11461                        >,
11462                        fidl::encoding::DefaultFuchsiaResourceDialect
11463                    )
11464                });
11465                fidl::decode!(
11466                    fidl::encoding::Endpoint<
11467                        fidl::endpoints::ClientEnd<
11468                            fidl_fuchsia_sysmem2::BufferCollectionTokenMarker,
11469                        >,
11470                    >,
11471                    fidl::encoding::DefaultFuchsiaResourceDialect,
11472                    val_ref,
11473                    decoder,
11474                    inner_offset,
11475                    inner_depth
11476                )?;
11477                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11478                {
11479                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11480                }
11481                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11482                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11483                }
11484            }
11485
11486            next_offset += envelope_size;
11487
11488            // Decode the remaining unknown envelopes.
11489            while next_offset < end_offset {
11490                _next_ordinal_to_read += 1;
11491                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11492                next_offset += envelope_size;
11493            }
11494
11495            Ok(())
11496        }
11497    }
11498
11499    impl ScreenCaptureConfig {
11500        #[inline(always)]
11501        fn max_ordinal_present(&self) -> u64 {
11502            if let Some(_) = self.rotation {
11503                return 4;
11504            }
11505            if let Some(_) = self.buffer_count {
11506                return 3;
11507            }
11508            if let Some(_) = self.size {
11509                return 2;
11510            }
11511            if let Some(_) = self.import_token {
11512                return 1;
11513            }
11514            0
11515        }
11516    }
11517
11518    impl fidl::encoding::ResourceTypeMarker for ScreenCaptureConfig {
11519        type Borrowed<'a> = &'a mut Self;
11520        fn take_or_borrow<'a>(
11521            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11522        ) -> Self::Borrowed<'a> {
11523            value
11524        }
11525    }
11526
11527    unsafe impl fidl::encoding::TypeMarker for ScreenCaptureConfig {
11528        type Owned = Self;
11529
11530        #[inline(always)]
11531        fn inline_align(_context: fidl::encoding::Context) -> usize {
11532            8
11533        }
11534
11535        #[inline(always)]
11536        fn inline_size(_context: fidl::encoding::Context) -> usize {
11537            16
11538        }
11539    }
11540
11541    unsafe impl
11542        fidl::encoding::Encode<ScreenCaptureConfig, fidl::encoding::DefaultFuchsiaResourceDialect>
11543        for &mut ScreenCaptureConfig
11544    {
11545        unsafe fn encode(
11546            self,
11547            encoder: &mut fidl::encoding::Encoder<
11548                '_,
11549                fidl::encoding::DefaultFuchsiaResourceDialect,
11550            >,
11551            offset: usize,
11552            mut depth: fidl::encoding::Depth,
11553        ) -> fidl::Result<()> {
11554            encoder.debug_check_bounds::<ScreenCaptureConfig>(offset);
11555            // Vector header
11556            let max_ordinal: u64 = self.max_ordinal_present();
11557            encoder.write_num(max_ordinal, offset);
11558            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11559            // Calling encoder.out_of_line_offset(0) is not allowed.
11560            if max_ordinal == 0 {
11561                return Ok(());
11562            }
11563            depth.increment()?;
11564            let envelope_size = 8;
11565            let bytes_len = max_ordinal as usize * envelope_size;
11566            #[allow(unused_variables)]
11567            let offset = encoder.out_of_line_offset(bytes_len);
11568            let mut _prev_end_offset: usize = 0;
11569            if 1 > max_ordinal {
11570                return Ok(());
11571            }
11572
11573            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11574            // are envelope_size bytes.
11575            let cur_offset: usize = (1 - 1) * envelope_size;
11576
11577            // Zero reserved fields.
11578            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11579
11580            // Safety:
11581            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11582            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11583            //   envelope_size bytes, there is always sufficient room.
11584            fidl::encoding::encode_in_envelope_optional::<BufferCollectionImportToken, fidl::encoding::DefaultFuchsiaResourceDialect>(
11585            self.import_token.as_mut().map(<BufferCollectionImportToken as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
11586            encoder, offset + cur_offset, depth
11587        )?;
11588
11589            _prev_end_offset = cur_offset + envelope_size;
11590            if 2 > max_ordinal {
11591                return Ok(());
11592            }
11593
11594            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11595            // are envelope_size bytes.
11596            let cur_offset: usize = (2 - 1) * envelope_size;
11597
11598            // Zero reserved fields.
11599            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11600
11601            // Safety:
11602            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11603            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11604            //   envelope_size bytes, there is always sufficient room.
11605            fidl::encoding::encode_in_envelope_optional::<
11606                fidl_fuchsia_math::SizeU,
11607                fidl::encoding::DefaultFuchsiaResourceDialect,
11608            >(
11609                self.size
11610                    .as_ref()
11611                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
11612                encoder,
11613                offset + cur_offset,
11614                depth,
11615            )?;
11616
11617            _prev_end_offset = cur_offset + envelope_size;
11618            if 3 > max_ordinal {
11619                return Ok(());
11620            }
11621
11622            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11623            // are envelope_size bytes.
11624            let cur_offset: usize = (3 - 1) * envelope_size;
11625
11626            // Zero reserved fields.
11627            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11628
11629            // Safety:
11630            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11631            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11632            //   envelope_size bytes, there is always sufficient room.
11633            fidl::encoding::encode_in_envelope_optional::<
11634                u32,
11635                fidl::encoding::DefaultFuchsiaResourceDialect,
11636            >(
11637                self.buffer_count.as_ref().map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
11638                encoder,
11639                offset + cur_offset,
11640                depth,
11641            )?;
11642
11643            _prev_end_offset = cur_offset + envelope_size;
11644            if 4 > max_ordinal {
11645                return Ok(());
11646            }
11647
11648            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
11649            // are envelope_size bytes.
11650            let cur_offset: usize = (4 - 1) * envelope_size;
11651
11652            // Zero reserved fields.
11653            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
11654
11655            // Safety:
11656            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
11657            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
11658            //   envelope_size bytes, there is always sufficient room.
11659            fidl::encoding::encode_in_envelope_optional::<
11660                Rotation,
11661                fidl::encoding::DefaultFuchsiaResourceDialect,
11662            >(
11663                self.rotation.as_ref().map(<Rotation as fidl::encoding::ValueTypeMarker>::borrow),
11664                encoder,
11665                offset + cur_offset,
11666                depth,
11667            )?;
11668
11669            _prev_end_offset = cur_offset + envelope_size;
11670
11671            Ok(())
11672        }
11673    }
11674
11675    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
11676        for ScreenCaptureConfig
11677    {
11678        #[inline(always)]
11679        fn new_empty() -> Self {
11680            Self::default()
11681        }
11682
11683        unsafe fn decode(
11684            &mut self,
11685            decoder: &mut fidl::encoding::Decoder<
11686                '_,
11687                fidl::encoding::DefaultFuchsiaResourceDialect,
11688            >,
11689            offset: usize,
11690            mut depth: fidl::encoding::Depth,
11691        ) -> fidl::Result<()> {
11692            decoder.debug_check_bounds::<Self>(offset);
11693            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
11694                None => return Err(fidl::Error::NotNullable),
11695                Some(len) => len,
11696            };
11697            // Calling decoder.out_of_line_offset(0) is not allowed.
11698            if len == 0 {
11699                return Ok(());
11700            };
11701            depth.increment()?;
11702            let envelope_size = 8;
11703            let bytes_len = len * envelope_size;
11704            let offset = decoder.out_of_line_offset(bytes_len)?;
11705            // Decode the envelope for each type.
11706            let mut _next_ordinal_to_read = 0;
11707            let mut next_offset = offset;
11708            let end_offset = offset + bytes_len;
11709            _next_ordinal_to_read += 1;
11710            if next_offset >= end_offset {
11711                return Ok(());
11712            }
11713
11714            // Decode unknown envelopes for gaps in ordinals.
11715            while _next_ordinal_to_read < 1 {
11716                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11717                _next_ordinal_to_read += 1;
11718                next_offset += envelope_size;
11719            }
11720
11721            let next_out_of_line = decoder.next_out_of_line();
11722            let handles_before = decoder.remaining_handles();
11723            if let Some((inlined, num_bytes, num_handles)) =
11724                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11725            {
11726                let member_inline_size =
11727                    <BufferCollectionImportToken as fidl::encoding::TypeMarker>::inline_size(
11728                        decoder.context,
11729                    );
11730                if inlined != (member_inline_size <= 4) {
11731                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11732                }
11733                let inner_offset;
11734                let mut inner_depth = depth.clone();
11735                if inlined {
11736                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11737                    inner_offset = next_offset;
11738                } else {
11739                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11740                    inner_depth.increment()?;
11741                }
11742                let val_ref = self.import_token.get_or_insert_with(|| {
11743                    fidl::new_empty!(
11744                        BufferCollectionImportToken,
11745                        fidl::encoding::DefaultFuchsiaResourceDialect
11746                    )
11747                });
11748                fidl::decode!(
11749                    BufferCollectionImportToken,
11750                    fidl::encoding::DefaultFuchsiaResourceDialect,
11751                    val_ref,
11752                    decoder,
11753                    inner_offset,
11754                    inner_depth
11755                )?;
11756                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11757                {
11758                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11759                }
11760                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11761                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11762                }
11763            }
11764
11765            next_offset += envelope_size;
11766            _next_ordinal_to_read += 1;
11767            if next_offset >= end_offset {
11768                return Ok(());
11769            }
11770
11771            // Decode unknown envelopes for gaps in ordinals.
11772            while _next_ordinal_to_read < 2 {
11773                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11774                _next_ordinal_to_read += 1;
11775                next_offset += envelope_size;
11776            }
11777
11778            let next_out_of_line = decoder.next_out_of_line();
11779            let handles_before = decoder.remaining_handles();
11780            if let Some((inlined, num_bytes, num_handles)) =
11781                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11782            {
11783                let member_inline_size =
11784                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
11785                        decoder.context,
11786                    );
11787                if inlined != (member_inline_size <= 4) {
11788                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11789                }
11790                let inner_offset;
11791                let mut inner_depth = depth.clone();
11792                if inlined {
11793                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11794                    inner_offset = next_offset;
11795                } else {
11796                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11797                    inner_depth.increment()?;
11798                }
11799                let val_ref = self.size.get_or_insert_with(|| {
11800                    fidl::new_empty!(
11801                        fidl_fuchsia_math::SizeU,
11802                        fidl::encoding::DefaultFuchsiaResourceDialect
11803                    )
11804                });
11805                fidl::decode!(
11806                    fidl_fuchsia_math::SizeU,
11807                    fidl::encoding::DefaultFuchsiaResourceDialect,
11808                    val_ref,
11809                    decoder,
11810                    inner_offset,
11811                    inner_depth
11812                )?;
11813                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11814                {
11815                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11816                }
11817                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11818                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11819                }
11820            }
11821
11822            next_offset += envelope_size;
11823            _next_ordinal_to_read += 1;
11824            if next_offset >= end_offset {
11825                return Ok(());
11826            }
11827
11828            // Decode unknown envelopes for gaps in ordinals.
11829            while _next_ordinal_to_read < 3 {
11830                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11831                _next_ordinal_to_read += 1;
11832                next_offset += envelope_size;
11833            }
11834
11835            let next_out_of_line = decoder.next_out_of_line();
11836            let handles_before = decoder.remaining_handles();
11837            if let Some((inlined, num_bytes, num_handles)) =
11838                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11839            {
11840                let member_inline_size =
11841                    <u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11842                if inlined != (member_inline_size <= 4) {
11843                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11844                }
11845                let inner_offset;
11846                let mut inner_depth = depth.clone();
11847                if inlined {
11848                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11849                    inner_offset = next_offset;
11850                } else {
11851                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11852                    inner_depth.increment()?;
11853                }
11854                let val_ref = self.buffer_count.get_or_insert_with(|| {
11855                    fidl::new_empty!(u32, fidl::encoding::DefaultFuchsiaResourceDialect)
11856                });
11857                fidl::decode!(
11858                    u32,
11859                    fidl::encoding::DefaultFuchsiaResourceDialect,
11860                    val_ref,
11861                    decoder,
11862                    inner_offset,
11863                    inner_depth
11864                )?;
11865                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11866                {
11867                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11868                }
11869                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11870                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11871                }
11872            }
11873
11874            next_offset += envelope_size;
11875            _next_ordinal_to_read += 1;
11876            if next_offset >= end_offset {
11877                return Ok(());
11878            }
11879
11880            // Decode unknown envelopes for gaps in ordinals.
11881            while _next_ordinal_to_read < 4 {
11882                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11883                _next_ordinal_to_read += 1;
11884                next_offset += envelope_size;
11885            }
11886
11887            let next_out_of_line = decoder.next_out_of_line();
11888            let handles_before = decoder.remaining_handles();
11889            if let Some((inlined, num_bytes, num_handles)) =
11890                fidl::encoding::decode_envelope_header(decoder, next_offset)?
11891            {
11892                let member_inline_size =
11893                    <Rotation as fidl::encoding::TypeMarker>::inline_size(decoder.context);
11894                if inlined != (member_inline_size <= 4) {
11895                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
11896                }
11897                let inner_offset;
11898                let mut inner_depth = depth.clone();
11899                if inlined {
11900                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
11901                    inner_offset = next_offset;
11902                } else {
11903                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
11904                    inner_depth.increment()?;
11905                }
11906                let val_ref = self.rotation.get_or_insert_with(|| {
11907                    fidl::new_empty!(Rotation, fidl::encoding::DefaultFuchsiaResourceDialect)
11908                });
11909                fidl::decode!(
11910                    Rotation,
11911                    fidl::encoding::DefaultFuchsiaResourceDialect,
11912                    val_ref,
11913                    decoder,
11914                    inner_offset,
11915                    inner_depth
11916                )?;
11917                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
11918                {
11919                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
11920                }
11921                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
11922                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
11923                }
11924            }
11925
11926            next_offset += envelope_size;
11927
11928            // Decode the remaining unknown envelopes.
11929            while next_offset < end_offset {
11930                _next_ordinal_to_read += 1;
11931                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
11932                next_offset += envelope_size;
11933            }
11934
11935            Ok(())
11936        }
11937    }
11938
11939    impl ScreenshotTakeFileRequest {
11940        #[inline(always)]
11941        fn max_ordinal_present(&self) -> u64 {
11942            if let Some(_) = self.format {
11943                return 1;
11944            }
11945            0
11946        }
11947    }
11948
11949    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileRequest {
11950        type Borrowed<'a> = &'a mut Self;
11951        fn take_or_borrow<'a>(
11952            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
11953        ) -> Self::Borrowed<'a> {
11954            value
11955        }
11956    }
11957
11958    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileRequest {
11959        type Owned = Self;
11960
11961        #[inline(always)]
11962        fn inline_align(_context: fidl::encoding::Context) -> usize {
11963            8
11964        }
11965
11966        #[inline(always)]
11967        fn inline_size(_context: fidl::encoding::Context) -> usize {
11968            16
11969        }
11970    }
11971
11972    unsafe impl
11973        fidl::encoding::Encode<
11974            ScreenshotTakeFileRequest,
11975            fidl::encoding::DefaultFuchsiaResourceDialect,
11976        > for &mut ScreenshotTakeFileRequest
11977    {
11978        unsafe fn encode(
11979            self,
11980            encoder: &mut fidl::encoding::Encoder<
11981                '_,
11982                fidl::encoding::DefaultFuchsiaResourceDialect,
11983            >,
11984            offset: usize,
11985            mut depth: fidl::encoding::Depth,
11986        ) -> fidl::Result<()> {
11987            encoder.debug_check_bounds::<ScreenshotTakeFileRequest>(offset);
11988            // Vector header
11989            let max_ordinal: u64 = self.max_ordinal_present();
11990            encoder.write_num(max_ordinal, offset);
11991            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
11992            // Calling encoder.out_of_line_offset(0) is not allowed.
11993            if max_ordinal == 0 {
11994                return Ok(());
11995            }
11996            depth.increment()?;
11997            let envelope_size = 8;
11998            let bytes_len = max_ordinal as usize * envelope_size;
11999            #[allow(unused_variables)]
12000            let offset = encoder.out_of_line_offset(bytes_len);
12001            let mut _prev_end_offset: usize = 0;
12002            if 1 > max_ordinal {
12003                return Ok(());
12004            }
12005
12006            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12007            // are envelope_size bytes.
12008            let cur_offset: usize = (1 - 1) * envelope_size;
12009
12010            // Zero reserved fields.
12011            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12012
12013            // Safety:
12014            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12015            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12016            //   envelope_size bytes, there is always sufficient room.
12017            fidl::encoding::encode_in_envelope_optional::<
12018                ScreenshotFormat,
12019                fidl::encoding::DefaultFuchsiaResourceDialect,
12020            >(
12021                self.format
12022                    .as_ref()
12023                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
12024                encoder,
12025                offset + cur_offset,
12026                depth,
12027            )?;
12028
12029            _prev_end_offset = cur_offset + envelope_size;
12030
12031            Ok(())
12032        }
12033    }
12034
12035    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12036        for ScreenshotTakeFileRequest
12037    {
12038        #[inline(always)]
12039        fn new_empty() -> Self {
12040            Self::default()
12041        }
12042
12043        unsafe fn decode(
12044            &mut self,
12045            decoder: &mut fidl::encoding::Decoder<
12046                '_,
12047                fidl::encoding::DefaultFuchsiaResourceDialect,
12048            >,
12049            offset: usize,
12050            mut depth: fidl::encoding::Depth,
12051        ) -> fidl::Result<()> {
12052            decoder.debug_check_bounds::<Self>(offset);
12053            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12054                None => return Err(fidl::Error::NotNullable),
12055                Some(len) => len,
12056            };
12057            // Calling decoder.out_of_line_offset(0) is not allowed.
12058            if len == 0 {
12059                return Ok(());
12060            };
12061            depth.increment()?;
12062            let envelope_size = 8;
12063            let bytes_len = len * envelope_size;
12064            let offset = decoder.out_of_line_offset(bytes_len)?;
12065            // Decode the envelope for each type.
12066            let mut _next_ordinal_to_read = 0;
12067            let mut next_offset = offset;
12068            let end_offset = offset + bytes_len;
12069            _next_ordinal_to_read += 1;
12070            if next_offset >= end_offset {
12071                return Ok(());
12072            }
12073
12074            // Decode unknown envelopes for gaps in ordinals.
12075            while _next_ordinal_to_read < 1 {
12076                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12077                _next_ordinal_to_read += 1;
12078                next_offset += envelope_size;
12079            }
12080
12081            let next_out_of_line = decoder.next_out_of_line();
12082            let handles_before = decoder.remaining_handles();
12083            if let Some((inlined, num_bytes, num_handles)) =
12084                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12085            {
12086                let member_inline_size =
12087                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12088                if inlined != (member_inline_size <= 4) {
12089                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12090                }
12091                let inner_offset;
12092                let mut inner_depth = depth.clone();
12093                if inlined {
12094                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12095                    inner_offset = next_offset;
12096                } else {
12097                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12098                    inner_depth.increment()?;
12099                }
12100                let val_ref = self.format.get_or_insert_with(|| {
12101                    fidl::new_empty!(
12102                        ScreenshotFormat,
12103                        fidl::encoding::DefaultFuchsiaResourceDialect
12104                    )
12105                });
12106                fidl::decode!(
12107                    ScreenshotFormat,
12108                    fidl::encoding::DefaultFuchsiaResourceDialect,
12109                    val_ref,
12110                    decoder,
12111                    inner_offset,
12112                    inner_depth
12113                )?;
12114                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12115                {
12116                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12117                }
12118                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12119                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12120                }
12121            }
12122
12123            next_offset += envelope_size;
12124
12125            // Decode the remaining unknown envelopes.
12126            while next_offset < end_offset {
12127                _next_ordinal_to_read += 1;
12128                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12129                next_offset += envelope_size;
12130            }
12131
12132            Ok(())
12133        }
12134    }
12135
12136    impl ScreenshotTakeFileResponse {
12137        #[inline(always)]
12138        fn max_ordinal_present(&self) -> u64 {
12139            if let Some(_) = self.size {
12140                return 2;
12141            }
12142            if let Some(_) = self.file {
12143                return 1;
12144            }
12145            0
12146        }
12147    }
12148
12149    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeFileResponse {
12150        type Borrowed<'a> = &'a mut Self;
12151        fn take_or_borrow<'a>(
12152            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12153        ) -> Self::Borrowed<'a> {
12154            value
12155        }
12156    }
12157
12158    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeFileResponse {
12159        type Owned = Self;
12160
12161        #[inline(always)]
12162        fn inline_align(_context: fidl::encoding::Context) -> usize {
12163            8
12164        }
12165
12166        #[inline(always)]
12167        fn inline_size(_context: fidl::encoding::Context) -> usize {
12168            16
12169        }
12170    }
12171
12172    unsafe impl
12173        fidl::encoding::Encode<
12174            ScreenshotTakeFileResponse,
12175            fidl::encoding::DefaultFuchsiaResourceDialect,
12176        > for &mut ScreenshotTakeFileResponse
12177    {
12178        unsafe fn encode(
12179            self,
12180            encoder: &mut fidl::encoding::Encoder<
12181                '_,
12182                fidl::encoding::DefaultFuchsiaResourceDialect,
12183            >,
12184            offset: usize,
12185            mut depth: fidl::encoding::Depth,
12186        ) -> fidl::Result<()> {
12187            encoder.debug_check_bounds::<ScreenshotTakeFileResponse>(offset);
12188            // Vector header
12189            let max_ordinal: u64 = self.max_ordinal_present();
12190            encoder.write_num(max_ordinal, offset);
12191            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12192            // Calling encoder.out_of_line_offset(0) is not allowed.
12193            if max_ordinal == 0 {
12194                return Ok(());
12195            }
12196            depth.increment()?;
12197            let envelope_size = 8;
12198            let bytes_len = max_ordinal as usize * envelope_size;
12199            #[allow(unused_variables)]
12200            let offset = encoder.out_of_line_offset(bytes_len);
12201            let mut _prev_end_offset: usize = 0;
12202            if 1 > max_ordinal {
12203                return Ok(());
12204            }
12205
12206            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12207            // are envelope_size bytes.
12208            let cur_offset: usize = (1 - 1) * envelope_size;
12209
12210            // Zero reserved fields.
12211            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12212
12213            // Safety:
12214            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12215            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12216            //   envelope_size bytes, there is always sufficient room.
12217            fidl::encoding::encode_in_envelope_optional::<
12218                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>>,
12219                fidl::encoding::DefaultFuchsiaResourceDialect,
12220            >(
12221                self.file.as_mut().map(
12222                    <fidl::encoding::Endpoint<
12223                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12224                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12225                ),
12226                encoder,
12227                offset + cur_offset,
12228                depth,
12229            )?;
12230
12231            _prev_end_offset = cur_offset + envelope_size;
12232            if 2 > max_ordinal {
12233                return Ok(());
12234            }
12235
12236            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12237            // are envelope_size bytes.
12238            let cur_offset: usize = (2 - 1) * envelope_size;
12239
12240            // Zero reserved fields.
12241            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12242
12243            // Safety:
12244            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12245            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12246            //   envelope_size bytes, there is always sufficient room.
12247            fidl::encoding::encode_in_envelope_optional::<
12248                fidl_fuchsia_math::SizeU,
12249                fidl::encoding::DefaultFuchsiaResourceDialect,
12250            >(
12251                self.size
12252                    .as_ref()
12253                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
12254                encoder,
12255                offset + cur_offset,
12256                depth,
12257            )?;
12258
12259            _prev_end_offset = cur_offset + envelope_size;
12260
12261            Ok(())
12262        }
12263    }
12264
12265    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12266        for ScreenshotTakeFileResponse
12267    {
12268        #[inline(always)]
12269        fn new_empty() -> Self {
12270            Self::default()
12271        }
12272
12273        unsafe fn decode(
12274            &mut self,
12275            decoder: &mut fidl::encoding::Decoder<
12276                '_,
12277                fidl::encoding::DefaultFuchsiaResourceDialect,
12278            >,
12279            offset: usize,
12280            mut depth: fidl::encoding::Depth,
12281        ) -> fidl::Result<()> {
12282            decoder.debug_check_bounds::<Self>(offset);
12283            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12284                None => return Err(fidl::Error::NotNullable),
12285                Some(len) => len,
12286            };
12287            // Calling decoder.out_of_line_offset(0) is not allowed.
12288            if len == 0 {
12289                return Ok(());
12290            };
12291            depth.increment()?;
12292            let envelope_size = 8;
12293            let bytes_len = len * envelope_size;
12294            let offset = decoder.out_of_line_offset(bytes_len)?;
12295            // Decode the envelope for each type.
12296            let mut _next_ordinal_to_read = 0;
12297            let mut next_offset = offset;
12298            let end_offset = offset + bytes_len;
12299            _next_ordinal_to_read += 1;
12300            if next_offset >= end_offset {
12301                return Ok(());
12302            }
12303
12304            // Decode unknown envelopes for gaps in ordinals.
12305            while _next_ordinal_to_read < 1 {
12306                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12307                _next_ordinal_to_read += 1;
12308                next_offset += envelope_size;
12309            }
12310
12311            let next_out_of_line = decoder.next_out_of_line();
12312            let handles_before = decoder.remaining_handles();
12313            if let Some((inlined, num_bytes, num_handles)) =
12314                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12315            {
12316                let member_inline_size = <fidl::encoding::Endpoint<
12317                    fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12318                > as fidl::encoding::TypeMarker>::inline_size(
12319                    decoder.context
12320                );
12321                if inlined != (member_inline_size <= 4) {
12322                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12323                }
12324                let inner_offset;
12325                let mut inner_depth = depth.clone();
12326                if inlined {
12327                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12328                    inner_offset = next_offset;
12329                } else {
12330                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12331                    inner_depth.increment()?;
12332                }
12333                let val_ref = self.file.get_or_insert_with(|| {
12334                    fidl::new_empty!(
12335                        fidl::encoding::Endpoint<
12336                            fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12337                        >,
12338                        fidl::encoding::DefaultFuchsiaResourceDialect
12339                    )
12340                });
12341                fidl::decode!(
12342                    fidl::encoding::Endpoint<
12343                        fidl::endpoints::ClientEnd<fidl_fuchsia_io::FileMarker>,
12344                    >,
12345                    fidl::encoding::DefaultFuchsiaResourceDialect,
12346                    val_ref,
12347                    decoder,
12348                    inner_offset,
12349                    inner_depth
12350                )?;
12351                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12352                {
12353                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12354                }
12355                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12356                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12357                }
12358            }
12359
12360            next_offset += envelope_size;
12361            _next_ordinal_to_read += 1;
12362            if next_offset >= end_offset {
12363                return Ok(());
12364            }
12365
12366            // Decode unknown envelopes for gaps in ordinals.
12367            while _next_ordinal_to_read < 2 {
12368                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12369                _next_ordinal_to_read += 1;
12370                next_offset += envelope_size;
12371            }
12372
12373            let next_out_of_line = decoder.next_out_of_line();
12374            let handles_before = decoder.remaining_handles();
12375            if let Some((inlined, num_bytes, num_handles)) =
12376                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12377            {
12378                let member_inline_size =
12379                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
12380                        decoder.context,
12381                    );
12382                if inlined != (member_inline_size <= 4) {
12383                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12384                }
12385                let inner_offset;
12386                let mut inner_depth = depth.clone();
12387                if inlined {
12388                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12389                    inner_offset = next_offset;
12390                } else {
12391                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12392                    inner_depth.increment()?;
12393                }
12394                let val_ref = self.size.get_or_insert_with(|| {
12395                    fidl::new_empty!(
12396                        fidl_fuchsia_math::SizeU,
12397                        fidl::encoding::DefaultFuchsiaResourceDialect
12398                    )
12399                });
12400                fidl::decode!(
12401                    fidl_fuchsia_math::SizeU,
12402                    fidl::encoding::DefaultFuchsiaResourceDialect,
12403                    val_ref,
12404                    decoder,
12405                    inner_offset,
12406                    inner_depth
12407                )?;
12408                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12409                {
12410                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12411                }
12412                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12413                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12414                }
12415            }
12416
12417            next_offset += envelope_size;
12418
12419            // Decode the remaining unknown envelopes.
12420            while next_offset < end_offset {
12421                _next_ordinal_to_read += 1;
12422                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12423                next_offset += envelope_size;
12424            }
12425
12426            Ok(())
12427        }
12428    }
12429
12430    impl ScreenshotTakeRequest {
12431        #[inline(always)]
12432        fn max_ordinal_present(&self) -> u64 {
12433            if let Some(_) = self.format {
12434                return 1;
12435            }
12436            0
12437        }
12438    }
12439
12440    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeRequest {
12441        type Borrowed<'a> = &'a mut Self;
12442        fn take_or_borrow<'a>(
12443            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12444        ) -> Self::Borrowed<'a> {
12445            value
12446        }
12447    }
12448
12449    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeRequest {
12450        type Owned = Self;
12451
12452        #[inline(always)]
12453        fn inline_align(_context: fidl::encoding::Context) -> usize {
12454            8
12455        }
12456
12457        #[inline(always)]
12458        fn inline_size(_context: fidl::encoding::Context) -> usize {
12459            16
12460        }
12461    }
12462
12463    unsafe impl
12464        fidl::encoding::Encode<ScreenshotTakeRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
12465        for &mut ScreenshotTakeRequest
12466    {
12467        unsafe fn encode(
12468            self,
12469            encoder: &mut fidl::encoding::Encoder<
12470                '_,
12471                fidl::encoding::DefaultFuchsiaResourceDialect,
12472            >,
12473            offset: usize,
12474            mut depth: fidl::encoding::Depth,
12475        ) -> fidl::Result<()> {
12476            encoder.debug_check_bounds::<ScreenshotTakeRequest>(offset);
12477            // Vector header
12478            let max_ordinal: u64 = self.max_ordinal_present();
12479            encoder.write_num(max_ordinal, offset);
12480            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12481            // Calling encoder.out_of_line_offset(0) is not allowed.
12482            if max_ordinal == 0 {
12483                return Ok(());
12484            }
12485            depth.increment()?;
12486            let envelope_size = 8;
12487            let bytes_len = max_ordinal as usize * envelope_size;
12488            #[allow(unused_variables)]
12489            let offset = encoder.out_of_line_offset(bytes_len);
12490            let mut _prev_end_offset: usize = 0;
12491            if 1 > max_ordinal {
12492                return Ok(());
12493            }
12494
12495            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12496            // are envelope_size bytes.
12497            let cur_offset: usize = (1 - 1) * envelope_size;
12498
12499            // Zero reserved fields.
12500            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12501
12502            // Safety:
12503            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12504            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12505            //   envelope_size bytes, there is always sufficient room.
12506            fidl::encoding::encode_in_envelope_optional::<
12507                ScreenshotFormat,
12508                fidl::encoding::DefaultFuchsiaResourceDialect,
12509            >(
12510                self.format
12511                    .as_ref()
12512                    .map(<ScreenshotFormat as fidl::encoding::ValueTypeMarker>::borrow),
12513                encoder,
12514                offset + cur_offset,
12515                depth,
12516            )?;
12517
12518            _prev_end_offset = cur_offset + envelope_size;
12519
12520            Ok(())
12521        }
12522    }
12523
12524    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12525        for ScreenshotTakeRequest
12526    {
12527        #[inline(always)]
12528        fn new_empty() -> Self {
12529            Self::default()
12530        }
12531
12532        unsafe fn decode(
12533            &mut self,
12534            decoder: &mut fidl::encoding::Decoder<
12535                '_,
12536                fidl::encoding::DefaultFuchsiaResourceDialect,
12537            >,
12538            offset: usize,
12539            mut depth: fidl::encoding::Depth,
12540        ) -> fidl::Result<()> {
12541            decoder.debug_check_bounds::<Self>(offset);
12542            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12543                None => return Err(fidl::Error::NotNullable),
12544                Some(len) => len,
12545            };
12546            // Calling decoder.out_of_line_offset(0) is not allowed.
12547            if len == 0 {
12548                return Ok(());
12549            };
12550            depth.increment()?;
12551            let envelope_size = 8;
12552            let bytes_len = len * envelope_size;
12553            let offset = decoder.out_of_line_offset(bytes_len)?;
12554            // Decode the envelope for each type.
12555            let mut _next_ordinal_to_read = 0;
12556            let mut next_offset = offset;
12557            let end_offset = offset + bytes_len;
12558            _next_ordinal_to_read += 1;
12559            if next_offset >= end_offset {
12560                return Ok(());
12561            }
12562
12563            // Decode unknown envelopes for gaps in ordinals.
12564            while _next_ordinal_to_read < 1 {
12565                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12566                _next_ordinal_to_read += 1;
12567                next_offset += envelope_size;
12568            }
12569
12570            let next_out_of_line = decoder.next_out_of_line();
12571            let handles_before = decoder.remaining_handles();
12572            if let Some((inlined, num_bytes, num_handles)) =
12573                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12574            {
12575                let member_inline_size =
12576                    <ScreenshotFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context);
12577                if inlined != (member_inline_size <= 4) {
12578                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12579                }
12580                let inner_offset;
12581                let mut inner_depth = depth.clone();
12582                if inlined {
12583                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12584                    inner_offset = next_offset;
12585                } else {
12586                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12587                    inner_depth.increment()?;
12588                }
12589                let val_ref = self.format.get_or_insert_with(|| {
12590                    fidl::new_empty!(
12591                        ScreenshotFormat,
12592                        fidl::encoding::DefaultFuchsiaResourceDialect
12593                    )
12594                });
12595                fidl::decode!(
12596                    ScreenshotFormat,
12597                    fidl::encoding::DefaultFuchsiaResourceDialect,
12598                    val_ref,
12599                    decoder,
12600                    inner_offset,
12601                    inner_depth
12602                )?;
12603                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12604                {
12605                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12606                }
12607                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12608                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12609                }
12610            }
12611
12612            next_offset += envelope_size;
12613
12614            // Decode the remaining unknown envelopes.
12615            while next_offset < end_offset {
12616                _next_ordinal_to_read += 1;
12617                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12618                next_offset += envelope_size;
12619            }
12620
12621            Ok(())
12622        }
12623    }
12624
12625    impl ScreenshotTakeResponse {
12626        #[inline(always)]
12627        fn max_ordinal_present(&self) -> u64 {
12628            if let Some(_) = self.size {
12629                return 2;
12630            }
12631            if let Some(_) = self.vmo {
12632                return 1;
12633            }
12634            0
12635        }
12636    }
12637
12638    impl fidl::encoding::ResourceTypeMarker for ScreenshotTakeResponse {
12639        type Borrowed<'a> = &'a mut Self;
12640        fn take_or_borrow<'a>(
12641            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12642        ) -> Self::Borrowed<'a> {
12643            value
12644        }
12645    }
12646
12647    unsafe impl fidl::encoding::TypeMarker for ScreenshotTakeResponse {
12648        type Owned = Self;
12649
12650        #[inline(always)]
12651        fn inline_align(_context: fidl::encoding::Context) -> usize {
12652            8
12653        }
12654
12655        #[inline(always)]
12656        fn inline_size(_context: fidl::encoding::Context) -> usize {
12657            16
12658        }
12659    }
12660
12661    unsafe impl
12662        fidl::encoding::Encode<
12663            ScreenshotTakeResponse,
12664            fidl::encoding::DefaultFuchsiaResourceDialect,
12665        > for &mut ScreenshotTakeResponse
12666    {
12667        unsafe fn encode(
12668            self,
12669            encoder: &mut fidl::encoding::Encoder<
12670                '_,
12671                fidl::encoding::DefaultFuchsiaResourceDialect,
12672            >,
12673            offset: usize,
12674            mut depth: fidl::encoding::Depth,
12675        ) -> fidl::Result<()> {
12676            encoder.debug_check_bounds::<ScreenshotTakeResponse>(offset);
12677            // Vector header
12678            let max_ordinal: u64 = self.max_ordinal_present();
12679            encoder.write_num(max_ordinal, offset);
12680            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12681            // Calling encoder.out_of_line_offset(0) is not allowed.
12682            if max_ordinal == 0 {
12683                return Ok(());
12684            }
12685            depth.increment()?;
12686            let envelope_size = 8;
12687            let bytes_len = max_ordinal as usize * envelope_size;
12688            #[allow(unused_variables)]
12689            let offset = encoder.out_of_line_offset(bytes_len);
12690            let mut _prev_end_offset: usize = 0;
12691            if 1 > max_ordinal {
12692                return Ok(());
12693            }
12694
12695            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12696            // are envelope_size bytes.
12697            let cur_offset: usize = (1 - 1) * envelope_size;
12698
12699            // Zero reserved fields.
12700            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12701
12702            // Safety:
12703            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12704            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12705            //   envelope_size bytes, there is always sufficient room.
12706            fidl::encoding::encode_in_envelope_optional::<
12707                fidl::encoding::HandleType<
12708                    fidl::Vmo,
12709                    { fidl::ObjectType::VMO.into_raw() },
12710                    2147483648,
12711                >,
12712                fidl::encoding::DefaultFuchsiaResourceDialect,
12713            >(
12714                self.vmo.as_mut().map(
12715                    <fidl::encoding::HandleType<
12716                        fidl::Vmo,
12717                        { fidl::ObjectType::VMO.into_raw() },
12718                        2147483648,
12719                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
12720                ),
12721                encoder,
12722                offset + cur_offset,
12723                depth,
12724            )?;
12725
12726            _prev_end_offset = cur_offset + envelope_size;
12727            if 2 > max_ordinal {
12728                return Ok(());
12729            }
12730
12731            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12732            // are envelope_size bytes.
12733            let cur_offset: usize = (2 - 1) * envelope_size;
12734
12735            // Zero reserved fields.
12736            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12737
12738            // Safety:
12739            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12740            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12741            //   envelope_size bytes, there is always sufficient room.
12742            fidl::encoding::encode_in_envelope_optional::<
12743                fidl_fuchsia_math::SizeU,
12744                fidl::encoding::DefaultFuchsiaResourceDialect,
12745            >(
12746                self.size
12747                    .as_ref()
12748                    .map(<fidl_fuchsia_math::SizeU as fidl::encoding::ValueTypeMarker>::borrow),
12749                encoder,
12750                offset + cur_offset,
12751                depth,
12752            )?;
12753
12754            _prev_end_offset = cur_offset + envelope_size;
12755
12756            Ok(())
12757        }
12758    }
12759
12760    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
12761        for ScreenshotTakeResponse
12762    {
12763        #[inline(always)]
12764        fn new_empty() -> Self {
12765            Self::default()
12766        }
12767
12768        unsafe fn decode(
12769            &mut self,
12770            decoder: &mut fidl::encoding::Decoder<
12771                '_,
12772                fidl::encoding::DefaultFuchsiaResourceDialect,
12773            >,
12774            offset: usize,
12775            mut depth: fidl::encoding::Depth,
12776        ) -> fidl::Result<()> {
12777            decoder.debug_check_bounds::<Self>(offset);
12778            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
12779                None => return Err(fidl::Error::NotNullable),
12780                Some(len) => len,
12781            };
12782            // Calling decoder.out_of_line_offset(0) is not allowed.
12783            if len == 0 {
12784                return Ok(());
12785            };
12786            depth.increment()?;
12787            let envelope_size = 8;
12788            let bytes_len = len * envelope_size;
12789            let offset = decoder.out_of_line_offset(bytes_len)?;
12790            // Decode the envelope for each type.
12791            let mut _next_ordinal_to_read = 0;
12792            let mut next_offset = offset;
12793            let end_offset = offset + bytes_len;
12794            _next_ordinal_to_read += 1;
12795            if next_offset >= end_offset {
12796                return Ok(());
12797            }
12798
12799            // Decode unknown envelopes for gaps in ordinals.
12800            while _next_ordinal_to_read < 1 {
12801                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12802                _next_ordinal_to_read += 1;
12803                next_offset += envelope_size;
12804            }
12805
12806            let next_out_of_line = decoder.next_out_of_line();
12807            let handles_before = decoder.remaining_handles();
12808            if let Some((inlined, num_bytes, num_handles)) =
12809                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12810            {
12811                let member_inline_size = <fidl::encoding::HandleType<
12812                    fidl::Vmo,
12813                    { fidl::ObjectType::VMO.into_raw() },
12814                    2147483648,
12815                > as fidl::encoding::TypeMarker>::inline_size(
12816                    decoder.context
12817                );
12818                if inlined != (member_inline_size <= 4) {
12819                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12820                }
12821                let inner_offset;
12822                let mut inner_depth = depth.clone();
12823                if inlined {
12824                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12825                    inner_offset = next_offset;
12826                } else {
12827                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12828                    inner_depth.increment()?;
12829                }
12830                let val_ref =
12831                self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
12832                fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
12833                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12834                {
12835                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12836                }
12837                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12838                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12839                }
12840            }
12841
12842            next_offset += envelope_size;
12843            _next_ordinal_to_read += 1;
12844            if next_offset >= end_offset {
12845                return Ok(());
12846            }
12847
12848            // Decode unknown envelopes for gaps in ordinals.
12849            while _next_ordinal_to_read < 2 {
12850                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12851                _next_ordinal_to_read += 1;
12852                next_offset += envelope_size;
12853            }
12854
12855            let next_out_of_line = decoder.next_out_of_line();
12856            let handles_before = decoder.remaining_handles();
12857            if let Some((inlined, num_bytes, num_handles)) =
12858                fidl::encoding::decode_envelope_header(decoder, next_offset)?
12859            {
12860                let member_inline_size =
12861                    <fidl_fuchsia_math::SizeU as fidl::encoding::TypeMarker>::inline_size(
12862                        decoder.context,
12863                    );
12864                if inlined != (member_inline_size <= 4) {
12865                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
12866                }
12867                let inner_offset;
12868                let mut inner_depth = depth.clone();
12869                if inlined {
12870                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
12871                    inner_offset = next_offset;
12872                } else {
12873                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
12874                    inner_depth.increment()?;
12875                }
12876                let val_ref = self.size.get_or_insert_with(|| {
12877                    fidl::new_empty!(
12878                        fidl_fuchsia_math::SizeU,
12879                        fidl::encoding::DefaultFuchsiaResourceDialect
12880                    )
12881                });
12882                fidl::decode!(
12883                    fidl_fuchsia_math::SizeU,
12884                    fidl::encoding::DefaultFuchsiaResourceDialect,
12885                    val_ref,
12886                    decoder,
12887                    inner_offset,
12888                    inner_depth
12889                )?;
12890                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
12891                {
12892                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
12893                }
12894                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
12895                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
12896                }
12897            }
12898
12899            next_offset += envelope_size;
12900
12901            // Decode the remaining unknown envelopes.
12902            while next_offset < end_offset {
12903                _next_ordinal_to_read += 1;
12904                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
12905                next_offset += envelope_size;
12906            }
12907
12908            Ok(())
12909        }
12910    }
12911
12912    impl ViewBoundProtocols {
12913        #[inline(always)]
12914        fn max_ordinal_present(&self) -> u64 {
12915            if let Some(_) = self.mouse_source {
12916                return 4;
12917            }
12918            if let Some(_) = self.touch_source {
12919                return 3;
12920            }
12921            if let Some(_) = self.view_focuser {
12922                return 2;
12923            }
12924            if let Some(_) = self.view_ref_focused {
12925                return 1;
12926            }
12927            0
12928        }
12929    }
12930
12931    impl fidl::encoding::ResourceTypeMarker for ViewBoundProtocols {
12932        type Borrowed<'a> = &'a mut Self;
12933        fn take_or_borrow<'a>(
12934            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
12935        ) -> Self::Borrowed<'a> {
12936            value
12937        }
12938    }
12939
12940    unsafe impl fidl::encoding::TypeMarker for ViewBoundProtocols {
12941        type Owned = Self;
12942
12943        #[inline(always)]
12944        fn inline_align(_context: fidl::encoding::Context) -> usize {
12945            8
12946        }
12947
12948        #[inline(always)]
12949        fn inline_size(_context: fidl::encoding::Context) -> usize {
12950            16
12951        }
12952    }
12953
12954    unsafe impl
12955        fidl::encoding::Encode<ViewBoundProtocols, fidl::encoding::DefaultFuchsiaResourceDialect>
12956        for &mut ViewBoundProtocols
12957    {
12958        unsafe fn encode(
12959            self,
12960            encoder: &mut fidl::encoding::Encoder<
12961                '_,
12962                fidl::encoding::DefaultFuchsiaResourceDialect,
12963            >,
12964            offset: usize,
12965            mut depth: fidl::encoding::Depth,
12966        ) -> fidl::Result<()> {
12967            encoder.debug_check_bounds::<ViewBoundProtocols>(offset);
12968            // Vector header
12969            let max_ordinal: u64 = self.max_ordinal_present();
12970            encoder.write_num(max_ordinal, offset);
12971            encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
12972            // Calling encoder.out_of_line_offset(0) is not allowed.
12973            if max_ordinal == 0 {
12974                return Ok(());
12975            }
12976            depth.increment()?;
12977            let envelope_size = 8;
12978            let bytes_len = max_ordinal as usize * envelope_size;
12979            #[allow(unused_variables)]
12980            let offset = encoder.out_of_line_offset(bytes_len);
12981            let mut _prev_end_offset: usize = 0;
12982            if 1 > max_ordinal {
12983                return Ok(());
12984            }
12985
12986            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
12987            // are envelope_size bytes.
12988            let cur_offset: usize = (1 - 1) * envelope_size;
12989
12990            // Zero reserved fields.
12991            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
12992
12993            // Safety:
12994            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
12995            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
12996            //   envelope_size bytes, there is always sufficient room.
12997            fidl::encoding::encode_in_envelope_optional::<
12998                fidl::encoding::Endpoint<
12999                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
13000                >,
13001                fidl::encoding::DefaultFuchsiaResourceDialect,
13002            >(
13003                self.view_ref_focused.as_mut().map(
13004                    <fidl::encoding::Endpoint<
13005                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
13006                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13007                ),
13008                encoder,
13009                offset + cur_offset,
13010                depth,
13011            )?;
13012
13013            _prev_end_offset = cur_offset + envelope_size;
13014            if 2 > max_ordinal {
13015                return Ok(());
13016            }
13017
13018            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13019            // are envelope_size bytes.
13020            let cur_offset: usize = (2 - 1) * envelope_size;
13021
13022            // Zero reserved fields.
13023            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13024
13025            // Safety:
13026            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13027            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13028            //   envelope_size bytes, there is always sufficient room.
13029            fidl::encoding::encode_in_envelope_optional::<
13030                fidl::encoding::Endpoint<
13031                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
13032                >,
13033                fidl::encoding::DefaultFuchsiaResourceDialect,
13034            >(
13035                self.view_focuser.as_mut().map(
13036                    <fidl::encoding::Endpoint<
13037                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
13038                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13039                ),
13040                encoder,
13041                offset + cur_offset,
13042                depth,
13043            )?;
13044
13045            _prev_end_offset = cur_offset + envelope_size;
13046            if 3 > max_ordinal {
13047                return Ok(());
13048            }
13049
13050            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13051            // are envelope_size bytes.
13052            let cur_offset: usize = (3 - 1) * envelope_size;
13053
13054            // Zero reserved fields.
13055            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13056
13057            // Safety:
13058            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13059            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13060            //   envelope_size bytes, there is always sufficient room.
13061            fidl::encoding::encode_in_envelope_optional::<
13062                fidl::encoding::Endpoint<
13063                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
13064                >,
13065                fidl::encoding::DefaultFuchsiaResourceDialect,
13066            >(
13067                self.touch_source.as_mut().map(
13068                    <fidl::encoding::Endpoint<
13069                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
13070                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13071                ),
13072                encoder,
13073                offset + cur_offset,
13074                depth,
13075            )?;
13076
13077            _prev_end_offset = cur_offset + envelope_size;
13078            if 4 > max_ordinal {
13079                return Ok(());
13080            }
13081
13082            // Write at offset+(ordinal-1)*envelope_size, since ordinals are one-based and envelopes
13083            // are envelope_size bytes.
13084            let cur_offset: usize = (4 - 1) * envelope_size;
13085
13086            // Zero reserved fields.
13087            encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
13088
13089            // Safety:
13090            // - bytes_len is calculated to fit envelope_size*max(member.ordinal).
13091            // - Since cur_offset is envelope_size*(member.ordinal - 1) and the envelope takes
13092            //   envelope_size bytes, there is always sufficient room.
13093            fidl::encoding::encode_in_envelope_optional::<
13094                fidl::encoding::Endpoint<
13095                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
13096                >,
13097                fidl::encoding::DefaultFuchsiaResourceDialect,
13098            >(
13099                self.mouse_source.as_mut().map(
13100                    <fidl::encoding::Endpoint<
13101                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
13102                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
13103                ),
13104                encoder,
13105                offset + cur_offset,
13106                depth,
13107            )?;
13108
13109            _prev_end_offset = cur_offset + envelope_size;
13110
13111            Ok(())
13112        }
13113    }
13114
13115    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
13116        for ViewBoundProtocols
13117    {
13118        #[inline(always)]
13119        fn new_empty() -> Self {
13120            Self::default()
13121        }
13122
13123        unsafe fn decode(
13124            &mut self,
13125            decoder: &mut fidl::encoding::Decoder<
13126                '_,
13127                fidl::encoding::DefaultFuchsiaResourceDialect,
13128            >,
13129            offset: usize,
13130            mut depth: fidl::encoding::Depth,
13131        ) -> fidl::Result<()> {
13132            decoder.debug_check_bounds::<Self>(offset);
13133            let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
13134                None => return Err(fidl::Error::NotNullable),
13135                Some(len) => len,
13136            };
13137            // Calling decoder.out_of_line_offset(0) is not allowed.
13138            if len == 0 {
13139                return Ok(());
13140            };
13141            depth.increment()?;
13142            let envelope_size = 8;
13143            let bytes_len = len * envelope_size;
13144            let offset = decoder.out_of_line_offset(bytes_len)?;
13145            // Decode the envelope for each type.
13146            let mut _next_ordinal_to_read = 0;
13147            let mut next_offset = offset;
13148            let end_offset = offset + bytes_len;
13149            _next_ordinal_to_read += 1;
13150            if next_offset >= end_offset {
13151                return Ok(());
13152            }
13153
13154            // Decode unknown envelopes for gaps in ordinals.
13155            while _next_ordinal_to_read < 1 {
13156                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13157                _next_ordinal_to_read += 1;
13158                next_offset += envelope_size;
13159            }
13160
13161            let next_out_of_line = decoder.next_out_of_line();
13162            let handles_before = decoder.remaining_handles();
13163            if let Some((inlined, num_bytes, num_handles)) =
13164                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13165            {
13166                let member_inline_size = <fidl::encoding::Endpoint<
13167                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
13168                > as fidl::encoding::TypeMarker>::inline_size(
13169                    decoder.context
13170                );
13171                if inlined != (member_inline_size <= 4) {
13172                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13173                }
13174                let inner_offset;
13175                let mut inner_depth = depth.clone();
13176                if inlined {
13177                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13178                    inner_offset = next_offset;
13179                } else {
13180                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13181                    inner_depth.increment()?;
13182                }
13183                let val_ref = self.view_ref_focused.get_or_insert_with(|| {
13184                    fidl::new_empty!(
13185                        fidl::encoding::Endpoint<
13186                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
13187                        >,
13188                        fidl::encoding::DefaultFuchsiaResourceDialect
13189                    )
13190                });
13191                fidl::decode!(
13192                    fidl::encoding::Endpoint<
13193                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::ViewRefFocusedMarker>,
13194                    >,
13195                    fidl::encoding::DefaultFuchsiaResourceDialect,
13196                    val_ref,
13197                    decoder,
13198                    inner_offset,
13199                    inner_depth
13200                )?;
13201                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13202                {
13203                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13204                }
13205                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13206                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13207                }
13208            }
13209
13210            next_offset += envelope_size;
13211            _next_ordinal_to_read += 1;
13212            if next_offset >= end_offset {
13213                return Ok(());
13214            }
13215
13216            // Decode unknown envelopes for gaps in ordinals.
13217            while _next_ordinal_to_read < 2 {
13218                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13219                _next_ordinal_to_read += 1;
13220                next_offset += envelope_size;
13221            }
13222
13223            let next_out_of_line = decoder.next_out_of_line();
13224            let handles_before = decoder.remaining_handles();
13225            if let Some((inlined, num_bytes, num_handles)) =
13226                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13227            {
13228                let member_inline_size = <fidl::encoding::Endpoint<
13229                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
13230                > as fidl::encoding::TypeMarker>::inline_size(
13231                    decoder.context
13232                );
13233                if inlined != (member_inline_size <= 4) {
13234                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13235                }
13236                let inner_offset;
13237                let mut inner_depth = depth.clone();
13238                if inlined {
13239                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13240                    inner_offset = next_offset;
13241                } else {
13242                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13243                    inner_depth.increment()?;
13244                }
13245                let val_ref = self.view_focuser.get_or_insert_with(|| {
13246                    fidl::new_empty!(
13247                        fidl::encoding::Endpoint<
13248                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
13249                        >,
13250                        fidl::encoding::DefaultFuchsiaResourceDialect
13251                    )
13252                });
13253                fidl::decode!(
13254                    fidl::encoding::Endpoint<
13255                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_views::FocuserMarker>,
13256                    >,
13257                    fidl::encoding::DefaultFuchsiaResourceDialect,
13258                    val_ref,
13259                    decoder,
13260                    inner_offset,
13261                    inner_depth
13262                )?;
13263                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13264                {
13265                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13266                }
13267                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13268                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13269                }
13270            }
13271
13272            next_offset += envelope_size;
13273            _next_ordinal_to_read += 1;
13274            if next_offset >= end_offset {
13275                return Ok(());
13276            }
13277
13278            // Decode unknown envelopes for gaps in ordinals.
13279            while _next_ordinal_to_read < 3 {
13280                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13281                _next_ordinal_to_read += 1;
13282                next_offset += envelope_size;
13283            }
13284
13285            let next_out_of_line = decoder.next_out_of_line();
13286            let handles_before = decoder.remaining_handles();
13287            if let Some((inlined, num_bytes, num_handles)) =
13288                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13289            {
13290                let member_inline_size = <fidl::encoding::Endpoint<
13291                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
13292                > as fidl::encoding::TypeMarker>::inline_size(
13293                    decoder.context
13294                );
13295                if inlined != (member_inline_size <= 4) {
13296                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13297                }
13298                let inner_offset;
13299                let mut inner_depth = depth.clone();
13300                if inlined {
13301                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13302                    inner_offset = next_offset;
13303                } else {
13304                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13305                    inner_depth.increment()?;
13306                }
13307                let val_ref = self.touch_source.get_or_insert_with(|| {
13308                    fidl::new_empty!(
13309                        fidl::encoding::Endpoint<
13310                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
13311                        >,
13312                        fidl::encoding::DefaultFuchsiaResourceDialect
13313                    )
13314                });
13315                fidl::decode!(
13316                    fidl::encoding::Endpoint<
13317                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::TouchSourceMarker>,
13318                    >,
13319                    fidl::encoding::DefaultFuchsiaResourceDialect,
13320                    val_ref,
13321                    decoder,
13322                    inner_offset,
13323                    inner_depth
13324                )?;
13325                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13326                {
13327                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13328                }
13329                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13330                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13331                }
13332            }
13333
13334            next_offset += envelope_size;
13335            _next_ordinal_to_read += 1;
13336            if next_offset >= end_offset {
13337                return Ok(());
13338            }
13339
13340            // Decode unknown envelopes for gaps in ordinals.
13341            while _next_ordinal_to_read < 4 {
13342                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13343                _next_ordinal_to_read += 1;
13344                next_offset += envelope_size;
13345            }
13346
13347            let next_out_of_line = decoder.next_out_of_line();
13348            let handles_before = decoder.remaining_handles();
13349            if let Some((inlined, num_bytes, num_handles)) =
13350                fidl::encoding::decode_envelope_header(decoder, next_offset)?
13351            {
13352                let member_inline_size = <fidl::encoding::Endpoint<
13353                    fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
13354                > as fidl::encoding::TypeMarker>::inline_size(
13355                    decoder.context
13356                );
13357                if inlined != (member_inline_size <= 4) {
13358                    return Err(fidl::Error::InvalidInlineBitInEnvelope);
13359                }
13360                let inner_offset;
13361                let mut inner_depth = depth.clone();
13362                if inlined {
13363                    decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
13364                    inner_offset = next_offset;
13365                } else {
13366                    inner_offset = decoder.out_of_line_offset(member_inline_size)?;
13367                    inner_depth.increment()?;
13368                }
13369                let val_ref = self.mouse_source.get_or_insert_with(|| {
13370                    fidl::new_empty!(
13371                        fidl::encoding::Endpoint<
13372                            fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
13373                        >,
13374                        fidl::encoding::DefaultFuchsiaResourceDialect
13375                    )
13376                });
13377                fidl::decode!(
13378                    fidl::encoding::Endpoint<
13379                        fidl::endpoints::ServerEnd<fidl_fuchsia_ui_pointer::MouseSourceMarker>,
13380                    >,
13381                    fidl::encoding::DefaultFuchsiaResourceDialect,
13382                    val_ref,
13383                    decoder,
13384                    inner_offset,
13385                    inner_depth
13386                )?;
13387                if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
13388                {
13389                    return Err(fidl::Error::InvalidNumBytesInEnvelope);
13390                }
13391                if handles_before != decoder.remaining_handles() + (num_handles as usize) {
13392                    return Err(fidl::Error::InvalidNumHandlesInEnvelope);
13393                }
13394            }
13395
13396            next_offset += envelope_size;
13397
13398            // Decode the remaining unknown envelopes.
13399            while next_offset < end_offset {
13400                _next_ordinal_to_read += 1;
13401                fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
13402                next_offset += envelope_size;
13403            }
13404
13405            Ok(())
13406        }
13407    }
13408}